This repository contains a lexical analyzer implemented in C for the B Minor programming language. The program reads a source code file and performs lexical analysis, identifying and categorizing tokens such as keywords, identifiers, integers, operators, delimiters, and strings in the B Minor language.
The program utilizes a set of functions to recognize and process different types of tokens. It maintains a symbol table to store unique identifiers and replaces token values with corresponding identifiers when printing token information. The lexical analysis is performed character by character, identifying and printing tokens based on their characteristics specific to the B Minor language.
const char *inputPath = "..\\input.txt"; // For Windows
// const char *inputPath = "../input.txt"; // For Linux
const char *outputPath = "..\\output.txt"; // For Windows
// const char *outputPath = "../output.txt"; // For Linux-
Clone the Repository:
git clone https://github.com/Ali-Noghabi/BMinor-Compiler.git
-
Compile the Code:
cd BMinor-Compiler mkdir build cd build gcc ..\main.c -o b_minor_lexical_analyzer
-
Run the Program:
b_minor_lexical_analyzer.exe
-
Clone the Repository:
git clone https://github.com/Ali-Noghabi/BMinor-Compiler.git
-
Compile the Code:
cd BMinor-Compiler mkdir build cd build gcc ..\main.c -o b_minor_lexical_analyzer
-
Run the Program:
./b_minor_lexical_analyzer
The input source code file is specified in the inputPath variable within the code. The program performs lexical analysis and prints token information to both the console and an output file specified in the outputPath variable.
The program maintains a dynamic symbol table to store unique identifiers encountered during lexical analysis. This table is used to replace token values with corresponding identifiers, reducing redundancy in the output.
Feel free to explore and modify the code according to your needs to suit the lexical analysis requirements of the B Minor language!
- Ali Noghabi: a.noghabi2002@gmail.com
- Ghaf0o0r: profile