Skip to content

A terminal/console based cpp program for demonstrating the work of lexical analysis

Notifications You must be signed in to change notification settings

tahsinhasib/Mini-Lexical-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Program for Lexical Analyzer

Users may modify or put their code in the source text file. The code in code.txt file:

Input

#include <iostream>
using namespace std;

void customFunc() {
    cout << "Function call";
}

int main()
{
    int myNumInt = "15";
    myNumInt = 10; 
    float myFloat = '123.54';
    float num = 232.4233;
    char c = 'd';
    string str = "text";
    cout << myNum;  
    bool truthtable = false;

    for (int j = 0; j<= 200; j++) {
        cout << "loopiteration" << "\n";
    }

    if (myNumInt > 15) {cout << "Greater than";}
    else {cout << "Less than";}
    while (myNumInt < 10) {cout << "whileiteration";}

    customFunc();
}

Output

After executing the program the list of all Keywords, Constants, Operators, Punctuation, Identifiers are displayed in the terminal depending on the code provided in code.txt file.

Alt text

About

A terminal/console based cpp program for demonstrating the work of lexical analysis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages