T.R | Title | User | Personal Name | Date | Lines |
---|
8605.1 | looks like your lexer | SMURF::GAF | Jerry Feldman, Unix Dev. Environment, DTN:381-2970 | Tue Jan 28 1997 15:32 | 3 |
| I don't see anything wrong with your grammar file per se. Is your lexer
properly terminating the string it passes to yacc. All yacc is going to
do is to save the yylvals in an array.
|
8605.2 | oh .. | CSC32::S_LEDOUX | Want some cheese with that whine ? | Tue Jan 28 1997 23:42 | 6 |
| Oh... Told you it was a dumb question... Am I to understand then that I
have to cap yytext with a null byte ?? I thought that yylex took care of
that somehow.
thanks -
Scott ;)
|
8605.3 | Here's smore help. | SMURF::GAF | Jerry Feldman, Unix Dev. Environment, DTN:381-2970 | Wed Jan 29 1997 15:04 | 25 |
| Whose yylex are you using. The lexer is responsible for nul terminating
yytext. In your example, $1, $2, ... are instances of the _yystype_
union. Depending on how you define the tokens, $1 will point to the
instance of the union that is set by the lexer.
For example, in your yacc grammar:
%union {
long i;
unsigned char *cp;
};
%token CHAR
r: CHAR
={ $$.i = mn0($1.i); }
or:
%token<cp> CHAR
={ $$ = mn0($1); }
yytext is shared between yylex and yacc, but is is static.You would
need to define your YYSTYPE either with the %union rule if you have
multiple types, or define YYSTYPE as a pointer to some character array.
In any case, the lexer does not do it automatically. If you have a lex
based lexer, yytext will contain the null terminated string.
|
8605.4 | workin now... | CSC32::S_LEDOUX | Want some cheese with that whine ? | Wed Jan 29 1997 17:49 | 7 |
| I'm using lex. Actually I got flex & bison on a vms machine. I missed the
point that capping off yytext is my job. That makes perfect sense to me now
thanks. Is is safe to presume that I can change the buffer upto the point
that yylex has parsed without hosing myself ??
Thanks
scott ;)
|
8605.5 | in lex it is easy to yhose yourself. | SMURF::GAF | Jerry Feldman, Unix Dev. Environment, DTN:381-2970 | Thu Jan 30 1997 12:26 | 7 |
| >Is is safe to presume that I can change the buffer upto the point
>that yylex has parsed without hosing myself ??
The lexer owns yytext. Generally, before returning a token to yacc,
if you are passing a string to yacc, you would copy that string to the
yylval union. Also note that lex adds the current character to yytext,
and null terminates yytext. If any of your actions modify yytext, you
can cause some problems.
|