help-bison
[Top][All Lists]
Advanced

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

Re: Accessing token type with .token()


From: Akim Demaille
Subject: Re: Accessing token type with .token()
Date: Mon, 6 Apr 2020 19:12:50 +0200

hi Felix,

> Le 6 avr. 2020 à 14:52, Felix Nieuwenhuizen <address@hidden> a écrit :
> 
> Hi all,
> 
> I have some testcases that test basic lexing.

Yes, this is a pattern I not anticipated (the API was not public),
and that I broke.  Sorry about that.

It has been reported several times, with workarounds, here:

https://lists.gnu.org/r/bug-bison/2020-01/msg00001.html



I am well aware of the problem and I'm working right now on something
that should address you concern: I'm providing a public interface to
check the symbol kind, i.e., the internal numbers.  So your test cases
will be able to check that the tokens are correct, but without having
to pay for the conversion and for the table that is associated.

That's something I announced in the aforementioned thread here:
https://lists.gnu.org/r/bug-bison/2020-03/msg00020.html
but there was no answer.

This will be part of Bison 3.6, and it's well advanced.  But I'm eager
to get feedback about it.

It will look like this:

for (auto id : ids) {
 auto symbol = lexer->yylex(*driver);
 ASSERT_EQ(symbol.kind_get(), YYSYMBOL_BASIC_IDENTIFIER);
 ASSERT_EQ(symbol.value.as<std::string>(), id);
}

WDYT?




reply via email to

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