Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Lexing C++

by afoken (Chancellor)
on Sep 02, 2019 at 09:19 UTC ( [id://11105413]=note: print w/replies, xml ) Need Help??


in reply to Re: Lexing C++
in thread Lexing C++

At least it doesn't fail any of your provided test cases :)

But a single escaped double quote in the example is sufficient to make it return garbage.

// comment should not appear main(void) { int foo = 1 << 5; puts("testing \"quoted\" string"); exit(0); // done }
... [ 'Identifier', 'puts' ], [ 'LeftParen', '(' ], [ 'string', 'testing \\' ], [ 'Identifier', 'quoted' ], [ 'character', '\\' ], [ 'string', ' string' ], [ 'RightParen', ')' ], [ 'Semicolon', ';' ], ...

There is no identifier named quoted in the example C/C++ code. quoted is part of a string passed to puts().

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^3: Lexing C++
by tybalt89 (Monsignor) on Sep 02, 2019 at 11:18 UTC

    Sure.

    I did say it is incomplete. That's a part of it. Also many more multi-character ops are missing, such as == != += -= ++ -- etc.

    It is true that no test case with quoted double quotes was provided :)

    My C++ is very rusty, I'm sire there are many more lexical elements that are missing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105413]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-23 06:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found