# abhibha1807/semantic-analyser architecture

> Architecture diagram of the GitHub repository abhibha1807/semantic-analyser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhibha1807/semantic-analyser
- Repository: https://github.com/abhibha1807/semantic-analyser

## Overview

This is a C-oriented semantic analyzer: source text is tokenized and parsed, then grammar actions perform context-sensitive checks and maintain a symbol table; the command-line run reports success or failure and displays the table. The README documents checks for reserved names, arithmetic expressions, conflicting declarations, break placement, and function-argument types. The parser excerpt shows its entry point and semantic-action calls, while the lexer excerpt shows token actions. The map omits code generation, which the README describes as a later compiler phase, not an implemented capability here.

Main entry points: [`code/y.tab.c`](https://github.com/abhibha1807/semantic-analyser/blob/main/code/y.tab.c) (Grammar parser), [`code/lex.yy.c`](https://github.com/abhibha1807/semantic-analyser/blob/main/code/lex.yy.c) (Token scanner), [`code/assgn3.l`](https://github.com/abhibha1807/semantic-analyser/blob/main/code/assgn3.l) (Lexer rules), [`code/assgn3.y`](https://github.com/abhibha1807/semantic-analyser/blob/main/code/assgn3.y) (Grammar rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Frontend"]
  node_lexer["Token scanner<br/>[lex.yy.c]"]
  node_lexer_spec["Lexer rules<br/>[assgn3.l]"]
  node_parser["Grammar parser<br/>[y.tab.c]"]
  node_grammar_spec["Grammar rules<br/>[assgn3.y]"]
end

subgraph group_semantics["Semantic analysis"]
  node_semantic_checks["Semantic checks<br/>[y.tab.c]"]
  node_symbols[("Symbol table<br/>[symbolTable.c]")]
end

subgraph group_report["Results"]
  node_reporting["Status and display<br/>[y.tab.c]"]
end

node_user(("C source user"))
node_console(("Console output"))

node_user -->|"submits source"| node_parser
node_lexer_spec -->|"defines tokens"| node_lexer
node_grammar_spec -->|"defines grammar"| node_parser
node_parser -->|"includes scanner"| node_lexer
node_parser -->|"runs actions"| node_semantic_checks
node_semantic_checks -->|"queries and updates"| node_symbols
node_parser -->|"runs parse and display"| node_reporting
node_reporting -->|"prints results"| node_console

click node_lexer "https://github.com/abhibha1807/semantic-analyser/blob/main/code/lex.yy.c"
click node_lexer_spec "https://github.com/abhibha1807/semantic-analyser/blob/main/code/assgn3.l"
click node_parser "https://github.com/abhibha1807/semantic-analyser/blob/main/code/y.tab.c"
click node_grammar_spec "https://github.com/abhibha1807/semantic-analyser/blob/main/code/assgn3.y"
click node_semantic_checks "https://github.com/abhibha1807/semantic-analyser/blob/main/code/y.tab.c"
click node_symbols "https://github.com/abhibha1807/semantic-analyser/blob/main/code/symbolTable.c"
click node_reporting "https://github.com/abhibha1807/semantic-analyser/blob/main/code/y.tab.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_lexer,node_lexer_spec,node_parser,node_grammar_spec,node_user toneBlue
class node_semantic_checks,node_symbols toneAmber
class node_reporting toneMint
class node_console toneIndigo
```

## Components

### Frontend

- [Token scanner](https://github.com/abhibha1807/semantic-analyser/blob/main/code/lex.yy.c): `code/lex.yy.c`
- [Lexer rules](https://github.com/abhibha1807/semantic-analyser/blob/main/code/assgn3.l): `code/assgn3.l`
- [Grammar parser](https://github.com/abhibha1807/semantic-analyser/blob/main/code/y.tab.c): `code/y.tab.c`
- [Grammar rules](https://github.com/abhibha1807/semantic-analyser/blob/main/code/assgn3.y): `code/assgn3.y`

### Semantic analysis

- [Semantic checks](https://github.com/abhibha1807/semantic-analyser/blob/main/code/y.tab.c): `code/y.tab.c`
- [Symbol table](https://github.com/abhibha1807/semantic-analyser/blob/main/code/symbolTable.c): `code/symbolTable.c`

### Results

- [Status and display](https://github.com/abhibha1807/semantic-analyser/blob/main/code/y.tab.c): `code/y.tab.c`

### Other components

- **C source user**
- **Console output**

## Connections

- C source user → Grammar parser: submits source (evidence: `README.md`)
- Lexer rules → Token scanner: defines tokens (evidence: `README.md`)
- Grammar rules → Grammar parser: defines grammar (evidence: `README.md`)
- Grammar parser → Token scanner: includes scanner (evidence: `code/y.tab.c`)
- Grammar parser → Semantic checks: runs actions (evidence: `code/y.tab.c`)
- Semantic checks → Symbol table: queries and updates (evidence: `code/y.tab.c`)
- Grammar parser → Status and display: runs parse and display (evidence: `code/y.tab.c`)
- Status and display → Console output: prints results (evidence: `code/y.tab.c`)
