I want to return DOLLARID($foo) and DOTID(.foo),so I wirte tow rule(A code snippet of my lex file):
ID ([_a-zA-Z]+[a-zA-Z0-9_\-]*)
DOLLAR ("$"|("$!"))
DOT "."
%x DIRECTIVE REFERENCE
%%
[^#$]*?/"$" {BEGIN REFERENCE;yylval.string = yytext;printf("==========begin reference flex content===content:%s=====\n",yytext);return CONTENT;}
[^$#]*?/"#" {BEGIN DIRECTIVE;yylval.string = yytext; return CONTENT;}
<REFERENCE,DIRECTIVE>{DOLLAR}{ID} {yylval.string = yytext;printf("==========flex content===ID:%s=====\n",yytext);return DOLLARID;}
<REFERENCE,DIRECTIVE>{DOT}{ID} {yylval.string = yytext;printf("==========flex content===DOTID:%s=====\n",yytext);return DOTID;}
A code snippet of my yacc file:
set:SET PARENTHESIS reference EQUAL expression CLOSE_PARENTHESIS { $$ = set_directive($3,$5); }
;
reference: DOLLARID {printf("reference ---Id,key:%s\n",$1);$$ = reference($1);}
|DOLLARID DOTID {printf("reference ---dotId\n");$$ = reference($2);}
;
I write a test file test.vm
#set($arr = [1..5])
#set($hell = "sinory")
$hell
$arr
when I run it,a part of the result is:

line 1 is printed by lexer, it's right
line 2 is printed by bison, it's more than two characters(" =")
Because of flex needs more than a token?
I don't know why?please help me to fix it.