(f)lex can you have multiple expressions in one state?
is it possible to have multiple expression in one state that are similar? I was hoping to group together a few expressions to make life easy for myself. i want to do something similar below but its not working and only recognise the 1st expr and although it does match the expr开发者_JS百科 it doesnt save into the array using yytext. im guessing im doing something wrong so any help would be appreciated.Thanks
<some_state>"Milk;" |
"Honey;" |
"Cinnamon;" |
"Cardamon;" |
"Rum;" |
"Brandy;" |
"Whiskey;" |
"Aquavit;" |
"Kahula;" { printf("Example"); array[i].addition = yytext;BEGIN(amount_state);}
If flex
is allowed, you can use start condition scope like the following:
<some_state>{
"Milk;" |
"Honey;" |
... |
"Kahula;" { printf("Example"); ... }
}
If only AT&T lex
is allowed, unfortunately this may be invalid...
精彩评论