help-bison
[Top][All Lists]
Advanced

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

glr parser and getting semantic values from the lexer


From: Jot Dot
Subject: glr parser and getting semantic values from the lexer
Date: Sun, 20 Dec 2020 13:55:42 -0700 (MST)

I feel real dumb asking this but,

How do you pass values back from the lexer when using %glr-parser?

I know I must use POD data types.
In the .y file, I am using:

%define api.value.type union
%token <int64_t> CONSTANT

and in the lexer file:
{inum}  {       // Integer
                int64_t number = strtol(yytext, NULL, 10);
                ??? = number; // What do I do here?
                return MyPrefix::MyParser::token::CONSTANT;
        }

yylval is not defined. I have read you shouldn't really modify it anyways,
for reasons mentioned in the manual (which make sense).

My only other project was parsing a small portion of SQL. I used variants
and everything worked quite well for that project, but I know I can not
use variants here.

I'm really stumped here. Can anybody advise?

Thanks.



reply via email to

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