c - How do I define a pattern that will equate to all tokens not recognized by the scanner in Flex? -


i trying define pattern in flex throw error when reads token isn't defined. tried this:

digit       [0-9] int         -?[0-9][0-9]* double      {int}"."({digit})* char        [a-za-z] char_       [a-za-z_] id          {char}({char_}|{digit})* hex         (0x | 0x)[a-fa-f0-9][a-fa-f0-9]* stringlit   \"(\\.|[^"])*\" errstring   \"(\\.|[^"])* unrecchar   [^("+"|"-"|"*"|"/"|"%"|"<"|">"|"="|"!"|";"|","|"."|"["|"]"|"{"|"}"|{char_}|{digit})]  %%  "+"           {return '+';} "-"           {return '-';} "*"           {return '*';} "/"           {return '/';} "%"           {return '%';} "<"           {return '<';} ">"           {return '>';} "="           {return '=';} "!"           {return '!';} ";"           {return ';';} ","           {return ',';} "."           {return '.';} "["           {return '[';} "]"           {return ']';} "("           {return '(';} ")"           {return ')';} "{"           {return '{';} "}"           {return '}';}  {unrecchar} {             reporterror::unrecogchar(&yyloc, yytext);             } 

and

.           {             reporterror::unrecogchar(&yyloc, yytext);             } 

both not compile. error saying

scanner.l: unrecognized rule

why happening?

note: error handling done separate c file.

. has been working me thirty years. must have done else wrong.

but suggest:

. return yytext[0]; 

that match character not matched prior rule, except newline, , return parser deal with, parser's error recovery.

nb should handle unary minus in parser, not scanner.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -