Skip to content

Lexical analysis : is the process of converting a sequence of characters in a source code file into a sequence of tokens that can be more easily processed by a compiler or interpreter. Syntax analysis : also known as parsing, is the process of analyzing a string of symbols, either in natural language or in a computer language, according to the rule

Notifications You must be signed in to change notification settings

ZeadShalaby/Compiler-lexical-Syntax-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation


Logo

Building a simple Compiler from scratch in java

Compiler Project with two phases lexical & Syntax Analysis

Forks Issues License

Table Of Contents

About The Project

📌Lexical analysis :

Lexical analysis is the first phase of a compiler. It takes the modified source code from language preprocessors that are written in the form of sentences. The lexical analyzer breaks these syntax's into a series of tokens, by removing any whitespace or comments in the source code.

  • Tokenization: Start by creating a lexer that will take the source code and break it into tokens.
  • Regular Expressions: We will use regular expressions to match the tokens.
  • Symbol Table: We will use a symbol table to store the tokens.

📌Syntax analysis :

Syntax analysis is the second phase of a compiler. It takes the token produced by lexical analysis as input and generates a parse tree (or syntax tree). Syntax analysis checks the tokens for any syntax errors. It also adds the additional information to the parse tree.

  • Grammar: We will use a grammar to define the syntax of our language.
  • Parser: We will use a parser to parse the tokens.
  • Abstract Syntax Tree: We will use an abstract syntax tree to store the tokens.
  • Error Handling: We will use error handling to handle any syntax errors.

Contributing

Any contributions you make are greatly appreciated.

  • If you have suggestions for adding or removing projects, feel free to open an issue to discuss it, or directly create a pull request after you edit the README.md file with necessary changes.
  • Please make sure you check your spelling and grammar.
  • Create individual PR for each suggestion.
  • Make sure to add a meaningful description

Creating A Pull Request

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/GoalFeature)
  3. Commit your Changes (git commit -m 'Add some GoalFeature')
  4. Push to the Branch (git push origin feature/GoalFeature)
  5. Open a Pull Request

Authors

About

Lexical analysis : is the process of converting a sequence of characters in a source code file into a sequence of tokens that can be more easily processed by a compiler or interpreter. Syntax analysis : also known as parsing, is the process of analyzing a string of symbols, either in natural language or in a computer language, according to the rule

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages