-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
231 lines (185 loc) · 9.72 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Linguaggi_Traduttori" default="default" basedir=".">
<description>Builds, tests, and runs the project Linguaggi_Traduttori.</description>
<import file="nbproject/build-impl.xml"/>
<!--TASK ESTERNO-->
<taskdef name="jflex"
classname="JFlex.anttask.JFlexTask"
/>
<!--TASK ESTERNO-->
<taskdef name="cup"
classname="java_cup.AntTask"
/>
<property name="parser.dir" location="${basedir}/parser" />
<property name="src.dir" location="${basedir}/src" />
<property name="generated.dir" location="${basedir}/generated" />
<property name="bin.dir" location="${basedir}/bin" />
<property name="lib.dir" location="${basedir}/lib" />
<property name="input.dir" location="${basedir}/input" />
<property name="generated.package" location="${generated.dir}/it/polito/lt/skype/generated/parser" />
<property name="input.file" location="${input.dir}/prova.txt" />
<property name="scanner.file" location="${parser.dir}/scanner.jflex" />
<property name="parser.file" location="${parser.dir}/parser.cup" />
<property name="tj" location="/home/jo/tooljava/" />
<property name="drawTree.dir" location="${basedir}/drawTree" />
<property name="input.arg" location="prova.txt" />
<property name="debug" value="true" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.7" />
<property name="source" value="1.7" />
<path id="project.classpath">
<pathelement location="${bin.dir}" />
</path>
<path id="lib.dir.classpath">
<pathelement location="${bin.dir}" />
<fileset dir="${lib.dir}" casesensitive="true" >
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<mkdir dir="${bin.dir}" />
<mkdir dir="${generated.dir}" />
</target>
<target name="clean" description="Clean all">
<delete dir="${bin.dir}" />
<delete dir="${generated.dir}" />
</target>
<!--<target name="clean-scanner" description="Clean scanner generated file (not binary)">
<delete file="${generated.package}/Lexer.java" />
<delete file ="${generated.package}/sym.java" />
</target>
<target name="clean-parser" description="Clean parser generated file (not binary)">
<delete file="${generated.package}/parser.java" />
</target> -->
<target name="chk-parser-artifacts">
<uptodate property="generate-artifacts.notRequired" targetfile="${generated.dir}/.flagfile">
<srcfiles dir="${parser.dir}">
<include name="**/*.cup" />
<include name="**/*.jflex" />
</srcfiles>
</uptodate>
</target>
<target name="generate-parser-artifacts" unless="generate-artifacts.notRequired" depends="init, chk-parser-artifacts" description="generate-parser-artifatcs">
<jflex
file="/${scanner.file}"
destdir="${generated.dir}"
/>
<!--non fa il settaggio della property package...agisco direttamente sulla dir di output-->
<cup
file="/${parser.file}"
dir="${generated.package}"
package="${generated.pakage}"
/>
<touch file="${generated.dir}/.flagfile" />
<echo>Running REWRITE Lexer.java</echo>
<replaceregexp file="${generated.package}/Lexer.java" match="Lexer\(java." replace="public Lexer\(java." byline="true"/>
<echo>...</echo>
<replaceregexp file="${generated.package}/Lexer.java" match="class Lexer " replace="public class Lexer "/>
<echo>REWRITE DONE!</echo>
</target>
<target name="create-test-file" description="tests files">
<exec dir="${input.dir}" executable="/bin/sh">
<arg line="test_script"/>
</exec>
</target>
<target name="fix-lexer" description="fix lexer.java public issues">
<echo>Running REWRITE Lexer.java</echo>
<replaceregexp file="${generated.package}/Lexer.java" match="Lexer\(java." replace="public Lexer\(java." byline="true"/>
<echo>...</echo>
<replaceregexp file="${generated.package}/Lexer.java" match="class Lexer " replace="public class Lexer "/>
<echo>REWRITE DONE!</echo>
</target>
<target name="generate-treeCleanParser" description="generate a cleaned parser for DrawTree">
<echo>TREE CLEAN START</echo>
<copy file="${parser.dir}/parser.cup" tofile="${drawTree.dir}/parser_clean.cup" overwrite="true"/>
<echo>...</echo>
<replaceregexp file="${drawTree.dir}/parser_clean.cup" match="\{:" replace="{:\/\*" byline="true"/>
<replaceregexp file="${drawTree.dir}/parser_clean.cup" match=":\}" replace="\*\/:\}" byline="true"/>
<replaceregexp file="${drawTree.dir}/parser_clean.cup" match="package" replace="\/\/package" byline="true"/>
<replaceregexp file="${drawTree.dir}/parser_clean.cup" match="import" replace="\/\/import" byline="true"/>
<replaceregexp file="${drawTree.dir}/parser_clean.cup" match="\/\/import java_cup" replace="import java_cup"/>
<replaceregexp file="${drawTree.dir}/parser_clean.cup" match="terminal (.+)[\t]+" replace="terminal " byline="true"/>
<replaceregexp file="${drawTree.dir}/parser_clean.cup" match="non terminal (.+)[\t]" replace="non terminal " byline="true"/>
<echo>TREE CLEAN DONE!</echo>
</target>
<target name="generate-treeCleanScanner" description="generate a cleaned scanner for DrawTree">
<echo>TREE CLEAN START</echo>
<copy file="${parser.dir}/scanner.jflex" tofile="${drawTree.dir}/scanner_clean.jflex" overwrite="true"/>
<echo>...</echo>
<replaceregexp file="${drawTree.dir}/scanner_clean.jflex" match="Utility.mf" replace="System.out.println" byline="true"/>
<replaceregexp file="${drawTree.dir}/scanner_clean.jflex" match="package" replace="\/\/package" byline="true"/>
<replaceregexp file="${drawTree.dir}/scanner_clean.jflex" match="import" replace="\/\/import" byline="true"/>
<replaceregexp file="${drawTree.dir}/scanner_clean.jflex" match="\/\/import java_cup" replace="import java_cup" />
<replaceregexp file="${drawTree.dir}/scanner_clean.jflex" match="terminal .+ " replace="terminal " byline="true"/>
<echo>TREE CLEAN DONE!</echo>
</target>
<target name="launch-drawTree" depends="generate-treeCleanParser, generate-treeCleanScanner" description="generate a cleaned scanner for DrawTree">
<echo>Launch DrawTree</echo>
<echo>...</echo>
<exec executable="/bin/tcsh">
<arg value="${drawTree.dir}/cmd.sh"/>
</exec>
<echo>DrawTree Finish!</echo>
</target>
<target name="copy-drawTree" description="generate a clea parser for DrawTree">
<echo>COPY</echo>
<copy file="${generated.package}/Lexer.java" tofile="${drawTree.dir}/Lexer.java" overwrite="true"/>
<copy file="${generated.package}/prova.txt" tofile="${drawTree.dir}/prova.txt" overwrite="true"/>
<copy file="${generated.package}/parser.java" tofile="${drawTree.dir}/parser.java" overwrite="true"/>
<copy file="${generated.package}/sym.java" tofile="${drawTree.dir}/sym.java" overwrite="true"/>
<echo>COPY DONE!</echo>
</target>
<target name="build" depends="init, generate-parser-artifacts" description="Build the sources">
<javac debug="${debug}" debuglevel="${debuglevel}" source="${source}" target="${target}" destdir="${bin.dir}">
<src path="${generated.dir}" />
<src path="${src.dir}" />
<classpath refid="project.classpath" />
<classpath refid="lib.dir.classpath" />
</javac>
</target>
<target name="run.commandline" depends="build" description="launch parser in command line">
<echo>Running COMMAND LINE...</echo>
<java classname="it.polito.lt.skype.parser.ParserMain" failonerror="true" fork="yes">
<classpath>
<path refid="lib.dir.classpath" />
<pathelement path="${bin.dir}" />
</classpath>
</java>
</target>
<target name="run.filearg" depends="build" description="launch parser with file input: /input/prova.txt">
<echo>Running FILE ARGUMENT ${input.arg}...</echo>
<java classname="it.polito.lt.skype.parser.ParserFileInputMain" failonerror="true" fork="yes">
<classpath>
<path refid="lib.dir.classpath" />
<pathelement path="${bin.dir}" />
</classpath>
<arg value="/${input.dir}/${input.arg}"/>
</java>
</target>
<target name="run.CommandTest" depends="build" description="launch command object">
<echo>Running TEST OBJECT...</echo>
<java classname="it.polito.lt.skype.command.Test" failonerror="true" fork="yes">
<classpath>
<path refid="lib.dir.classpath" />
<pathelement path="${bin.dir}" />
</classpath>
</java>
</target>
<target name="run.skypeBot" depends="build" description="launch skype daemon">
<echo>Running SKYPE DAEMON...</echo>
<java classname="it.polito.lt.skype.bot.SkyBot" failonerror="true" fork="yes">
<classpath>
<path refid="lib.dir.classpath" />
<pathelement path="${bin.dir}" />
</classpath>
</java>
</target>
</project>