Skip to content

This project implements a lexical analyzer using Lex to tokenize and analyze the structure of a given input file. It efficiently identifies tokens such as keywords, identifiers, operators, and literals, serving as the foundational component of a compiler or interpreter.

License

Notifications You must be signed in to change notification settings

missipsag/LEX-ical-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lexical Analyzer

This project implements a lexical analyzer using Lex. It processes defined tokens to analyze a specific language, identifying keywords, operators, and important syntactic structures.

Tokens Table

Here are the tokens supported by the lexical analyzer, along with their models and attributes:

Token Model Attribute
FIN EOF \0
PV ; -
IF if -
THEN then -
ELSE else -
END end -
REPEAT repeat -
UNTIL until -
ID L(_?|(L|C))* NOM
READ read -
WRITE write -
OPREL < | = COPREL ∈ {INF, EGAL}
OPADD + | - COPADD ∈ {PLUS, MOINS}
OPMUL * | / COPMUL ∈ {PROD, DIV}
PARG ( -
PARD ) -
ENTIER C+ VAL
AFFECT := -

Notes

  • The regular expressions L and C correspond to [A-Za-z] and [0-9], respectively.

Features

  • Lexical Analysis: Identifies tokens in a textual input.
  • Extended Support: Handles operators, identifiers, and integers.
  • Extensible: Tokens can be modified or extended to fit other requirements.

Usage

  1. Clone the Repository

    git clone https://github.com/your_username/lexical-analyzer.git
    cd lexical-analyzer
  2. Compile the Lex File

    flex lexer.l
    gcc lex.yy.c -o lexical-analyzer -lfl
  3. Run the Lexical Analyzer

    ./lexical-analyzer < input.txt

License

This project is open-source and available under the MIT License.

About

This project implements a lexical analyzer using Lex to tokenize and analyze the structure of a given input file. It efficiently identifies tokens such as keywords, identifiers, operators, and literals, serving as the foundational component of a compiler or interpreter.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published