bison-patches
[Top][All Lists]
Advanced

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

%parse-param {int *foo}, {foo}


From: Akim Demaille
Subject: %parse-param {int *foo}, {foo}
Date: Fri, 15 Nov 2002 17:41:44 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

Hi Paul,

I'm installing this.  We talked about not including the `, {foo}'
part, but I said that I feard it's influence when addressing other
languages, and it doesn't work for arrays for arrays or functions (but
a typedef can solve this, agreed).  Since I saw no answer, I'm
installing the basic version.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/parse-gram.y (declaration): Have %parse-param and %lex-param
        take two BRACED_CODE, not two string_content.
        Free the scanner's obstack when we are done.
        (code_content): New.
        * tests/calc.at: Adjust.
        * doc/bison.texinfo: Adjust.
        Also, make sure to include the `,' for these declarations.

Index: doc/bison.texinfo
===================================================================
RCS file: /cvsroot/bison/bison/doc/bison.texinfo,v
retrieving revision 1.82
diff -u -u -r1.82 bison.texinfo
--- doc/bison.texinfo 14 Nov 2002 09:58:01 -0000 1.82
+++ doc/bison.texinfo 15 Nov 2002 16:37:13 -0000
@@ -3847,7 +3847,7 @@
 parameter information to it in a reentrant way.  To do so, use the
 declaration @code{%parse-param}:
 
address@hidden {Directive} %parse-param @var{argument-declaration} 
@var{argument-name}
address@hidden {Directive} %parse-param @address@hidden@}, @address@hidden@}
 @findex %parse-param
 Declare that @code{argument-name} is an additional @code{yyparse}
 argument.  This argument is also passed to @code{yyerror}.  The
@@ -3858,8 +3858,8 @@
 Here's an example.  Write this in the parser:
 
 @example
-%parse-param "int *nastiness"  "nastiness"
-%parse-param "int *randomness" "randomness"
+%parse-param @{int address@hidden,  @address@hidden
+%parse-param @{int address@hidden, @address@hidden
 @end example
 
 @noindent
@@ -4090,7 +4090,7 @@
 @code{%lex-param} just like @code{%parse-param} (@pxref{Parser
 Function}).
 
address@hidden {Directive} lex-param @var{argument-declaration} 
@var{argument-name}
address@hidden {Directive} lex-param @address@hidden@}, @address@hidden@}
 @findex %lex-param
 Declare that @code{argument-name} is an additional @code{yylex}
 argument.
@@ -4099,9 +4099,9 @@
 For instance:
 
 @example
-%parse-param "int *nastiness"  "nastiness"
-%lex-param   "int *nastiness"  "nastiness"
-%parse-param "int *randomness" "randomness"
+%parse-param @{int address@hidden,  @address@hidden
+%lex-param   @{int address@hidden,  @address@hidden
+%parse-param @{int address@hidden, @address@hidden
 @end example
 
 @noindent
@@ -4190,7 +4190,7 @@
 void yyerror (YYLTYPE *locp, const char *msg);  /* GLR parsers.   */
 @end example
 
-If @samp{%parse-param "int *nastiness"  "nastiness"} is used, then:
+If @samp{%parse-param @{int address@hidden, @address@hidden is used, then:
 
 @example
 void yyerror (int *randomness, const char *msg);  /* Yacc parsers.  */
@@ -4207,10 +4207,10 @@
 %locations
 /* Pure yylex.  */
 %pure-parser
-%lex-param   "int *nastiness"  "nastiness"
+%lex-param   @{int address@hidden,  @address@hidden
 /* Pure yyparse.  */
-%parse-param "int *nastiness"  "nastiness"
-%parse-param "int *randomness" "randomness"
+%parse-param @{int address@hidden,  @address@hidden
+%parse-param @{int address@hidden, @address@hidden
 @end example
 
 @noindent
@@ -6498,7 +6498,7 @@
 @xref{Precedence Decl, ,Operator Precedence}.
 @end deffn
 
address@hidden {Directive} %lex-param "@var{argument-declaration}" 
"@var{argument-name}"
address@hidden {Directive} %lex-param @address@hidden@}. @address@hidden"@}
 Bison declaration to specifying an additional parameter that
 @code{yylex} should accept.  @xref{Pure Calling,, Calling Conventions
 for Pure Parsers}.
@@ -6530,7 +6530,7 @@
 Summary}.
 @end deffn
 
address@hidden {Directive} %parse-param "@var{argument-declaration}" 
"@var{argument-name}"
address@hidden {Directive} %parse-param @address@hidden@}, @address@hidden@}
 Bison declaration to specifying an additional parameter that
 @code{yyparse} should accept.  @xref{Parser Function,, The Parser
 Function @code{yyparse}}.
Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.28
diff -u -u -r1.28 parse-gram.y
--- src/parse-gram.y 12 Nov 2002 08:26:38 -0000 1.28
+++ src/parse-gram.y 15 Nov 2002 16:37:13 -0000
@@ -158,7 +158,7 @@
 
 
 %type <string> STRING string_content
-               BRACED_CODE action
+               BRACED_CODE code_content action
                PROLOGUE EPILOGUE
 %type <struniq> TYPE
 %type <integer> INT
@@ -194,14 +194,20 @@
 | "%expect" INT                            { expected_conflicts = $2; }
 | "%file-prefix" "=" string_content        { spec_file_prefix = $3; }
 | "%glr-parser"                           { glr_parser = 1; }
-| "%lex-param" string_content "," string_content
-                           { muscle_pair_list_grow ("lex_param", $2, $4); }
+| "%lex-param" code_content "," code_content
+                           {
+                            muscle_pair_list_grow ("lex_param", $2, $4);
+                            scanner_last_string_free ();
+                          }
 | "%locations"                             { locations_flag = 1; }
 | "%name-prefix" "=" string_content        { spec_name_prefix = $3; }
 | "%no-lines"                              { no_lines_flag = 1; }
 | "%output" "=" string_content             { spec_outfile = $3; }
-| "%parse-param" string_content "," string_content
-                           { muscle_pair_list_grow ("parse_param", $2, $4); }
+| "%parse-param" code_content "," code_content
+                           {
+                            muscle_pair_list_grow ("parse_param", $2, $4);
+                            scanner_last_string_free ();
+                          }
 | "%pure-parser"                           { pure_parser = 1; }
 | "%skeleton" string_content               { skeleton = $2; }
 | "%token-table"                           { token_table_flag = 1; }
@@ -410,6 +416,15 @@
 /* A string used for its contents.  Strip the quotes. */
 string_content:
   STRING
+    {
+      $$ = $1 + 1;
+      $$[strlen ($$) - 1] = '\0';
+    };
+
+
+/* A BRACED_CODE used for its contents.  Strip the braces. */
+code_content:
+  BRACED_CODE
     {
       $$ = $1 + 1;
       $$[strlen ($$) - 1] = '\0';
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.43
diff -u -u -r1.43 calc.at
--- tests/calc.at 15 Nov 2002 08:56:39 -0000 1.43
+++ tests/calc.at 15 Nov 2002 16:37:13 -0000
@@ -562,7 +562,7 @@
 
 AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines 
%name-prefix="calc" %verbose %yacc])
 
-AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines 
%name-prefix="calc" %verbose %yacc %parse-param "value_t *result", "result" 
%parse-param "int *count", "count"])
+AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines 
%name-prefix="calc" %verbose %yacc %parse-param {value_t *result}, {result} 
%parse-param {int *count}, {count}])
 
 
 # ----------------------- #
@@ -597,4 +597,4 @@
 
 AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines 
%name-prefix="calc" %verbose %yacc])
 
-AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines 
%name-prefix="calc" %verbose %yacc %parse-param "value_t *result", "result" 
%parse-param "int *count", "count"])
+AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines 
%name-prefix="calc" %verbose %yacc %parse-param {value_t *result}, {result} 
%parse-param {int *count}, {count}])




reply via email to

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