/[bison]/bison/doc/bison.texinfo
ViewVC logotype

Diff of /bison/doc/bison.texinfo

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.105 by akim, Mon Mar 31 07:10:44 2003 UTC revision 1.106 by akim, Tue Apr 29 09:57:34 2003 UTC
# Line 39  Line 39 
39  This manual is for @acronym{GNU} Bison (version @value{VERSION},  This manual is for @acronym{GNU} Bison (version @value{VERSION},
40  @value{UPDATED}), the @acronym{GNU} parser generator.  @value{UPDATED}), the @acronym{GNU} parser generator.
41    
42  Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998, 2003,  Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998,
43  1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.  1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
44    
45  @quotation  @quotation
# Line 286  Frequently Asked Questions Line 286  Frequently Asked Questions
286  * Parser Stack Overflow::      Breaking the Stack Limits  * Parser Stack Overflow::      Breaking the Stack Limits
287  * How Can I Reset @code{yyparse}::    @code{yyparse} Keeps some State  * How Can I Reset @code{yyparse}::    @code{yyparse} Keeps some State
288  * Strings are Destroyed::      @code{yylval} Loses Track of Strings  * Strings are Destroyed::      @code{yylval} Loses Track of Strings
289    * C++ Parsers::                Compiling Parsers with C++ Compilers
290    * Implementing Loops::         Control Flow in the Calculator
291    
292  Copying This Manual  Copying This Manual
293    
# Line 3495  is called when a symbol is thrown away. Line 3497  is called when a symbol is thrown away.
3497  Declare that the @var{code} must be invoked for each of the  Declare that the @var{code} must be invoked for each of the
3498  @var{symbols} that will be discarded by the parser.  The @var{code}  @var{symbols} that will be discarded by the parser.  The @var{code}
3499  should use @code{$$} to designate the semantic value associated to the  should use @code{$$} to designate the semantic value associated to the
3500  @var{symbols}.  The additional parser parameters are also avaible  @var{symbols}.  The additional parser parameters are also available
3501  (@pxref{Parser Function, , The Parser Function @code{yyparse}}).  (@pxref{Parser Function, , The Parser Function @code{yyparse}}).
3502    
3503  @strong{Warning:} as of Bison 1.875, this feature is still considered as  @strong{Warning:} as of Bison 1.875, this feature is still considered as
# Line 6356  are addressed. Line 6358  are addressed.
6358  * Parser Stack Overflow::      Breaking the Stack Limits  * Parser Stack Overflow::      Breaking the Stack Limits
6359  * How Can I Reset @code{yyparse}::    @code{yyparse} Keeps some State  * How Can I Reset @code{yyparse}::    @code{yyparse} Keeps some State
6360  * Strings are Destroyed::      @code{yylval} Loses Track of Strings  * Strings are Destroyed::      @code{yylval} Loses Track of Strings
6361    * C++ Parsers::                Compiling Parsers with C++ Compilers
6362    * Implementing Loops::         Control Flow in the Calculator
6363  @end menu  @end menu
6364    
6365  @node Parser Stack Overflow  @node Parser Stack Overflow
# Line 6511  $ @kbd{printf 'one\ntwo\n' | ./split-lin Line 6515  $ @kbd{printf 'one\ntwo\n' | ./split-lin
6515  @end example  @end example
6516    
6517    
6518    @node C++ Parsers
6519    @section C++ Parsers
6520    
6521    @display
6522    How can I generate parsers in C++?
6523    @end display
6524    
6525    We are working on a C++ output for Bison, but unfortunately, for lack
6526    of time, the skeleton is not finished.  It is functional, but in
6527    numerous respects, it will require additional work which @emph{might}
6528    break backward compatibility.  Since the skeleton for C++ is not
6529    documented, we do not consider ourselves bound to this interface,
6530    nevertheless, as much as possible we will try to keep compatibility.
6531    
6532    Another possibility is to use the regular C parsers, and to compile
6533    them with a C++ compiler.  This works properly, provided that you bear
6534    some simple C++ rules in mind, such as not including ``real classes''
6535    (i.e., structure with constructors) in unions.  Therefore, in the
6536    @code{%union}, use pointers to classes, or better yet, a single
6537    pointer type to the root of your lexical/syntactic hierarchy.
6538    
6539    
6540    @node Implementing Loops
6541    @section Implementing Loops
6542    
6543    @display
6544    My simple calculator supports variables, assignments, and functions,
6545    but how can I implement loops?
6546    @end display
6547    
6548    Although very pedagogical, the examples included in the document blur
6549    the distinction to make between the parser ---whose job is to recover
6550    the structure of a text and to transmit it to subsequent modules of
6551    the program--- and the processing (such as the execution) of this
6552    structure.  This works well with so called straight line programs,
6553    i.e., precisely those that have a straightforward execution model:
6554    execute simple instructions one after the others.
6555    
6556    @cindex abstract syntax tree
6557    @cindex @acronym{AST}
6558    If you want a richer model, you will probably need to use the parser
6559    to construct a tree that does represent the structure it has
6560    recovered; this tree is usually called the @dfn{abstract syntax tree},
6561    or @dfn{@acronym{AST}} for short.  Then, walking through this tree,
6562    traversing it in various ways, will enable treatments such as its
6563    execution or its translation, which will result in an interpreter or a
6564    compiler.
6565    
6566    This topic is way beyond the scope of this manual, and the reader is
6567    invited to consult the dedicated literature.
6568    
6569    
6570    
6571  @c ================================================= Table of Symbols  @c ================================================= Table of Symbols
6572    
6573  @node Table of Symbols  @node Table of Symbols
# Line 7052  grammatically indivisible.  The piece of Line 7109  grammatically indivisible.  The piece of
7109  @printindex cp  @printindex cp
7110    
7111  @bye  @bye
7112    
7113    @c LocalWords: texinfo setfilename settitle setchapternewpage finalout
7114    @c LocalWords: ifinfo smallbook shorttitlepage titlepage GPL FIXME iftex
7115    @c LocalWords: akim fn cp syncodeindex vr tp synindex dircategory direntry
7116    @c LocalWords: ifset vskip pt filll insertcopying sp ISBN Etienne Suvasa
7117    @c LocalWords: ifnottex yyparse detailmenu GLR RPN Calc var Decls Rpcalc
7118    @c LocalWords: rpcalc Lexer Gen Comp Expr ltcalc mfcalc Decl Symtab yylex
7119    @c LocalWords: yyerror pxref LR yylval cindex dfn LALR samp gpl BNF xref
7120    @c LocalWords: const int paren ifnotinfo AC noindent emph expr stmt findex
7121    @c LocalWords: glr YYSTYPE TYPENAME prog dprec printf decl init stmtMerge
7122    @c LocalWords: pre STDC GNUC endif yy YY alloca lf stddef stdlib YYDEBUG
7123    @c LocalWords: NUM exp subsubsection kbd Ctrl ctype EOF getchar isdigit
7124    @c LocalWords: ungetc stdin scanf sc calc ulator ls lm cc NEG prec yyerrok
7125    @c LocalWords: longjmp fprintf stderr preg yylloc YYLTYPE cos ln
7126    @c LocalWords: smallexample symrec val tptr FNCT fnctptr func struct sym
7127    @c LocalWords: fnct putsym getsym fname arith fncts atan ptr malloc sizeof
7128    @c LocalWords: strlen strcpy fctn strcmp isalpha symbuf realloc isalnum
7129    @c LocalWords: ptypes itype YYPRINT trigraphs yytname expseq vindex dtype
7130    @c LocalWords: Rhs YYRHSLOC LE nonassoc op deffn typeless typefull yynerrs
7131    @c LocalWords: yychar yydebug msg YYNTOKENS YYNNTS YYNRULES YYNSTATES
7132    @c LocalWords: cparse clex deftypefun NE defmac YYACCEPT YYABORT param
7133    @c LocalWords: strncmp intval tindex lvalp locp llocp typealt YYBACKUP
7134    @c LocalWords: YYEMPTY YYRECOVERING yyclearin GE def UMINUS maybeword
7135    @c LocalWords: Johnstone Shamsa Sadaf Hussain Tomita TR uref YYMAXDEPTH
7136    @c LocalWords: YYINITDEPTH stmnts ref stmnt initdcl maybeasm VCG notype
7137    @c LocalWords: hexflag STR exdent itemset asis DYYDEBUG YYFPRINTF args
7138    @c LocalWords: YYPRINTF infile ypp yxx outfile itemx vcg tex leaderfill
7139    @c LocalWords: hbox hss hfill tt ly yyin fopen fclose ofirst gcc ll
7140    @c LocalWords: yyrestart nbar yytext fst snd osplit ntwo strdup AST
7141    @c LocalWords: YYSTACK DVI fdl printindex

Legend:
Removed from v.1.105  
changed lines
  Added in v.1.106

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26