Skip to content

Commit aa1986c

Browse files
mmazasmmazas
authored andcommitted
Laundry pass on /bugs to make them work the same in java, cpp & csharp
Signed-off-by: mmazas <mmazas@ITEM-S104678.emea.msad.sopra> Signed-off-by: mmazas <mmazas@ITEM-S104678.emea.msad.sopra>
1 parent c3a4a0f commit aa1986c

File tree

19 files changed

+200
-332
lines changed

19 files changed

+200
-332
lines changed
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Found a match of kind:9; kind: <Id> using the first: 1 characters.
1414
Looking to move from state: 1 for: <Id>
1515
state=1 vectorindex=0 bitpattern=512 jjChars[state][vectorIndex]=287984085547089920
1616
Done with NFA at pos: 2
17-
aa
1817
Returning token: 'aa'
1918
<DEFAULT>
2019
Current character: ' ' at 1:8
@@ -356,7 +355,6 @@ Found a match of kind:9; kind: <Id> using the first: 2 characters.
356355
Looking to move from state: 1 for: <Id>
357356
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
358357
Done with NFA at pos: 3
359-
ten
360358
Returning token: 'ten'
361359
<DEFAULT>
362360
Current character: ' ' at 2:4
@@ -389,7 +387,6 @@ Found a match of kind:9; kind: <Id> using the first: 3 characters.
389387
Looking to move from state: 1 for: <Id>
390388
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
391389
Done with NFA at pos: 4
392-
Int1
393390
Returning token: 'Int1'
394391
<DEFAULT>
395392
Current character: ' ' at 2:9
@@ -442,7 +439,6 @@ Found a match of kind:9; kind: <Id> using the first: 8 characters.
442439
Looking to move from state: 1 for: <Id>
443440
state=1 vectorindex=0 bitpattern=8192 jjChars[state][vectorIndex]=287984085547089920
444441
Done with NFA at pos: 9
445-
other-ten
446442
Returning token: 'other-ten'
447443
<DEFAULT>
448444
Current character: '' at 2:19
@@ -504,7 +500,6 @@ Found a match of kind:9; kind: <Id> using the first: 8 characters.
504500
Looking to move from state: 1 for: <Id>
505501
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
506502
Done with NFA at pos: 9
507-
other-ten
508503
Returning token: 'other-ten'
509504
<DEFAULT>
510505
Current character: ' ' at 3:10
@@ -537,7 +532,6 @@ Found a match of kind:9; kind: <Id> using the first: 3 characters.
537532
Looking to move from state: 1 for: <Id>
538533
state=1 vectorindex=0 bitpattern=8192 jjChars[state][vectorIndex]=287984085547089920
539534
Done with NFA at pos: 4
540-
Int2
541535
Returning token: 'Int2'
542536
<DEFAULT>
543537
Current character: '' at 3:15
@@ -571,3 +565,4 @@ Looking for string literal match of kind:3 token image: '\n'
571565
Currently matched the first: 1 chars as kind: 3,with image: \n
572566
Found a SKIP match.
573567
<DEFAULT> Reached EOF at 4:2
568+
Input file parsed successfully

bugs/bug001/files/clc1.exp_out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
aa
2+
ten
3+
Int1
4+
other-ten
5+
other-ten
6+
Int2
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Found a match of kind:9; kind: <Id> using the first: 1 characters.
1414
Looking to move from state: 1 for: <Id>
1515
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
1616
Done with NFA at pos: 2
17-
aa
1817
Returning token: 'aa'
1918
<DEFAULT>
2019
Current character: ' ' at 1:3
@@ -130,7 +129,6 @@ Found a match of kind:9; kind: <Id> using the first: 1 characters.
130129
Looking to move from state: 1 for: <Id>
131130
state=1 vectorindex=0 bitpattern=8192 jjChars[state][vectorIndex]=287984085547089920
132131
Done with NFA at pos: 2
133-
bb
134132
Returning token: 'bb'
135133
<DEFAULT>
136134
Current character: '' at 1:16
@@ -148,3 +146,4 @@ Looking for string literal match of kind:3 token image: '\n'
148146
Currently matched the first: 1 chars as kind: 3,with image: \n
149147
Found a SKIP match.
150148
<DEFAULT> Reached EOF at 1:17
149+
Input file parsed successfully

bugs/bug001/files/clc2.exp_out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
aa
2+
bb

bugs/bug001/pom.xml

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ THE POSSIBILITY OF SUCH DAMAGE.
3232
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3333
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3434
<modelVersion>4.0.0</modelVersion>
35-
35+
3636
<parent>
3737
<groupId>org.javacc.generator.cpp</groupId>
3838
<artifactId>bugs</artifactId>
3939
<version>1.1.0-SNAPSHOT</version>
4040
</parent>
41-
41+
4242
<groupId>org.javacc.generator.cpp.bugs</groupId>
4343
<artifactId>bug001</artifactId>
4444
<packaging>nar</packaging>
@@ -76,7 +76,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
7676

7777
<!-- execute the tests -->
7878

79-
<!-- <plugin>
79+
<!-- <plugin>
8080
<groupId>com.github.maven-nar</groupId>
8181
<artifactId>nar-maven-plugin</artifactId>
8282
<extensions>true</extensions>
@@ -86,9 +86,9 @@ THE POSSIBILITY OF SUCH DAMAGE.
8686
<type>executable</type>
8787
<run>true</run>
8888
<args>
89-
<arg>${project.basedir}/test/clc2.in</arg>
90-
<arg>${project.basedir}/test/clc2.out</arg>
91-
<arg>${project.basedir}/test/clc2.err</arg>
89+
<arg>${project.basedir}/files/clc2.in</arg>
90+
<arg>${project.basedir}/files/clc2.out</arg>
91+
<arg>${project.basedir}/files/clc2.err</arg>
9292
</args>
9393
</library>
9494
</libraries>
@@ -125,11 +125,12 @@ THE POSSIBILITY OF SUCH DAMAGE.
125125
<goal>exec</goal>
126126
</goals>
127127
<configuration>
128-
<executable>${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
128+
<executable>
129+
${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
129130
<arguments>
130-
<argument>${project.basedir}/test/clc1.in</argument>
131-
<argument>${project.basedir}/test/clc1.out</argument>
132-
<argument>${project.basedir}/test/clc1.err</argument>
131+
<argument>${project.basedir}/files/clc1.in</argument>
132+
<argument>${project.basedir}/files/clc1.out</argument>
133+
<argument>${project.basedir}/files/clc1.err</argument>
133134
</arguments>
134135
</configuration>
135136
</execution>
@@ -140,17 +141,19 @@ THE POSSIBILITY OF SUCH DAMAGE.
140141
<goal>exec</goal>
141142
</goals>
142143
<configuration>
143-
<executable>${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
144+
<executable>
145+
${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
144146
<arguments>
145-
<argument>${project.basedir}/test/clc2.in</argument>
146-
<argument>${project.basedir}/test/clc2.out</argument>
147-
<argument>${project.basedir}/test/clc2.err</argument>
147+
<argument>${project.basedir}/files/clc2.in</argument>
148+
<argument>${project.basedir}/files/clc2.out</argument>
149+
<argument>${project.basedir}/files/clc2.err</argument>
148150
</arguments>
149151
</configuration>
150152
</execution>
151153
</executions>
152154
</plugin>
153155

156+
<!-- check the tests results -->
154157
<plugin>
155158
<groupId>org.apache.maven.plugins</groupId>
156159
<artifactId>maven-antrun-plugin</artifactId>
@@ -165,33 +168,33 @@ THE POSSIBILITY OF SUCH DAMAGE.
165168
<skip>false</skip>
166169
<target unless="maven.test.skip">
167170
<!-- out -->
168-
<available file="${project.basedir}/test/clc1.out" property="isActualOutAvailable" />
171+
<available file="${project.basedir}/files/clc1.out" property="isActualOutAvailable" />
169172
<fail unless="isActualOutAvailable"
170-
message="${project.basedir}/test/clc1.out does not exist!" />
171-
<available file="${project.basedir}/test/clc1.exp_out"
173+
message="${project.basedir}/files/clc1.out does not exist!" />
174+
<available file="${project.basedir}/files/clc1.exp_out"
172175
property="isExpectedOutAvailable" />
173176
<fail unless="isExpectedOutAvailable"
174-
message="${project.basedir}/test/clc1.exp_out does not exist!" />
177+
message="${project.basedir}/files/clc1.exp_out does not exist!" />
175178
<condition property="out.files.match">
176-
<filesmatch textfile="true" file1="${project.basedir}/test/clc1.out"
177-
file2="${project.basedir}/test/clc1.exp_out" />
179+
<filesmatch textfile="true" file1="${project.basedir}/files/clc1.out"
180+
file2="${project.basedir}/files/clc1.exp_out" />
178181
</condition>
179182
<fail unless="out.files.match"
180-
message="${project.basedir}/test/clc1.out does not match ${project.basedir}/test/clc1.exp_out!" />
183+
message="${project.basedir}/files/clc1.out does not match ${project.basedir}/files/clc1.exp_out!" />
181184
<!-- err -->
182-
<available file="${project.basedir}/test/clc1.err" property="isActualErrAvailable" />
185+
<available file="${project.basedir}/files/clc1.err" property="isActualErrAvailable" />
183186
<fail unless="isActualErrAvailable"
184-
message="${project.basedir}/test/clc1.err does not exist!" />
185-
<available file="${project.basedir}/test/clc1.exp_err"
187+
message="${project.basedir}/files/clc1.err does not exist!" />
188+
<available file="${project.basedir}/files/clc1.exp_err"
186189
property="isExpectedErrAvailable" />
187190
<fail unless="isExpectedErrAvailable"
188-
message="${project.basedir}/test/clc1.exp_err does not exist!" />
191+
message="${project.basedir}/files/clc1.exp_err does not exist!" />
189192
<condition property="err.files.match">
190-
<filesmatch textfile="true" file1="${project.basedir}/test/clc1.err"
191-
file2="${project.basedir}/test/clc1.exp_err" />
193+
<filesmatch textfile="true" file1="${project.basedir}/files/clc1.err"
194+
file2="${project.basedir}/files/clc1.exp_err" />
192195
</condition>
193196
<fail unless="err.files.match"
194-
message="${project.basedir}/test/clc1.err does not match ${project.basedir}/test/clc1.exp_err!" />
197+
message="${project.basedir}/files/clc1.err does not match ${project.basedir}/files/clc1.exp_err!" />
195198
</target>
196199
</configuration>
197200
</execution>
@@ -205,33 +208,33 @@ THE POSSIBILITY OF SUCH DAMAGE.
205208
<skip>false</skip>
206209
<target unless="maven.test.skip">
207210
<!-- out -->
208-
<available file="${project.basedir}/test/clc2.out" property="isActualOutAvailable" />
211+
<available file="${project.basedir}/files/clc2.out" property="isActualOutAvailable" />
209212
<fail unless="isActualOutAvailable"
210-
message="${project.basedir}/test/clc2.out does not exist!" />
211-
<available file="${project.basedir}/test/clc2.exp_out"
213+
message="${project.basedir}/files/clc2.out does not exist!" />
214+
<available file="${project.basedir}/files/clc2.exp_out"
212215
property="isExpectedOutAvailable" />
213216
<fail unless="isExpectedOutAvailable"
214-
message="${project.basedir}/test/clc2.exp_out does not exist!" />
217+
message="${project.basedir}/files/clc2.exp_out does not exist!" />
215218
<condition property="out.files.match">
216-
<filesmatch textfile="true" file1="${project.basedir}/test/clc2.out"
217-
file2="${project.basedir}/test/clc2.exp_out" />
219+
<filesmatch textfile="true" file1="${project.basedir}/files/clc2.out"
220+
file2="${project.basedir}/files/clc2.exp_out" />
218221
</condition>
219222
<fail unless="out.files.match"
220-
message="${project.basedir}/test/clc2.out does not match ${project.basedir}/test/clc2.exp_out!" />
223+
message="${project.basedir}/files/clc2.out does not match ${project.basedir}/files/clc2.exp_out!" />
221224
<!-- err -->
222-
<available file="${project.basedir}/test/clc2.err" property="isActualErrAvailable" />
225+
<available file="${project.basedir}/files/clc2.err" property="isActualErrAvailable" />
223226
<fail unless="isActualErrAvailable"
224-
message="${project.basedir}/test/clc2.err does not exist!" />
225-
<available file="${project.basedir}/test/clc2.exp_err"
227+
message="${project.basedir}/files/clc2.err does not exist!" />
228+
<available file="${project.basedir}/files/clc2.exp_err"
226229
property="isExpectedErrAvailable" />
227230
<fail unless="isExpectedErrAvailable"
228-
message="${project.basedir}/test/clc2.exp_err does not exist!" />
231+
message="${project.basedir}/files/clc2.exp_err does not exist!" />
229232
<condition property="err.files.match">
230-
<filesmatch textfile="true" file1="${project.basedir}/test/clc2.err"
231-
file2="${project.basedir}/test/clc2.exp_err" />
233+
<filesmatch textfile="true" file1="${project.basedir}/files/clc2.err"
234+
file2="${project.basedir}/files/clc2.exp_err" />
232235
</condition>
233236
<fail unless="err.files.match"
234-
message="${project.basedir}/test/clc2.err does not match ${project.basedir}/test/clc2.exp_err!" />
237+
message="${project.basedir}/files/clc2.err does not match ${project.basedir}/files/clc2.exp_err!" />
235238
</target>
236239
</configuration>
237240
</execution>

bugs/bug001/src/main/cpp/Main.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <iostream>
22
#include <fstream>
33
#include <iomanip>
4-
#include <string>
54

65
#include "JavaCC.h"
76
#include "ComplexLineCommentTokenManager.h"
@@ -27,9 +26,9 @@ using namespace std;
2726

2827
int main(int argc, char **argv) {
2928

30-
if (argc != 4) {
29+
if (argc > 4) {
3130
cerr << "Error: invalid number of arguments (" << (argc - 1) << ")" << endl;
32-
cerr << "Usage: MYPARSER [ inputfile [ outputfile [ errorfile ] ] ]" << endl;
31+
cerr << "Usage: ComplexLineComment [ inputfile [ outputfile [ errorfile ] ] ]" << endl;
3332
return 4;
3433
}
3534

@@ -47,32 +46,35 @@ int main(int argc, char **argv) {
4746
try {
4847
// open files and redirect standard streams to them
4948
switch (argc) {
50-
case 4:
51-
efs.open(argv[3]);
52-
case 3:
53-
ofs.open(argv[2]);
54-
case 2:
55-
ifs.open(argv[1], ifstream::binary);
49+
case 4:
50+
efs.open(argv[3]);
51+
case 3:
52+
ofs.open(argv[2]);
53+
case 2:
54+
ifs.open(argv[1], ifstream::binary);
5655
}
5756
if (ifs.is_open()) {
5857
sr = new StreamReader(ifs);
5958
cs = new CHARSTREAM(sr);
6059
cinbuf = cin.rdbuf();
6160
cin.rdbuf(ifs.rdbuf());
6261
} else {
63-
cerr << "Cannot open input file" << endl;
62+
cerr << "Cannot open input file " << argv[1] << endl;
6463
return 8;
6564
}
6665
if (ofs.is_open()) {
6766
coutbuf = cout.rdbuf();
6867
cout.rdbuf(ofs.rdbuf());
6968
} else {
70-
cerr << "Cannot open output file" << endl;
69+
cerr << "Cannot open output file " << argv[2] << endl;
7170
return 8;
7271
}
7372
if (efs.is_open()) {
7473
cerrbuf = cerr.rdbuf();
7574
cerr.rdbuf(efs.rdbuf());
75+
} else {
76+
cerr << "Cannot open error file " << argv[3] << endl;
77+
return 8;
7678
}
7779

7880
// parse

bugs/bug001/test/clc1.exp_err

Lines changed: 0 additions & 1 deletion
This file was deleted.

bugs/bug001/test/clc2.exp_err

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)