aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/lexer.l
diff options
context:
space:
mode:
authorChristian Theune <ct@flyingcircus.io>2016-01-05 00:40:40 +0100
committerChristian Theune <ct@flyingcircus.io>2016-01-05 00:40:40 +0100
commit14ebde52893263930cdcde1406cc91cc5c42556f (patch)
tree2b65c11405f9aef33eb284208716f9cb5b434599 /src/libexpr/lexer.l
parentb8258a4475726b56a4caa6553568c67a343a091d (diff)
First hit at providing support for floats in the language.
Diffstat (limited to 'src/libexpr/lexer.l')
-rw-r--r--src/libexpr/lexer.l7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index 1f2957ec7..8f9d686a1 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -85,6 +85,7 @@ static Expr * unescapeStr(SymbolTable & symbols, const char * s)
ID [a-zA-Z\_][a-zA-Z0-9\_\'\-]*
INT [0-9]+
+FLOAT {INT}[0-9]+\.[0-9]+[eE]-?{INT}
PATH [a-zA-Z0-9\.\_\-\+]*(\/[a-zA-Z0-9\.\_\-\+]+)+
HPATH \~(\/[a-zA-Z0-9\.\_\-\+]+)+
SPATH \<[a-zA-Z0-9\.\_\-\+]+(\/[a-zA-Z0-9\.\_\-\+]+)*\>
@@ -123,6 +124,12 @@ or { return OR_KW; }
throw ParseError(format("invalid integer ‘%1%’") % yytext);
return INT;
}
+{FLOAT} { errno = 0;
+ yylval->n = strtod(yytext, 0);
+ if (errno != 0)
+ throw ParseError(format("invalid float ‘%1%’") % yytext);
+ return FLOAT;
+ }
\$\{ { PUSH_STATE(INITIAL); return DOLLAR_CURLY; }
\{ { PUSH_STATE(INITIAL); return '{'; }