AutonomousVehicleControlBeginnersGuide
关于自动驾驶车辆控制算法的 Python 示例代码与文档。本项目可作为技术指南书,供初学者学习这些算法与软件架构。
AI 翻译
尚未检测到更新。GitHub 发布版本后会显示在这里。
制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗Interactive GUI for Bottom-Up Parsing (LR Family), Compiler Design Lab.
Live demo: https://lr-parser-visualizer.vercel.app
Review mode (LR(0) and SLR(1) only): https://lr-parser-visualizer.vercel.app/?review1
Source code: https://github.com/likithtech2006-pixel/LR-Parser-Visualizer
You enter a grammar, pick LR(0), SLR(1), CLR(1) or LALR(1), and watch the parser being built one step at a time:
Light theme by default, with a dark-mode toggle in the top-right corner.
No installation and no server. Open index.html in Chrome, Edge, Firefox or Safari.
Review 1 mode: open index.html?review1 to show only the LR(0) and SLR(1) variants (CLR(1) and LALR(1) are hidden).
→ next step, ← previous step.E -> E + T | T
T -> T * F | F
F -> ( E ) | id
->, → and ::= all work as the arrow. Use | for alternatives.S->CC, aAb and (E).)ε, eps or epsilon for an empty body.| Example | LR(0) | SLR(1) | LALR(1) | CLR(1) | Shows |
|---|---|---|---|---|---|
S → C C, C → c C | d | ✓ | ✓ | ✓ | ✓ | LALR merge I36, I47, I89 |
S → ( L ) | x, L → S | L , S | ✓ | ✓ | ✓ | ✓ | a pure LR(0) grammar |
S → ( S ) S | ε | ✗ | ✓ | ✓ | ✓ | ε-productions |
Expression grammar E → E + T | T … | ✗ S/R | ✓ | ✓ | ✓ | LR(0) conflict demo |
S → A a | B b, A → x, B → x | ✗ R/R | ✓ | ✓ | ✓ | LR(0) reduce-reduce |
S → L = R | R, L → * R | id, R → L | ✗ | ✗ S/R | ✓ | ✓ | SLR(1) conflict demo |
S → a A d | b B d | a B e | b A e, A → c, B → c | ✗ | ✗ | ✗ R/R | ✓ | LALR(1) conflict demo |
E → E + E | E * E | ( E ) | id | ✗ | ✗ | ✗ | ✗ S/R | CLR(1) conflict demo (ambiguous) |
S → i S e S | i S | a | ✗ | ✗ | ✗ | ✗ S/R | dangling else |
S → A | B, A → x, B → x | ✗ | ✗ | ✗ | ✗ R/R | reduce-reduce everywhere |
The same grammars are in samples/ as text files.
| File | Purpose |
|---|---|
index.html | page structure: Bottom-Up Parsing → LR Parsing / Operator Precedence |
style.css | light and dark themes, layout, table and diagram styling |
engine.js | the parser-construction engine (pure logic, no UI): grammar reading, FIRST/FOLLOW, closure/GOTO, LR(0) and LR(1) collections, LALR merging, ACTION/GOTO table with provenance and conflicts, shift-reduce driver |
graph.js | layered layout and SVG drawing of the state diagram and the parse tree |
app.js | UI controller: phases, step counters, inspector, examples, theme |
lr_parser.c | console version of the same engine in C (all four variants) |
samples/*.txt | test grammars |
tests/engine.test.js | automated tests against textbook results |
node tests/engine.test.js
node tests/examples.test.js
examples.test.js runs 67 more grammar/variant cases with hand-written expected answers, cross-checks every string with an independent Earley parser, and exhaustively compares all strings up to length 6 (about 139,000). Results are in docs/TEST_RESULTS.md.
21 checks against Aho, Lam, Sethi & Ullman (the Dragon Book): state counts (12 LR(0) / 22 CLR / 12 LALR for the expression grammar, I36/I47/I89 for S → CC), FOLLOW sets, conflict type and location for each demo, and the 14-step SLR trace for id * id + id.
gcc -O2 -Wall -o lr_parser lr_parser.c
./lr_parser samples/expr.txt SLR1 "id * id + id"
./lr_parser samples/lalr_rr.txt LALR1 "a c d"
./lr_parser samples/lr_eq.txt SLR1 "id = * id"
Variants: LR0, SLR1, CLR1, LALR1. The program prints the augmented grammar, FIRST/FOLLOW, the canonical collection (with GOTO origins and closure items), the LALR merges, the ACTION/GOTO table with conflicts and the verdict, and the parse trace. For every sample grammar and variant, its state and conflict counts match the JavaScript engine.
On macOS, if
gccasks you to accept the Xcode licence, runsudo xcodebuild -license acceptonce.