X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/2648a72df7261c37235587d49f820fb22258634c..ea6cfe9ebd960e2cb4573c2c6f02b02931ac1f86:/src/lex.c?ds=sidebyside diff --git a/src/lex.c b/src/lex.c index 60e392ce..489fdf9c 100644 --- a/src/lex.c +++ b/src/lex.c @@ -130,7 +130,7 @@ skip_white_space (void) | Do a getc, but give error message if EOF encountered | `-----------------------------------------------------*/ -static int +int xgetc (FILE *f) { int c = getc (f); @@ -482,43 +482,54 @@ parse_percent_token (void) size_t arg_offset = 0; int c = getc (finput); + obstack_1grow (&token_obstack, '%'); + obstack_1grow (&token_obstack, c); switch (c) { case '%': + token_buffer = obstack_finish (&token_obstack); return tok_two_percents; case '{': + token_buffer = obstack_finish (&token_obstack); return tok_percent_left_curly; - /* FIXME: Who the heck are those 5 guys!?! `%<' = `%left'!!! - Let's ask for there removal. */ + /* The following guys are here for backward compatibility with + very ancient Yacc versions. The paper of Johnson mentions + them (as ancient :). */ case '<': + token_buffer = obstack_finish (&token_obstack); return tok_left; case '>': + token_buffer = obstack_finish (&token_obstack); return tok_right; case '2': + token_buffer = obstack_finish (&token_obstack); return tok_nonassoc; case '0': + token_buffer = obstack_finish (&token_obstack); return tok_token; case '=': + token_buffer = obstack_finish (&token_obstack); return tok_prec; } if (!isalpha (c)) - return tok_illegal; + { + token_buffer = obstack_finish (&token_obstack); + return tok_illegal; + } - obstack_1grow (&token_obstack, '%'); - while (isalpha (c) || c == '_' || c == '-') + while (c = getc (finput), isalpha (c) || c == '_' || c == '-') { if (c == '_') c = '-'; obstack_1grow (&token_obstack, c); - c = getc (finput); } /* %DIRECTIVE="ARG". Separate into