- Course: Programming Language
- Project: Term Project
- Implementation Language: Java
This project is a mini programming language inspired by Turkish syntax and keywords. The goal is to design and implement the core front-end components of a compiler.
- Lexical Analyzer (Lexer)
- Recursive Descent Parser
- Symbol Table
- Syntax Error Detection
- Test Case Execution with Sample Source Files
- Variable Declarations
- Assignment Statements
- Arithmetic Expressions
- Conditional Statements (
if / else) - Loop Structures (
while) - Block Scope with Braces
src/
├── Main.java
├── Lexer.java
├── Parser.java
├── Token.java
├── TokenType.java
└── SymbolTable.java
tests/
├── ArithmeticExample.txt
├── ConditionalExample.txt
├── LoopExample.txt
└── VariableDeclarationExample.txt
Sample source codes are located in the tests/ folder.
Run Main.java
degisken x;
x = 5 + 3;
eger (x > 5) {
yazdir(x);
}
+-------------------+
| Main.java |
| Program Entry |
+---------+---------+
|
v
+-------------------+
| Lexer.java |
| Source Scanner |
+---------+---------+
|
v
+-------------------+
| Token.java |
| Token Objects |
+---------+---------+
|
v
+-------------------+
| Parser.java |
| Syntax Analyzer |
+----+---------+----+
| |
v v
+---------+ +------------------+
|TokenType| | SymbolTable.java |
| Enum | | Variable Storage |
+---------+ +------------------+
- Main.java → Starts program execution and loads input files.
- Lexer.java → Converts source code into tokens.
- Token.java → Stores token type and value.
- TokenType.java → Defines all token categories using enum.
- Parser.java → Validates syntax using Recursive Descent Parsing.
- SymbolTable.java → Stores declared identifiers and metadata.
Sample source codes and test files are located in the tests/ folder. The project includes both valid test cases to demonstrate correct language syntax and invalid test cases to verify the error-handling capabilities of the Lexer, Parser, and Symbol Table.
These files contain correct syntax, obey the language rules, and should be processed by the compiler without any errors:
ArithmeticExample.txt: Demonstrates mathematical operations and assignments.ConditionalExample.txt: Demonstrateseger/degilse(if/else) logic, reversed parentheses)(, and block scoping[[ ]].LoopExample.txt: Demonstrates thedongu(while) structure.VariableDeclarationExample.txt: Demonstrates variable definitions with language-specific data types (tam,ondlk,cml, etc.).
These files contain intentional lexical, syntactic, or semantic errors to test if the compiler correctly catches and reports them:
InvalidVariableDeclarationExample.txt: Tests Duplicate variable declarations and Undefined variable assignments (Triggers SymbolTable exceptions).InvalidConditionalExample.txt: Tests incorrect block braces (e.g.,{instead of[[), traditional parentheses(), and invalid comparison operators.InvalidLoopExample.txt: Tests unclosed string literals and missing end-of-statement markers (:).InvalidArithmeticExample.txt: Tests unrecognized characters (e.g.,^) and incorrect assignment operators (Triggers Lexer errors).
Complated
Programming Languages Course Project Team:
- Semi Kazar - 230316066
- Ufuk Akkuzu - 230316049
- Berat Uzdil - 230316043
- Berkay Altunbag - 230316009