bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: push parser documentation


From: Bob Rossi
Subject: Re: push parser documentation
Date: Sat, 4 Aug 2007 07:30:39 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

Thank you very much for such a speedy patch review!!!

On Fri, Aug 03, 2007 at 09:36:47PM -0400, Joel E. Denny wrote:
> On Mon, 30 Jul 2007, Bob Rossi wrote:
> > @@ -4519,6 +4522,99 @@
> >  You can generate either a pure parser or a nonreentrant parser from any
> >  valid grammar.
> >  
> > address@hidden Push Decl
> > address@hidden A Push Parser
> > address@hidden push parser
> > address@hidden push parser
> > address@hidden %push-parser
> > +
> > +A pull parser is called once with a given amount of input and it
> 
> The amount of input isn't necessarily defined at the time of invocation.  
> Imagine reading from the console.  Perhaps just drop the "with" phrase.

OK.

> > takes 
> > +control (blocks) until all it's input is completely parsed.  A push parser,
> 
> I see taking control as the opposite of blocking.  This explains it ok:
> 
>   http://en.wikipedia.org/wiki/Blocking_%28scheduling%29
> 
> Perhaps just drop "(blocks)".
> 
> Also, "it's" -> "its".

OK, I dropped it. I meant that the caller to yyparse would block, while
the parser chugs along. I suppose this wasn't understandable though.

> > +on the other hand, is called each time some new input is made available.
> 
> How about "some new input" -> "a new token"?

OK.

> > +A pull parser can parse it's input faster, but it must have all the 
> > +input up front and it blocks while it is parsing.  The push parser 
> > +generally takes longer to parse the same amount of data, but it can
> > +be told about input while the application is receiving it.
> > +The push parser is typically useful when the parser is part of a 
> > +main event loop and it is important for the event loop to be triggered
> > +within a certain time period.  This is often the case with a GUI 
> > +application.
> 
> I'm afraid I find this paragraph confusing.  Fixing the same problems I 
> mentioned above would help.  Alternatively, we could drop it and assume 
> your first paragraph is enough of an introduction.

I've dropped 1/2 of it, if you don't like the rest, I'll drop it too.

> > +Normally, Bison generates a pull parser.  The Bison declaration 
> > address@hidden says that you want the parser to be a push parser.
> > +It looks like this:
> > +
> > address@hidden
> > +%push-parser
> > address@hidden example
> > +
> > +When a push parser is selected, Bison will generate some new symbols in
> > +the generated parser.  @code{yypstate} is a structure that the generated 
> > +parser uses to store the parsers state.  @code{yypstate_new} is the 
> 
> "parsers" -> "parser's".

done.

> > +function that will create a new parser instance.  @code{yypstate_delete}
> > +will free the resources associated with the corresponding parser instance.
> > +Finally, @code{yypush_parse} is the function that should be called 
> > whenever a 
> > +token is available to provide the parser.  A trivial example
> > +of using a push parser would look like this:
> > +
> > address@hidden
> > +int yystatus;
> > +struct yypstate *yyps = yypstate_new ();
> > +do @{
> > +  yychar = yylex ();
> > +  yystatus = yypush_parse (yyps);
> > address@hidden while (yystatus == YYPUSH_MORE);
> > +yypstate_delete (yyps);
> > address@hidden example
> 
> It's not necessary to use the keyword "struct" when declaring a yypstate.

done.

> > +
> > +It is acceptable to have many parser instances, of the same type of parser,
> > +in memory at the same time.  However, in order to ensure that the parsers
> > +are reentrant, you must provide the @code{pure-parser} declaration in the
> > +grammar.
> 
> It sounds like you're saying it's fine to have those multiple parsers even 
> without %pure-parser.  I believe that's true except that yynerrs is shared 
> and so its value couldn't be trusted in that scenario.
> 
> The only reason I implemented impure push parsers is backward 
> compatibility with the Yacc pull mode interface.  Other than that, I can't 
> see why anyone would want impure mode.  I think the documentation should 
> strongly discourage its usage in new push parsers.  Perhaps it should even 
> start with your pure example and only mention impure mode later as an 
> explanation of what happens when you drop the %pure-parser directive.

Done.

> Moreover, to keep users safe, I wonder if impure push mode should have a 
> global variable that counts yypstate instances.  If yypstate_new detects 
> more than 1 instance, it should invoke yyerror with a message about 
> %pure-parser and then return NULL.
> 
> What do you think?

I'm not sure. There are some unfortunate limitations this would impose
on the user. Say they wanted to create all of the objects up front but
then there program is "smart enough" to ensure they are only used one at
a time. At least with the new documentation, they are warned...

If you prefer the functionality you described above, I wouldn't oppose
it.

> > @xref{Pure Decl, ,A Pure (Reentrant) Parser}.  When this
> > +is done, the @code{yychar} variable becomes a local variable in the 
> > address@hidden function.  In order to allow the the next token to be 
> > +passed to the @code{yypush_parse} function, its signature is changed to 
> > +accept the next token as a parameter.  A reentrant push parser example 
> > +would thus look like this:
> > +
> > address@hidden
> > +int yystatus;
> > +struct yypstate *yyps = yypstate_new ();
> > +do @{
> > +  yystatus = yypush_parse (yyps, yylex ());
> > address@hidden while (yystatus == YYPUSH_MORE);
> > +yypstate_delete (yyps);
> > address@hidden example
> > +
> > +That's it. Simply pass the next token into the @code{yypush_parse} function
> > +as a parameter.
> > +
> > +Bison also supports both the push parser interface along with the pull 
> > parser 
> > +interface in the same generated parser.  In order to get this 
> > functionality,
> > +you should provide the grammar with the @code{%push-pull-parser} 
> > declaration.
> 
> How about "you should provide the grammar" -> "you should replace the 
> @code{%push-parser} declaration"?

done.

> > +Doing this will create all of the symbols mentioned earlier along with the 
> > +two extra symbols, @code{yyparse} and @code{yypull_parse}.  @code{yyparse} 
> > +can be used exactly as it normally would be used.  However, the user should
> > +not that it is implemented in the generated parser by calling 
> 
> "not" -> "note".

done.

> > address@hidden  This makes the @code{yyparse} function that is generated 
> > +with the @code{%push-pull-parser} declaration slower than the normal 
> > address@hidden function.  If the user calls the @code{yypull_parse} function
> > +it will parse the rest of the input stream.  It is possible to
> > +yypush_parse tokens to select a subgrammar and then yypull_parse the rest  
> >                            
> > +of the input stream.  If you would like to switch back and forth between
> > +between parsing styles, you would have to write your own yypull_parse 
> > function
> > +that knows when to quit looking for input.
> 
> Some example invocations of these functions too would help.

I added an example with yypull_parse, good enough, or did you have
something else in mind?

> > +
> > +Adding the @code{pure-parser} declaration does exactly the same thing to 
> > the 
> > +generated parser with @code{%push-pull-parser} as it did for 
> > address@hidden
> > +
> > +When the @code{%push-parser} or @code{%push-pull-parser} declaration is 
> > used
> > +then it is important to understand that all references to the 
> > @code{yyparse}
> > +function in this manual corresponds to the @code{yypush_parser} function 
> > +unless otherwise stated.
> 
> I'm afraid I don't understand what you mean in that last paragraph.  Can 
> we drop it?

OK, This sentence seemed important to me. I'll describe the problem, let
me know what a good solution is. There are lots of places in the manual
where it says "X happens when pure parser is used" or "X is in yyparse
function". I wanted to make it clear the the yyparse function is the
same as the yypush_parse function in that regards. Maybe that is just
obvious to the uesr?

> >  @node Decl Summary
> >  @subsection Bison Declaration Summary
> >  @cindex Bison declaration summary
> > @@ -4797,10 +4893,12 @@
> >  in C parsers
> >  is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
> >  @code{yylval}, @code{yychar}, @code{yydebug}, and
> > -(if locations are used) @code{yylloc}.  For example, if you use
> > address@hidden "c_"}, the names become @code{c_parse}, @code{c_lex},
> > -and so on.  In C++ parsers, it is only the surrounding namespace which is
> > -named @var{prefix} instead of @samp{yy}.
> > +(if locations are used) @code{yylloc}.  If you use a push parser, 
> > +yypush_parse, yypull_parse, yypstate, yypstate_new and yypstate_delete 
> > will 
> 
> Put these symbol names in @code{...}.

done.

> > address@hidden Push Parser Function
> > address@hidden The Push Parser Function @code{yypush_parse}
> > address@hidden yypush_parse
> > +
> > +You call the function @code{yypush_parse} to parse a single token.  This 
> > +function is available if either the @code{%push-parser} or 
> > address@hidden declaration is used.  
> 
> You dropped the "%" in "%push-pull-parser" here and in several places 
> below.

done.

> > address@hidden Decl, ,A Push Parser}.
> > +
> > address@hidden int yypush_parse (yypstate *yyps)
> > +The value returned by @code{yypush_parse} is the same as for yyparse with 
> > the 
> > +following exception.  @code{yypush_parse} will return YYPUSH_MORE if more 
> > input
> > +is required to finish parsing the grammar.
> > address@hidden deftypefun
> > +
> > address@hidden Pull Parser Function
> > address@hidden The Pull Parser Function @code{yypull_parse}
> > address@hidden yypull_parse
> > +
> > +You call the function @code{yypull_parse} to parse the rest of the input 
> > +stream.  This function is available if either the @code{%push-parser} or 
> > address@hidden declaration is used.  
> 
> yypull_parse is not available for %push-parser.

done.

> > address@hidden Decl, ,A Push Parser}.
> > +
> > address@hidden int yypull_parse (yypstate *yyps)
> > +The value returned by @code{yypull_parse} is the same as for yyparse.
> 
> "yyparse" -> "@code{yyparse}".

done.

> > address@hidden deftypefun
> > +
> > address@hidden Parser Create Function
> > address@hidden The Parser Create Function @code{yystate_new}
> > address@hidden yypstate_new
> > +
> > +You call the function @code{yypstate_new} to create a new parser instance. 
> >  
> > +This function is available if either the @code{%push-parser} or 
> > address@hidden declaration is used.  
> > address@hidden Decl, ,A Push Parser}.
> > +
> > address@hidden yypstate *yypstate_new (void)
> > +The fuction will return a valid parser instance if there was memory 
> > available
> > +or NULL if no memory was avialable.
> 
> Typo in 2nd "available".

done.

> > address@hidden deftypefun
> > +
> > address@hidden Parser Delete Function
> > address@hidden The Parser Delete Function @code{yystate_delete}
> > address@hidden yypstate_delete
> > +
> > +You call the function @code{yypstate_delete} to delete a parser instance.  
> > This 
> > +function is available if either the @code{%push-parser} or 
> > address@hidden declaration is used.  
> > address@hidden Decl, ,A Push Parser}.
> > +
> > address@hidden void yypstate_delete (yypstate *yyps)
> > +This function will reclaim the memory associate with a parser instance.  
> > After
> 
> "associated".

done.

> > +this call, you shoul no longer attempt to use the parser instance.
> 
> "should".

done.

> > address@hidden deftypefun
> >  
> >  @node Lexical
> >  @section The Lexical Analyzer Function @code{yylex}
> > @@ -9279,6 +9439,16 @@
> >  @xref{Pure Decl, ,A Pure (Reentrant) Parser}.
> >  @end deffn
> >  
> > address@hidden {Directive} %push-parser
> > +Bison declaration to request a push parser.
> > address@hidden Decl, ,A Push Parser}.
> > address@hidden deffn
> > +
> > address@hidden {Directive} %push-pull-parser
> > +Bison declaration to request a push and a pull parser.
> > address@hidden Decl, ,A Push Parser}.
> > address@hidden deffn
> > +
> 
> The section "@node Decl Summary" should probably list these too since it 
> claims to list all Bison declarations.

done.

> >  @deffn {Directive} %require "@var{version}"
> >  Require version @var{version} or higher of Bison.  @xref{Require Decl, ,
> >  Require a Version of Bison}.
> > @@ -9453,7 +9623,8 @@
> >  
> >  @deffn {Variable} yynerrs
> >  Global variable which Bison increments each time it reports a syntax error.
> > -(In a pure parser, it is a local variable within @code{yyparse}.)
> > +(In a pure parser, it is a local variable within @code{yyparse}. In a 
> > +push parser, it is a member of yypstate.)
> 
> yynerrs is a member of yypstate only in a pure push parser.

done.

> >  @xref{Error Reporting, ,The Error Reporting Function @code{yyerror}}.
> >  @end deffn
> >  
> > @@ -9462,6 +9633,31 @@
> >  parsing.  @xref{Parser Function, ,The Parser Function @code{yyparse}}.
> >  @end deffn
> >  
> > address@hidden {Function} yypush_parse
> > +The parser function produced by Bison in push mode; call this function to 
> > +parse a single token.  @xref{Push Parser Function, ,The Push Parser 
> > Function 
> > address@hidden
> > address@hidden deffn
> > +
> > address@hidden {Function} yypull_parse
> > +The parser function produced by Bison in push mode; call this function to 
> > +parse the rest of the input stream.  
> > address@hidden Parser Function, ,The Pull Parser Function 
> > address@hidden
> > address@hidden deffn
> > +
> > address@hidden {Function} yypstate_new
> > +The function to create a parser instance, produced by Bison in push mode; 
> > +call this function to create a new parser.
> > address@hidden Create Function, ,The Parser Create Function 
> > @code{yypstate_new}}.
> > address@hidden deffn
> > +
> > address@hidden {Function} yypstate_delete
> > +The function to delete a parser instance, produced by Bison in push mode; 
> > +call this function to delete the memory associate with a parser.
> > address@hidden Delete Function, ,The Parser Delete Function 
> > @code{yypstate_delete}}.
> > address@hidden deffn
> > +
> >  @deffn {Macro} YYPARSE_PARAM
> >  An obsolete macro for specifying the name of a parameter that
> >  @code{yyparse} should accept.  The use of this macro is deprecated, and
> 
> Alphabetize these entries.

done.

> Thanks for all this work.  I hope my comments don't put you out.

They helped out a lot. Let me know what you think now!

Bob Rossi

2007-08-04  Bob Rossi  <address@hidden>

        * doc/bison.texinfo (Push Decl): Document the push parser.
        (Table of Symbols): Ditto.
        (Pure Decl): Ditto.
        (Decl Summary): Ditto.
        (Multiple Parsers, Push Parser Function, Pull Parser Function, 
        Parser Create Function, Parser Delete Function): 
        Add new push parser symbols.
        (Table of Symbols): Document push-parser, push-pull-parser, 
yypush_parse,
        yypull_parse, yypstate_new and yypstate_delete.


Index: doc/bison.texinfo
===================================================================
RCS file: /sources/bison/bison/doc/bison.texinfo,v
retrieving revision 1.232
diff -u -r1.232 bison.texinfo
--- doc/bison.texinfo   26 May 2007 20:08:18 -0000      1.232
+++ doc/bison.texinfo   4 Aug 2007 11:28:28 -0000
@@ -224,6 +224,7 @@
 * Expect Decl::       Suppressing warnings about parsing conflicts.
 * Start Decl::        Specifying the start symbol.
 * Pure Decl::         Requesting a reentrant parser.
+* Push Decl::         Requesting a push parser.
 * Decl Summary::      Table of all Bison declarations.
 
 Parser C-Language Interface
@@ -3978,6 +3979,7 @@
 * Expect Decl::       Suppressing warnings about parsing conflicts.
 * Start Decl::        Specifying the start symbol.
 * Pure Decl::         Requesting a reentrant parser.
+* Push Decl::         Requesting a push parser.
 * Decl Summary::      Table of all Bison declarations.
 @end menu
 
@@ -4510,8 +4512,9 @@
 @code{yylloc} become local variables in @code{yyparse}, and a different
 calling convention is used for the lexical analyzer function
 @code{yylex}.  @xref{Pure Calling, ,Calling Conventions for Pure
-Parsers}, for the details of this.  The variable @code{yynerrs} also
-becomes local in @code{yyparse} (@pxref{Error Reporting, ,The Error
+Parsers}, for the details of this.  The variable @code{yynerrs} 
+becomes local in @code{yyparse} in pull mode but it becomes a member 
+of yypstate in push mode.  (@pxref{Error Reporting, ,The Error
 Reporting Function @code{yyerror}}).  The convention for calling
 @code{yyparse} itself is unchanged.
 
@@ -4519,6 +4522,111 @@
 You can generate either a pure parser or a nonreentrant parser from any
 valid grammar.
 
address@hidden Push Decl
address@hidden A Push Parser
address@hidden push parser
address@hidden push parser
address@hidden %push-parser
+
+A pull parser is called once and it takes control until all its input 
+is completely parsed.  A push parser, on the other hand, is called 
+each time a new token is made available.
+
+A push parser is typically useful when the parser is part of a 
+main event loop in the clients application.  Especially when
+the event loop needs to be triggered within a certain time period.  
+This is often the case with a GUI application.
+
+Normally, Bison generates a pull parser.  The Bison declaration 
address@hidden says that you want the parser to be a push parser.
+It looks like this:
+
address@hidden
+%push-parser
address@hidden example
+
+In almost all cases, you want to ensure that your push parser is also
+a pure parser (@pxref{Pure Decl, ,A Pure (Reentrant) Parser}).  The only
+time you should create an impure push parser is to have backwards 
+compatibility with the Yacc pull mode interface.  Unless you know
+what you are doing, your declarations should look like this:
+
address@hidden
+%pure-parser
+%push-parser
address@hidden example
+
+There is a major notable functional difference between the pure push parser 
+and the impure push parser.  It is acceptable for a pure push parser to have 
+many parser instances, of the same type of parser, in memory at the same time.
+An impure push parser should only use one parser at a time.
+
+When a push parser is selected, Bison will generate some new symbols in
+the generated parser.  @code{yypstate} is a structure that the generated 
+parser uses to store the parser's state.  @code{yypstate_new} is the 
+function that will create a new parser instance.  @code{yypstate_delete}
+will free the resources associated with the corresponding parser instance.
+Finally, @code{yypush_parse} is the function that should be called whenever a 
+token is available to provide the parser.  A trivial example
+of using a pure push parser would look like this:
+
address@hidden
+int yystatus;
+yypstate *yyps = yypstate_new ();
+do @{
+  yystatus = yypush_parse (yyps, yylex ());
address@hidden while (yystatus == YYPUSH_MORE);
+yypstate_delete (yyps);
address@hidden example
+
+If the user decided to use an impure push parser, a few things about
+the generated parser will change.  The @code{yychar} variable becomes 
+a global variable instead of a variable in the @code{yypush_parse} function.
+For this reason, the signature of the @code{yypush_parse} function is
+changed to remove the token as a parameter.  A nonreentrant push parser 
+example would thus look like this:
+
address@hidden
+int yystatus;
+yypstate *yyps = yypstate_new ();
+do @{
+  yychar = yylex ();
+  yystatus = yypush_parse (yyps);
address@hidden while (yystatus == YYPUSH_MORE);
+yypstate_delete (yyps);
address@hidden example
+
+That's it. Notice the next token is put into the global variable @code{yychar} 
+for use by the next invocation of the @code{yypush_parse} function.
+
+Bison also supports both the push parser interface along with the pull parser 
+interface in the same generated parser.  In order to get this functionality,
+you should replace the @code{%push-parser} declaration with the 
address@hidden declaration.  Doing this will create all of the 
+symbols mentioned earlier along with the two extra symbols, @code{yyparse} 
+and @code{yypull_parse}.  @code{yyparse} can be used exactly as it normally 
+would be used.  However, the user should note that it is implemented in the 
+generated parser by calling @code{yypull_parse}.  This makes the 
address@hidden function that is generated with the @code{%push-pull-parser} 
+declaration slower than the normal @code{yyparse} function.  If the user 
+calls the @code{yypull_parse} function it will parse the rest of the input 
+stream.  It is possible to yypush_parse tokens to select a subgrammar and 
+then yypull_parse the rest of the input stream.  If you would like to 
+switch back and forth between between parsing styles, you would have to write 
+your own yypull_parse function that knows when to quit looking for input.
+An example of using the yypull_parse function would look like this:
+
address@hidden
+int yystatus;
+yypstate *yyps = yypstate_new ();
+yypull_parse (yyps); /* Will call the lexer */
+yypstate_delete (yyps);
address@hidden example
+
+Adding the @code{%pure-parser} declaration does exactly the same thing to the 
+generated parser with @code{%push-pull-parser} as it did for 
address@hidden
+
 @node Decl Summary
 @subsection Bison Declaration Summary
 @cindex Bison declaration summary
@@ -4797,10 +4905,13 @@
 in C parsers
 is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
 @code{yylval}, @code{yychar}, @code{yydebug}, and
-(if locations are used) @code{yylloc}.  For example, if you use
address@hidden "c_"}, the names become @code{c_parse}, @code{c_lex},
-and so on.  In C++ parsers, it is only the surrounding namespace which is
-named @var{prefix} instead of @samp{yy}.
+(if locations are used) @code{yylloc}.  If you use a push parser, 
address@hidden, @code{yypull_parse}, @code{yypstate}, 
address@hidden and @code{yypstate_delete} will 
+also be renamed.  For example, if you use @samp{%name-prefix "c_"}, the 
+names become @code{c_parse}, @code{c_lex}, and so on.  In C++ parsers, 
+it is only the surrounding namespace which is named @var{prefix} instead 
+of @samp{yy}.
 @xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
 @end deffn
 
@@ -4840,6 +4951,16 @@
 (Reentrant) Parser}).
 @end deffn
 
address@hidden {Directive} %push-parser
+Bison declaration to request a push parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
+
address@hidden {Directive} %push-pull-parser
+Bison declaration to request a push and a pull parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
+
 @deffn {Directive} %require "@var{version}"
 Require version @var{version} or higher of Bison.  @xref{Require Decl, ,
 Require a Version of Bison}.
@@ -4923,8 +5044,11 @@
 
 The precise list of symbols renamed is @code{yyparse}, @code{yylex},
 @code{yyerror}, @code{yynerrs}, @code{yylval}, @code{yylloc},
address@hidden and @code{yydebug}.  For example, if you use @samp{-p c},
-the names become @code{cparse}, @code{clex}, and so on.
address@hidden and @code{yydebug}.  If you use a push parser, 
address@hidden, @code{yypull_parse}, @code{yypstate}, 
address@hidden and @code{yypstate_delete} will also be renamed.
+For example, if you use @samp{-p c}, the names become @code{cparse}, 
address@hidden, and so on.
 
 @strong{All the other variables and macros associated with Bison are not
 renamed.} These others are not global; there is no conflict if the same
@@ -4953,6 +5077,10 @@
 
 @menu
 * Parser Function::   How to call @code{yyparse} and what it returns.
+* Push Parser Function::  How to call @code{yypush_parse} and what it returns.
+* Pull Parser Function::  How to call @code{yypull_parse} and what it returns.
+* Parser Create Function::  How to call @code{yypstate_new} and what it 
returns.
+* Parser Delete Function::  How to call @code{yypstate_delete} and what it 
returns.
 * Lexical::           You must supply a function @code{yylex}
                         which reads tokens.
 * Error Reporting::   You must supply a function @code{yyerror}.
@@ -5035,6 +5163,61 @@
 exp: @dots{}    @{ @dots{}; *randomness += 1; @dots{} @}
 @end example
 
address@hidden Push Parser Function
address@hidden The Push Parser Function @code{yypush_parse}
address@hidden yypush_parse
+
+You call the function @code{yypush_parse} to parse a single token.  This 
+function is available if either the @code{%push-parser} or 
address@hidden declaration is used.  
address@hidden Decl, ,A Push Parser}.
+
address@hidden int yypush_parse (yypstate *yyps)
+The value returned by @code{yypush_parse} is the same as for yyparse with the 
+following exception.  @code{yypush_parse} will return YYPUSH_MORE if more input
+is required to finish parsing the grammar.
address@hidden deftypefun
+
address@hidden Pull Parser Function
address@hidden The Pull Parser Function @code{yypull_parse}
address@hidden yypull_parse
+
+You call the function @code{yypull_parse} to parse the rest of the input 
+stream.  This function is available if the @code{%push-pull-parser} 
+declaration is used.  
address@hidden Decl, ,A Push Parser}.
+
address@hidden int yypull_parse (yypstate *yyps)
+The value returned by @code{yypull_parse} is the same as for @code{yyparse}.
address@hidden deftypefun
+
address@hidden Parser Create Function
address@hidden The Parser Create Function @code{yystate_new}
address@hidden yypstate_new
+
+You call the function @code{yypstate_new} to create a new parser instance.  
+This function is available if either the @code{%push-parser} or 
address@hidden declaration is used.  
address@hidden Decl, ,A Push Parser}.
+
address@hidden yypstate *yypstate_new (void)
+The fuction will return a valid parser instance if there was memory available
+or NULL if no memory was available.
address@hidden deftypefun
+
address@hidden Parser Delete Function
address@hidden The Parser Delete Function @code{yystate_delete}
address@hidden yypstate_delete
+
+You call the function @code{yypstate_delete} to delete a parser instance.  
This 
+function is available if either the @code{%push-parser} or 
address@hidden declaration is used.  
address@hidden Decl, ,A Push Parser}.
+
address@hidden void yypstate_delete (yypstate *yyps)
+This function will reclaim the memory associated with a parser instance.  After
+this call, you should no longer attempt to use the parser instance.
address@hidden deftypefun
 
 @node Lexical
 @section The Lexical Analyzer Function @code{yylex}
@@ -9279,6 +9462,16 @@
 @xref{Pure Decl, ,A Pure (Reentrant) Parser}.
 @end deffn
 
address@hidden {Directive} %push-parser
+Bison declaration to request a push parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
+
address@hidden {Directive} %push-pull-parser
+Bison declaration to request a push and a pull parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
+
 @deffn {Directive} %require "@var{version}"
 Require version @var{version} or higher of Bison.  @xref{Require Decl, ,
 Require a Version of Bison}.
@@ -9453,7 +9646,8 @@
 
 @deffn {Variable} yynerrs
 Global variable which Bison increments each time it reports a syntax error.
-(In a pure parser, it is a local variable within @code{yyparse}.)
+(In a pure parser, it is a local variable within @code{yyparse}. In a 
+pure push parser, it is a member of yypstate.)
 @xref{Error Reporting, ,The Error Reporting Function @code{yyerror}}.
 @end deffn
 
@@ -9462,6 +9656,31 @@
 parsing.  @xref{Parser Function, ,The Parser Function @code{yyparse}}.
 @end deffn
 
address@hidden {Function} yypstate_delete
+The function to delete a parser instance, produced by Bison in push mode; 
+call this function to delete the memory associate with a parser.
address@hidden Delete Function, ,The Parser Delete Function 
@code{yypstate_delete}}.
address@hidden deffn
+
address@hidden {Function} yypstate_new
+The function to create a parser instance, produced by Bison in push mode; 
+call this function to create a new parser.
address@hidden Create Function, ,The Parser Create Function 
@code{yypstate_new}}.
address@hidden deffn
+
address@hidden {Function} yypull_parse
+The parser function produced by Bison in push mode; call this function to 
+parse the rest of the input stream.  
address@hidden Parser Function, ,The Pull Parser Function 
address@hidden
address@hidden deffn
+
address@hidden {Function} yypush_parse
+The parser function produced by Bison in push mode; call this function to 
+parse a single token.  @xref{Push Parser Function, ,The Push Parser Function 
address@hidden
address@hidden deffn
+
 @deffn {Macro} YYPARSE_PARAM
 An obsolete macro for specifying the name of a parameter that
 @code{yyparse} should accept.  The use of this macro is deprecated, and




reply via email to

[Prev in Thread] Current Thread [Next in Thread]