NetC is a domain-specific language designed with a focus on logic-flow and network-like structures. This project implements a lightweight compiler pipeline—including a Scanner, Parser, and Semantic Analyzer—designed to transform NetC source into a validated Abstract Syntax Tree (AST).
The compiler is built in C++17 and follows a classic three-phase analysis:
- Lexical Analysis (Scanner): Converts source code into a stream of tokens.
- Syntax Analysis (Parser): Generates an Abstract Syntax Tree (AST) using Recursive Descent.
- Semantic Analysis: Enforces scope rules, type checking, and variable initialization invariants.
NetC uses a strict type system to ensure memory safety.
| Keyword | Logical Type | C++ Equivalent | Memory Logic |
|---|---|---|---|
dnum |
Discrete Number | int |
Integer values for indexing and counting. |
cnum |
Continuous Number | float |
Real numbers for calculations and weights. |
text |
String Literal | std::string |
Sequence of characters for messages. |
flag |
Boolean Logic | bool |
Binary state: true or false. |
network: Defines a function or logic block.init: The main entry point of the program (similar tomainin C++).yield: Returns a value from anetworkfunction.feed/forward: Input and Output operations.iterate/until: Loop structures for repetitive logic.
Run the compiler against a .netc file using the following syntax:
./bin/netc tests/example.netc [options]Available Options:
--show-ast: Prints the Abstract Syntax Tree to the console.--show-symbols: Displays the Symbol Table and Function Table.-s/--scan-only: Executes only the Lexical Analysis phase.-p/--parse-only: Executes only the Syntax Analysis phase.
To use the interactive Streamlit-based GUI:
- Install streamlit
pip install streamlit- Navigate to the project root then run the app:
streamlit run src/netc_streamlit.pyNetC-Compiler/
├── bin/ # Compiled executable binaries
├── docs/ # Documentation for the language and compiler
├── include/ # Header files (.h)
├── output/ # Generated token lists and analysis results
├── src/ # Source code files (.cpp)
├── tests/ # Sample NetC source files (.netc)
├── .gitignore # Files and folders to be ignored by Git
└── README.md # Project overview and documentation