[Flex-help] Floating-point constant suffixes
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Rodrigo D. <ro...@ho...> - 2012-05-16 15:33:59
|
Hello, I am writing the lexical rules for a C-like language and I am having some issues with floating-point constant suffixes: The input to the lexer is "8.0f". I have two rules in the following order in my file: D [0-9] L [a-zA-Z_] H [a-fA-F0-9] E [Ee][+-]?{D}+ O [0-7] %% {L}({L}|{D})* { return(IDENTIFIER); } {D}+"."{D}*({E})?[fF]? { return(FLOATCONSTANT); } For some reason I would like to understand, the input is being tokenized as "8.0" (FLOATCONSTANT) and "f" (IDENTIFIER) instead of "8.0f" (FLOATCONSTANT). I have reviewed the precedence rules and it still doesn't make sense to me. Any help would be appreciated. Rod |