This project consists of the first three phases of compiling a programming language.
- Lexical Analysis - breaking the code into tokens (e.g., <INT, 65>, <PLUS, +>, etc...)
- Syntax Analysis - checks if the structure of the code written is correct based on the rules determined
- Semantic Analysis - examines the meaning of the code itself (e.g., int value = "hello";, is incorrect because it should only store an integer)
The programming language that can be used here is only concocted for educational purposes and the 3 keywords are:
var - declares a new variable (note: all variables must be declared first before using them)
input - reads a variable from the console
output - displays (in the console) the value of the variable or a mathematical expression that was specified
- All statements will end in a semi-colon
- White is not significant (e.g., a+b is equal to a + b)
- Comments begin with /* and end with */ and can extend in multiple lines
- The value of all variables must be integers or decimals (positive or negative).
- The only operations allowed are: {+, -, *, /, =}
- Parentheses may be used in mathematical expressions
- Identifiers may only consist of uppercase and lowercase letters, underscores, and digits
- An idenfitier may not begin with a number
https://drive.google.com/file/d/1_VOKo4xagQBumHLjf8uXAicxHtOG98D9/view?usp=sharing
Code Editor - this is where you can use the made-up programming language wherein the compiling phases were based upon
Lexical Analyzer - this is where you can view the tokens that were extracted from the code
Console - this is where the result of the code (assuming it's correct) is displayed and it is also interactive
Compile & Run - once clicked, the code undergoes the first three phases of compiling (Lexical, Syntax, and Semantic Analysis), and then the result of the code is displayed in the console (however, if the code is incorrect, then the error will be displayed instead)
Save - creates a text file wherein the code will be saved (the name of the file is an input)
Load - loads a text file into the code editor
Undo - repeats the previous operation
Redo - repeats the operation that was undid
- syntax highlighting
If you're going to run this project, then it is preferable to use Eclipse IDE since that's the one that I used.