Re: symbol_type::token () removed?

Egor Pugin <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <CAHtU+mpX_xYKpDPhkOUF9gbA3sTNc3SV4gP9EFtT20ycDkHJdA@mail.gmail.com>
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 <[email protected]> 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 <[email protected]> wrote:
>
> > Hi!
> >
> > > Le 7 mars 2020 à 19:16, pramod kumbhar <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.