Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Sep 21, 2024
1 parent dee8ffe commit c4258f9
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions doc/development/compressed_state_table/main.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
# Compressed State Table

LR parser generates two large tables, action table and GOTO table.
Action table is a matrix of current state and token. Each cell of action table indicates next action (shift, reduce, accept and error).
GOTO table is a matrix of current state and nonterminal symbol. Each cell of GOTO table indicates next state.
Action table is a matrix of states and tokens. Each cell of action table indicates next action (shift, reduce, accept and error).
GOTO table is a matrix of states and nonterminal symbols. Each cell of GOTO table indicates next state.

Action table of "parse.y":

| |EOF| LF|NUM|'+'|'*'|'('|')'|
--------------------------------------
|State 0| r1| | s1| | | s2| |
|State 1| r3| r3| r3| r3| r3| r3| r3|
|State 2| | | s1| | | s2| |
|State 3| s6| | | | | | |
|State 4| | s7| | s8| s9| | |
|State 5| | | | s8| s9| |s10|
|State 6|acc|acc|acc|acc|acc|acc|acc|
|State 7| r2| r2| r2| r2| r2| r2| r2|
|State 8| | | s1| | | s2| |
|State 9| | | s1| | | s2| |
|State 10| r6| r6| r6| r6| r6| r6| r6|
|State 11| | r4| | r4| s9| | r4|
|State 12| | r5| | r5| r5| | r5|

GOTO table of "parse.y":

| |$accept|program|expr|
-------------------------------
|State 0| | g3| g4|
|State 1| | | |
|State 2| | | g5|
|State 3| | | |
|State 4| | | |
|State 5| | | |
|State 6| | | |
|State 7| | | |
|State 8| | | g11|
|State 9| | | g12|
|State 10| | | |
|State 11| | | |
|State 12| | | |


Both action table and GOTO table are sparse. Therefore LR parser generator compresses both tables and creates these tables.

Expand Down

0 comments on commit c4258f9

Please sign in to comment.