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!
=== Bottom-up parse steps for example A * 2 + 1 === {| class="wikitable" |- ! <small>Step</small> !! <small>Parse Stack</small> !! <small>Unparsed</small> !! <small>Shift/Reduce</small> |- | 0 || ''empty'' || align="right" | A * 2 + 1 || shift |- | 1 || ''id'' || align="right" | * 2 + 1 || Value β ''id'' |- | 2 || Value || align="right" | * 2 + 1 || Products β Value |- | 3 || Products || align="right" | * 2 + 1 || shift |- | 4 || Products * || align="right" | 2 + 1 || shift |- | 5 || Products * ''int'' || align="right" | + 1 || Value β ''int'' |- | 6 || Products * Value || align="right" | + 1 || Products β Products * Value |- | 7 || Products || align="right" | + 1 || Sums β Products |- | 8 || Sums || align="right" | + 1 || shift |- | 9 || Sums + || align="right" | 1 || shift |- | 10 || Sums + ''int'' || ''eof'' || Value β ''int'' |- | 11 || Sums + Value || ''eof'' || Products β Value |- | 12 || Sums + Products || ''eof'' || Sums β Sums + Products |- | 13 || Sums || ''eof'' || accept |- |} Step 6 applies a grammar rule with multiple parts: : Products β Products * Value This matches the stack top holding the parsed phrases "... Products * Value". The reduce step replaces this instance of the rule's right hand side, "Products * Value" by the rule's left hand side symbol, here a larger Products. If the parser builds complete parse trees, the three trees for inner Products, *, and Value are combined by a new tree root for Products. Otherwise, [[Semantics#Programming languages|semantic]]{{Broken anchor|date=2025-04-28|bot=User:Cewbot/log/20201008/configuration|target_link=Semantics#Programming languages|reason=Anchor "Semantics#Programming languages" links to a specific web page: "Programming languages". The anchor (Programming languages) [[Special:Diff/1208968924|has been deleted]].|diff_id=1208968924}} details from the inner Products and Value are output to some later compiler pass, or are combined and saved in the new Products symbol.<ref> Crafting and Compiler, by Charles Fischer, Ron Cytron, and Richard LeBlanc, Addison Wesley 2009.</ref>
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)