标签:解析器 syntaxState1 ABB syntaxState3 syntaxState4 一键 classDef stroke syntaxState2
Compiler of ABB
The C# source code of the compiler ABB
is generated by bitzhuwei.GrammarFormat
.
Grammar
// 3 VnRegulations:
A : A '+' B // [0]
| 'a' ; // [1]
B : 'b' ; // [2]
// 0 VtPatterns:
Lexical Analyzer States
flowchart
classDef c0001 color:#FF0000;
classDef c0010 stroke-dasharray: 10 10;
classDef c0011 stroke-dasharray: 10 10,color:#FF0000;
classDef c0100 fill:#BB66EE;
classDef c0101 fill:#BB66EE,color:#FF0000;
classDef c0110 fill:#BB66EE,stroke-dasharray: 10 10;
classDef c0111 fill:#BB66EE,stroke-dasharray: 10 10,color:#FF0000;
classDef c1000 stroke:#333,stroke-width:4px;
classDef c1001 stroke:#333,stroke-width:4px,color:#FF0000;
classDef c1010 stroke:#333,stroke-width:4px,stroke-dasharray: 10 10;
classDef c1011 stroke:#333,stroke-width:4px,stroke-dasharray: 10 10,color:#FF0000;
classDef c1100 stroke:#333,stroke-width:4px,fill:#BB66EE;
classDef c1101 stroke:#333,stroke-width:4px,fill:#BB66EE,color:#FF0000;
classDef c1110 stroke:#333,stroke-width:4px,fill:#BB66EE,stroke-dasharray: 10 10;
classDef c1111 stroke:#333,stroke-width:4px,fill:#BB66EE,stroke-dasharray: 10 10,color:#FF0000;
DFA0_1303046169{{"DFA0 wholeStart"}}
class DFA0_1303046169 c1000;
DFA1_642929875[\"DFA1 {1}"/]
class DFA1_642929875 c0101;
DFA2_1083584447[\"DFA2 {1}"/]
class DFA2_1083584447 c0101;
DFA3_924445311[\"DFA3 {1}"/]
class DFA3_924445311 c0101;
DFA0_1303046169 -->|"+
BeginToken '+'
ExtendToken '+'"|DFA1_642929875
DFA0_1303046169 -->|"a
BeginToken 'a'
ExtendToken 'a'"|DFA2_1083584447
DFA0_1303046169 -->|"b
BeginToken 'b'
ExtendToken 'b'"|DFA3_924445311
FIRST
[0]: FIRST( A ) = { 'a' }
[1]: FIRST( B ) = { 'b' }
[2]: FIRST( '+' ) = { '+' }
[3]: FIRST( 'a' ) = { 'a' }
[4]: FIRST( 'b' ) = { 'b' }
[5]: FIRST( ) = { empty }
[6]: FIRST( A '+' B ) = { 'a' }
FOLLOW
[0]: FOLLOW( A ) = { '+' }
[1]: FOLLOW( B ) = { '+' }
LL(1) Syntax Machine
状态 |
'+' |
'a' |
'b' |
A |
|
R[0] R[1] |
|
B |
|
|
R[2] |
LR(0) Syntax Machine
状态 |
'+' |
'a' |
'b' |
'¥' |
A |
B |
0 |
|
S2 |
|
|
G1 |
|
1 |
S3 |
|
|
完成 |
|
|
2 |
R[1] |
R[1] |
R[1] |
R[1] |
|
|
3 |
|
|
S5 |
|
|
G4 |
4 |
R[0] |
R[0] |
R[0] |
R[0] |
|
|
5 |
R[2] |
R[2] |
R[2] |
R[2] |
|
|
flowchart
classDef default fill:#C7EDCC,stroke:#993399,stroke-width:0px,text-align:left;
classDef titlebarStyle fill:gold;
titlebar>"LR(1) syntax states"]
class titlebar titlebarStyle
syntaxState0("syntaxState0
[-1] BCounter> : ⏳ A ;
[0] A : ⏳ A '+' B ;
[1] A : ⏳ 'a' ; ")
syntaxState1("syntaxState1
[-1] BCounter> : A ⏳ ;
[0] A : A ⏳ '+' B ; ")
syntaxState2("syntaxState2
[1] A : 'a' ⏳ ; ")
syntaxState3("syntaxState3
[0] A : A '+' ⏳ B ;
[2] B : ⏳ 'b' ; ")
syntaxState4("syntaxState4
[0] A : A '+' B ⏳ ; ")
syntaxState5("syntaxState5
[2] B : 'b' ⏳ ; ")
syntaxState0 -.-> |"A"| syntaxState1
syntaxState0 --> |"'a'"| syntaxState2
syntaxState1 --> |"'+'"| syntaxState3
syntaxState3 -.-> |"B"| syntaxState4
syntaxState3 --> |"'b'"| syntaxState5
syntaxState1 o--o |"'¥'"| syntaxState1
syntaxState2 x==x |"'+' 'a' 'b' '¥'
R[1]= A : 'a' ;"| syntaxState2
syntaxState4 x==x |"'+' 'a' 'b' '¥'
R[0]= A : A '+' B ;"| syntaxState4
syntaxState5 x==x |"'+' 'a' 'b' '¥'
R[2]= B : 'b' ;"| syntaxState5
SLR(1) Syntax Machine
状态 |
'+' |
'a' |
'b' |
'¥' |
A |
B |
0 |
|
S2 |
|
|
G1 |
|
1 |
S3 |
|
|
完成 |
|
|
2 |
R[1] |
|
|
R[1] |
|
|
3 |
|
|
S5 |
|
|
G4 |
4 |
R[0] |
|
|
R[0] |
|
|
5 |
R[2] |
|
|
|
|
|
flowchart
classDef default fill:#C7EDCC,stroke:#993399,stroke-width:0px,text-align:left;
classDef titlebarStyle fill:gold;
titlebar>"LR(1) syntax states"]
class titlebar titlebarStyle
syntaxState0("syntaxState0
[-1] BCounter> : ⏳ A ;
[0] A : ⏳ A '+' B ;
[1] A : ⏳ 'a' ; ")
syntaxState1("syntaxState1
[-1] BCounter> : A ⏳ ;
[0] A : A ⏳ '+' B ; ")
syntaxState2("syntaxState2
[1] A : 'a' ⏳ ; ")
syntaxState3("syntaxState3
[0] A : A '+' ⏳ B ;
[2] B : ⏳ 'b' ; ")
syntaxState4("syntaxState4
[0] A : A '+' B ⏳ ; ")
syntaxState5("syntaxState5
[2] B : 'b' ⏳ ; ")
syntaxState0 -.-> |"A"| syntaxState1
syntaxState0 --> |"'a'"| syntaxState2
syntaxState1 --> |"'+'"| syntaxState3
syntaxState3 -.-> |"B"| syntaxState4
syntaxState3 --> |"'b'"| syntaxState5
syntaxState1 o--o |"'¥'"| syntaxState1
syntaxState2 x==x |"'+' '¥'
R[1]= A : 'a' ;"| syntaxState2
syntaxState4 x==x |"'+' '¥'
R[0]= A : A '+' B ;"| syntaxState4
syntaxState5 x==x |"'+'
R[2]= B : 'b' ;"| syntaxState5
LALR(1) Syntax Machine
状态 |
'+' |
'a' |
'b' |
'¥' |
A |
B |
0 |
|
S2 |
|
|
G1 |
|
1 |
S3 |
|
|
完成 |
|
|
2 |
R[1] |
|
|
R[1] |
|
|
3 |
|
|
S5 |
|
|
G4 |
4 |
R[0] |
|
|
R[0] |
|
|
5 |
R[2] |
|
|
R[2] |
|
|
flowchart
classDef default fill:#C7EDCC,stroke:#993399,stroke-width:0px,text-align:left;
classDef titlebarStyle fill:gold;
titlebar>"LR(1) syntax states"]
class titlebar titlebarStyle
syntaxState0("syntaxState0
[-1] BCounter> : ⏳ A ; '¥'
[0] A : ⏳ A '+' B ; '¥' '+'
[1] A : ⏳ 'a' ; '¥' '+' ")
syntaxState1("syntaxState1
[-1] BCounter> : A ⏳ ; '¥'
[0] A : A ⏳ '+' B ; '¥' '+' ")
syntaxState2("syntaxState2
[1] A : 'a' ⏳ ; '¥' '+' ")
syntaxState3("syntaxState3
[0] A : A '+' ⏳ B ; '¥' '+'
[2] B : ⏳ 'b' ; '¥' '+' ")
syntaxState4("syntaxState4
[0] A : A '+' B ⏳ ; '¥' '+' ")
syntaxState5("syntaxState5
[2] B : 'b' ⏳ ; '¥' '+' ")
syntaxState0 -.-> |"A"| syntaxState1
syntaxState0 --> |"'a'"| syntaxState2
syntaxState1 --> |"'+'"| syntaxState3
syntaxState3 -.-> |"B"| syntaxState4
syntaxState3 --> |"'b'"| syntaxState5
syntaxState1 o--o |"'¥'"| syntaxState1
syntaxState2 x==x |"'¥' '+'
R[1]= A : 'a' ;"| syntaxState2
syntaxState4 x==x |"'¥' '+'
R[0]= A : A '+' B ;"| syntaxState4
syntaxState5 x==x |"'¥' '+'
R[2]= B : 'b' ;"| syntaxState5
LR(1) Syntax Machine
状态 |
'+' |
'a' |
'b' |
'¥' |
A |
B |
0 |
|
S2 |
|
|
G1 |
|
1 |
S3 |
|
|
完成 |
|
|
2 |
R[1] |
|
|
R[1] |
|
|
3 |
|
|
S5 |
|
|
G4 |
4 |
R[0] |
|
|
R[0] |
|
|
5 |
R[2] |
|
|
R[2] |
|
|
flowchart
classDef default fill:#C7EDCC,stroke:#993399,stroke-width:0px,text-align:left;
classDef titlebarStyle fill:gold;
titlebar>"LR(1) syntax states"]
class titlebar titlebarStyle
syntaxState0("syntaxState0
[-1] BCounter> : ⏳ A ; '¥'
[0] A : ⏳ A '+' B ; '¥' '+'
[1] A : ⏳ 'a' ; '¥' '+' ")
syntaxState1("syntaxState1
[-1] BCounter> : A ⏳ ; '¥'
[0] A : A ⏳ '+' B ; '¥' '+' ")
syntaxState2("syntaxState2
[1] A : 'a' ⏳ ; '¥' '+' ")
syntaxState3("syntaxState3
[0] A : A '+' ⏳ B ; '¥' '+'
[2] B : ⏳ 'b' ; '¥' '+' ")
syntaxState4("syntaxState4
[0] A : A '+' B ⏳ ; '¥' '+' ")
syntaxState5("syntaxState5
[2] B : 'b' ⏳ ; '¥' '+' ")
syntaxState0 -.-> |"A"| syntaxState1
syntaxState0 --> |"'a'"| syntaxState2
syntaxState1 --> |"'+'"| syntaxState3
syntaxState3 -.-> |"B"| syntaxState4
syntaxState3 --> |"'b'"| syntaxState5
syntaxState1 o--o |"'¥'"| syntaxState1
syntaxState2 x==x |"'¥' '+'
R[1]= A : 'a' ;"| syntaxState2
syntaxState4 x==x |"'¥' '+'
R[0]= A : A '+' B ;"| syntaxState4
syntaxState5 x==x |"'¥' '+'
R[2]= B : 'b' ;"| syntaxState5
End
标签:解析器,
syntaxState1,
ABB,
syntaxState3,
syntaxState4,
一键,
classDef,
stroke,
syntaxState2
From: https://www.cnblogs.com/bitzhuwei/p/ABB-readme-full.html