Skip to content

Commit

Permalink
Laundry pass on /bugs to make them work the same in java, cpp & csharp
Browse files Browse the repository at this point in the history
Signed-off-by: mmazas <[email protected]>
Signed-off-by: mmazas <[email protected]>
  • Loading branch information
mmazas authored and mmazas committed Sep 4, 2024
1 parent c3a4a0f commit aa1986c
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Found a match of kind:9; kind: <Id> using the first: 1 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=512 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 2
aa
Returning token: 'aa'
<DEFAULT>
Current character: ' ' at 1:8
Expand Down Expand Up @@ -356,7 +355,6 @@ Found a match of kind:9; kind: <Id> using the first: 2 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 3
ten
Returning token: 'ten'
<DEFAULT>
Current character: ' ' at 2:4
Expand Down Expand Up @@ -389,7 +387,6 @@ Found a match of kind:9; kind: <Id> using the first: 3 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 4
Int1
Returning token: 'Int1'
<DEFAULT>
Current character: ' ' at 2:9
Expand Down Expand Up @@ -442,7 +439,6 @@ Found a match of kind:9; kind: <Id> using the first: 8 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=8192 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 9
other-ten
Returning token: 'other-ten'
<DEFAULT>
Current character: '' at 2:19
Expand Down Expand Up @@ -504,7 +500,6 @@ Found a match of kind:9; kind: <Id> using the first: 8 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 9
other-ten
Returning token: 'other-ten'
<DEFAULT>
Current character: ' ' at 3:10
Expand Down Expand Up @@ -537,7 +532,6 @@ Found a match of kind:9; kind: <Id> using the first: 3 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=8192 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 4
Int2
Returning token: 'Int2'
<DEFAULT>
Current character: '' at 3:15
Expand Down Expand Up @@ -571,3 +565,4 @@ Looking for string literal match of kind:3 token image: '\n'
Currently matched the first: 1 chars as kind: 3,with image: \n
Found a SKIP match.
<DEFAULT> Reached EOF at 4:2
Input file parsed successfully
Expand Down
6 changes: 6 additions & 0 deletions bugs/bug001/files/clc1.exp_out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
aa
ten
Int1
other-ten
other-ten
Int2
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Found a match of kind:9; kind: <Id> using the first: 1 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 2
aa
Returning token: 'aa'
<DEFAULT>
Current character: ' ' at 1:3
Expand Down Expand Up @@ -130,7 +129,6 @@ Found a match of kind:9; kind: <Id> using the first: 1 characters.
Looking to move from state: 1 for: <Id>
state=1 vectorindex=0 bitpattern=8192 jjChars[state][vectorIndex]=287984085547089920
Done with NFA at pos: 2
bb
Returning token: 'bb'
<DEFAULT>
Current character: '' at 1:16
Expand All @@ -148,3 +146,4 @@ Looking for string literal match of kind:3 token image: '\n'
Currently matched the first: 1 chars as kind: 3,with image: \n
Found a SKIP match.
<DEFAULT> Reached EOF at 1:17
Input file parsed successfully
Expand Down
2 changes: 2 additions & 0 deletions bugs/bug001/files/clc2.exp_out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aa
bb
File renamed without changes.
87 changes: 45 additions & 42 deletions bugs/bug001/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ THE POSSIBILITY OF SUCH DAMAGE.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.javacc.generator.cpp</groupId>
<artifactId>bugs</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>

<groupId>org.javacc.generator.cpp.bugs</groupId>
<artifactId>bug001</artifactId>
<packaging>nar</packaging>
Expand Down Expand Up @@ -76,7 +76,7 @@ THE POSSIBILITY OF SUCH DAMAGE.

<!-- execute the tests -->

<!-- <plugin>
<!-- <plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
Expand All @@ -86,9 +86,9 @@ THE POSSIBILITY OF SUCH DAMAGE.
<type>executable</type>
<run>true</run>
<args>
<arg>${project.basedir}/test/clc2.in</arg>
<arg>${project.basedir}/test/clc2.out</arg>
<arg>${project.basedir}/test/clc2.err</arg>
<arg>${project.basedir}/files/clc2.in</arg>
<arg>${project.basedir}/files/clc2.out</arg>
<arg>${project.basedir}/files/clc2.err</arg>
</args>
</library>
</libraries>
Expand Down Expand Up @@ -125,11 +125,12 @@ THE POSSIBILITY OF SUCH DAMAGE.
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
<executable>
${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
<arguments>
<argument>${project.basedir}/test/clc1.in</argument>
<argument>${project.basedir}/test/clc1.out</argument>
<argument>${project.basedir}/test/clc1.err</argument>
<argument>${project.basedir}/files/clc1.in</argument>
<argument>${project.basedir}/files/clc1.out</argument>
<argument>${project.basedir}/files/clc1.err</argument>
</arguments>
</configuration>
</execution>
Expand All @@ -140,17 +141,19 @@ THE POSSIBILITY OF SUCH DAMAGE.
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
<executable>
${project.basedir}/target/nar/${project.artifactId}-${project.version}-${nar.aol}-executable/bin/${nar.aol}/${project.artifactId}.exe</executable>
<arguments>
<argument>${project.basedir}/test/clc2.in</argument>
<argument>${project.basedir}/test/clc2.out</argument>
<argument>${project.basedir}/test/clc2.err</argument>
<argument>${project.basedir}/files/clc2.in</argument>
<argument>${project.basedir}/files/clc2.out</argument>
<argument>${project.basedir}/files/clc2.err</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>

<!-- check the tests results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
Expand All @@ -165,33 +168,33 @@ THE POSSIBILITY OF SUCH DAMAGE.
<skip>false</skip>
<target unless="maven.test.skip">
<!-- out -->
<available file="${project.basedir}/test/clc1.out" property="isActualOutAvailable" />
<available file="${project.basedir}/files/clc1.out" property="isActualOutAvailable" />
<fail unless="isActualOutAvailable"
message="${project.basedir}/test/clc1.out does not exist!" />
<available file="${project.basedir}/test/clc1.exp_out"
message="${project.basedir}/files/clc1.out does not exist!" />
<available file="${project.basedir}/files/clc1.exp_out"
property="isExpectedOutAvailable" />
<fail unless="isExpectedOutAvailable"
message="${project.basedir}/test/clc1.exp_out does not exist!" />
message="${project.basedir}/files/clc1.exp_out does not exist!" />
<condition property="out.files.match">
<filesmatch textfile="true" file1="${project.basedir}/test/clc1.out"
file2="${project.basedir}/test/clc1.exp_out" />
<filesmatch textfile="true" file1="${project.basedir}/files/clc1.out"
file2="${project.basedir}/files/clc1.exp_out" />
</condition>
<fail unless="out.files.match"
message="${project.basedir}/test/clc1.out does not match ${project.basedir}/test/clc1.exp_out!" />
message="${project.basedir}/files/clc1.out does not match ${project.basedir}/files/clc1.exp_out!" />
<!-- err -->
<available file="${project.basedir}/test/clc1.err" property="isActualErrAvailable" />
<available file="${project.basedir}/files/clc1.err" property="isActualErrAvailable" />
<fail unless="isActualErrAvailable"
message="${project.basedir}/test/clc1.err does not exist!" />
<available file="${project.basedir}/test/clc1.exp_err"
message="${project.basedir}/files/clc1.err does not exist!" />
<available file="${project.basedir}/files/clc1.exp_err"
property="isExpectedErrAvailable" />
<fail unless="isExpectedErrAvailable"
message="${project.basedir}/test/clc1.exp_err does not exist!" />
message="${project.basedir}/files/clc1.exp_err does not exist!" />
<condition property="err.files.match">
<filesmatch textfile="true" file1="${project.basedir}/test/clc1.err"
file2="${project.basedir}/test/clc1.exp_err" />
<filesmatch textfile="true" file1="${project.basedir}/files/clc1.err"
file2="${project.basedir}/files/clc1.exp_err" />
</condition>
<fail unless="err.files.match"
message="${project.basedir}/test/clc1.err does not match ${project.basedir}/test/clc1.exp_err!" />
message="${project.basedir}/files/clc1.err does not match ${project.basedir}/files/clc1.exp_err!" />
</target>
</configuration>
</execution>
Expand All @@ -205,33 +208,33 @@ THE POSSIBILITY OF SUCH DAMAGE.
<skip>false</skip>
<target unless="maven.test.skip">
<!-- out -->
<available file="${project.basedir}/test/clc2.out" property="isActualOutAvailable" />
<available file="${project.basedir}/files/clc2.out" property="isActualOutAvailable" />
<fail unless="isActualOutAvailable"
message="${project.basedir}/test/clc2.out does not exist!" />
<available file="${project.basedir}/test/clc2.exp_out"
message="${project.basedir}/files/clc2.out does not exist!" />
<available file="${project.basedir}/files/clc2.exp_out"
property="isExpectedOutAvailable" />
<fail unless="isExpectedOutAvailable"
message="${project.basedir}/test/clc2.exp_out does not exist!" />
message="${project.basedir}/files/clc2.exp_out does not exist!" />
<condition property="out.files.match">
<filesmatch textfile="true" file1="${project.basedir}/test/clc2.out"
file2="${project.basedir}/test/clc2.exp_out" />
<filesmatch textfile="true" file1="${project.basedir}/files/clc2.out"
file2="${project.basedir}/files/clc2.exp_out" />
</condition>
<fail unless="out.files.match"
message="${project.basedir}/test/clc2.out does not match ${project.basedir}/test/clc2.exp_out!" />
message="${project.basedir}/files/clc2.out does not match ${project.basedir}/files/clc2.exp_out!" />
<!-- err -->
<available file="${project.basedir}/test/clc2.err" property="isActualErrAvailable" />
<available file="${project.basedir}/files/clc2.err" property="isActualErrAvailable" />
<fail unless="isActualErrAvailable"
message="${project.basedir}/test/clc2.err does not exist!" />
<available file="${project.basedir}/test/clc2.exp_err"
message="${project.basedir}/files/clc2.err does not exist!" />
<available file="${project.basedir}/files/clc2.exp_err"
property="isExpectedErrAvailable" />
<fail unless="isExpectedErrAvailable"
message="${project.basedir}/test/clc2.exp_err does not exist!" />
message="${project.basedir}/files/clc2.exp_err does not exist!" />
<condition property="err.files.match">
<filesmatch textfile="true" file1="${project.basedir}/test/clc2.err"
file2="${project.basedir}/test/clc2.exp_err" />
<filesmatch textfile="true" file1="${project.basedir}/files/clc2.err"
file2="${project.basedir}/files/clc2.exp_err" />
</condition>
<fail unless="err.files.match"
message="${project.basedir}/test/clc2.err does not match ${project.basedir}/test/clc2.exp_err!" />
message="${project.basedir}/files/clc2.err does not match ${project.basedir}/files/clc2.exp_err!" />
</target>
</configuration>
</execution>
Expand Down
24 changes: 13 additions & 11 deletions bugs/bug001/src/main/cpp/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

#include "JavaCC.h"
#include "ComplexLineCommentTokenManager.h"
Expand All @@ -27,9 +26,9 @@ using namespace std;

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

if (argc != 4) {
if (argc > 4) {
cerr << "Error: invalid number of arguments (" << (argc - 1) << ")" << endl;
cerr << "Usage: MYPARSER [ inputfile [ outputfile [ errorfile ] ] ]" << endl;
cerr << "Usage: ComplexLineComment [ inputfile [ outputfile [ errorfile ] ] ]" << endl;
return 4;
}

Expand All @@ -47,32 +46,35 @@ int main(int argc, char **argv) {
try {
// open files and redirect standard streams to them
switch (argc) {
case 4:
efs.open(argv[3]);
case 3:
ofs.open(argv[2]);
case 2:
ifs.open(argv[1], ifstream::binary);
case 4:
efs.open(argv[3]);
case 3:
ofs.open(argv[2]);
case 2:
ifs.open(argv[1], ifstream::binary);
}
if (ifs.is_open()) {
sr = new StreamReader(ifs);
cs = new CHARSTREAM(sr);
cinbuf = cin.rdbuf();
cin.rdbuf(ifs.rdbuf());
} else {
cerr << "Cannot open input file" << endl;
cerr << "Cannot open input file " << argv[1] << endl;
return 8;
}
if (ofs.is_open()) {
coutbuf = cout.rdbuf();
cout.rdbuf(ofs.rdbuf());
} else {
cerr << "Cannot open output file" << endl;
cerr << "Cannot open output file " << argv[2] << endl;
return 8;
}
if (efs.is_open()) {
cerrbuf = cerr.rdbuf();
cerr.rdbuf(efs.rdbuf());
} else {
cerr << "Cannot open error file " << argv[3] << endl;
return 8;
}

// parse
Expand Down
1 change: 0 additions & 1 deletion bugs/bug001/test/clc1.exp_err

This file was deleted.

1 change: 0 additions & 1 deletion bugs/bug001/test/clc2.exp_err

This file was deleted.

52 changes: 52 additions & 0 deletions bugs/bug002/files/bug.exp_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<DEFAULT>
Current character: '{' at 1:1
Looking for string literal match of kind:7 token image: '{'
Current character: '{'
Currently matched the first: 1 chars as kind: 7,with image: {
No NFA state at pos: 2
Returning token: '{'
<DEFAULT>
Current character: ' ' at 1:2
Looking for string literal match of kind:1 token image: ' '
Current character: ' '
Currently matched the first: 1 chars as kind: 1,with image:
No NFA state at pos: 2
Found a SKIP match.
<DEFAULT>
Current character: 'c' at 1:3
No string literal start with char: 'c'
Starting NFA with start state: 0
Current character: 'c'
Looking to move from state: 3 for: <IDENTIFIANT>
state=3 vectorindex=1 bitpattern=34359738368 jjChars[state][vectorIndex]=576460743713488896
Found a match of kind:17; kind: <IDENTIFIANT> using the first: 0 characters.
Looking to move from state: 1 for: <NUMBER>
state=1 vectorindex=1 bitpattern=34359738368 jjChars[state][vectorIndex]=0
Looking to move from state: 0 for: <NUMBER>
state=0 vectorindex=1 bitpattern=34359738368 jjChars[state][vectorIndex]=0
Current character: ' '
Looking to move from state: 7 for: <VALUEREFERENCE>
state=7 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287948901175001088
Looking to move from state: 6 for: <UNKNOWN>
state=6 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=35184372088832
Looking to move from state: 5 for: <IDENTIFIANT>
state=5 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=287948901175001088
Looking to move from state: 4 for: <UNKNOWN>
state=4 vectorindex=0 bitpattern=4294967296 jjChars[state][vectorIndex]=35184372088832
Done with NFA at pos: 1
Returning token: 'c'
<DEFAULT>
Current character: ' ' at 1:4
Looking for string literal match of kind:1 token image: ' '
Current character: ' '
Currently matched the first: 1 chars as kind: 1,with image:
No NFA state at pos: 2
Found a SKIP match.
<DEFAULT>
Current character: '}' at 1:5
Looking for string literal match of kind:8 token image: '}'
Current character: '}'
Currently matched the first: 1 chars as kind: 8,with image: }
No NFA state at pos: 2
Returning token: '}'
Input file parsed successfully
Binary file added bugs/bug002/files/bug.exp_out
Binary file not shown.
File renamed without changes.
Loading

0 comments on commit aa1986c

Please sign in to comment.