> Le 8 mai 2019 à 21:38, EML <[email protected]> a écrit :
> 
> On 08/05/2019 19:14, Hans Åberg wrote:
> 
>> One can store the Bison token value on the lookup table that the lexer uses. 
>> So the lexer matches the identifier, then, checks if it has been identified, 
>> and if so, returns its token and semantic values. Otherwise it is just a 
>> name, like in a definition, whose Bison rule action puts it on the lookup 
>> table.
> 
> Hi Hans - presumably this isn't possible with flex? Do you know of a lexer 
> which can do this?

Flex is hardly concerned with this: once it matched the rule
for "identifier", it is *your* action which is in charge whether
to return a "type identifier" or "variable identifier" etc.

See also the so-called lexical tie-in in the doc.

https://www.gnu.org/software/bison/manual/html_node/Context-Dependency.html#Context-Dependency

Note that GLR parsers are another option: just return "identifier",
and have a rule for variable and a rule for type, and let glr
decide from the context which parse is right.
_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to