状态I0:
产生式打点项目:
S -> · statements
statements -> · statements M statement
statements -> ·
GOTO状态转换:
GOTO(0,statements)=1
状态I1:
产生式打点项目:
S -> statements ·
statements -> statements · M statement
M -> ·
GOTO状态转换:
GOTO(1,M)=2
状态I2:
产生式打点项目:
statements -> statements M · statement
statement -> · selectionStatement
statement -> · whileStatement
statement -> · compoundStatement
statement -> · expressionStatement
selectionStatement -> · if ( T ) M statement
selectionStatement -> · if ( T ) M statement N else M statement
whileStatement -> · while M ( T ) M statement
compoundStatement -> · { declaration statements }
expressionStatement -> · expression ;
expressionStatement -> · ;
expression -> · assignmentExp
expression -> · expression , assignmentExp
assignmentExp -> · logicalOrExp
assignmentExp -> · ID = logicalOrExp
logicalOrExp -> · logicalAndExp
logicalOrExp -> · logicalOrExp || M logicalAndExp
logicalAndExp -> · equalityExp
logicalAndExp -> · logicalAndExp && M equalityExp
equalityExp -> · relationalExp
equalityExp -> · equalityExp == relationalExp
equalityExp -> · equalityExp != relationalExp
relationalExp -> · additiveExp
relationalExp -> · relationalExp < additiveExp
relationalExp -> · relationalExp <= additiveExp
relationalExp -> · relationalExp > additiveExp
relationalExp -> · relationalExp >= additiveExp
additiveExp -> · multiplicativeExp
additiveExp -> · additiveExp + multiplicativeExp
additiveExp -> · additiveExp - multiplicativeExp
multiplicativeExp -> · unaryExp
multiplicativeExp -> · multiplicativeExp * unaryExp
multiplicativeExp -> · multiplicativeExp / unaryExp
unaryExp -> · primaryExp
unaryExp -> · - primaryExp
unaryExp -> · + primaryExp
primaryExp -> · ID
primaryExp -> · constant
primaryExp -> · ( expression )
constant -> · integer
constant -> · character
GOTO状态转换:
GOTO(2,()=26
GOTO(2,+)=24
GOTO(2,-)=23
GOTO(2,;)=12
GOTO(2,ID)=15
GOTO(2,additiveExp)=19
GOTO(2,assignmentExp)=13
GOTO(2,character)=28
GOTO(2,compoundStatement)=6
GOTO(2,constant)=25
GOTO(2,equalityExp)=17
GOTO(2,expression)=11
GOTO(2,expressionStatement)=7
GOTO(2,if)=8
GOTO(2,integer)=27
GOTO(2,logicalAndExp)=16
GOTO(2,logicalOrExp)=14
GOTO(2,multiplicativeExp)=20
GOTO(2,primaryExp)=22
GOTO(2,relationalExp)=18
GOTO(2,selectionStatement)=4
GOTO(2,statement)=3
GOTO(2,unaryExp)=21
GOTO(2,while)=9
GOTO(2,whileStatement)=5
GOTO(2,{)=10
状态I3:
产生式打点项目:
statements -> statements M statement ·
GOTO状态转换:
状态I4:
产生式打点项目:
statement -> selectionStatement ·
GOTO状态转换:
状态I5:
产生式打点项目:
statement -> whileStatement ·
GOTO状态转换:
状态I6:
产生式打点项目:
statement -> compoundStatement ·
GOTO状态转换:
状态I7:
产生式打点项目:
statement -> expressionStatement ·
GOTO状态转换:
状态I8:
产生式打点项目:
selectionStatement -> if · ( T ) M statement
selectionStatement -> if · ( T ) M statement N else M statement
GOTO状态转换:
GOTO(8,()=29
状态I9:
产生式打点项目:
whileStatement -> while · M ( T ) M statement
M -> ·
GOTO状态转换:
GOTO(9,M)=30
状态I10:
产生式打点项目:
compoundStatement -> { · declaration statements }
declaration -> · typeSpecifier initDeclarator ; declaration
declaration -> · typeSpecifier ;
declaration -> ·
typeSpecifier -> · int
typeSpecifier -> · char
GOTO状态转换:
GOTO(10,char)=34
GOTO(10,declaration)=31
GOTO(10,int)=33
GOTO(10,typeSpecifier)=32
状态I11:
产生式打点项目:
expressionStatement -> expression · ;
expression -> expression · , assignmentExp
GOTO状态转换:
GOTO(11,,)=36
GOTO(11,;)=35
状态I12:
产生式打点项目:
expressionStatement -> ; ·
GOTO状态转换:
状态I13:
产生式打点项目:
expression -> assignmentExp ·
GOTO状态转换:
状态I14:
产生式打点项目:
assignmentExp -> logicalOrExp ·
logicalOrExp -> logicalOrExp · || M logicalAndExp
GOTO状态转换:
GOTO(14,||)=37
状态I15:
产生式打点项目:
assignmentExp -> ID · = logicalOrExp
primaryExp -> ID ·
GOTO状态转换:
GOTO(15,=)=38
状态I16:
产生式打点项目:
logicalOrExp -> logicalAndExp ·
logicalAndExp -> logicalAndExp · && M equalityExp
GOTO状态转换:
GOTO(16,&&)=39
状态I17:
产生式打点项目:
logicalAndExp -> equalityExp ·
equalityExp -> equalityExp · == relationalExp
equalityExp -> equalityExp · != relationalExp
GOTO状态转换:
GOTO(17,!=)=41
GOTO(17,==)=40
状态I18:
产生式打点项目:
equalityExp -> relationalExp ·
relationalExp -> relationalExp · < additiveExp
relationalExp -> relationalExp · <= additiveExp
relationalExp -> relationalExp · > additiveExp
relationalExp -> relationalExp · >= additiveExp
GOTO状态转换:
GOTO(18,<)=42
GOTO(18,<=)=43
GOTO(18,>)=44
GOTO(18,>=)=45
状态I19:
产生式打点项目:
relationalExp -> additiveExp ·
additiveExp -> additiveExp · + multiplicativeExp
additiveExp -> additiveExp · - multiplicativeExp
GOTO状态转换:
GOTO(19,+)=46
GOTO(19,-)=47
状态I20:
产生式打点项目:
additiveExp -> multiplicativeExp ·
multiplicativeExp -> multiplicativeExp · * unaryExp
multiplicativeExp -> multiplicativeExp · / unaryExp
GOTO状态转换:
GOTO(20,*)=48
GOTO(20,/)=49
状态I21:
产生式打点项目:
multiplicativeExp -> unaryExp ·
GOTO状态转换:
状态I22:
产生式打点项目:
unaryExp -> primaryExp ·
GOTO状态转换:
状态I23:
产生式打点项目:
unaryExp -> - · primaryExp
primaryExp -> · ID
primaryExp -> · constant
primaryExp -> · ( expression )
constant -> · integer
constant -> · character
GOTO状态转换:
GOTO(23,()=26
GOTO(23,ID)=51
GOTO(23,character)=28
GOTO(23,constant)=25
GOTO(23,integer)=27
GOTO(23,primaryExp)=50
状态I24:
产生式打点项目:
unaryExp -> + · primaryExp
primaryExp -> · ID
primaryExp -> · constant
primaryExp -> · ( expression )
constant -> · integer
constant -> · character
GOTO状态转换:
GOTO(24,()=26
GOTO(24,ID)=51
GOTO(24,character)=28
GOTO(24,constant)=25
GOTO(24,integer)=27
GOTO(24,primaryExp)=52
状态I25:
产生式打点项目:
primaryExp -> constant ·
GOTO状态转换:
状态I26:
产生式打点项目:
primaryExp -> ( · expression )
expression -> · assignmentExp
expression -> · expression , assignmentExp
assignmentExp -> · logicalOrExp
assignmentExp -> · ID = logicalOrExp
logicalOrExp -> · logicalAndExp
logicalOrExp -> · logicalOrExp || M logicalAndExp
logicalAndExp -> · equalityExp
logicalAndExp -> · logicalAndExp && M equalityExp
equalityExp -> · relationalExp
equalityExp -> · equalityExp == relationalExp
equalityExp -> · equalityExp != relationalExp
relationalExp -> · additiveExp
relationalExp -> · relationalExp < additiveExp
relationalExp -> · relationalExp <= additiveExp
relationalExp -> · relationalExp > additiveExp
relationalExp -> · relationalExp >= additiveExp
additiveExp -> · multiplicativeExp
additiveExp -> · additiveExp + multiplicativeExp
评论2