mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
* src/lex.c (read_typename): New function.
(lex): Use it. * src/reader.c (copy_dollar): Likewise.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2000-10-16 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/lex.c (read_typename): New function.
|
||||||
|
(lex): Use it.
|
||||||
|
* src/reader.c (copy_dollar): Likewise.
|
||||||
|
|
||||||
|
|
||||||
2000-10-16 Akim Demaille <akim@epita.fr>
|
2000-10-16 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/reader.c (copy_comment2): Expect the input stream to be on
|
* src/reader.c (copy_comment2): Expect the input stream to be on
|
||||||
|
|||||||
53
src/lex.c
53
src/lex.c
@@ -323,6 +323,37 @@ unlex (int token)
|
|||||||
unlexed_symval = symval;
|
unlexed_symval = symval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------.
|
||||||
|
| We just read `<' from FIN. Store in TOKEN_BUFFER, the type name |
|
||||||
|
| specified between the `<...>'. |
|
||||||
|
`-----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void
|
||||||
|
read_type_name (FILE *fin)
|
||||||
|
{
|
||||||
|
char *p = token_buffer;
|
||||||
|
int c = getc (fin);
|
||||||
|
|
||||||
|
while (c != '>')
|
||||||
|
{
|
||||||
|
if (c == EOF)
|
||||||
|
fatal (_("unterminated type name at end of file"));
|
||||||
|
if (c == '\n')
|
||||||
|
{
|
||||||
|
complain (_("unterminated type name"));
|
||||||
|
ungetc (c, fin);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p == token_buffer + maxtoken)
|
||||||
|
p = grow_token_buffer (p);
|
||||||
|
|
||||||
|
*p++ = c;
|
||||||
|
c = getc (fin);
|
||||||
|
}
|
||||||
|
*p = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
lex (void)
|
lex (void)
|
||||||
@@ -488,29 +519,9 @@ lex (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case '<':
|
case '<':
|
||||||
p = token_buffer;
|
read_type_name (finput);
|
||||||
c = getc (finput);
|
|
||||||
while (c != '>')
|
|
||||||
{
|
|
||||||
if (c == EOF)
|
|
||||||
fatal (_("unterminated type name at end of file"));
|
|
||||||
if (c == '\n')
|
|
||||||
{
|
|
||||||
complain (_("unterminated type name"));
|
|
||||||
ungetc (c, finput);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p == token_buffer + maxtoken)
|
|
||||||
p = grow_token_buffer (p);
|
|
||||||
|
|
||||||
*p++ = c;
|
|
||||||
c = getc (finput);
|
|
||||||
}
|
|
||||||
*p = 0;
|
|
||||||
return TYPENAME;
|
return TYPENAME;
|
||||||
|
|
||||||
|
|
||||||
case '%':
|
case '%':
|
||||||
return parse_percent_token ();
|
return parse_percent_token ();
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ char *grow_token_buffer PARAMS ((char *));
|
|||||||
void init_lex PARAMS ((void));
|
void init_lex PARAMS ((void));
|
||||||
int skip_white_space PARAMS ((void));
|
int skip_white_space PARAMS ((void));
|
||||||
void unlex PARAMS ((int));
|
void unlex PARAMS ((int));
|
||||||
|
void read_type_name PARAMS ((FILE *fin));
|
||||||
|
|
||||||
/* Return one of the token-type codes. When an identifier is seen,
|
/* Return one of the token-type codes. When an identifier is seen,
|
||||||
the code IDENTIFIER is returned and the name is looked up in the
|
the code IDENTIFIER is returned and the name is looked up in the
|
||||||
|
|||||||
23
src/reader.c
23
src/reader.c
@@ -344,22 +344,12 @@ copy_dollar (FILE *fin, FILE *fout,
|
|||||||
int c = getc (fin);
|
int c = getc (fin);
|
||||||
char *type_name = NULL;
|
char *type_name = NULL;
|
||||||
|
|
||||||
/* Get the typename if explicit. */
|
/* Get the type name if explicit. */
|
||||||
if (c == '<')
|
if (c == '<')
|
||||||
{
|
{
|
||||||
char *cp = token_buffer;
|
read_type_name (fin);
|
||||||
|
|
||||||
while ((c = getc (fin)) != '>' && c > 0)
|
|
||||||
{
|
|
||||||
if (cp == token_buffer + maxtoken)
|
|
||||||
cp = grow_token_buffer (cp);
|
|
||||||
|
|
||||||
*cp++ = c;
|
|
||||||
}
|
|
||||||
*cp = 0;
|
|
||||||
type_name = token_buffer;
|
type_name = token_buffer;
|
||||||
value_components_used = 1;
|
value_components_used = 1;
|
||||||
|
|
||||||
c = getc (fin);
|
c = getc (fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1372,9 +1362,9 @@ readgram (void)
|
|||||||
{
|
{
|
||||||
bucket *sdummy;
|
bucket *sdummy;
|
||||||
|
|
||||||
/* Since the action was written out with this rule's */
|
/* Since the action was written out with this rule's
|
||||||
/* number, we must give the new rule this number */
|
number, we must give the new rule this number by
|
||||||
/* by inserting the new rule before it. */
|
inserting the new rule before it. */
|
||||||
|
|
||||||
/* Make a dummy nonterminal, a gensym. */
|
/* Make a dummy nonterminal, a gensym. */
|
||||||
sdummy = gensym ();
|
sdummy = gensym ();
|
||||||
@@ -1395,7 +1385,8 @@ readgram (void)
|
|||||||
p->next = crule1;
|
p->next = crule1;
|
||||||
crule1->next = crule;
|
crule1->next = crule;
|
||||||
|
|
||||||
/* insert the dummy generated by that rule into this rule. */
|
/* Insert the dummy generated by that rule into this
|
||||||
|
rule. */
|
||||||
nitems++;
|
nitems++;
|
||||||
p = XCALLOC (symbol_list, 1);
|
p = XCALLOC (symbol_list, 1);
|
||||||
p->sym = sdummy;
|
p->sym = sdummy;
|
||||||
|
|||||||
@@ -39,7 +39,10 @@ typedef struct bucket
|
|||||||
{
|
{
|
||||||
struct bucket *link;
|
struct bucket *link;
|
||||||
struct bucket *next;
|
struct bucket *next;
|
||||||
|
|
||||||
|
/* The key, name of the symbol. */
|
||||||
char *tag;
|
char *tag;
|
||||||
|
/* Its type. */
|
||||||
char *type_name;
|
char *type_name;
|
||||||
short value;
|
short value;
|
||||||
short prec;
|
short prec;
|
||||||
|
|||||||
Reference in New Issue
Block a user