문제

When I try to define a token like this:

NAP (([0-9])/([a-z]))

...which means a digit only if a letter come after it (r/s), and I try to use this:

{NAP}   showToken("NAP");

...the compiler throw "unrecognized rule".

Does anyone know why?

도움이 되었습니까?

해결책

You cannot use flex's / operator inside parentheses. That can make it impossible to use in a definition, depending on your flex version, because flex implicitly surrounds the expansion of definitions with parentheses.

Just write your regex directly in the rule. (And no need for redundant parentheses around brackets.)

[0-9]/[a-z]     showToken("NAP");

다른 팁

It works for me.

NAP [0-9]
%%
{NAP}/([a-z])   showToken("NAP");
%%
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top