How jbezoz/c_tac_mips works
Purpose
C_TAC_MIPS is a compact C-based compiler/transpiler project centered on parsing preprocessed source and producing a MIPS-oriented representation or output. The repository is built around a lexer/parser pipeline rather than an application server or web runtime.
Entry Points and Build
• Makefile is the primary build entry point and likely drives lexer/parser generation plus C compilation.
• input.c is the probable executable-facing source file: it should own input handling, invoke parsing, and/or coordinate output generation.
• The generated program is expected to run as a native C executable.
Lexical Analysis
• preprocessor.l defines the Flex/Lex scanner.
• This stage consumes source text, recognizes tokens, and supplies them to the parser.
• The lexer/parser boundary is the token stream and semantic values defined or shared through generated parser headers and project declarations.
Parsing and Translation Control
• preprocessor.y defines the Yacc/Bison grammar and parser actions.
• It is the likely central control layer for syntactic structure, semantic actions, and translation from source constructs into TAC, MIPS instructions, or intermediate state.
• Parser actions are the principal boundary where language syntax becomes compiler-owned data structures or emitted code.
Shared Compiler State and Interfaces
• function.h contains shared declarations for compiler functions, structures, globals, or code-generation interfaces.
• input.c and grammar actions in preprocessor.y should depend on this contract rather than directly duplicating compiler state.
• This header is the key internal API boundary between driver logic, parser actions, and any code-emission routines.
Primary Flow
1. Native executable starts from logic in input.c.
2. Input source is passed to the scanner from preprocessor.l.
3. Tokens flow into the parser defined by preprocessor.y.
4. Grammar reductions execute semantic/translation actions.
5. Shared interfaces in function.h support intermediate handling and final MIPS-oriented output.
Runtime and External Dependencies
• Build/runtime dependencies are a C compiler plus Flex/Lex and Bison/Yacc-compatible tools, coordinated by Makefile.
• No database, network service, browser runtime, cloud infrastructure, or external API integration is represented in the repository tree.
Main entry points: Makefile Makefile · input.c Input Driver · preprocessor.y Semantic Actions · preprocessor.l Scanner
Components 12
Build Toolchain
- Makefile · Generates parser/scanner sources and compiles the native executable.
Makefile - C Compiler
- Flex / Lex
- Bison / Yacc
- Native Compiler · Native C program produced by the build.
Compiler Front End
- Input Driver · Owns input handling and starts parsing/output coordination.
input.c - Scanner · Recognizes source tokens and supplies semantic values.
preprocessor.l - Token Stream
- Parser Grammar · Defines syntax and invokes semantic translation actions.
preprocessor.y
Translation Core
- Semantic Actions · Converts grammar reductions into compiler-owned representation or output.
preprocessor.y - Compiler API · Shared declarations for compiler state and code-generation interfaces.
function.h - MIPS-Oriented Output · Generated MIPS representation or emitted output.
Connections 14
- Makefile → Flex / Lex: invokes
- Makefile → Bison / Yacc: invokes
- Makefile → C Compiler: invokes
- Flex / Lex → Scanner: generates scanner from
- Bison / Yacc → Parser Grammar: generates parser from
- C Compiler → Native Compiler: builds
- Native Compiler → Input Driver: starts
- Input Driver → Scanner: passes source input
- Scanner → Token Stream: emits
- Token Stream → Parser Grammar: feeds
- Parser Grammar → Semantic Actions: reductions execute
- Input Driver → Compiler API: uses
- Semantic Actions → Compiler API: uses
- Semantic Actions → MIPS-Oriented Output: produces