summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-13 18:16:50 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-13 18:16:50 +0200
commit88d6f0be579103de28940b31d235d81190191d52 (patch)
tree63d6985b1608be37b48b183b6b52d56029ddc859
parent4a6598906402ace1e9e40e312bef3a61112b28a2 (diff)
downloadfastd-88d6f0be579103de28940b31d235d81190191d52.tar
fastd-88d6f0be579103de28940b31d235d81190191d52.zip
lexer: simplify whitespace handling
-rw-r--r--src/config.l26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/config.l b/src/config.l
index e04903b..bf06446 100644
--- a/src/config.l
+++ b/src/config.l
@@ -154,26 +154,23 @@ auto { TOKEN(TOK_AUTO); }
BEGIN(NEEDSPACE);
return TOK_ADDR6;
}
-
-[;:\{\}] { UPDATE_LOCATION; return yytext[0]; }
-
-[ \t] { yylloc->last_column++; }
-\n { yylloc->last_column = 0; yylloc->last_line++; }
-\r ;
}
-<NEEDSPACE>{
+<INITIAL,NEEDSPACE>{
[;:\{\}] { UPDATE_LOCATION; BEGIN(INITIAL); return yytext[0]; }
-[ \t] { yylloc->last_column++; BEGIN(INITIAL); }
\n { yylloc->last_column = 0; yylloc->last_line++; BEGIN(INITIAL); }
-\r ;
+
+[ \t\r] |
+#.* |
+\/\/.* { UPDATE_LOCATION; BEGIN(INITIAL); }
+
+\/\* { UPDATE_LOCATION; BEGIN(COMMENT); }
}
<INITIAL>\" { UPDATE_LOCATION; BEGIN(STRING); }
-<STRING>[^"\\\n\r] { yylloc->last_column++; yymore(); }
+<STRING>[^"\\\n] { yylloc->last_column++; yymore(); }
<STRING>\n { yylloc->last_line++; yylloc->last_column = 0; yymore(); }
-<STRING>\r { yymore(); }
<STRING>\\. { yylloc->last_column+=2; yymore(); }
<STRING>\\\n { yylloc->last_line++; yylloc->last_column = 0; yymore(); }
<STRING>\" {
@@ -202,14 +199,9 @@ auto { TOKEN(TOK_AUTO); }
}
-<INITIAL,NEEDSPACE>#.* { yylloc->last_column += yyleng; }
-<INITIAL,NEEDSPACE>\/\/.* { yylloc->last_column += yyleng; }
-
-<INITIAL,NEEDSPACE>\/\* { UPDATE_LOCATION; BEGIN(COMMENT); }
<COMMENT>\*\/ { yylloc->last_column += yyleng; BEGIN(INITIAL); }
-<COMMENT>[^\n\r] { yylloc->last_column++; }
+<COMMENT>[^\n] { yylloc->last_column++; }
<COMMENT>\n { yylloc->last_line++; yylloc->last_column = 0; }
-<COMMENT>\r {}
. {
yylloc->first_line = yylloc->last_line;