Skip to content

Commit 2f28ebe

Browse files
committed
Removed unverifiable documentation metrics
1 parent bc634cf commit 2f28ebe

File tree

13 files changed

+48
-76
lines changed

13 files changed

+48
-76
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)
44
![Language: C11](https://img.shields.io/badge/Language-C11-blue.svg)
55
![Build: CMake](https://img.shields.io/badge/Build-CMake_3.14+-orange.svg)
6-
![Tests: 81 passing](https://img.shields.io/badge/Tests-81_passing-brightgreen.svg)
7-
![cppcheck: clean](https://img.shields.io/badge/cppcheck-clean-brightgreen.svg)
86

97
Minimal C subset → VHDL translator
108

@@ -73,7 +71,7 @@ Each C function becomes a VHDL entity with clock/reset ports, input parameters a
7371
- Self-contained functions with return value propagation, plus structs and arrays
7472
- VHDL entity/architecture generation with clock/reset, signals, and synchronous processes
7573
- Multi-level error diagnostics (error/warning/note across 5 categories)
76-
- 81 unit, integration, structural validation, and edge case tests (GoogleTest)
74+
- GoogleTest-based unit, integration, structural validation, and edge case coverage
7775

7876
## Requirements
7977

@@ -115,7 +113,7 @@ examples/ — Sample C input files
115113
- No pointer support
116114
- No `switch/case` or `do-while`
117115
- Function calls are parsed, but cross-function hardware wiring is not yet synthesized. Multi-function files emit independent entities, so keep hardware-generating examples self-contained.
118-
- Generated VHDL targets the currently supported C subset. Structural well-formedness is verified by self-contained validation tests (balanced constructs, declared signals, proper type wrapping). The output is unoptimized — no resource sharing, no pipelining, no constant folding (see [ROADMAP.md](ROADMAP.md) Phase 4 for planned optimizations)
116+
- Generated VHDL targets the currently supported C subset. Structural well-formedness is verified by self-contained validation tests (balanced constructs, declared signals, proper type wrapping). Current output does not perform resource sharing, pipelining, or constant folding (see [ROADMAP.md](ROADMAP.md) for planned future work)
119117

120118
## Documentation
121119

ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This document outlines the planned features, improvements, and milestones for Ga
1818
- Multi-level error diagnostics (error/warning/note × 5 categories)
1919
- Source location tracking with line/column reporting
2020
- Colored terminal output (ANSI: red errors, yellow warnings, blue notes)
21-
- Unit, integration, and edge case test suite (75 tests, GoogleTest)
21+
- Unit, integration, structural validation, and edge case test coverage (GoogleTest)
2222
- Signal naming collision handling (`emit_mapped_signal_name()` with `_local` suffix, PR #12)
2323

2424
### 📋 Planned

docs/source/architecture.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Developer Debug Output
5959
Global State and Threading
6060
--------------------------
6161

62-
The compiler uses global state in several modules for simplicity and performance:
62+
The compiler uses global state in several modules to keep the current single-file pipeline simple:
6363

6464
**Error Handler** (``error_handler.c``):
6565

@@ -70,7 +70,7 @@ The compiler uses global state in several modules for simplicity and performance
7070
**Symbol Tables** (``symbol_structs.c``, ``symbol_arrays.c``):
7171

7272
- Global tables for struct definitions and array size tracking.
73-
- **Rationale**: Struct types and array sizes are needed during code generation but are discovered during parsing. A global table provides O(1) lookup without threading pointers through the AST.
73+
- **Rationale**: Struct types and array sizes are needed during code generation but are discovered during parsing. A global table keeps that information available without threading additional context through the AST.
7474
- **Limitation**: Not thread-safe. For parallel compilation, each thread would need isolated symbol tables.
7575
- **Reset**: Call ``reset_struct_table()`` and ``reset_array_table()`` between compilations.
7676

docs/source/code_quality.rst

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,11 @@ parse_expression.c
213213
size_t copy_length = strlen(source);
214214
char full_expression_buffer[FULL_EXPRESSION_BUFFER_SIZE];
215215
216-
**Impact:**
216+
**Result:**
217217

218-
* 80% reduction in main function size
219-
* Each helper function is easily testable in isolation
220-
* Clear separation between different expression types
221-
* Much easier to understand and maintain
218+
* Each helper function can be tested in isolation
219+
* Expression handling is separated into focused helpers
220+
* The control flow is easier to follow and modify
222221

223222
parse_statement.c
224223
~~~~~~~~~~~~~~~~~
@@ -275,13 +274,12 @@ parse_statement.c
275274
ASTNode *struct_node, *field_node;
276275
int index_value, array_size;
277276
278-
**Impact:**
277+
**Result:**
279278

280-
* 87% reduction in main function size
281-
* Each statement type has dedicated, testable function
282-
* Much clearer control flow
283-
* Easy to add new statement types
284-
* Dramatically improved maintainability
279+
* Each statement type has a dedicated, testable function
280+
* Control flow is easier to trace
281+
* New statement types can be added within the existing structure
282+
* Maintenance work is localized to smaller helpers
285283

286284
parse_function.c
287285
~~~~~~~~~~~~~~~~
@@ -590,12 +588,12 @@ The refactoring effort delivered significant improvements:
590588
* Pattern is established and consistent
591589
* New contributors can easily follow established style
592590

593-
**Quality Metrics:**
591+
**Observed outcomes:**
594592

595-
* Average function length reduced by 70-85%
596-
* Cyclomatic complexity reduced significantly
597-
* Code duplication eliminated
598-
* Named constants replace all magic numbers
593+
* Helper functions are shorter and more focused
594+
* Named constants replace magic numbers in the refactored areas
595+
* Repeated parsing patterns were extracted into shared helpers
596+
* Control-flow handling follows a consistent structure across modules
599597

600598
Future Refactoring Opportunities
601599
---------------------------------
@@ -629,14 +627,14 @@ Areas for potential future improvement:
629627
Conclusion
630628
----------
631629

632-
The comprehensive refactoring of the parser modules has transformed the codebase from a collection of monolithic functions into a well-organized, maintainable, and extensible foundation. The established patterns and principles provide a clear model for future development and make the compiler significantly easier to understand, modify, and extend.
630+
The parser refactoring replaced large monolithic functions with smaller helpers and clearer module boundaries. The resulting structure provides a concrete model for future changes and makes the compiler easier to review, modify, and extend.
633631

634632
The refactoring demonstrates that **code quality is not just about correctness** — it's about creating code that is:
635633

636634
* Easy to understand
637635
* Easy to modify
638636
* Easy to test
639637
* Easy to extend
640-
* A pleasure to work with
638+
* Consistent with the surrounding codebase
641639

642640
These improvements lay a solid foundation for future compiler enhancements and serve as a model for maintaining high code quality throughout the project.

docs/source/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Development Setup
1212
cd gates && mkdir build && cd build
1313
cmake .. -DCMAKE_BUILD_TYPE=Debug
1414
cmake --build .
15-
ctest # Verify all 75 tests pass
15+
ctest # Verify the test suite passes
1616
1717
Branch Naming
1818
-------------

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ clocked VHDL for its supported subset, with clock/reset ports, signals, and sync
2525
Features
2626
--------
2727

28-
- Recursive-descent parser with full operator precedence (12 levels)
28+
- Recursive-descent parser with full operator precedence
2929
- Control flow: ``if/else``, ``while``, ``for``, ``break``, ``continue``
3030
- Self-contained functions with return value propagation, plus structs with field access and arrays with indexing
3131
- VHDL entity/architecture generation with clock/reset, signals, and synchronous processes
3232
- Multi-level error diagnostics with colored output (error/warning/note across 5 categories)
33-
- 81 unit, integration, structural validation, and edge case tests (GoogleTest)
33+
- GoogleTest-based unit, integration, structural validation, and edge case coverage
3434

3535
See :doc:`examples` for C-to-VHDL translation samples and :doc:`modules` for the
3636
complete source code reference.

docs/source/internals/ast.rst

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ The core AST node structure is defined in ``include/astnode.h``:
5151
.. code-block:: text
5252
5353
ASTNode (stack or heap)
54-
├─ type: NodeType (4 bytes)
55-
├─ token: Token struct (264 bytes)
54+
├─ type: NodeType
55+
├─ token: Token struct
5656
├─ value: char* → heap-allocated string
5757
├─ parent: ASTNode*
5858
├─ children: ASTNode** → heap-allocated array
@@ -239,7 +239,7 @@ Adds a child node to a parent node, growing the children array if necessary:
239239
**Behavior:**
240240

241241
* **Lazy initialization**: Allocates children array on first child (initial capacity = 4)
242-
* **Dynamic growth**: Doubles capacity when array is full (amortized O(1) insertion)
242+
* **Dynamic growth**: Doubles capacity when the current array is full
243243
* **Bidirectional links**: Sets child's ``parent`` pointer for bottom-up traversal
244244
* **Null safety**: Checks for NULL ``parent`` or ``child`` parameters
245245
* **Error handling**: Reports errors via ``log_error()`` and returns early on allocation failure (no ``exit``)
@@ -541,37 +541,13 @@ Memory Management Patterns
541541
* Parent nodes "own" their children (responsible for freeing them)
542542
* Root node must be freed with ``free_node()`` to avoid leaks
543543

544-
Performance Characteristics
545-
----------------------------
546-
547-
**Node creation:**
548-
549-
* Time: O(1)
550-
* Space: ~280 bytes per node (struct + initial overhead)
551-
552-
**Child addition:**
553-
554-
* Amortized time: O(1) (due to doubling strategy)
555-
* Worst case: O(n) when array needs reallocation
556-
* Space: Wastes at most 50% of allocated capacity
557-
558-
**Tree traversal:**
559-
560-
* Time: O(n) where n is total number of nodes
561-
* Space: O(h) stack depth where h is tree height (for recursive traversal)
562-
563-
**Memory overhead:**
564-
565-
* Node struct: 280+ bytes
566-
* Children array: 8 bytes per child slot (64-bit pointers)
567-
* Wasted capacity: Up to 50% of children array (due to doubling)
568-
569-
**Example memory usage for 100-node AST:**
544+
Operational Characteristics
545+
---------------------------
570546

571-
* Node structs: ~28 KB
572-
* Value strings: Variable (depends on identifier lengths)
573-
* Children arrays: ~3 KB (assuming average 4 children per node with 50% waste)
574-
* **Total: ~32-40 KB**
547+
* Node allocation is explicit and paired with ``free_node()`` cleanup
548+
* Child arrays are created lazily and expanded as the tree grows
549+
* Recursive traversal utilities depend on tree depth and structure
550+
* Memory use depends on node count, child fan-out, and stored string values
575551

576552
Design Decisions
577553
----------------
@@ -585,7 +561,7 @@ Design Decisions
585561

586562
**Dynamic children array:**
587563

588-
* **Pro**: Efficient for nodes with many children (statements, function bodies)
564+
* **Pro**: Works well for nodes with many children (statements, function bodies)
589565
* **Pro**: No fixed limits on tree width
590566
* **Con**: Memory overhead for leaf nodes (NULL children array)
591567
* **Con**: Reallocation overhead during tree construction
@@ -594,7 +570,7 @@ Design Decisions
594570

595571
* **Pro**: Enables bottom-up traversal (child to parent)
596572
* **Pro**: Useful for semantic analysis (e.g., finding enclosing function)
597-
* **Con**: Extra 8 bytes per node for ``parent`` pointer
573+
* **Con**: Additional per-node storage for the ``parent`` pointer
598574
* **Con**: Must maintain invariant during tree manipulation
599575

600576
**String values:**
@@ -633,8 +609,8 @@ The AST implementation provides:
633609

634610
* **Simple, uniform node structure** with dynamic children arrays
635611
* **Minimal memory management API**: ``create_node()``, ``add_child()``, ``free_node()``
636-
* **Efficient child storage** with amortized O(1) insertion
612+
* **Geometric child-array growth** as nodes are added
637613
* **Bidirectional tree links** for flexible traversal
638-
* **Recursive memory deallocation** for easy cleanup
614+
* **Recursive memory deallocation** for straightforward cleanup
639615

640-
The design prioritizes **simplicity and ease of use** over memory efficiency, making it straightforward to construct and traverse the AST during parsing and code generation.
616+
The design prioritizes **simplicity and ease of use** over more specialized representations, making it straightforward to construct and traverse the AST during parsing and code generation.

docs/source/internals/codegen.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Internal function that dispatches to specialized generators based on node type:
7676
}
7777
}
7878
79-
**Design:** Uses switch statement for efficient dispatch. Ignores node types that don't directly produce VHDL output (e.g., ``NODE_VAR_DECL`` is handled within statement generation).
79+
**Design:** Uses a central switch-based dispatcher. Node types that do not directly produce VHDL output are handled in the relevant higher-level generators (for example, ``NODE_VAR_DECL`` is handled within statement generation).
8080

8181
Program Generation
8282
------------------

docs/source/internals/error_handling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ Why Variadic Functions?
494494
Printf-style variadic functions (``...``) are used because:
495495

496496
1. Familiar interface for C programmers
497-
2. Efficient string formatting
497+
2. Formatted string composition without custom message builders
498498
3. Type-safe with compiler warnings
499499
4. Flexible message composition
500500

docs/source/internals/lexer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Tokens are represented by the ``Token`` struct defined in ``include/token.h``:
6464
**Fields:**
6565

6666
* ``type``: The category of the token (keyword, identifier, operator, etc.)
67-
* ``value``: The actual text of the token (fixed-size buffer of ``TOKEN_VALUE_SIZE`` bytes)
67+
* ``value``: The actual text of the token (stored in a fixed-size buffer)
6868
* ``line``: Line number where the token appears (for error messages)
6969

7070
Token Types
@@ -94,7 +94,7 @@ The lexer recognizes 13 distinct token types defined in ``include/token.h``:
9494

9595
* Operators are unified into a single ``TOKEN_OPERATOR`` type. The actual operator is distinguished by the token's ``value`` field.
9696
* Keywords are identified after tokenization by checking against a keyword table.
97-
* Punctuation characters have dedicated token types for efficient parsing.
97+
* Punctuation characters have dedicated token types for straightforward parsing.
9898

9999
Keyword Recognition
100100
-------------------

0 commit comments

Comments
 (0)