summaryrefslogtreecommitdiffstats
path: root/util/qlalr/examples/qparser/calc.l
diff options
context:
space:
mode:
Diffstat (limited to 'util/qlalr/examples/qparser/calc.l')
-rw-r--r--util/qlalr/examples/qparser/calc.l20
1 files changed, 20 insertions, 0 deletions
diff --git a/util/qlalr/examples/qparser/calc.l b/util/qlalr/examples/qparser/calc.l
new file mode 100644
index 0000000..95181d5
--- /dev/null
+++ b/util/qlalr/examples/qparser/calc.l
@@ -0,0 +1,20 @@
+
+%option noyywrap
+
+%{
+#include "calc_parser.h"
+#include <cstdlib>
+
+#define YY_DECL int CalcParser::nextToken()
+%}
+
+%%
+
+[ \t\n] { /* eat me */ }
+[0-9]+ { sym(1) = atoi (yytext); return Token_number; }
+"(" { return Token_lparen; }
+")" { return Token_rparen; }
+"+" { return Token_plus; }
+"-" { return Token_minus; }
+
+%%