Skip to content

Vicecorehp/My-Compiler-Syntax-Checking-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiler Syntax Checking Project

  1. It's a git test, which means I'm totally a green hand.
  2. It's just one of my assignment, and it may not satisfy you.
  3. Ignore my bad code style...
  4. Most of the work done in Visual Studio Code

Usage

1. Linux or UNIX

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.

2. Windows with Visual Studio (VS)

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.

3. Windows without Visual Studio (VS)

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.

Regulation

A.1.2 High-level Definitions

Program(A) → ExtDefList(B)
ExtDefList(B) → ExtDef(C) ExtDefList(B) | ɛ
ExtDef(C) → Specifier(D) FunDec(E) Compst(F)

A.1.3 Specifiers

Specifier(D) → TYPE

A.1.4 Declarators

VarDec(G) → ID
FunDec(E) → ID LP RP

A.1.5 Statements

Compst(F) → LC DefList(H) StmtList(I) RC
StmtList(I) → Stmt(J) StmtList(I) | ɛ
Stmt(J) → Exp(K) SEMI | RETURN Exp(K) SEMI

A.1.6 Local Definitions

DefList(H) → Def(L) DefList(H) | ɛ
Def(L) → Specifier(D) DecList(M) SEMI
DecList(M) → Dec(N)
Dec(N) → VarDec(G) ASSIGNOP Exp(K)

A.1.7 Expressions

Exp(K) → LP Exp(K) RP | NOT Exp(K) | INT | ID

Simplified

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

About

My C-- Language Syntax Checking Project

Resources

Stars

Watchers

Forks

Contributors