Error parsing enum containing hexadecimal initalizer for an enumeration constant
GoogleCodeExporter opened this issue · comments
What steps will reproduce the problem?
1. try to parse attached file.
What is the expected output? What do you see instead?
You can see an exception:
parsing exception occured while parsing 'literal' expected
'skip(ident_next_char^)' at
line number 0, and character number 13
enum a{ B = 0x1} C
^
What version of the product are you using? On what operating system?
sept-9-2009-source
Rootcause:
What is happening is, that the 0x1 hexadecimal value is parsed as an
octal_literal("0") and not as a hex_literal("0x1"). The cause is, that in the
place of unsigned_literal, the octal_literal is checked first, and that breaks
the compiler paradigm of searching the longest possible token string.
Proposed fix:
the simplest way to fix this issue is to re-arrange the parsing order from:
unsigned_literal
= decimal_literal
| octal_literal
| hex_literal;
to:
unsigned_literal
= decimal_literal
| hex_literal
| octal_literal;
this way the hex literal(which is always longer because of "0x" factor) will be
parsed before octal.
Original issue reported on code.google.com by edanor2...@gmail.com
on 15 Oct 2013 at 3:02
Attachments: