Skip to content

Commit

Permalink
Merge pull request #1 from zbynek/annotations-and-tests
Browse files Browse the repository at this point in the history
Move displaced @deprecated annotations, add tests
  • Loading branch information
zosrothko authored Jun 2, 2022
2 parents 34604cc + 22ef6c6 commit 0942ada
Show file tree
Hide file tree
Showing 23 changed files with 388 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target/
.classpath
.project
.settings/
.idea
bin/

local-repo/
Expand Down
4 changes: 2 additions & 2 deletions bugs/bug001/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<available file="${project.basedir}/test/clc1.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/test/clc1.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/test/clc1.out" file2="${project.basedir}/test/clc1.ref" />
<filesmatch file1="${project.basedir}/test/clc1.out" file2="${project.basedir}/test/clc1.ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/test/clc1.out does not match ${project.basedir}/test/clc1.ref!" />
</target>
Expand All @@ -83,7 +83,7 @@
<available file="${project.basedir}/test/clc2.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/test/clc2.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/test/clc2.out" file2="${project.basedir}/test/clc2.ref" />
<filesmatch file1="${project.basedir}/test/clc2.out" file2="${project.basedir}/test/clc2.ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/test/clc2.out does not match ${project.basedir}/test/clc2.ref!" />
</target>
Expand Down
2 changes: 1 addition & 1 deletion bugs/bug002/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<available file="${project.basedir}/test/bug.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/test/bug.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/test/bug.out" file2="${project.basedir}/test/bug.ref" />
<filesmatch file1="${project.basedir}/test/bug.out" file2="${project.basedir}/test/bug.ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/test/bug.out does not match ${project.basedir}/test/bug.ref!" />
</target>
Expand Down
29 changes: 29 additions & 0 deletions examples/Gwt/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Copyright (c) 2006, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

This directory contains two examples using the modern template (compatible with GWT).
95 changes: 95 additions & 0 deletions examples/Gwt/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" 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.java</groupId>
<artifactId>examples</artifactId>
<version>1.0.0</version>
</parent>
<groupId>org.javacc.generator.java.examples</groupId>
<artifactId>gwt</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>gwt1</id>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>GwtSimpleParser</mainClass>
<arguments>
<argument>${project.basedir}/simple/out</argument>
<argument>${project.basedir}/simple/err</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>unicode</id>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>GwtUnicodeParser</mainClass>
<arguments>
<argument>${project.basedir}/unicode/out</argument>
<argument>${project.basedir}/unicode/err</argument>
</arguments>
</configuration>
</execution>

</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compare-simple</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<available file="${project.basedir}/simple/out" property="isActualAvailable" />
<fail unless="isActualAvailable" message="${project.basedir}/simple/out does not exist!" />
<available file="${project.basedir}/simple/ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/simple/ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/simple/out" file2="${project.basedir}/simple/ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/simple/out does not match ${project.basedir}/simple/ref!" />
</target>
</configuration>
</execution>
<execution>
<id>compare-unicode</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<available file="${project.basedir}/unicode/out" property="isActualAvailable" />
<fail unless="isActualAvailable" message="${project.basedir}/unicode/out does not exist!" />
<available file="${project.basedir}/unicode/ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/unicode/ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/unicode/out" file2="${project.basedir}/unicode/ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/unicode/out does not match ${project.basedir}/unicode/ref!" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<name>JavaCC examples Java Simple</name>
</project>
2 changes: 2 additions & 0 deletions examples/Gwt/simple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
out
err
1 change: 1 addition & 0 deletions examples/Gwt/simple/ref
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
96 changes: 96 additions & 0 deletions examples/Gwt/src/main/javacc/GwtSimpleParser.jj
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright (c) 2006, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/


options {
LOOKAHEAD = 1;
CHOICE_AMBIGUITY_CHECK = 2;
OTHER_AMBIGUITY_CHECK = 1;
STATIC = true;
DEBUG_PARSER = false;
DEBUG_LOOKAHEAD = false;
DEBUG_TOKEN_MANAGER = false;
ERROR_REPORTING = true;
JAVA_UNICODE_ESCAPE = false;
UNICODE_INPUT = false;
IGNORE_CASE = false;
USER_TOKEN_MANAGER = false;
USER_CHAR_STREAM = false;
BUILD_PARSER = true;
BUILD_TOKEN_MANAGER = true;
SANITY_CHECK = true;
FORCE_LA_CHECK = false;
JAVA_TEMPLATE_TYPE = "modern";
}

PARSER_BEGIN(GwtSimpleParser)

import java.io.IOException;
import java.io.PrintStream;

/** Simple brace matcher. */
public class GwtSimpleParser {

/** Main entry point. */
public static void main(String args[]) throws ParseException, IOException {
PrintStream output = System.out;
PrintStream error = System.err;
PrintStream prevOutput = null;
PrintStream prevError = null;
if (args.length == 2) {
prevOutput = output;
output = new PrintStream(args[0]);
prevError = error;
error = new PrintStream(args[1]);
System.setOut(output);
System.setErr(error);
}
try {
GwtSimpleParser parser = new GwtSimpleParser(new StringProvider("A"));
parser.Input();
} catch (Exception e) {
error.println(e.getMessage());
} finally {
if (prevOutput != null) System.setOut(prevOutput);
if (prevError != null) System.setErr(prevError);
}
}

}

PARSER_END(GwtSimpleParser)

/** Root production. */
void Input() :
{}
{

"A" {
System.out.println("hello");
} <EOF>
}
96 changes: 96 additions & 0 deletions examples/Gwt/src/main/javacc/GwtUnicodeParser.jj
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright (c) 2006, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/


options {
LOOKAHEAD = 1;
CHOICE_AMBIGUITY_CHECK = 2;
OTHER_AMBIGUITY_CHECK = 1;
STATIC = true;
DEBUG_PARSER = false;
DEBUG_LOOKAHEAD = false;
DEBUG_TOKEN_MANAGER = false;
ERROR_REPORTING = true;
JAVA_UNICODE_ESCAPE = true;
UNICODE_INPUT = false;
IGNORE_CASE = false;
USER_TOKEN_MANAGER = false;
USER_CHAR_STREAM = false;
BUILD_PARSER = true;
BUILD_TOKEN_MANAGER = true;
SANITY_CHECK = true;
FORCE_LA_CHECK = false;
JAVA_TEMPLATE_TYPE = "modern";
}

PARSER_BEGIN(GwtUnicodeParser)

import java.io.IOException;
import java.io.PrintStream;

/** Simple brace matcher. */
public class GwtUnicodeParser {

/** Main entry point. */
public static void main(String args[]) throws ParseException, IOException {
PrintStream output = System.out;
PrintStream error = System.err;
PrintStream prevOutput = null;
PrintStream prevError = null;
if (args.length == 2) {
prevOutput = output;
output = new PrintStream(args[0]);
prevError = error;
error = new PrintStream(args[1]);
System.setOut(output);
System.setErr(error);
}
try {
GwtUnicodeParser parser = new GwtUnicodeParser(new StringProvider("A"));
parser.Input();
} catch (Exception e) {
error.println(e.getMessage());
} finally {
if (prevOutput != null) System.setOut(prevOutput);
if (prevError != null) System.setErr(prevError);
}
}

}

PARSER_END(GwtUnicodeParser)

/** Root production. */
void Input() :
{}
{

"A" {
System.out.println("hello");
} <EOF>
}
2 changes: 2 additions & 0 deletions examples/Gwt/unicode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
out
err
1 change: 1 addition & 0 deletions examples/Gwt/unicode/ref
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
6 changes: 3 additions & 3 deletions examples/Interpreter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<available file="${project.basedir}/spl/fact/fact.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/spl/fact/fact.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/spl/fact/fact.out" file2="${project.basedir}/spl/fact/fact.ref" />
<filesmatch file1="${project.basedir}/spl/fact/fact.out" file2="${project.basedir}/spl/fact/fact.ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/spl/fact/fact.out does not match ${project.basedir}/spl/fact/fact.ref!" />
</target>
Expand All @@ -101,7 +101,7 @@
<available file="${project.basedir}/spl/odd/odd.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/spl/odd/odd.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/spl/odd/odd.out" file2="${project.basedir}/spl/odd/odd.ref" />
<filesmatch file1="${project.basedir}/spl/odd/odd.out" file2="${project.basedir}/spl/odd/odd.ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/spl/odd/odd.out does not match ${project.basedir}/spl/odd/odd.ref!" />
</target>
Expand All @@ -120,7 +120,7 @@
<available file="${project.basedir}/spl/sqrt/sqrt.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable" message="${project.basedir}/spl/sqrt/sqrt.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/spl/sqrt/sqrt.out" file2="${project.basedir}/spl/sqrt/sqrt.ref" />
<filesmatch file1="${project.basedir}/spl/sqrt/sqrt.out" file2="${project.basedir}/spl/sqrt/sqrt.ref" textfile="true" />
</condition>
<fail unless="files.match" message="${project.basedir}/spl/sqrt/sqrt.out does not match ${project.basedir}/spl/sqrt/sqrt.ref!" />
</target>
Expand Down
Loading

0 comments on commit 0942ada

Please sign in to comment.