https://github.com/missipsag/lex-ical-analyzer
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.
https://github.com/missipsag/lex-ical-analyzer
compiler flex lex lexical-analysis lexical-analyzer lexical-parser
Last synced: 6 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/missipsag/lex-ical-analyzer
- Owner: missipsag
- License: mit
- Created: 2024-12-30T09:12:12.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-12-30T09:46:52.000Z (9 months ago)
- Last Synced: 2025-03-28T23:30:24.588Z (6 months ago)
- Topics: compiler, flex, lex, lexical-analysis, lexical-analyzer, lexical-parser
- Language: C
- Homepage:
- Size: 41 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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**
```bash
git clone https://github.com/your_username/lexical-analyzer.git
cd lexical-analyzer
```2. **Compile the Lex File**
```bash
flex lexer.l
gcc lex.yy.c -o lexical-analyzer -lfl
```3. **Run the Lexical Analyzer**
```bash
./lexical-analyzer < input.txt
```## License
This project is open-source and available under the [MIT License](LICENSE).