The purpose of this project is to learn about the compilation process of programming languages by implementing one in Java.
- Lexer
- Parser
- Constrainer
- Compiler
- Interpreter
- And &
- Assign =
- BOOLean boolean
- Case case
- Char char
- CharLit
- Colon :
- Comma ,
- Comment //
- Default default
- Divide /
- Else else
- EndProgram XD
- Equal ==
- Function function
- Greater >
- GreaterEqual >=
- INTeger
- Identifier
- If if
- Int int
- LeftBrace {
- LeftParen (
- Less <
- LessEqual <=
- Minus -
- Multiply *
- NotEqual !=
- Or |
- Plus +
- Program program
- Return return
- RightBrace }
- RightParen )
- StringLit
- StringType string
- Switch switch
- Then then
- Unless unless
- While while
Production | Description |
---|---|
TYPE->'char' | Char Token |
TYPE->'string' | StringType Token |
F→<char> | Char literals |
F→<string> | String literals |
S→'if' E 'then' BLOCK | if statement (without else) |
S→'unless' E 'then' BLOCK | unless statement |
SwitchBlock→'{' CaseStatement+ DefaultStatement? '}' | switch statement block (one or more case statements followed by none or one default statement) |
CaseStatement→'case' <int> ':' S | case statement with only one statement |
DefaultStatement→'default' ':' S | default statement with only one statement |
E→SE '>' SE | Greater token |
E→SE '>=' SE | GreaterEqual token |
Batch files are provided for compiling and executing most components. For example, to compile the lexer, run clexer
in the project root. To run the lexer, run lexer {source_file}
. The commands which accept a source file as input use sample_files\simple.x
as a default source file.
Written with StackEdit.