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
Yacc
(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!
== Description == The input to Yacc is a grammar with snippets of [[C (programming language)|C]] code (called "actions") attached to its rules. Its output is a [[shift-reduce parser]] in C that executes the C snippets associated with each rule as soon as the rule is recognized. Typical actions involve the construction of [[parse tree]]s. Using an example from Johnson, if the call {{mono|node(label, left, right)}} constructs a binary parse tree node with the specified {{mono|label}} and children, then the rule <syntaxhighlight lang="C"> expr : expr '+' expr { $$ = node('+', $1, $3); } </syntaxhighlight> recognizes summation expressions and constructs nodes for them. The special identifiers {{mono|$$}}, {{mono|$1}} and {{mono|$3}} refer to items on the parser's [[Push-down automaton|stack]].{{r|Yacc: Yet Another Compiler-Compiler}} Yacc produces only a parser (phrase analyzer) which can be used alone in the case of [[scannerless parsing]] however, full syntactic analysis typically requires an external [[lexical analyzer]] to perform a tokenization stage first (word analysis), which is then followed by the parsing stage proper.<ref name="Yacc: Yet Another Compiler-Compiler"/> Lexical analyzer generators, such as [[Lex (software)|Lex]] or [[Flex (lexical analyser generator)|Flex]], are widely available for this purpose. The [[IEEE]] [[POSIX]] P1003.2 standard defines the functionality and requirements for both Lex and Yacc.<ref>{{man|cu|lex}}, {{man|cu|yacc}}.</ref> Some versions of AT&T Yacc have become [[open-source software|open source]]. For example, [[source code]] is available with the standard distributions of [[Plan 9 from Bell Labs|Plan 9]].<ref>{{cite web|title=plan9: UC Berkeley release of Plan 9 under the GPLv2|website=[[GitHub]] |url=https://github.com/brho/plan9/blob/89d43d2262ad43eb4b26c2a8d6a27cfeddb33828/sys/src/cmd/yacc.c|access-date=2 January 2018|date=26 December 2017}}</ref>
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
Yacc
(section)
Add topic