Skip to content

markjasongalang/Lexical-Syntax-and-Semantic-Analyzer-in-GUI-using-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lexical-Syntax-and-Semantic-Analyzer-in-GUI-using-Java

Quick Info

This project consists of the first three phases of compiling a programming language.

  1. Lexical Analysis - breaking the code into tokens (e.g., <INT, 65>, <PLUS, +>, etc...)
  2. Syntax Analysis - checks if the structure of the code written is correct based on the rules determined
  3. Semantic Analysis - examines the meaning of the code itself (e.g., int value = "hello";, is incorrect because it should only store an integer)

Made-up Programming Language (to be used)

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

Programming Language Constraints

  • 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

Syntax Rules (that I created)

https://drive.google.com/file/d/1_VOKo4xagQBumHLjf8uXAicxHtOG98D9/view?usp=sharing

3 Main Parts of the Program

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

Buttons

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

Extra Feature

  • syntax highlighting

Screenshots

image

image

image

Note from the developer

If you're going to run this project, then it is preferable to use Eclipse IDE since that's the one that I used.

Releases

No releases published

Packages

 
 
 

Languages