Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
LR parser
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Action and goto tables === The two LR(0) parsing tables for this grammar look as follows: {| class=wikitable |- style="text-align:center; background:#e0e0e0;" | '''''state''''' | colspan="5"|'''''action''''' | colspan="2"|'''''goto''''' |- style="text-align:center;" | style="width:12%;"| | style="width:11%; background:#d0e0ff;"|'''*''' | style="width:11%; background:#d0e0ff;"|'''+''' | style="width:11%; background:#d0e0ff;"|'''0''' | style="width:11%; background:#d0e0ff;"|'''1''' | style="width:11%; background:#d0e0ff;"|'''$''' | style="width:11%; background:#c0e0d0;"|'''E''' | style="width:11%; background:#c0e0d0;"|'''B''' |- style="text-align:center;" | '''0''' || || || s1 || s2 || || 3 || 4 |- style="text-align:center;" | '''1''' || r4 || r4 || r4 || r4 || r4 || || |- style="text-align:center;" | '''2''' || r5 || r5 || r5 || r5 || r5 || || |- style="text-align:center;" | '''3''' || s5 || s6 || || || acc || || |- style="text-align:center;" | '''4''' || r3 || r3 || r3 || r3 || r3 || || |- style="text-align:center;" | '''5''' || || || s1 || s2 || || || 7 |- style="text-align:center;" | '''6''' || || || s1 || s2 || || || 8 |- style="text-align:center;" | '''7''' || r1 || r1 || r1 || r1 || r1 || || |- style="text-align:center;" | '''8''' || r2 || r2 || r2 || r2 || r2 || || |} The '''action table''' is indexed by a state of the parser and a terminal (including a special terminal $ that indicates the end of the input stream) and contains three types of actions: * ''shift'', which is written as "s''n''" and indicates that the next state is ''n'' * ''reduce'', which is written as "r''m''" and indicates that a reduction with grammar rule ''m'' should be performed * ''accept'', which is written as "acc" and indicates that the parser accepts the string in the input stream. The '''goto table''' is indexed by a state of the parser and a nonterminal and simply indicates what the next state of the parser will be if it has recognized a certain nonterminal. This table is important to find out the next state after every reduction. After a reduction, the next state is found by looking up the '''goto table''' entry for top of the stack (i.e. current state) and the reduced rule's LHS (i.e. non-terminal).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)