How pablosambuco/compilador-lenguajes-2008 works
Project type and purpose
• This is a compiler for a custom programming language, built as an academic exercise for a Lenguajes y Compiladores course (UNLaM 2008).
• It consumes source files (programa1.txt, programa2.txt) and produces diagnostics or intermediate output.
File structure
• Top-level directories:
• BYACC-J: contains the parser generator executable (yacc.exe, yacc.lnx), an input grammar (input.y) and helper scripts (generar.bat).
• lib: junit-3.8.1.jar for unit tests.
• src/java: main compiler code, divided into subpackages:
– analizadorLexicografico (Automata.java for lexical analysis)
– parser (Parser.java, ParserVal.java generated by BYACC-J)
– semantica (many IRutinaSemantica implementations for semantic actions)
– beans (symbol table entries, reserved words)
– util (ArchivoReader.java)
• src/test: JUnit test harness for compiler validation.
• Build and run scripts (make.bat, clean.bat, compilar.sh, run1.bat/ run2.bat) orchestrate compilation and tests.
README
• Confirms the tool’s nature (a custom-language compiler) and academic context.
a. Main components
• Source Code Input (text files)
• Lexical Analyzer (Automata in analizadorLexicografico)
• Syntax Analyzer / Parser (BYACC-J + Parser.java)
• Semantic Analyzer (semantica package)
• Symbol Table (beans package)
• Utility Component (ArchivoReader)
• Test Harness (JUnit in src/test)
• External Tools (BYACC-J executable)
b. Relationships and interactions
• Source Code → ArchivoReader → Lexical Analyzer
• Lexical Analyzer → stream of Tokens → Parser
• Parser → calls semantic routines (IRutinaSemantica implementations)
• Semantic routines ↔ Symbol Table (insert / lookup entries)
• Parser / Semantic Analyzer → produces output (errors, logs)
• Build scripts invoke BYACC-J to regenerate parser classes, compile Java code, run JUnit tests.
c. Architectural patterns / design principles
• Pipeline (lex → parse → semantic)
• Separation of concerns by package
• Use of a parser generator (BYACC-J) to decouple grammar from code
• Strategy pattern for semantic routines (IRutinaSemantica interface with many implementations)
d. Key technologies
• Java 1.5+
• BYACC-J for syntax analysis
• JUnit 3.8.1 for testing
• Batch / shell scripts for build automation
Essential architectural elements
• Don’t just list every class; group them by function (all semantic routines under “Semantic Analyzer”).
• External dependencies (BYACC-J, JUnit) and their role in the workflow.
• Both build-time (parser generation, compilation) and run-time (analysis pipeline) phases.
• Symbol Table is prominently shown as a shared resource.