We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
0 parents commit c0200f7Copy full SHA for c0200f7
Compiler.l
@@ -0,0 +1,27 @@
1
+%{
2
+#include <stdio.h>
3
+%}
4
+
5
+DIGIT [0-9]
6
+NUMBER {DIGIT}+
7
+IDENTIFIER [a-zA-Z_][a-zA-Z0-9_]*
8
+OPERATOR "+"|"-"|"*"|"/"
9
+LPAREN "("
10
+RPAREN ")"
11
+WS [ \t\n]
12
13
+%%
14
+{NUMBER} { printf("NUMBER(%s)\n", yytext); }
15
+{IDENTIFIER}{ printf("IDENTIFIER(%s)\n", yytext); }
16
+{OPERATOR} { printf("OPERATOR(%s)\n", yytext); }
17
+{LPAREN} { printf("LPAREN\n"); }
18
+{RPAREN} { printf("RPAREN\n"); }
19
+{WS} { /* Ignore whitespace */ }
20
+. { printf("UNKNOWN(%s)\n", yytext); }
21
22
23
24
+int main() {
25
+ yylex();
26
+ return 0;
27
+}
0 commit comments