Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
LR parser
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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).
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
LR parser
(section)
Add topic