bug-bison
[Top][All Lists]
Advanced

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

Re: symbol_type::token () removed?


From: Egor Pugin
Subject: Re: symbol_type::token () removed?
Date: Sun, 15 Mar 2020 17:03:52 +0300

Hi,

I also used .token() in some code. After updating to 3.5, switch
became not so fancy IFs.
https://github.com/aimrebirth/DataManager/commit/d493543e6431a38fe7c2f248b68549ca64dc019e
(first incorrect fix)
https://github.com/aimrebirth/DataManager/commit/f720815621e96355559e0d0cbf93349749015e57?diff=split
(working fix)

On Sun, 8 Mar 2020 at 23:11, pramod kumbhar <address@hidden> wrote:
>
> Hello Akim,
>
> As mentioned by Wolfgang in the original thread[1], we also use this mostly
> for testing purpose and implementing some debug utilities.
> In [2] we have some tests which looks like:
>
> TokenType token_type(const std::string& name) {
>     // some glue code
>     SymbolType sym = scanner.next_token();
>     retun sym.token();
> }
>
> and then we test stuff as:
>
>    REQUIRE(token_type(" h' = (hInf-h)/hTau\n") == Token::PRIME);
>    REQUIRE(token_type("while") == Token::WHILE);
>    REQUIRE(token_type("if") == Token::IF);
>
> Also, we have code like below for some lexer debugging utility [3]:
>
>    switch (token) {
>        /// token with name ast class
>        case Token::NAME:
>        case Token::METHOD:
>        case Token::SUFFIX:
>        case Token::VALENCE:
>        case Token::DEL:
>        case Token::DEL2: {
>                              auto value = sym.value.as<ast::Name>();
>                              std::cout << *(value.get_token()) << std::endl;
>                              break;
>                          }
>         ...
>
> With 3.5, we have to change above code like this [4] which seems bit
> verbose ( / ugly).
>
> If you have any suggestions to do this more cleanly, please let me know and
> I will be happy to try / test.
>
> Regards,
> Pramod
>
> [1] https://lists.gnu.org/archive/html/bug-bison/2020-01/msg00001.html
> [2]
> https://github.com/BlueBrain/nmodl/blob/c763cfadb71a736dafc00ceaa6ad2803b0cc9169/test/lexer/tokens.cpp
> [3]
> https://github.com/BlueBrain/nmodl/blob/c763cfadb71a736dafc00ceaa6ad2803b0cc9169/src/lexer/main_nmodl.cpp
> [4] https://github.com/BlueBrain/nmodl/pull/270/files
>
> On Sun, Mar 8, 2020 at 6:55 AM Akim Demaille <address@hidden> wrote:
>
> > Hi!
> >
> > > Le 7 mars 2020 à 19:16, pramod kumbhar <address@hidden> a
> > écrit :
> > >
> > > Hello All,
> > >
> > > I am posting first time on this list, specifically in response to the old
> > > thread here :
> > > https://lists.gnu.org/archive/html/bug-bison/2020-01/msg00001.html
> > >
> > > Just want to highlight that our parsers also use symbol_type::token() and
> > > they started failing with v3.5.
> >
> > Could you tell us more about your own use case?  It is still not clear to
> > me what is actually needed.
> >
> > Cheers!



-- 
Egor Pugin



reply via email to

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