[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: pure bison and YYPARSE_PARAM
From: |
Urdaneta, Alfonso E (N-Summitt Technologies) |
Subject: |
RE: pure bison and YYPARSE_PARAM |
Date: |
Mon, 26 Jan 2004 11:15:02 -0500 |
> > In newer bison, use
> >
> > %parse-param {my_parse_context_t* my_parse_context}
> > %lex-param {my_lex_context_t* my_lex_context}
> >
> > (one such entry per parameter to pass).
> > [[Info Nodes: {Parser Function}, {Pure Calling}]]
>
> These options are not documented in my bison.info file
> for 1.875. I searched for lex-param (with /) or looked at the index.
>
> Which documentation are you referring to ?
It may not be documented, but there is definitely stuff in the code to handle
that option.
$ cd bison-1.875/
$ find . -name *.c -exec grep --with-filename --line-number "lex\-param" {} \;
./src/parse-gram.c:466: "\"%file-prefix\"", "\"%glr-parser\"", "\"%lex-param
{...}\"",
./src/parse-gram.c:1855:/* Add a lex-param or a parse-param (depending on TYPE)
with
(line 466)
nothing important, just setup stuff
(line 1855)
/* Add a lex-param or a parse-param (depending on TYPE) with
declaration DECL and location LOC. */
static void
add_param (char const *type, char *decl, location loc)
{
static char const alphanum[] =
"0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"_";
char const *alpha = alphanum + 10;
char const *name_start = NULL;
char *p;
for (p = decl; *p; p++)
if ((p == decl || ! strchr (alphanum, p[-1])) && strchr (alpha, p[0]))
name_start = p;
/* Strip the surrounding '{' and '}'. */
decl++;
p[-1] = '\0';
if (! name_start)
complain_at (loc, _("missing identifier in parameter declaration"));
else
{
char *name;
size_t name_len;
for (name_len = 1;
name_start[name_len] && strchr (alphanum, name_start[name_len]);
name_len++)
continue;
name = xmalloc (name_len + 1);
memcpy (name, name_start, name_len);
name[name_len] = '\0';
muscle_pair_list_grow (type, decl, name);
free (name);
}
scanner_last_string_free ();
}
--
alfonso e. urdaneta