How sandraeu/olc1-c-2s works
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: GBarras.java Reports · index.ts HTTP app · Ventana.java Editor UI · Evaluar.ts Interpreter core
Components 18
Java compiler exercises
Progressive JFlex/CUP-based front-end examples with Swing UIs, ASTs, file handling, and reports.
- Clase 3 core · 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 · Lexical grammar source for the class 3 example.
Ejemplo clase 3/OLC1-Clase2/src/Analizadores/A_Lexico.jflex - Parser spec · Parsing grammar source for the class 3 example.
Ejemplo clase 3/OLC1-Clase2/src/Analizadores/A_Sintactico.cup - AST builder · Adds syntax tree construction and visual output to the compiler exercise.
Ejemplo clase 4/OLC1_Clase4/src/olc1_clase4/Arbol.java - Editor 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 · Dot and batch artifacts used to render the syntax tree externally.
Ejemplo clase 4/OLC1_Clase4/Arbol_Sintactico.dot - File handling · Adds file workflow, comparison, and multiple analyzer variants.
Ejemplo clase 5/OLC1_Clase4_archivos/src/olc1_clase4/Archivo.java - Error model · Introduces structured error handling alongside the editor and tree logic.
Ejemplo clase 5/OLC1_Clase4_archivos/src/olc1_clase4/Errores.java - Reports · Reporting layer that aggregates characteristics and renders bar charts.
Ejemplo clase 6/OLC1_Clase6/src/Reportes/GBarras.java - Metrics data · Data objects used to compute reporting values and characteristics.
Ejemplo clase 6/OLC1_Clase6/src/Reportes/Caracteristica.java - Score reports · Extended reporting for puntajes and variables on top of the bar-chart pipeline.
Ejemplo clase 7/OLC1_Clase7/src/Reportes/Puntajes.java - Variables report · 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 · Thin browser presentation layer with markup, styles, and JavaScript only.
Interprete Sencillo/Cliente/index.html - Client logic · Browser-side behavior that sends user input to the server and renders responses.
Interprete Sencillo/Cliente/funcionalidad.js - HTTP app · Server entrypoint and route layer that exposes the interpreter over HTTP.
Interprete Sencillo/Servidor/app/index.ts - Jison grammar · Grammar sources and generated parsers for the server-side language processor.
Interprete Sencillo/Servidor/src/Analizador/gramatica.jison - Interpreter core · AST, expressions, instructions, symbol table, and evaluator for execution.
Interprete Sencillo/Servidor/src/Interprete/Evaluar.ts - Symbol table · Typed symbol management used during interpretation and evaluation.
Interprete Sencillo/Servidor/src/Interprete/TablaSimbolos/TablaSimbolos.ts
Connections 18
- 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.