# crocobob911/lexicalanalyzer_assignment1_plt architecture

> Architecture diagram of the GitHub repository crocobob911/lexicalanalyzer_assignment1_plt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crocobob911/lexicalanalyzer_assignment1_plt
- Repository: https://github.com/crocobob911/lexicalanalyzer_assignment1_plt

## Overview

##### Main Components

a) Lexical Analysis Pipeline:
- Input Handler (Reading code1.txt file)
- Tokenizer/Scanner
- Symbol Table Manager
- Error Handler

b) Parser Components:
- LL(1) Parser
- Grammar Rules Manager
- Semantic Analyzer
- Expression Evaluator

##### Component Relationships

**Input File → Lexical Analyzer → Parser → Expression Evaluator → Output**

##### Specific Design Elements

a) Input Processing Layer:
- File input component (code1.txt)
- Line-by-line processing component (mentioned as missing in README)
- Error handling mechanism

b) Lexical Analysis Layer:
- Token Generator
- Counter Components for ID, Const, and OP
- Dictionary-based token storage

c) Parser Layer:
- Grammar Rules Engine
- Epsilon/Lambda handling component
- Parse Tree Builder

d) Execution Layer:
- Variable Storage (for a, b, c)
- Expression Evaluator
- Result Calculator

##### Important Details to Highlight

- Error handling paths (showing how errors are collected in errorList)
- Token counting mechanism
- Line-by-line processing flow
- Variable evaluation pipeline

##### Specific Implementation Notes

Special considerations:
- Epsilon/Lambda production handling
- Error collection and reporting mechanism
- Token counting system
- Variable state tracking

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        IF["Input File"]:::input
        IH["Input Handler"]:::processor
    end

    subgraph "Lexical Analysis"
        LA["Lexical Analyzer"]:::processor
        TG["Token Generator"]:::processor
        ST[(Symbol Table)]:::storage
        TC["Token Counter"]:::processor
    end

    subgraph "Parser"
        PR["LL(1) Parser"]:::processor
        GR["Grammar Rules Engine"]:::processor
        PTB["Parse Tree Builder"]:::processor
        EH["Error Handler"]:::error
        EL[(Error List)]:::storage
    end

    subgraph "Execution"
        EE["Expression Evaluator"]:::processor
        VS[(Variable Storage)]:::storage
        RC["Result Calculator"]:::processor
    end

    %% Main Flow
    IF --> IH
    IH --> LA
    LA --> TG
    TG --> ST
    TG --> TC
    TC --> PR
    PR --> GR
    GR --> PTB
    PTB --> EE
    EE --> VS
    EE --> RC

    %% Error Handling
    LA -.-> EH
    PR -.-> EH
    EE -.-> EH
    EH --> EL

    %% Styling
    classDef processor fill:#a8d1ff,stroke:#000
    classDef storage fill:#90EE90,stroke:#000
    classDef error fill:#ffb3b3,stroke:#000
    classDef input fill:#fff4b3,stroke:#000

    %% Click Events
    click IF "https://github.com/Crocobob911/LexicalAnalyzer_Assignment1_PLT/blob/main/code1.txt"
    click IH "https://github.com/Crocobob911/LexicalAnalyzer_Assignment1_PLT/blob/main/Program.cs"
    click LA "https://github.com/Crocobob911/LexicalAnalyzer_Assignment1_PLT/blob/main/Program.cs"
    click PR "https://github.com/Crocobob911/LexicalAnalyzer_Assignment1_PLT/blob/main/Program.cs"
    click EE "https://github.com/Crocobob911/LexicalAnalyzer_Assignment1_PLT/blob/main/Program.cs"

    %% Legend
    subgraph Legend
        L1["Processing Component"]:::processor
        L2[(Storage Component)]:::storage
        L3["Error Component"]:::error
        L4["Input/Output"]:::input
    end
```
