diff options
Diffstat (limited to 'glcpp-lex.l')
-rw-r--r-- | glcpp-lex.l | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/glcpp-lex.l b/glcpp-lex.l index 747e24056f..a220fef76b 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -31,12 +31,27 @@ %option reentrant noyywrap +%x ST_DEFINE +%x ST_DEFVAL + +SPACE [[:space:]] +NONSPACE [^[:space:]] +NOTNEWLINE [^\n] +HSPACE [ \t] +HASH ^{HSPACE}*# +IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* +DEFVAL {NONSPACE}{NOTNEWLINE}* %% - /* Silently eat all whitespace. */ -[[:space:]]+ +{HASH}define { BEGIN ST_DEFINE; return DEFINE; } + +<ST_DEFINE>{HSPACE}+ +<ST_DEFINE>{IDENTIFIER} { BEGIN ST_DEFVAL; yylval = strdup (yytext); return IDENTIFIER; } + +<ST_DEFVAL>{SPACE}+ +<ST_DEFVAL>{DEFVAL} { BEGIN INITIAL; yylval = strdup (yytext); return DEFVAL; } - /* Any non-whitespace is a token. */ -[^[:space:]]+ { return TOKEN; } + /* Anything we don't specifically recognize is a stream of tokens */ +{NONSPACE}+ { yylval = strdup (yytext); return TOKEN; } %% |