Compiler Design Lab Project

Syntax Tree Visualizer

Explore parsing, semantic analysis, optimization and virtual target code.

Recursive-Descent Parser Interactive SVG Zero Dependencies
Interactive Lab
Compiler Workbench Inspect each stage below
1Source Code→ 2Lexical Analysis→ 3Syntax Analysis→ 4Semantic Checks→ 5TAC & Optimization
01 · Input

Source Code

Paste an educational C-like program or write one directly, then generate its tokens and AST.

program.txt Ctrl + Enter

Tip: C-style #include lines are ignored before parsing. End normal statements with a semicolon.

02 · Visual Output

Abstract Syntax Tree

Click a node to inspect it. Drag to pan and use the mouse wheel to zoom.

100%
Nodes0
Depth0
Tokens0
ParserReady
⌘

No tree generated

Enter code and press “Analyze Program”.

Statement Expression Value
Traversal order will appear here.
04 · Beyond the syntax tree

Compiler Workbench

Follow declarations through scopes, intermediate instructions and basic blocks.

Analyze a program to inspect compiler stages.

Diagnostics

Checks names, lexical scopes, constant writes, call arity and control-statement placement. Full C type rules and definite assignment are not implemented.

Scoped Symbol Table

05 · Syntax analysis laboratory

Grammar Lab

Edit a context-free grammar and inspect predictive parsing.

One rule per line: E -> T E_tail. Separate all symbols with spaces; use | for alternatives and ε or epsilon for empty. First left-hand side is the start symbol. Any symbol never defined on the left is a terminal.

Enter terminal names separated by spaces. Leave empty to test the empty word. The end marker $ is added automatically. This grammar is independent of the C-like source parser above.

FIRST and FOLLOW

Numbered Productions

LL(1) Predictive Parsing Table

P1, P2, … refer to productions above. Multiple rules in one cell are a conflict; empty cells are parsing errors.

Parsing Trace