In flex, I want to return multiple tokens for one match of a regular expression. Is there a way to do this?
A:
Do you mean all matches? Are you using regex functions or string functions? Use the global flag.
As for GNU flex, I don't think you can do that. You test for a match with one pattern at a time so that's probably out of scope. Why'd you want that? As an optimization? Scoping issues?
dirkgently
2009-02-22 09:26:29
To be honest, I am fairly new to flex and I am not sure. I thought I was using a combination of regular expressions and string matching.Here is an example"(" { return L_PAREN; }{INT} { yylval.Int = atoi(yytext); return INT; }What I want is to be able to return two tokens at once.
Ebu
2009-02-22 09:44:23
Damn, I took this to be the other Flex (as in MXML, AIR, Flash). My bad!
dirkgently
2009-02-22 10:00:27
+1
A:
The way I've been doing this is to create a queue of to-be-returned tokens, and at the beginning of yylex()
, check for tokens and return them.
Zifre
2009-03-30 16:16:20