- It's a git test, which means I'm totally a green hand.
- It's just one of my assignment, and it may not satisfy you.
- Ignore my bad code style...
- Most of the work done in Visual Studio Code
Step 1: Clone my repository to your workplace via git
Step 2: cd My-Compiler-Syntax-Checking-Project && make && ./target
Step 3: <input your testing code>
tip: In the last Step, press Ctrl+D to finish inputting.
Step 1: Create a None-file ConsoleApplication in VS
Step 2: Import the *.h and *.cpp files
Step 3: Click Run Button and a terminal Window will pop up
Step 4: <input your testing code>
tip: In the last Step, press Ctrl+Z to finish inputting.
Step 1: Change directory to your current workspace in cmd or powershell
Step 2: Write a batch script(compiler.bat): g++ main.cpp Syntax.h Syntax.cpp Word_info.h -o target
Step 3: Run compiler.bat file by typing .\compiler.bat and keep waiting while compiling
Step 4: After Step 3, input .\target to begin Syntax Checking
Step 5: <input your testing code>
tip: In the last Step, press Ctrl+Z to finish inputting.
Program(A) → ExtDefList(B)
ExtDefList(B) → ExtDef(C) ExtDefList(B) | ɛ
ExtDef(C) → Specifier(D) FunDec(E) Compst(F)
Specifier(D) → TYPE
VarDec(G) → ID
FunDec(E) → ID LP RP
Compst(F) → LC DefList(H) StmtList(I) RC
StmtList(I) → Stmt(J) StmtList(I) | ɛ
Stmt(J) → Exp(K) SEMI | RETURN Exp(K) SEMI
DefList(H) → Def(L) DefList(H) | ɛ
Def(L) → Specifier(D) DecList(M) SEMI
DecList(M) → Dec(N)
Dec(N) → VarDec(G) ASSIGNOP Exp(K)
Exp(K) → LP Exp(K) RP | NOT Exp(K) | INT | ID
1.2.1 A → B
1.2.2 B → C B | ɛ
1.2.3 C → D E F
1.3.1 D → TYPE
1.4.1 G → ID
1.4.2 E → ID LP RP
1.5.1 F → LC H I RC
1.5.2 I → J I | ɛ
1.5.3 J → K SEMI | RETURN K SEMI
1.6.1 H → L H | ɛ
1.6.2 L → D M SEMI
1.6.3 M → N
1.6.4 N → G ASSIGNOP K
1.7.1 K → LP K RP | NOT K | INT | ID