# jbezoz/c_tac_mips architecture

> Architecture diagram of the GitHub repository jbezoz/c_tac_mips, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jbezoz/c_tac_mips
- Repository: https://github.com/jbezoz/c_tac_mips

## Overview

#### 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`](https://github.com/jbezoz/c_tac_mips/blob/main/Makefile) (Makefile), [`input.c`](https://github.com/jbezoz/c_tac_mips/blob/main/input.c) (Input Driver), [`preprocessor.y`](https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.y) (Semantic Actions), [`preprocessor.l`](https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.l) (Scanner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build Toolchain"]
  node_makefile["Makefile<br/>build entry"]
  node_c_compiler{{"C Compiler<br/>external tool"}}
  node_flex{{"Flex / Lex<br/>external tool"}}
  node_bison{{"Bison / Yacc<br/>external tool"}}
  node_native_executable["Native Compiler<br/>executable"]
end

subgraph group_frontend["Compiler Front End"]
  node_input["Input Driver<br/>C source<br/>[input.c]"]
  node_lexer["Scanner<br/>Flex specification<br/>[preprocessor.l]"]
  node_token_stream["Token Stream<br/>compiler boundary"]
  node_parser["Parser Grammar<br/>Bison specification<br/>[preprocessor.y]"]
end

subgraph group_core["Translation Core"]
  node_parser_actions["Semantic Actions<br/>translation layer<br/>[preprocessor.y]"]
  node_compiler_api["Compiler API<br/>C header<br/>[function.h]"]
  node_mips_output["MIPS-Oriented Output<br/>compiler output"]
end

node_makefile -->|"invokes"| node_flex
node_makefile -->|"invokes"| node_bison
node_makefile -->|"invokes"| node_c_compiler
node_flex -->|"generates scanner from"| node_lexer
node_bison -->|"generates parser from"| node_parser
node_c_compiler -->|"builds"| node_native_executable
node_native_executable -->|"starts"| node_input
node_input -->|"passes source input"| node_lexer
node_lexer -->|"emits"| node_token_stream
node_token_stream -->|"feeds"| node_parser
node_parser -->|"reductions execute"| node_parser_actions
node_input -.->|"uses"| node_compiler_api
node_parser_actions -.->|"uses"| node_compiler_api
node_parser_actions -->|"produces"| node_mips_output

click node_makefile "https://github.com/jbezoz/c_tac_mips/blob/main/Makefile"
click node_input "https://github.com/jbezoz/c_tac_mips/blob/main/input.c"
click node_lexer "https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.l"
click node_parser "https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.y"
click node_parser_actions "https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.y"
click node_compiler_api "https://github.com/jbezoz/c_tac_mips/blob/main/function.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_makefile,node_c_compiler,node_flex,node_bison,node_native_executable toneBlue
class node_input,node_lexer,node_token_stream,node_parser toneAmber
class node_parser_actions,node_compiler_api,node_mips_output toneMint
```

## Components

### Build Toolchain

- [Makefile](https://github.com/jbezoz/c_tac_mips/blob/main/Makefile): build entry · Generates parser/scanner sources and compiles the native executable. · `Makefile`
- **C Compiler**: external tool
- **Flex / Lex**: external tool
- **Bison / Yacc**: external tool
- **Native Compiler**: executable · Native C program produced by the build.

### Compiler Front End

- [Input Driver](https://github.com/jbezoz/c_tac_mips/blob/main/input.c): C source · Owns input handling and starts parsing/output coordination. · `input.c`
- [Scanner](https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.l): Flex specification · Recognizes source tokens and supplies semantic values. · `preprocessor.l`
- **Token Stream**: compiler boundary
- [Parser Grammar](https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.y): Bison specification · Defines syntax and invokes semantic translation actions. · `preprocessor.y`

### Translation Core

- [Semantic Actions](https://github.com/jbezoz/c_tac_mips/blob/main/preprocessor.y): translation layer · Converts grammar reductions into compiler-owned representation or output. · `preprocessor.y`
- [Compiler API](https://github.com/jbezoz/c_tac_mips/blob/main/function.h): C header · Shared declarations for compiler state and code-generation interfaces. · `function.h`
- **MIPS-Oriented Output**: compiler output · Generated MIPS representation or emitted output.

## Connections

- 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
