# sandraeu/olc1-c-2s architecture

> Architecture diagram of the GitHub repository sandraeu/olc1-c-2s, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sandraeu/olc1-c-2s
- Repository: https://github.com/sandraeu/olc1-c-2s

## Overview

1. **Repository shape**
   This is not a single application; it is a collection of course examples for “Organización de Lenguajes y Compiladores 1”. The repository contains several independent mini-projects that illustrate the same compiler/interpreter concepts at different stages.

2. **Two main architectural families**
   The codebase splits into:
   - **Java-based parser/compiler exercises** in the `Ejemplo clase 3` through `Ejemplo clase 7` folders.
   - **A separate interpreter application** in `Interprete Sencillo`, which is the most complete end-to-end system with client/server separation.

3. **Java compiler exercises: common pipeline**
   The Java projects follow a classic language-toolchain flow:
   **source text → lexical analysis (JFlex) → parsing (CUP) → AST / semantic handling → output/reporting**.
   The `src/Analizadores` packages hold the handwritten and generated lexer/parser code, while `src/Generadores` contains the generator entry points used to produce those classes.

4. **Java projects: generated vs source boundaries**
   These examples keep generator specifications alongside generated code:
   - `.jflex` files define lexers.
   - `.cup` files define grammars.
   - Generated Java classes live in `Analizadores` and `Generadores`.
   The `build/` directories show that generated artifacts are part of the build output, not the source of truth.

5. **Progression across class examples**
   The examples evolve from basic parsing to richer tooling:
   - **Clase 2–3**: lexer/parser basics and a small Swing UI.
   - **Clase 4–5**: AST construction, file handling, error management, and tree visualization.
   - **Clase 6–7**: reporting features, including chart generation with **JFreeChart**.
   This makes the repository useful as a timeline of compiler-front-end architecture.

6. **Java UI layer**
   Several Java projects include `Ventana`, `Editor`, or similar Swing forms (`.form` files). These are desktop front-ends that accept user input, trigger analysis, and present results such as tokens, parse trees, errors, or reports.

7. **Tree/reporting artifacts in Java projects**
   Some examples generate or consume external artifacts:
   - `Arbol_Sintactico.dot` and `.bat` files indicate Graphviz-based syntax-tree rendering.
   - `Reportes/` packages in later examples compute metrics and render bar charts.
   This shows a pattern where analysis output is not only textual but also visual.

8. **Interprete Sencillo: main system architecture**
   This project is structurally different and more complete. It is split into:
   - **Cliente**: browser-based UI with HTML/CSS/JavaScript.
   - **Servidor**: Node.js + TypeScript backend.
   The two halves are meant to communicate over HTTP, with the server owning all interpretation logic.

9. **Cliente boundary**
   The client is a thin presentation layer. It contains static assets only and no parsing logic. Its role is to gather user input, send it to the backend, and display results returned by the interpreter.

10. **Servidor boundary**
   The server contains the actual language processor. It includes:
   - `app/` for the HTTP entrypoint and routes.
   - `src/Analizador/` for grammar definitions and generated parsers using **Jison**.
   - `src/Interprete/` for the interpreter core.
   The server is the domain boundary that owns parsing, AST construction, symbol management, and evaluation.

11. **Interpreter internals**
   Inside `src/Interprete`, the code is organized by language concern:
   - **AST layer**: node and error representation.
   - **Expressions**: primitives, identifiers, arithmetic, logic, relational, ternary.
   - **Instructions**: declarations, assignments, function calls, loops, conditionals, transfer statements, I/O.
   - **TablaSimbolos**: symbol table and type model.
   This is a typical interpreter architecture where parsing produces structures that are then executed against a runtime environment.

12. **Runtime flow in the interpreter app**
   The execution path is:
   **browser input → server route → parser/analizador → AST/instruction objects → evaluator → result or error list → client display**.
   The important architectural boundary is that parsing and execution happen entirely on the server, while the client remains stateless UI.

13. **Packaging and deployment**
   The interpreter project includes `Dockerfile` files for both client and server, plus a `docker-compose.yml`. That indicates the app is intended to run as two coordinated containers rather than a monolith.

14. **Key architectural takeaway**
   Across the repository, the recurring pattern is language-processing infrastructure: lexer/parser generation, ASTs, symbol tables, and execution/reporting layers. The Java folders demonstrate progressive compiler-front-end examples, while `Interprete Sencillo` packages the same ideas into a deployable client/server interpreter.

Main entry points: [`Ejemplo clase 6/OLC1_Clase6/src/Reportes/GBarras.java`](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%206/OLC1_Clase6/src/Reportes/GBarras.java) (Reports), [`Interprete Sencillo/Servidor/app/index.ts`](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Servidor/app/index.ts) (HTTP app), [`Ejemplo clase 4/OLC1_Clase4/src/olc1_clase4/Ventana.java`](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%204/OLC1_Clase4/src/olc1_clase4/Ventana.java) (Editor UI), [`Interprete Sencillo/Servidor/src/Interprete/Evaluar.ts`](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Servidor/src/Interprete/Evaluar.ts) (Interpreter core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_java_examples["Java compiler exercises"]
  node_j3_src["Clase 3 core<br/>Java parser exercise<br/>[OLC1Clase2.java]"]
  node_j3_lex["Lexer spec<br/>JFlex spec<br/>[A_Lexico.jflex]"]
  node_j3_parse["Parser spec<br/>CUP grammar<br/>[A_Sintactico.cup]"]
  node_j4_ast["AST builder<br/>Java AST example<br/>[Arbol.java]"]
  node_j4_ui["Editor UI<br/>Swing desktop UI<br/>[Ventana.java]"]
  node_j4_tree["Tree export<br/>Graphviz output"]
  node_j5_files["File handling<br/>Java editor exercise<br/>[Archivo.java]"]
  node_j5_errors["Error model<br/>Java diagnostics<br/>[Errores.java]"]
  node_j6_reports["Reports<br/>Chart reporting<br/>[GBarras.java]"]
  node_j6_metrics["Metrics data<br/>Report model"]
  node_j7_scores["Score reports<br/>Report model<br/>[Puntajes.java]"]
  node_j7_vars["Variables report<br/>Report model<br/>[Variables.java]"]
end

subgraph group_interp_app["Interpreter app"]
  node_c_client["Client UI<br/>Static web client<br/>[index.html]"]
  node_c_script["Client logic<br/>Front-end script<br/>[funcionalidad.js]"]
  node_s_http["HTTP app<br/>Node entrypoint<br/>[index.ts]"]
  node_s_parse["Jison grammar<br/>Parser generation<br/>[gramatica.jison]"]
  node_s_core["Interpreter core<br/>TypeScript runtime<br/>[Evaluar.ts]"]
  node_s_symbols[("Symbol table<br/>Runtime state<br/>[TablaSimbolos.ts]")]
end

node_j3_lex -->|"tokenizes"| node_j3_src
node_j3_parse -->|"parses"| node_j3_src
node_j3_src -.->|"evolves into"| node_j4_ui
node_j4_ui -->|"triggers"| node_j4_ast
node_j4_ast -->|"exports"| node_j4_tree
node_j4_ui -.->|"extends"| node_j5_files
node_j5_files -->|"reports"| node_j5_errors
node_j5_errors -->|"feeds"| node_j6_reports
node_j6_reports -->|"computes"| node_j6_metrics
node_j6_reports -.->|"extends"| node_j7_scores
node_j6_reports -.->|"extends"| node_j7_vars
node_c_client -->|"drives"| node_c_script
node_c_script -->|"calls"| node_s_http
node_s_http -->|"invokes"| node_s_parse
node_s_parse -->|"builds"| node_s_core
node_s_core -->|"uses"| node_s_symbols
node_s_core -->|"returns results"| node_s_http
node_s_http -->|"responds to"| node_c_client

click node_j3_src "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 3/OLC1-Clase2/src/olc1/clase2/OLC1Clase2.java"
click node_j3_lex "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 3/OLC1-Clase2/src/Analizadores/A_Lexico.jflex"
click node_j3_parse "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 3/OLC1-Clase2/src/Analizadores/A_Sintactico.cup"
click node_j4_ast "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 4/OLC1_Clase4/src/olc1_clase4/Arbol.java"
click node_j4_ui "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 4/OLC1_Clase4/src/olc1_clase4/Ventana.java"
click node_j4_tree "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 4/OLC1_Clase4/Arbol_Sintactico.dot"
click node_j5_files "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 5/OLC1_Clase4_archivos/src/olc1_clase4/Archivo.java"
click node_j5_errors "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 5/OLC1_Clase4_archivos/src/olc1_clase4/Errores.java"
click node_j6_reports "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 6/OLC1_Clase6/src/Reportes/GBarras.java"
click node_j6_metrics "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 6/OLC1_Clase6/src/Reportes/Caracteristica.java"
click node_j7_scores "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 7/OLC1_Clase7/src/Reportes/Puntajes.java"
click node_j7_vars "https://github.com/sandraeu/olc1-c-2s/blob/main/Ejemplo clase 7/OLC1_Clase7/src/Reportes/Variables.java"
click node_c_client "https://github.com/sandraeu/olc1-c-2s/blob/main/Interprete Sencillo/Cliente/index.html"
click node_c_script "https://github.com/sandraeu/olc1-c-2s/blob/main/Interprete Sencillo/Cliente/funcionalidad.js"
click node_s_http "https://github.com/sandraeu/olc1-c-2s/blob/main/Interprete Sencillo/Servidor/app/index.ts"
click node_s_parse "https://github.com/sandraeu/olc1-c-2s/blob/main/Interprete Sencillo/Servidor/src/Analizador/gramatica.jison"
click node_s_core "https://github.com/sandraeu/olc1-c-2s/blob/main/Interprete Sencillo/Servidor/src/Interprete/Evaluar.ts"
click node_s_symbols "https://github.com/sandraeu/olc1-c-2s/blob/main/Interprete Sencillo/Servidor/src/Interprete/TablaSimbolos/TablaSimbolos.ts"

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_j3_src,node_j3_lex,node_j3_parse,node_j4_ast,node_j4_ui,node_j4_tree,node_j5_files,node_j5_errors,node_j6_reports,node_j6_metrics,node_j7_scores,node_j7_vars toneBlue
class node_c_client,node_c_script,node_s_http,node_s_parse,node_s_core,node_s_symbols toneAmber
```

## Components

### Java compiler exercises

Progressive JFlex/CUP-based front-end examples with Swing UIs, ASTs, file handling, and reports.

- [Clase 3 core](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%203/OLC1-Clase2/src/olc1/clase2/OLC1Clase2.java): Java parser exercise · Basic lexer/parser exercise with a Swing front-end and generated analyzer classes. · `Ejemplo clase 3/OLC1-Clase2/src/olc1/clase2/OLC1Clase2.java`
- [Lexer spec](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%203/OLC1-Clase2/src/Analizadores/A_Lexico.jflex): JFlex spec · Lexical grammar source for the class 3 example. · `Ejemplo clase 3/OLC1-Clase2/src/Analizadores/A_Lexico.jflex`
- [Parser spec](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%203/OLC1-Clase2/src/Analizadores/A_Sintactico.cup): CUP grammar · Parsing grammar source for the class 3 example. · `Ejemplo clase 3/OLC1-Clase2/src/Analizadores/A_Sintactico.cup`
- [AST builder](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%204/OLC1_Clase4/src/olc1_clase4/Arbol.java): Java AST example · Adds syntax tree construction and visual output to the compiler exercise. · `Ejemplo clase 4/OLC1_Clase4/src/olc1_clase4/Arbol.java`
- [Editor UI](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%204/OLC1_Clase4/src/olc1_clase4/Ventana.java): Swing desktop UI · Desktop front-end that accepts input and triggers analysis and tree generation. · `Ejemplo clase 4/OLC1_Clase4/src/olc1_clase4/Ventana.java`
- [Tree export](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%204/OLC1_Clase4/Arbol_Sintactico.dot): Graphviz output · Dot and batch artifacts used to render the syntax tree externally. · `Ejemplo clase 4/OLC1_Clase4/Arbol_Sintactico.dot`
- [File handling](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%205/OLC1_Clase4_archivos/src/olc1_clase4/Archivo.java): Java editor exercise · Adds file workflow, comparison, and multiple analyzer variants. · `Ejemplo clase 5/OLC1_Clase4_archivos/src/olc1_clase4/Archivo.java`
- [Error model](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%205/OLC1_Clase4_archivos/src/olc1_clase4/Errores.java): Java diagnostics · Introduces structured error handling alongside the editor and tree logic. · `Ejemplo clase 5/OLC1_Clase4_archivos/src/olc1_clase4/Errores.java`
- [Reports](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%206/OLC1_Clase6/src/Reportes/GBarras.java): Chart reporting · Reporting layer that aggregates characteristics and renders bar charts. · `Ejemplo clase 6/OLC1_Clase6/src/Reportes/GBarras.java`
- [Metrics data](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%206/OLC1_Clase6/src/Reportes/Caracteristica.java): Report model · Data objects used to compute reporting values and characteristics. · `Ejemplo clase 6/OLC1_Clase6/src/Reportes/Caracteristica.java`
- [Score reports](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%207/OLC1_Clase7/src/Reportes/Puntajes.java): Report model · Extended reporting for puntajes and variables on top of the bar-chart pipeline. · `Ejemplo clase 7/OLC1_Clase7/src/Reportes/Puntajes.java`
- [Variables report](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Ejemplo%20clase%207/OLC1_Clase7/src/Reportes/Variables.java): Report model · Additional report artifact for variable-oriented summaries. · `Ejemplo clase 7/OLC1_Clase7/src/Reportes/Variables.java`

### Interpreter app

Client/server interpreter split across static UI and a TypeScript backend.

- [Client UI](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Cliente/index.html): Static web client · Thin browser presentation layer with markup, styles, and JavaScript only. · `Interprete Sencillo/Cliente/index.html`
- [Client logic](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Cliente/funcionalidad.js): Front-end script · Browser-side behavior that sends user input to the server and renders responses. · `Interprete Sencillo/Cliente/funcionalidad.js`
- [HTTP app](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Servidor/app/index.ts): Node entrypoint · Server entrypoint and route layer that exposes the interpreter over HTTP. · `Interprete Sencillo/Servidor/app/index.ts`
- [Jison grammar](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Servidor/src/Analizador/gramatica.jison): Parser generation · Grammar sources and generated parsers for the server-side language processor. · `Interprete Sencillo/Servidor/src/Analizador/gramatica.jison`
- [Interpreter core](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Servidor/src/Interprete/Evaluar.ts): TypeScript runtime · AST, expressions, instructions, symbol table, and evaluator for execution. · `Interprete Sencillo/Servidor/src/Interprete/Evaluar.ts`
- [Symbol table](https://github.com/sandraeu/olc1-c-2s/blob/HEAD/Interprete%20Sencillo/Servidor/src/Interprete/TablaSimbolos/TablaSimbolos.ts): Runtime state · Typed symbol management used during interpretation and evaluation. · `Interprete Sencillo/Servidor/src/Interprete/TablaSimbolos/TablaSimbolos.ts`

## Connections

- Lexer spec → Clase 3 core: tokenizes · Lexer output feeds the first Java exercise entrypoint.
- Parser spec → Clase 3 core: parses · Grammar builds the parser used by the class 3 example.
- Clase 3 core → Editor UI: evolves into · The next class example adds a richer desktop editor and tree rendering.
- Editor UI → AST builder: triggers · UI actions construct and traverse the AST representation.
- AST builder → Tree export: exports · Syntax trees are emitted as Graphviz artifacts for visualization.
- Editor UI → File handling: extends · File workflow and editor management are added in the next example.
- File handling → Error model: reports · File/editor logic is paired with structured diagnostics.
- Error model → Reports: feeds · Later exercises summarize analysis results into report data.
- Reports → Metrics data: computes · Charting uses metric objects and characteristic aggregates.
- Reports → Score reports: extends · Reporting grows to include score-oriented summaries.
- Reports → Variables report: extends · Reporting also adds variable-focused summaries.
- Client UI → Client logic: drives · The static page is wired by browser-side JavaScript.
- Client logic → HTTP app: calls · Client script submits requests to the backend routes.
- HTTP app → Jison grammar: invokes · HTTP handling reaches the server-side parser generation layer.
- Jison grammar → Interpreter core: builds · Parsed programs are converted into interpreter structures.
- Interpreter core → Symbol table: uses · Evaluation reads and updates runtime symbols and types.
- Interpreter core → HTTP app: returns results · Execution output and errors are sent back through the server layer.
- HTTP app → Client UI: responds to · The browser UI displays results coming back from the server.
