How gustavoeso/linguagem-programacao works
Main Components and Their Roles
• Lexical Analyzer:
• Two implementations: one built with Flex (lexer.l in Flex_Bison, generating lex.yy.c) and another in Python (lexer.py).
• This component as responsible for tokenizing the input source code.
• Syntactic Analyzer (Parser):
• Again two versions: a C implementation using Bison (parser.y leading to parser.tab.c and parser.tab.h) and a Python version (parser.py).
• That the parser uses the EBNF grammar provided in the README.
• Interpreter / Execution Engine:
• The Python files (interpreter.py, main.py, and prepro.py) serve as the runtime to execute commands defined in ProductivityLang (like task management commands, control structures, function definitions, etc.).
• Build Automation Component:
• The Makefile (located in Flex_Bison) is essential for automating Flex and Bison processing and compiling the final C executable (“productivitylang”).
• Testing and Validation:
• “tests” directories inside both “linguagem” (with test*.org files) and “linguagem/Flex_Bison/tests” (with input_file* samples). Show how these feed into the interpreters/analyzers to validate the language’s behavior.
• External/Supporting Artifacts:
• Configuration files like tasks.json and tasks_test.json are used for saving/loading task data in ProductivityLang.
Relationships and Data Flow
• Input (ProductivityLang source code) is fed into the Lexical Analyzer.
• The Lexical Analyzer outputs tokens that pass to the Parser.
• The Parser builds an Abstract Syntax Tree (AST) based on the EBNF and defined grammar rules.
• The Interpreter then evaluates this AST to perform operations (defining tasks, setting deadlines, etc.) and interacts with the underlying task data structures.
• The Makefile coordinates the build processes, ensuring that modifications in the lexical/syntax modules lead to automatic regeneration of the C components.
• Testing modules/interface: Test input files (from “tests” directories) are used to drive the interpreters and verify system behavior.
Architectural Patterns and Design Principles
• Layered Architecture:
• Clearly separate the “front end” (lexer and parser, regardless of implementation language) from the “execution” layer (interpreter).
• Dual Implementation Path:
• Use of Makefile for Build Automation:
• That the build system uses typical Unix build procedures, coordinating Flex, Bison, and GCC commands.
• Modularity:
• Each component (lexical analysis, syntax analysis, interpretation, testing, and build automation) is self-contained and interacts via well-defined interfaces (e.g., token definitions shared via types.h).
Relevant Technologies, Frameworks, and Libraries
• Flex and Bison for C-based lexical and syntactic analysis.
• GCC as the compiler for the generated C code.
• Python for a more dynamic, scripting-based interpreter approach.
• Standard build tools (Make) to automate the compilation process.
Detailing the Essential Architectural Elements
• Maintain a focus on how each component collaborates to enforce the language specifications outlined in the EBNF grammar and the example use cases provided in the README.