File tree 9 files changed +3693
-0
lines changed
9 files changed +3693
-0
lines changed Original file line number Diff line number Diff line change
1
+ * .output
2
+ * .o
Original file line number Diff line number Diff line change
1
+ cd JavaTownCompiler
2
+ rm out/javat
3
+ bison -dv javat.y
4
+ flex -l javat.l
5
+ gcc -o out/javat javat.tab.c lex.yy.c
Original file line number Diff line number Diff line change
1
+ %option noyywrap
2
+
3
+ %{
4
+ #include < stdio.h>
5
+ #define YY_DECL int yylex ()
6
+ #include " javat.tab.h"
7
+ %}
8
+
9
+ %%
10
+ [ \t ] ; // ignore all space
11
+ " public" { return PUBLIC; }
12
+ " private" { return PRIVATE; }
13
+ " class" { return CLASS; }
14
+ [A -Za -z_ ] { yylval.string = strdup (yytext); return LETTER; }
15
+ [A -Za -z_ ]+ [A -Za -z0 -9_$ ]* { yylval.string = strdup (yytext); return WORD; }
16
+ [0 -9 ]+ \. [0 -9 ]+ { yylval.floating = atof (yytext); return FLOAT; }
17
+ [0 -9 ]+ [A -Za -z_ ]+ [A -Za -z0 -9_$ ]* { return DISALLOWED_INDENTIFIER; }
18
+ [0 -9 ]+ { yylval.number = atoi (yytext); return INT; }
19
+ " ;" { return SEMICOLON; }
20
+ " +" { return ADD; }
21
+ " -" { return SUBT; }
22
+ " *" { return MULT; }
23
+ " /" { return DIV; }
24
+ " (" { return LPAR; }
25
+ " )" { return RPAR; }
26
+ " {" { return LBRACE; }
27
+ " }" { return RBRACE; }
28
+ \" " " { return QUOTE; }
29
+ " =" { return EQUALS; }
30
+ " \n " { return NEW; }
31
+ %%
You can’t perform that action at this time.
0 commit comments