-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
148 lines (127 loc) · 4.62 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!-- ant build file for cse minijava compiler project -->
<!-- hp, 1/10, 8/11, 1/16, 9/18. aj, 9/19 -->
<!-- Possible future changes:
- use symbolic variables for various class and path names
- add options to interface better with internal eclipse compiler -->
<project name="minijava" default="compile">
<!-- build targets for compiler -->
<!-- you might not need to change much of anything here except for compiler warnings -->
<target name="init">
<mkdir dir="build/classes"/>
</target>
<target name="clean">
<delete dir="build"/>
<delete file="src/Parser/parser.java"/>
<delete file="src/Parser/sym.java"/>
<delete file="src/Scanner/scanner.java"/>
<delete file="src/Scanner/scanner.java~"/>
</target>
<target name="check.parse.files">
<uptodate targetfile="src/Parser/parser.java"
srcfile="src/Parser/minijava.cup"
property="parser.uptodate"/>
<uptodate targetfile="src/Scanner/scanner.java"
srcfile="src/Scanner/minijava.jflex"
property="scanner.uptodate"/>
<condition property="scanner.parser.uptodate">
<and>
<isset property="scanner.uptodate"/>
<isset property="parser.uptodate"/>
</and>
</condition>
</target>
<target name="gen-parser" depends="check.parse.files"
unless="parser.uptodate">
<java jar="lib/java-cup-11b.jar" fork="true" failonerror="true"
output="build/cup.out">
<arg value="-locations"/>
<arg value="-dump_states"/>
<arg value="-dump_grammar"/>
<arg value="-dump_tables"/>
<arg value="-destdir"/>
<arg value="src/Parser"/>
<arg value="src/Parser/minijava.cup"/>
</java>
</target>
<target name="gen-scanner" depends="gen-parser, check.parse.files"
unless="scanner.parser.uptodate">
<java classname="jflex.Main" classpath="lib/jflex-full-1.7.0.jar"
fork="true" failonerror="true">
<arg value="src/Scanner/minijava.jflex"/>
</java>
</target>
<!-- Remove comment on compilerarg line below to generate compiler warnings
for unchecked casts. Even if the minijava code is clean, there may be
warnings in java code generated by cup. -->
<target name="compile" depends="init, gen-scanner">
<javac srcdir="src" destdir="build/classes" classpath="lib/java-cup-11b.jar"
debug="true"
includeAntRuntime="false">
<!-- <compilerarg value="-Xlint:unchecked"/> -->
</javac>
</target>
<!-- targets for running demo programs -->
<target name="mj" depends="compile">
<java
classname="MiniJava"
classpath="build/classes;lib/java-cup-11b.jar"
fork="true"
>
<arg value="-P"/>
<arg value="test/resources/CodeGen/DoubleExpressions.java"/>
<assertions>
<enable/>
</assertions>
</java>
</target>
<!-- run scanner and parser test programs on initial demo input
located in SamplePrograms/Example.java. -->
<target name="demo-scanner" depends="compile">
<java classname="DemoScanner" classpath="build/classes;lib/java-cup-11b.jar"
fork="true"
input="SamplePrograms/Example.java">
<assertions>
<enable/>
</assertions>
</java>
</target>
<target name="demo-parser" depends="compile">
<java classname="DemoParser" classpath="build/classes;lib/java-cup-11b.jar"
fork="true"
input="SamplePrograms/Example.java">
<assertions>
<enable/>
</assertions>
</java>
</target>
<!-- targets for running test cases -->
<!-- you may want to expand on what's here! -->
<target name="compile-test" depends="compile">
<javac srcdir="test/junit;test/resources/CodeGen" destdir="build/classes"
classpath="lib/hamcrest-core-1.3.jar;lib/junit-4.12.jar;lib/java-cup-11b.jar"
debug="true"
includeAntRuntime="false">
</javac>
</target>
<!-- run all JUnit tests in the test/junit subdirectory -->
<!-- this target runs all tests in test/junit, but you may find it easier
to break things up, e.g. by portion of the project. to do so, copy
this target as needed and modify the <fileset> tag to <include> only
the test files you want. -->
<target name="test" depends="compile-test">
<junit>
<classpath>
<pathelement location="build/classes"/>
<pathelement location="lib/hamcrest-core-1.3.jar"/>
<pathelement location="lib/junit-4.12.jar"/>
<pathelement location="lib/java-cup-11b.jar"/>
</classpath>
<batchtest>
<fileset dir="test/junit">
<include name="**/*.java"/>
</fileset>
</batchtest>
<formatter type="plain" usefile="false"/>
</junit>
</target>
</project>