How kafmws/fakeyacc works
Project Type and Purpose
• This is a parser generator tool (a simplified or “fake” version of Yacc) that takes grammar definitions for different languages (ANSIC and Lua5.3) and processes them to compute parsing tables, FIRST/FOLLOW sets, production rules, and similar artifacts.
• The README’s title (“FakeYacc”) confirms that this project centers on generating parser components from language grammars.
File Structure
• Top-level files such as Candidate.java, FakeYACC.java, NonTerminal.java, Terminal.java, and Symbol.java indicate core logic and data structure definitions to support grammar parsing.
• Directories “ANSIC” and “Lua5.3” show that the project supports at least two grammatical domains. Each of these directories contains subdirectories (like “grammar”, “out”, “terminalSet”, “verification”) which suggest separation between source definitions, computed artifacts, and verification modules.
• A “pre” folder under Lua5.3, which may represent a pre-processing phase unique to that language.
Main Components of the System
• Driver/Core Module: Represented by FakeYACC.java; the main entry point that orchestrates the parsing generation process.
• Grammar Input Modules: For both ANSIC and Lua5.3, use “grammar” folders as the sources of grammar definitions.
• Language-specific Processors: Separate modules (or pipelines) that process the grammar for each language. This may include:
• Computation of Bison-style BNF representations (BisonBNF directory)
• Calculation of FIRST and FOLLOW sets
• Generation of parsing tables and production rules.
• Data Structure Components: Classes like NonTerminal.java, Terminal.java, and Symbol.java; these support representing grammar symbols and productions.
• Pre-processing and Verification Modules: The “pre” directory for Lua5.3 and “verification” directories in both language modules suggest an initial pre-processing phase and a validation phase respectively.
• Output Modules: The “out” directories (and their subdivisions) store results such as parsing tables, computed sets (FIRST, FOLLOW), production rules, and terminal sets.
Relationships and Interactions Between Components
• A user or external system provides grammar definitions (input) through the “grammar” directories.
• The FakeYACC core module reads these grammar inputs and then routes them through a processing pipeline which is split into several stages:
• The first stage parses the grammar, generating intermediate representations (BisonBNF, production rules, etc.).
• Next, the system computes necessary sets (FIRST, FOLLOW) and builds data structures using the NonTerminal, Terminal, and Symbol classes.
• Any pre-processing (for Lua5.3) and verification steps are applied to ensure correctness.
• Finally, the system outputs artifacts (parsing tables, production rules, etc.) into the “out” directories.
Architectural Patterns and Design Principles
• Modularity: Separate directories and modules for each language grammar signify modular design.
• Pipeline/Layered Architecture: The separate stages—input, processing (computation of FIRST/FOLLOW, parsing table generation), data structure manipulation, verification, and output generation—are best represented as sequential layers or connected modules.
• Separation of Concerns: Clearly isolate language-specific processes (ANSIC vs. Lua5.3) while using common core components.
Relevant Technologies and Libraries
• While the file tree does not show external frameworks, note that the project is Java-based. Emphasize that the system uses object-oriented design principles evident from the .java files.
• If the tool generates artifacts for parser generation (similar to Yacc), any conventions or libraries borrowed from classical compiler construction techniques should be noted.