diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..57564f5
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,44 @@
+description = 'Java code generator for JavaCC 8. Discovered by core via ServiceLoader.'
+
+base.archivesName = 'javacc-java'
+
+dependencies {
+ // 'api', not 'implementation': anyone invoking the generator needs
+ // org.javacc.parser.Main on the compile/runtime classpath as well.
+ api project(':javacc-8-core')
+
+ testImplementation "junit:junit:${providers.gradleProperty('junitVersion').get()}"
+}
+
+sourceSets {
+ main {
+ // src/main/util holds a stand-alone instrumentation agent used during
+ // generator development only. Upstream never compiles it either.
+ java {
+ srcDirs = ['src/main/java']
+ }
+ resources {
+ srcDirs = ['src/main/resources']
+ }
+ }
+}
+
+tasks.named('jar', Jar) {
+ manifest {
+ attributes('Automatic-Module-Name': 'org.javacc.generator.java')
+ }
+}
+
+// The templates under src/main/resources/templates/** are read verbatim at
+// generation time. Never let a resource filter touch them.
+tasks.named('processResources', ProcessResources) {
+ filteringCharset = 'UTF-8'
+}
+
+publishing.publications.named('maven', MavenPublication) {
+ artifactId = 'javacc-java'
+ pom {
+ name = 'JavaCC 8 Java Code Generator (Manticore fork)'
+ description = project.description
+ }
+}
diff --git a/examples/CORBA-IDL/README.md b/examples/CORBA-IDL/README.md
deleted file mode 100644
index dfe33cb..0000000
--- a/examples/CORBA-IDL/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-This directory contains an CORBA 2.0 grammar for [IDL](src/main/java/IDL.jj).
-
-It parses an input file and just outputs a success or failure message.
-
-Build it in the usual manner with [pom.xml](pom.xml):
-
-- Maven:
-
-```
- mvn clean verify
-```
diff --git a/examples/CORBA-IDL/files/Hello.exp_out b/examples/CORBA-IDL/files/Hello.exp_out
deleted file mode 100644
index 46511fc..0000000
--- a/examples/CORBA-IDL/files/Hello.exp_out
+++ /dev/null
@@ -1,2 +0,0 @@
-IDL Parser Version 0.1: Reading from file ${project-basedir}/files/Hello.idl . . .
-IDL Parser Version 0.1: IDL file parsed successfully.
diff --git a/examples/CORBA-IDL/files/Hello.idl b/examples/CORBA-IDL/files/Hello.idl
deleted file mode 100644
index 0dc1964..0000000
--- a/examples/CORBA-IDL/files/Hello.idl
+++ /dev/null
@@ -1,7 +0,0 @@
-module HelloApp
-{
- interface Hello
- {
- string sayHello();
- };
-};
diff --git a/examples/CORBA-IDL/pom.xml b/examples/CORBA-IDL/pom.xml
deleted file mode 100644
index 9a0a63f..0000000
--- a/examples/CORBA-IDL/pom.xml
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.javacc.generator.java
- examples
- 1.1.0-SNAPSHOT
-
-
- org.javacc.generator.java.examples
- corba-idl
- jar
-
- JavaCC Java code generator / examples / CORBA-IDL
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-clean-plugin
-
-
- clear-res-test
- process-test-resources
-
- clean
-
-
- true
-
-
- files
-
- *.out
- *.err
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
-
-
- exec-test
- test
-
- run
-
-
- ${skip.test.java.examples.CORBA-IDL}
-
-
-
-
-
-
-
-
-
-
-
- check-res-test
- test
-
- run
-
-
- ${skip.test.java.examples.CORBA-IDL}
- ${failOnError.check.java.examples.CORBA-IDL}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/CORBA-IDL/src/main/javacc/IDL.jj b/examples/CORBA-IDL/src/main/javacc/IDL.jj
deleted file mode 100644
index e519e7d..0000000
--- a/examples/CORBA-IDL/src/main/javacc/IDL.jj
+++ /dev/null
@@ -1,865 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-PARSER_BEGIN(IDLParser)
-
-public class IDLParser {
-
- public static void main(String args[]) {
- IDLParser parser;
- if (args.length == 0) {
- System.out.println("IDL Parser Version 0.1: Reading from standard input . . .");
- parser = new IDLParser(System.in);
- } else if (args.length == 1) {
- System.out.println("IDL Parser Version 0.1: Reading from file " + args[0] + " . . .");
- try {
- parser = new IDLParser(new java.io.FileInputStream(args[0]));
- } catch (java.io.FileNotFoundException e) {
- System.out.println("IDL Parser Version 0.1: File " + args[0] + " not found.");
- return;
- }
- } else {
- System.out.println("IDL Parser Version 0.1: Usage is one of:");
- System.out.println(" java IDLParser < inputfile");
- System.out.println("OR");
- System.out.println(" java IDLParser inputfile");
- return;
- }
- try {
- parser.specification();
- System.out.println("IDL Parser Version 0.1: IDL file parsed successfully.");
- } catch (ParseException e) {
- System.out.println("IDL Parser Version 0.1: Encountered errors during parse.");
- }
- }
-
-}
-
-PARSER_END(IDLParser)
-
-/*
- * Tokens to ignore in the BNF follow.
- */
-
-SKIP :
-{
- < " " >
-| < "\t" >
-| < "\n" >
-| < "\r" >
-| < "//" (~["\n"])* "\n" >
-| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
-| < "#" ([" ","\t"])* (["0"-"9"])+
- (([" ","\t"])* "\"" (~["\""])+ "\""
- ([" ","\t"])* (["0"-"9"])* ([" ","\t"])* (["0"-"9"])*)? "\n" >
-}
-
-/* Production 1 */
-
-void specification() :
-{}
-{
- ( definition() )+
-}
-
-/* Production 2 */
-
-void definition() :
-{}
-{
- type_dcl() ";"
-|
- const_dcl() ";"
-|
- except_dcl() ";"
-|
- interfacex() ";"
-|
- module() ";"
-}
-
-/* Production 3 */
-
-void module() :
-{}
-{
- "module" identifier() "{" ( definition() )+ "}"
-}
-
-/* Production 4 */
-
-void interfacex() :
-{}
-{
- LOOKAHEAD(3)
- interface_dcl()
-|
- forward_dcl()
-}
-
-/* Production 5 */
-
-void interface_dcl() :
-{}
-{
- interface_header() "{" interface_body() "}"
-}
-
-/* Production 6 */
-
-void forward_dcl() :
-{}
-{
- "interface" identifier()
-}
-
-/* Production 7 */
-
-void interface_header() :
-{}
-{
- "interface" identifier() [ inheritance_spec() ]
-}
-
-/* Production 8 */
-
-void interface_body() :
-{}
-{
- ( export() )*
-}
-
-/* Production 9 */
-
-void export() :
-{}
-{
- type_dcl() ";"
-|
- const_dcl() ";"
-|
- except_dcl() ";"
-|
- attr_dcl() ";"
-|
- op_dcl() ";"
-}
-
-/* Production 10 */
-
-void inheritance_spec() :
-{}
-{
- ":" scoped_name() ( "," scoped_name() )*
-}
-
-/* Production 11 */
-
-void scoped_name() :
-{}
-{
- [ "::" ] identifier() ( "::" identifier() )*
-}
-
-/* Production 12 */
-
-void const_dcl() :
-{}
-{
- "const" const_type() identifier() "=" const_exp()
-}
-
-/* Production 13 */
-
-void const_type() :
-{}
-{
- integer_type()
-|
- char_type()
-|
- boolean_type()
-|
- floating_pt_type()
-|
- string_type()
-|
- scoped_name()
-}
-
-/* Production 14 */
-
-void const_exp() :
-{}
-{
- or_expr()
-}
-
-/* Production 15 */
-
-void or_expr() :
-{}
-{
- xor_expr() ( "|" xor_expr() )*
-}
-
-/* Production 16 */
-
-void xor_expr() :
-{}
-{
- and_expr() ( "^" and_expr() )*
-}
-
-/* Production 17 */
-
-void and_expr() :
-{}
-{
- shift_expr() ( "&" shift_expr() )*
-}
-
-/* Production 18 */
-
-void shift_expr() :
-{}
-{
- add_expr() ( ( ">>" | "<<" ) add_expr() )*
-}
-
-/* Production 19 */
-
-void add_expr() :
-{}
-{
- mult_expr() ( ( "+" | "-" ) mult_expr() )*
-}
-
-/* Production 20 */
-
-void mult_expr() :
-{}
-{
- unary_expr() ( ( "*" | "/" | "%" ) unary_expr() )*
-}
-
-/* Production 21 */
-
-void unary_expr() :
-{}
-{
- [ unary_operator() ] primary_expr()
-}
-
-/* Production 22 */
-void unary_operator() :
-{}
-{
- "-"
-|
- "+"
-|
- "~"
-}
-
-/* Production 23 */
-
-void primary_expr() :
-{}
-{
- scoped_name()
-|
- literal()
-|
- "(" const_exp() ")"
-}
-
-/* Production 24 */
-
-void literal() :
-{}
-{
- integer_literal()
-|
- string_literal()
-|
- character_literal()
-|
- floating_pt_literal()
-|
- boolean_literal()
-}
-
-/* Production 25 */
-
-void boolean_literal() :
-{}
-{
- "TRUE"
-|
- "FALSE"
-}
-
-/* Production 26 */
-
-void positive_int_const() :
-{}
-{
- const_exp()
-}
-
-/* Production 27 */
-
-void type_dcl() :
-{}
-{
- "typedef" type_declarator()
-|
- struct_type()
-|
- union_type()
-|
- enum_type()
-}
-
-/* Production 28 */
-
-void type_declarator() :
-{}
-{
- type_spec() declarators()
-}
-
-/* Production 29 */
-
-void type_spec() :
-{}
-{
- simple_type_spec()
-|
- constr_type_spec()
-}
-
-/* Production 30 */
-
-void simple_type_spec() :
-{}
-{
- base_type_spec()
-|
- template_type_spec()
-|
- scoped_name()
-}
-
-/* Production 31 */
-
-void base_type_spec() :
-{}
-{
- floating_pt_type()
-|
- integer_type()
-|
- char_type()
-|
- boolean_type()
-|
- octet_type()
-|
- any_type()
-}
-
-/* Production 32 */
-
-void template_type_spec() :
-{}
-{
- sequence_type()
-|
- string_type()
-}
-
-/* Production 33 */
-
-void constr_type_spec() :
-{}
-{
- struct_type()
-|
- union_type()
-|
- enum_type()
-}
-
-/* Production 34 */
-
-void declarators() :
-{}
-{
- declarator() ( "," declarator() )*
-}
-
-/* Production 35 */
-
-void declarator() :
-{}
-{
- LOOKAHEAD(2)
- complex_declarator()
-|
- simple_declarator()
-}
-
-/* Production 36 */
-
-void simple_declarator() :
-{}
-{
- identifier()
-}
-
-/* Production 37 */
-
-void complex_declarator() :
-{}
-{
- array_declarator()
-}
-
-/* Production 38 */
-
-void floating_pt_type() :
-{}
-{
- "float"
-|
- "double"
-}
-
-/* Production 39 */
-
-void integer_type() :
-{}
-{
- signed_int()
-|
- unsigned_int()
-}
-
-/* Production 40 */
-
-void signed_int() :
-{}
-{
- signed_long_int()
-|
- signed_short_int()
-}
-
-/* Production 41 */
-
-void signed_long_int() :
-{}
-{
- "long"
-}
-
-/* Production 42 */
-
-void signed_short_int() :
-{}
-{
- "short"
-}
-
-/* Production 43 */
-
-void unsigned_int() :
-{}
-{
- LOOKAHEAD(2)
- unsigned_long_int()
-|
- unsigned_short_int()
-}
-
-/* Production 44 */
-
-void unsigned_long_int() :
-{}
-{
- "unsigned" "long"
-}
-
-/* Production 45 */
-
-void unsigned_short_int() :
-{}
-{
- "unsigned" "short"
-}
-
-/* Production 46 */
-
-void char_type() :
-{}
-{
- "char"
-}
-
-/* Production 47 */
-
-void boolean_type() :
-{}
-{
- "boolean"
-}
-
-/* Production 48 */
-
-void octet_type() :
-{}
-{
- "octet"
-}
-
-/* Production 49 */
-
-void any_type() :
-{}
-{
- "any"
-}
-
-/* Production 50 */
-
-void struct_type() :
-{}
-{
- "struct" identifier() "{" member_list() "}"
-}
-
-/* Production 51 */
-
-void member_list() :
-{}
-{
- ( member() )+
-}
-
-/* Production 52 */
-
-void member() :
-{}
-{
- type_spec() declarators() ";"
-}
-
-/* Production 53 */
-
-void union_type() :
-{}
-{
- "union" identifier() "switch" "(" switch_type_spec() ")" "{" switch_body() "}"
-}
-
-/* Production 54 */
-
-void switch_type_spec() :
-{}
-{
- integer_type()
-|
- char_type()
-|
- boolean_type()
-|
- enum_type()
-|
- scoped_name()
-}
-
-/* Production 55 */
-
-void switch_body() :
-{}
-{
- ( casex() )+
-}
-
-/* Production 56 */
-
-void casex() :
-{}
-{
- ( case_label() )+ element_spec() ";"
-}
-
-/* Production 57 */
-
-void case_label() :
-{}
-{
- "case" const_exp() ":"
-|
- "default" ":"
-}
-
-/* Production 58 */
-
-void element_spec() :
-{}
-{
- type_spec() declarator()
-}
-
-/* Production 59 */
-
-void enum_type() :
-{}
-{
- "enum" identifier() "{" enumerator() ( "," enumerator() )* "}"
-}
-
-/* Production 60 */
-
-void enumerator() :
-{}
-{
- identifier()
-}
-
-/* Production 61 */
-
-void sequence_type() :
-{}
-{
- "sequence" "<" simple_type_spec() [ "," positive_int_const() ] ">"
-}
-
-/* Production 62 */
-
-void string_type() :
-{}
-{
- "string" [ "<" positive_int_const() ">" ]
-}
-
-/* Production 63 */
-
-void array_declarator() :
-{}
-{
- identifier() ( fixed_array_size() )+
-}
-
-/* Production 64 */
-
-void fixed_array_size() :
-{}
-{
- "[" positive_int_const() "]"
-}
-
-/* Production 65 */
-
-void attr_dcl() :
-{}
-{
- [ "readonly" ] "attribute" param_type_spec() simple_declarator() ( "," simple_declarator() )*
-}
-
-/* Production 66 */
-
-void except_dcl() :
-{}
-{
- "exception" identifier() "{" ( member() )* "}"
-}
-
-/* Production 67 */
-
-void op_dcl() :
-{}
-{
- [ op_attribute() ] op_type_spec() identifier() parameter_dcls() [ raises_expr() ] [ context_expr() ]
-}
-
-/* Production 68 */
-
-void op_attribute() :
-{}
-{
- "oneway"
-}
-
-/* Production 69 */
-
-void op_type_spec() :
-{}
-{
- param_type_spec()
-|
- "void"
-}
-
-/* Production 70 */
-
-void parameter_dcls() :
-{}
-{
- "(" [ param_dcl() ( "," param_dcl() )* ] ")"
-}
-
-/* Production 71 */
-
-void param_dcl() :
-{}
-{
- param_attribute() param_type_spec() simple_declarator()
-}
-
-/* Production 72 */
-
-void param_attribute() :
-{}
-{
- "in"
-|
- "out"
-|
- "inout"
-}
-
-/* Production 73 */
-
-void raises_expr() :
-{}
-{
- "raises" "(" scoped_name() ( "," scoped_name() )* ")"
-}
-
-/* Production 74 */
-
-void context_expr() :
-{}
-{
- "context" "(" string_literal() ( "," string_literal() )* ")"
-}
-
-/* Production 75 */
-
-void param_type_spec() :
-{}
-{
- base_type_spec()
-|
- string_type()
-|
- scoped_name()
-}
-
-/* Definitions of complex regular expressions follow */
-
-void identifier() :
-{}
-{
-
-}
-
-void integer_literal() :
-{}
-{
-
-|
-
-|
-
-}
-
-void string_literal() :
-{}
-{
-
-}
-
-void character_literal() :
-{}
-{
-
-}
-
-void floating_pt_literal() :
-{}
-{
-
-|
-
-}
-
-TOKEN :
-{
- < ID : ["a"-"z","A"-"Z", "_"] (["a"-"z","A"-"Z","0"-"9","_"])* >
-| < OCTALINT : "0" (["0"-"7"])* (["u","U","l","L"])? >
-| < DECIMALINT : ["1"-"9"] (["0"-"9"])* (["u","U","l","L"])? >
-| < HEXADECIMALINT : ("0x"|"0X") (["0"-"9","a"-"f","A"-"F"])+ (["u","U","l","L"])? >
-| < FLOATONE : ((["0"-"9"])+ "." (["0"-"9"])* | (["0"-"9"])* "." (["0"-"9"])+)
- (["e","E"] (["-","+"])? (["0"-"9"])+)? (["f","F","l","L"])? >
-| < FLOATTWO : (["0"-"9"])+ ["e","E"] (["-","+"])?
- (["0"-"9"])+ (["f","F","l","L"])? >
-| < CHARACTER : "'"
- ( (~["'","\\","\n","\r"])
- | ("\\" (
- ["n","t","v","b","r","f","a","\\","?","'","\""]
- |
- "0" (["0"-"7"])*
- |
- ["1"-"9"] (["0"-"9"])*
- |
- ("0x" | "0X") (["0"-"9","a"-"f","A"-"F"])+
- )
- )
- )
- "'" >
-| < STRING : "\""
- ( ( ~["\"","\\","\n","\r"])
- | ("\\" (
- ["n","t","v","b","r","f","a","\\","?","'","\""]
- |
- "0" (["0"-"7"])*
- |
- ["1"-"9"] (["0"-"9"])*
- |
- ("0x" | "0X") (["0"-"9","a"-"f","A"-"F"])+
- )
- )
- )*
- "\"" >
-}
diff --git a/examples/CustomTemplate/pom.xml b/examples/CustomTemplate/pom.xml
deleted file mode 100644
index 30b999e..0000000
--- a/examples/CustomTemplate/pom.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.javacc.generator.java
- examples
- 1.1.0-SNAPSHOT
-
-
- org.javacc.generator.java.examples
- CustomTemplate
- jar
-
- JavaCC Java code generator / CustomTemplate
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
-
-
- custom-dir
- initialize
-
- copy-resources
-
-
- ${basedir}/target/custom
-
-
- ${basedir}/src/main/custom
-
-
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
-
- jar-cust-jar
- initialize
-
- exec
-
-
- jar
-
- cf
- ${basedir}/target/custom/cust-tpt.jar
- -C
- ${basedir}/src/main/custom
- templates/java
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-install-plugin
-
-
- install-cust-file
- initialize
-
- install-file
-
-
-
-
- ${basedir}/target/custom/cust-tpt.jar
- org.javacc.generator.java.examples.CustomTemplate
- custom-jar
- 1.1.0-SNAPSHOT
- jar
-
-
-
-
-
-
- org.javacc.plugin
- javacc-maven-plugin
-
-
- org.javacc.generator.java.examples.CustomTemplate
- custom-jar
- 1.1.0-SNAPSHOT
- runtime
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/CustomTemplate/src/main/custom/templates/java/ParseException.template b/examples/CustomTemplate/src/main/custom/templates/java/ParseException.template
deleted file mode 100644
index f0112ed..0000000
--- a/examples/CustomTemplate/src/main/custom/templates/java/ParseException.template
+++ /dev/null
@@ -1,258 +0,0 @@
-#if PRINT_LICENSE
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-#fi
-// !!!!!!!!!!!!!!!!!!!!!!!!!!
-// !!! Customization test !!!
-// !!!!!!!!!!!!!!!!!!!!!!!!!!
-/**
- * The class generated by Javacc/java (by JavaTemplates.java with java/ParseException.template)
- * that is thrown when parse errors are encountered.
- * You can explicitly create objects of this exception type by calling the method
- * generateParseException() in the generated parser.
- * You can modify this class to customize your error reporting mechanisms
- * so long as you retain the public fields.
- */
-public class ParseException extends Exception {
-
- /**
- * The version identifier for this Serializable class.
- * Increment only if the serialized form of the class changes.
- */
- private static final long serialVersionUID = 1L;
-
- /** The end of line string for this system. */
- protected static String EOL = System.getProperty("line.separator", "\n");
-
- /**
- * This constructor is used by the method "generateParseException" in the generated parser.
- * Calling this constructor generates a new object of this type with the fields "currentToken",
- * "expectedTokenSequences", "expectedTokenSequencesLoc", "tokenImage and "locationVal" set.
- */
- public ParseException( Token currentTokenVal,
- int[][] expectedTokenSequencesVal,
- String[][] expectedTokenSequencesLocVal,
- String[] tokenImageVal,
- String locationVal) {
- super(initialise(currentTokenVal,
- expectedTokenSequencesVal,
- expectedTokenSequencesLocVal,
- tokenImageVal,
- locationVal));
- currentToken = currentTokenVal;
- expectedTokenSequences = expectedTokenSequencesVal;
- expectedTokenSequencesLoc = expectedTokenSequencesLocVal;
- tokenImage = tokenImageVal;
- location = locationVal;
- }
-
- /*
- * The following constructors are for use by you for whatever purpose you can think of.
- * Constructing the exception in this manner makes the exception behave in the normal way.
- * The fields "errorToken", "expectedTokenSequences", "tokenImage and "location"
- * will not contain relevant information.
- * The JavaCC generated code does not use these constructors.
- */
-
- /** Constructor without message. */
- public ParseException() {
- super();
- }
-
- /** Constructor with message. */
- public ParseException(String message) {
- super(message);
- }
-
- /**
- * This is the last token that has been consumed successfully.
- * If this object has been created due to a parse error,
- * the token following this token will (therefore) be the first error token.
- */
- public Token currentToken;
-
- /**
- * Each entry in this array is an array of integers.
- * Each array of integers represents a sequence of tokens (by their ordinal values)
- * that are expected at this point of the parse.
- */
- public int[][] expectedTokenSequences;
-
- /**
- * Each entry in this array is an array of strings.
- * Each array of strings represents a sequence of tokens images (by their ordinal values)
- * that are expected at this point of the parse.
- */
- public String[][] expectedTokenSequencesLoc;
-
- /**
- * This is a reference to the "tokenImage" array of the generated parser within which
- * the parse error occurred.
- * This array is defined in the generated ParserConstants interface.
- */
- public String[] tokenImage;
-
- /**
- * The location of the expansion where the exception arose.
- */
- public String location;
-
- /**
- * Generate a parse error message and returns it.
- * If this object has been created due to a parse error and you do not catch it
- * (i.e. it gets thrown from the parser), the correct error message gets displayed.
- */
- private static String initialise( Token currToken,
- int[][] expTokenSequences,
- String[][] expTokenSequencesLoc,
- String[] tokImage,
- String loc) {
-
- final StringBuilder expected = new StringBuilder(32);
- int maxSize = 0;
-
- // outer:
- for (int i = 0; i < expTokenSequences.length; i++) {
- final int[] expTkSeq = expTokenSequences[i];
- // for the moment we prefer to keep printing duplicated sequences,
- // hoping we can find a way to print their (different) locations in the grammar
- // for (int k = 0; k < i; k++) {
- // // don't print duplicated sequences
- // if (java.util.Arrays.equals(expTkSeq, expTokenSequences[k])) {
- // continue outer;
- // }
- // }
- if (maxSize < expTkSeq.length) {
- maxSize = expTkSeq.length;
- }
- for (int j = 0; j < expTkSeq.length; j++) {
- if (j > 0) {
- expected.append(' ');
- } else {
- expected.append(" ");
- }
- expected.append(tokImage[expTkSeq[j]]).append(' ');
- expected.append("(inside ").append(expTokenSequencesLoc[i][j]).append(") ");
- }
- if (expTkSeq[expTkSeq.length - 1] != 0) {
- expected.append("...");
- }
- expected.append(EOL);
- }
-
- final StringBuilder sb = new StringBuilder(64);
-
- // temp debug
- /*
- sb.append("currToken = " + currToken).append(EOL);
- for (int i = 0; i < expTokenSequences.length; i++) {
- sb.append("expTokenSequences[" + i + "] = " + java.util.Arrays.toString(expTokenSequences[i])).append(EOL);
- }
- sb.append("tokImage = " + java.util.Arrays.toString(tokImage)).append(EOL);
- sb.append("loc = " + loc).append(EOL);
- */
-
- sb.append("Encountered:");
- Token tok = currToken.next;
- for (int i = 0; i < maxSize; i++) {
- sb.append(' ');
- if (tok.kind == 0) {
- sb.append(tokImage[0]);
- break;
- }
- sb.append(tokImage[tok.kind]).append(" / \"").append(add_escapes(tok.image)).append('"');
- tok = tok.next;
- }
-#if KEEP_LINE_COLUMN
- sb.append(", at line ").append(currToken.next.beginLine)
- .append(", column ").append(currToken.next.beginColumn);
-#fi
- sb.append('.').append(EOL);
-
- if (expTokenSequences.length == 0) {
- // Nothing to add here
- } else {
- if (expTokenSequences.length == 1) {
- sb.append("Was expecting this terminal");
- } else {
- sb.append("Was expecting one of these terminals");
- }
- sb.append(" within expansion starting at ").append(loc).append(':').append(EOL);
- sb.append(expected.toString());
- }
- return sb.toString();
-
- }
-
- /**
- * Used to convert raw characters to their escaped version when these raw version
- * cannot be used as part of an ASCII string literal.
- */
- static String add_escapes(String str) {
- final StringBuilder retval = new StringBuilder();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i)) {
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- }
- }
- return retval.toString();
- }
-}
diff --git a/examples/CustomTemplate/src/main/javacc/Simple1.jj b/examples/CustomTemplate/src/main/javacc/Simple1.jj
deleted file mode 100644
index e93a239..0000000
--- a/examples/CustomTemplate/src/main/javacc/Simple1.jj
+++ /dev/null
@@ -1,110 +0,0 @@
-/* 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;
-}
-
-PARSER_BEGIN(Simple1)
-package simple1;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-
-/** Simple brace matcher. */
-public class Simple1 {
-
- /** Main entry point. */
- public static void main(String args[]) throws ParseException, FileNotFoundException {
- InputStream input = System.in;
- PrintStream output = System.out;
- PrintStream error = System.err;
- InputStream prevInput = null;
- PrintStream prevOutput = null;
- PrintStream prevError = null;
- if (args.length == 3) {
- prevInput = input;
- input = new FileInputStream(args[0]);
- prevOutput = output;
- output = new PrintStream(args[1]);
- prevError = error;
- error = new PrintStream(args[2]);
- System.setIn(input);
- System.setOut(output);
- System.setErr(error);
- }
- try {
- Simple1 parser = new Simple1(input);
- parser.Input();
- output.println("matched");
- } catch (Exception e) {
- error.println(e.getMessage());
- } finally {
- if (prevInput != null) System.setIn(prevInput);
- if (prevOutput != null) System.setOut(prevOutput);
- if (prevError != null) System.setErr(prevError);
- }
- }
-
-}
-
-PARSER_END(Simple1)
-
-/** Root production. */
-void Input() :
-{}
-{
- MatchedBraces() ("\n"|"\r")*
-}
-
-/** Brace matching production. */
-void MatchedBraces() :
-{}
-{
- "{" [ MatchedBraces() ] "}"
-}
diff --git a/examples/CustomTemplate/verify-files.bsh b/examples/CustomTemplate/verify-files.bsh
deleted file mode 100644
index 0a2f34f..0000000
--- a/examples/CustomTemplate/verify-files.bsh
+++ /dev/null
@@ -1,26 +0,0 @@
-import java.io.*;
-import java.util.*;
-import org.codehaus.plexus.util.*;
-
-// just checks for a java file with customized contents
-
-try
-{
- File of = new File( basedir, "target/generated-sources/java/simple1/ParseException.java" );
-
- String contents = FileUtils.fileRead( of, "UTF-8" );
- if ( !contents.contains( "// !!! Customization test !!!" ) )
- {
- System.err.println( "Generated ParseException.java is not the customized one expected" );
- return false;
- }
-
- System.out.println( "Generated ParseException.java is the customized one expected" );
-}
-catch( Throwable t )
-{
- t.printStackTrace();
- return false;
-}
-
-return true;
diff --git a/examples/GUIParsing/ParserVersion/README.md b/examples/GUIParsing/ParserVersion/README.md
deleted file mode 100644
index 196579d..0000000
--- a/examples/GUIParsing/ParserVersion/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-This version of the GUI parsing example defines the GUI interaction as a JavaCC grammar using tokens that are generated by a user built token manager.
-Note that these tokens appear in the parser (`CalcInput.jj`) without definitions (such as ``, ``, etc.).
-JavaCC does not require token definitions when `USER_TOKEN_MANAGER` is set to `true`.
-The token manager is implemented in `TokenCollector.java` to extract tokens from a producer-consumer object in `ProducerConsumer.java`.
-The tokens are stuffed into `ProducerConsumer.java` by the GUI which is defined in `CalcGUI.java`.
-The whole system is invoked through `Main.java`.
-
-The point of this example is to illustrate:
-
-- How a parser can be used without the standard token manager.
-- The fact that tokens can be generated by entities that are not even streams (a GUI in this example).
-- That GUI interaction can be modeled as a grammar and this grammar can then be used to implement the innards of a GUI based tool.
-
-Build it in the usual manner with [pom.xml](pom.xml):
-
-- Maven:
-
-```
- mvn clean verify
-```
-
-Then run the GUI:
-
-- command line:
-
-```
- java -cp target/classes/ Main
-```
diff --git a/examples/GUIParsing/ParserVersion/pom.xml b/examples/GUIParsing/ParserVersion/pom.xml
deleted file mode 100644
index 2731c31..0000000
--- a/examples/GUIParsing/ParserVersion/pom.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.javacc.generator.java.examples
- guiparsing
- 1.1.0-SNAPSHOT
-
-
- org.javacc.examples.java.guiparsing
- ParserVersion
- jar
-
- JavaCC Java code generator / examples / GUIParsing / ParserVersion
-
-
-
-
\ No newline at end of file
diff --git a/examples/GUIParsing/ParserVersion/run.cmd b/examples/GUIParsing/ParserVersion/run.cmd
deleted file mode 100644
index ca7b6f3..0000000
--- a/examples/GUIParsing/ParserVersion/run.cmd
+++ /dev/null
@@ -1,3 +0,0 @@
-Rem script to run the calculator
-java -cp target/classes Main
-Pause
\ No newline at end of file
diff --git a/examples/GUIParsing/ParserVersion/src/main/java/CalcGUI.java b/examples/GUIParsing/ParserVersion/src/main/java/CalcGUI.java
deleted file mode 100644
index 953ea1f..0000000
--- a/examples/GUIParsing/ParserVersion/src/main/java/CalcGUI.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-import java.awt.*;
-
-public class CalcGUI extends Frame implements CalcInputParserConstants {
-
- /**
- * A button object is created for each calculator button.
- * Since there is going to be only one calculator GUI, these objects can be static.
- */
- static Button one = new Button("1");
- static Button two = new Button("2");
- static Button three = new Button("3");
- static Button four = new Button("4");
- static Button five = new Button("5");
- static Button six = new Button("6");
- static Button seven = new Button("7");
- static Button eight = new Button("8");
- static Button nine = new Button("9");
- static Button zero = new Button("0");
- static Button dot = new Button(".");
- static Button equal = new Button("=");
- static Button add = new Button("+");
- static Button sub = new Button("-");
- static Button mul = new Button("*");
- static Button div = new Button("/");
- static Button quit = new Button("QUIT");
-
- /** The display window with its initial setting. */
- static Label display = new Label("0 ");
-
- /**
- * Constructor that creates the full GUI.
- * This is called by the main program to create one calculator GUI.
- */
- public CalcGUI() {
-
- super("Calculator");
- GridBagLayout gb = new GridBagLayout();
- setLayout(gb);
- GridBagConstraints gbc = new GridBagConstraints();
-
- display.setFont(new Font("TimesRoman", Font.BOLD, 18));
- display.setAlignment(Label.RIGHT);
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gb.setConstraints(display, gbc);
- add(display);
-
- Panel buttonPanel = new Panel();
- buttonPanel.setFont(new Font("TimesRoman", Font.BOLD, 14));
- buttonPanel.setLayout(new GridLayout(4, 4));
- buttonPanel.add(one);
- buttonPanel.add(two);
- buttonPanel.add(three);
- buttonPanel.add(four);
- buttonPanel.add(five);
- buttonPanel.add(six);
- buttonPanel.add(seven);
- buttonPanel.add(eight);
- buttonPanel.add(nine);
- buttonPanel.add(zero);
- buttonPanel.add(dot);
- buttonPanel.add(equal);
- buttonPanel.add(add);
- buttonPanel.add(sub);
- buttonPanel.add(mul);
- buttonPanel.add(div);
- gbc.weighty = 1.0;
- gb.setConstraints(buttonPanel, gbc);
- add(buttonPanel);
-
- quit.setFont(new Font("TimesRoman", Font.BOLD, 14));
- gbc.gridheight = GridBagConstraints.REMAINDER;
- gbc.weighty = 0.0;
- gb.setConstraints(quit, gbc);
- add(quit);
- pack();
- show();
- }
-
- /**
- * Note how handleEvent creates tokens and sends them to the parser through the producer-consumer.
- */
- public boolean handleEvent(Event evt) {
- Token t;
- if (evt.id != Event.ACTION_EVENT) {
- return false;
- }
- if (evt.target == one) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "1";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == two) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "2";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == three) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "3";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == four) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "4";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == five) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "5";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == six) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "6";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == seven) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "7";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == eight) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "8";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == nine) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "9";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == zero) {
- t = new Token();
- t.kind = DIGIT;
- t.image = "0";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == dot) {
- t = new Token();
- t.kind = DOT;
- t.image = ".";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == equal) {
- t = new Token();
- t.kind = EQ;
- t.image = "=";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == add) {
- t = new Token();
- t.kind = ADD;
- t.image = "+";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == sub) {
- t = new Token();
- t.kind = SUB;
- t.image = "-";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == mul) {
- t = new Token();
- t.kind = MUL;
- t.image = "*";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == div) {
- t = new Token();
- t.kind = DIV;
- t.image = "/";
- ProducerConsumer.pc.addToken(t);
- return true;
- }
- if (evt.target == quit) {
- System.exit(0);
- }
- return false;
- }
-
- public static void print(double value) {
- display.setText(Double.toString(value) + " ");
- }
-
- public static void print(String image) {
- display.setText(image + " ");
- }
-}
diff --git a/examples/GUIParsing/ParserVersion/src/main/java/CalcInputParserTreeConstants.java b/examples/GUIParsing/ParserVersion/src/main/java/CalcInputParserTreeConstants.java
deleted file mode 100644
index fd2175d..0000000
--- a/examples/GUIParsing/ParserVersion/src/main/java/CalcInputParserTreeConstants.java
+++ /dev/null
@@ -1,4 +0,0 @@
-
-public interface CalcInputParserTreeConstants {
-
-}
diff --git a/examples/GUIParsing/ParserVersion/src/main/java/Main.java b/examples/GUIParsing/ParserVersion/src/main/java/Main.java
deleted file mode 100644
index a6b9c79..0000000
--- a/examples/GUIParsing/ParserVersion/src/main/java/Main.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-public class Main {
-
- public static void main(String[] args) {
- new CalcGUI();
- TokenManager tm = new TokenCollector();
- CalcInputParser cp = new CalcInputParser(tm);
- while (true) {
- try {
- cp.Input();
- } catch (ParseException e) {
- CalcGUI.print("ERROR (click 0)");
- }
- }
- }
-}
diff --git a/examples/GUIParsing/ParserVersion/src/main/java/ProducerConsumer.java b/examples/GUIParsing/ParserVersion/src/main/java/ProducerConsumer.java
deleted file mode 100644
index 4f1fa74..0000000
--- a/examples/GUIParsing/ParserVersion/src/main/java/ProducerConsumer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-public class ProducerConsumer {
-
- /** A single producer-consumer instance that is used by others. */
- public static ProducerConsumer pc = new ProducerConsumer();
-
- /** The data structure where the tokens are stored. */
- private java.util.Vector queue = new java.util.Vector();
-
- /** The producer calls this method to add a new token whenever it is available. */
- public synchronized void addToken(Token token) {
- queue.addElement(token);
- notify();
- }
-
- /**
- * The consumer calls this method to get the next token in the queue.
- * If the queue is empty, this method blocks until a token becomes available.
- */
- public synchronized Token getToken() {
- if (queue.isEmpty()) {
- try {
- wait();
- } catch (InterruptedException willNotHappen) {
- throw new Error();
- }
- }
- Token retval = (Token) (queue.elementAt(0));
- queue.removeElementAt(0);
- return retval;
- }
-}
diff --git a/examples/GUIParsing/ParserVersion/src/main/java/TokenCollector.java b/examples/GUIParsing/ParserVersion/src/main/java/TokenCollector.java
deleted file mode 100644
index 057fe35..0000000
--- a/examples/GUIParsing/ParserVersion/src/main/java/TokenCollector.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-public class TokenCollector implements TokenManager {
-
- public Token getNextToken() {
- return ProducerConsumer.pc.getToken();
- }
-}
diff --git a/examples/GUIParsing/ParserVersion/src/main/javacc/CalcInput.jj b/examples/GUIParsing/ParserVersion/src/main/javacc/CalcInput.jj
deleted file mode 100644
index 67b6d51..0000000
--- a/examples/GUIParsing/ParserVersion/src/main/javacc/CalcInput.jj
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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
-{
- USER_TOKEN_MANAGER = true;
-}
-
-PARSER_BEGIN(CalcInputParser)
-
-public class CalcInputParser {}
-
-PARSER_END(CalcInputParser)
-
-void Input() :
-{
- double larg = 0.0;
- double rarg;
-}
-{
- (
- [
- larg = Number()
- {
- CalcGUI.print(larg);
- }
- ]
- (
- < ADD >
- rarg = Number()
- {
- larg = larg + rarg;
- CalcGUI.print(larg);
- }
- |
- < SUB >
- rarg = Number()
- {
- larg = larg - rarg;
- CalcGUI.print(larg);
- }
- |
- < MUL >
- rarg = Number()
- {
- larg = larg * rarg;
- CalcGUI.print(larg);
- }
- |
- < DIV >
- rarg = Number()
- {
- larg = (rarg == 0) ? Float.POSITIVE_INFINITY : (larg / rarg);
- CalcGUI.print(larg);
- }
- )*
- < EQ : "=" >
- )*
-}
-
-double Number() :
-{
- Token t;
- String image = "";
- double value = 0.0;
- double decimalPlace = 1.0;
-}
-{
- (
- t = < DIGIT >
- {
- image += t.image;
- value = value * 10 + Integer.parseInt(t.image);
- CalcGUI.print(image);
- }
- )+
- [
- < DOT >
- {
- image += ".";
- CalcGUI.print(image);
- }
- (
- t = < DIGIT >
- {
- image += t.image;
- decimalPlace *= 0.1;
- value = value + Integer.parseInt(t.image) * decimalPlace;
- CalcGUI.print(image);
- }
- )+
- ]
- {
- return value;
- }
-|
- < DOT >
- {
- image = "0.";
- CalcGUI.print(image);
- }
- (
- t = < DIGIT >
- {
- image += t.image;
- decimalPlace *= 0.1;
- value = value + Integer.parseInt(t.image) * decimalPlace;
- CalcGUI.print(image);
- }
- )+
- {
- return value;
- }
-}
diff --git a/examples/GUIParsing/README.md b/examples/GUIParsing/README.md
deleted file mode 100644
index f99bda5..0000000
--- a/examples/GUIParsing/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-In this directory are two examples that illustrate the use of JavaCC generated parsers to collect input from a GUI and process it appropriately.
-
-The example used is a simple calculator.
-
-There are two versions of this example:
-
-- A version that uses a JavaCC parser without the JavaCC token manager in directory ParserVersion.
-
-- A version that uses a JavaCC token manager without the JavaCC parser in directory TokenMgrVersion.
-This example also illustrates the ability to build a state machine as a lexical specification.
-
-The README.md files in these directories provide more details.
diff --git a/examples/GUIParsing/TokenMgrVersion/README.md b/examples/GUIParsing/TokenMgrVersion/README.md
deleted file mode 100644
index 3cb5445..0000000
--- a/examples/GUIParsing/TokenMgrVersion/README.md
+++ /dev/null
@@ -1,38 +0,0 @@
-This version of the GUI parsing example defines the GUI interaction as a JavaCC lexical specification where the characters are read from the GUI and there is an finite automaton (FA) built out of lexical states that have moves on these characters.
-In the grammar, the `USER_CHAR_STREAM option` has been set to `true` and the `BUILD_PARSER` option has been set to `false`.
-The event handler method stuffs the characters into a buffer from which characters are returned to the lexical analyzer (by `readChar()`).
-The whole system is invoked through`Main.java`.
-
-The point of this example is to illustrate:
-
-- A very detailed example of an FA simulation using lexical states where every character moves the FA.
-
-- How a lexical analyzer can be used without a standard (JavaCC generated) CharStream object.
-
-- How a lexical analyzer can be used without a parser.
-
-- The fact that input can come from entities that are not even streams (a GUI in this example).
-
-- That GUI interaction can be modeled as a regular expression specification.
-
-Build it in the usual manner with [pom.xml](pom.xml):
-
-- Maven:
-
-```
- mvn clean verify
-```
-
-Then run the GUI:
-
-- command line:
-
-```
- java -cp target/classes/ Main
-```
-
-Homework:
-
- Simplify the grammar so that (["0"-"9"])* is treated as a single
- entity for moving the FA.
-
diff --git a/examples/GUIParsing/TokenMgrVersion/pom.xml b/examples/GUIParsing/TokenMgrVersion/pom.xml
deleted file mode 100644
index 544d4a4..0000000
--- a/examples/GUIParsing/TokenMgrVersion/pom.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.javacc.generator.java.examples
- guiparsing
- 1.1.0-SNAPSHOT
-
-
- org.javacc.examples.java.guiparsing
- TokenMgrVersion
- jar
-
- JavaCC Java code generator / examples / GUIParsing / TokenMgrVersion
-
-
-
-
\ No newline at end of file
diff --git a/examples/GUIParsing/TokenMgrVersion/run.cmd b/examples/GUIParsing/TokenMgrVersion/run.cmd
deleted file mode 100644
index ca7b6f3..0000000
--- a/examples/GUIParsing/TokenMgrVersion/run.cmd
+++ /dev/null
@@ -1,3 +0,0 @@
-Rem script to run the calculator
-java -cp target/classes Main
-Pause
\ No newline at end of file
diff --git a/examples/GUIParsing/TokenMgrVersion/src/main/java/CalcGUI.java b/examples/GUIParsing/TokenMgrVersion/src/main/java/CalcGUI.java
deleted file mode 100644
index 4b2eb98..0000000
--- a/examples/GUIParsing/TokenMgrVersion/src/main/java/CalcGUI.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-import java.awt.*;
-
-public class CalcGUI extends Frame implements CalcInputParserConstants {
-
- /*
- * A button object is created for each calculator button. Since there is going to be only one
- * calculator GUI, these objects can be static.
- */
-
- static Button one = new Button("1");
- static Button two = new Button("2");
- static Button three = new Button("3");
- static Button four = new Button("4");
- static Button five = new Button("5");
- static Button six = new Button("6");
- static Button seven = new Button("7");
- static Button eight = new Button("8");
- static Button nine = new Button("9");
- static Button zero = new Button("0");
- static Button dot = new Button(".");
- static Button equal = new Button("=");
- static Button add = new Button("+");
- static Button sub = new Button("-");
- static Button mul = new Button("*");
- static Button div = new Button("/");
- static Button quit = new Button("QUIT");
-
- /** The display window with its initial setting. */
- static Label display = new Label("0 ");
-
- /** The class that collects the characters produced by the GUI */
- static final CharCollector collector = new CharCollector();
-
- static final CharStream getCollector() {
- return collector;
- }
-
- /** string that holds what the calculator displays */
- static String label = "0";
-
- /** flag to indicate if this is the first digit. */
- static boolean firstDigit = true;
-
- /** Indicates an error has occured */
- static boolean error = false;
-
- /**
- * Constructor that creates the full GUI.
- * This is called by the main program to create one calculator GUI.
- */
- public CalcGUI() {
-
- super("Calculator");
-
- GridBagLayout gb = new GridBagLayout();
- setLayout(gb);
- GridBagConstraints gbc = new GridBagConstraints();
-
- display.setFont(new Font("TimesRoman", Font.BOLD, 18));
- display.setAlignment(Label.RIGHT);
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gb.setConstraints(display, gbc);
- add(display);
-
- Panel buttonPanel = new Panel();
- buttonPanel.setFont(new Font("TimesRoman", Font.BOLD, 14));
- buttonPanel.setLayout(new GridLayout(4, 4));
- buttonPanel.add(one);
- buttonPanel.add(two);
- buttonPanel.add(three);
- buttonPanel.add(four);
- buttonPanel.add(five);
- buttonPanel.add(six);
- buttonPanel.add(seven);
- buttonPanel.add(eight);
- buttonPanel.add(nine);
- buttonPanel.add(zero);
- buttonPanel.add(dot);
- buttonPanel.add(equal);
- buttonPanel.add(add);
- buttonPanel.add(sub);
- buttonPanel.add(mul);
- buttonPanel.add(div);
- gbc.weighty = 1.0;
- gb.setConstraints(buttonPanel, gbc);
- add(buttonPanel);
-
- quit.setFont(new Font("TimesRoman", Font.BOLD, 14));
- gbc.gridheight = GridBagConstraints.REMAINDER;
- gbc.weighty = 0.0;
- gb.setConstraints(quit, gbc);
- add(quit);
- pack();
- show();
- }
-
- /** Here we just return the character that is input. */
- public boolean handleEvent(Event evt) {
- char c = 0;
-
- if (evt.id != Event.ACTION_EVENT) {
- return false;
- }
-
- if (evt.target == quit) {
- System.exit(0);
- }
-
- if (error) {
- if (evt.target == zero) {
- error = false;
- print("0");
- firstDigit = true;
- return true;
- }
-
- return false;
- }
-
- if (evt.target == equal) {
- c = '=';
- firstDigit = true;
- } else if (evt.target == add) {
- c = '+';
- label = "0";
- firstDigit = true;
- } else if (evt.target == sub) {
- c = '-';
- label = "0";
- firstDigit = true;
- } else if (evt.target == mul) {
- c = '*';
- label = "0";
- firstDigit = true;
- } else if (evt.target == div) {
- c = '/';
- label = "0";
- firstDigit = true;
- } else {
- if (firstDigit) label = "";
- firstDigit = false;
-
- if (evt.target == one) {
- c = '1';
- label += c;
- } else if (evt.target == two) {
- c = '2';
- label += c;
- } else if (evt.target == three) {
- c = '3';
- label += c;
- } else if (evt.target == four) {
- c = '4';
- label += c;
- } else if (evt.target == five) {
- c = '5';
- label += c;
- } else if (evt.target == six) {
- c = '6';
- label += c;
- } else if (evt.target == seven) {
- c = '7';
- label += c;
- } else if (evt.target == eight) {
- c = '8';
- label += c;
- } else if (evt.target == nine) {
- c = '9';
- label += c;
- } else if (evt.target == zero) {
- c = '0';
- label += c;
- } else if (evt.target == dot) {
- c = '.';
- label += ".";
- } else return false;
- }
-
- print(label);
- collector.put(c);
- return true;
- }
-
- public static void print(double value) {
- display.setText(label = Double.toString(value));
- }
-
- public static void print(String image) {
- display.setText(label = image);
- }
-
- public static void Error(String image) {
- print(image);
- Toolkit.getDefaultToolkit().beep();
- collector.Clear();
- label = "0";
- error = true;
- }
-}
diff --git a/examples/GUIParsing/TokenMgrVersion/src/main/java/CharCollector.java b/examples/GUIParsing/TokenMgrVersion/src/main/java/CharCollector.java
deleted file mode 100644
index a544f89..0000000
--- a/examples/GUIParsing/TokenMgrVersion/src/main/java/CharCollector.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-/**
- * A CharStream implementation for an event driven stream that produces / consumes one character at
- * a time.
- * Adapted from the SimpleCharStream, removing constructors and reinitialize methods, removing
- * internal lines & columns updates (which is different from lines & columns tracking), filling the
- * buffer directly.
- */
-public class CharCollector implements CharStream {
-
- int bufsize;
- int available;
- int tokenBegin;
- public int bufpos = -1;
-
- protected char[] buffer;
- protected int maxNextCharInd = 0;
- protected int inBuf = 0;
-
- protected boolean trackLineColumn = true;
- protected int tabSize = 1;
-
- /** Puts a character into the buffer. Called by the GUI. */
- public final synchronized void put(char c) {
- buffer[maxNextCharInd++] = c;
- notify();
- }
-
- public void Clear() {
- bufpos = -1;
- maxNextCharInd = 0;
- inBuf = 0;
- }
-
- public char BeginToken() throws java.io.IOException {
- tokenBegin = -1;
- char c = readChar();
- tokenBegin = bufpos;
-
- return c;
- }
-
- // same as in SimpleCharStream but shorter (and with chars forced in the ASCII range)
- public final synchronized char readChar() throws java.io.IOException {
- if (inBuf > 0) {
- --inBuf;
- return (char) ((char) 0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]);
- }
-
- if (++bufpos >= maxNextCharInd) {
- FillBuff();
- }
- return buffer[bufpos];
- }
-
- private final void FillBuff() {
- if (maxNextCharInd == available) {
- if (available == bufsize) {
- if (tokenBegin > 2048) {
- bufpos = maxNextCharInd = 0;
- available = tokenBegin;
- } else if (tokenBegin < 0) {
- bufpos = maxNextCharInd = 0;
- } else {
- ExpandBuff(false);
- }
- } else if (available > tokenBegin) {
- available = bufsize;
- } else if ((tokenBegin - available) < 2048) {
- ExpandBuff(true);
- } else {
- available = tokenBegin;
- }
- }
- try {
- wait();
- } catch (InterruptedException willNotHappen) {
- throw new Error();
- }
- }
-
- private final void ExpandBuff(boolean wrapAround) {
- char[] newbuffer = new char[bufsize + 2048];
-
- try {
- if (wrapAround) {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
- buffer = newbuffer;
- maxNextCharInd = (bufpos += (bufsize - tokenBegin));
- } else {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- buffer = newbuffer;
- maxNextCharInd = (bufpos -= tokenBegin);
- }
- } catch (Throwable t) {
- System.out.println("Error : " + t.getClass().getName());
- throw new Error();
- }
-
- bufsize += 2048;
- available = bufsize;
- tokenBegin = 0;
- }
-
- public final void backup(int amount) {
- inBuf += amount;
- if ((bufpos -= amount) < 0) {
- bufpos += bufsize;
- }
- }
-
- public void Done() {
- buffer = null;
- }
-
- public final String GetImage() {
- if (bufpos >= tokenBegin) {
- return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
- } else
- return new String(buffer, tokenBegin, bufsize - tokenBegin)
- + new String(buffer, 0, bufpos + 1);
- }
-
- public final char[] GetSuffix(int len) {
- char[] ret = new char[len];
- if (bufpos + 1 >= len) {
- System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
- } else {
- System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1);
- System.arraycopy(buffer, 0, ret, len - bufpos, bufpos + 1);
- }
- return ret;
- }
-
- public CharCollector() {
- available = bufsize = 4096;
- buffer = new char[4096];
- }
-
- @Deprecated
- public final int getLine() {
- return 0;
- }
-
- @Deprecated
- public final int getColumn() {
- return 0;
- }
-
- public final int getBeginLine() {
- return 0;
- }
-
- public final int getBeginColumn() {
- return 0;
- }
-
- public final int getEndLine() {
- return 0;
- }
-
- public final int getEndColumn() {
- return 0;
- }
-
- public boolean getTrackLineColumn() {
- return trackLineColumn;
- }
-
- public void setTrackLineColumn(boolean tlc) {
- trackLineColumn = tlc;
- }
-
- public int getTabSize() {
- return tabSize;
- }
-
- public void setTabSize(int i) {
- tabSize = i;
- }
-}
diff --git a/examples/GUIParsing/TokenMgrVersion/src/main/java/Main.java b/examples/GUIParsing/TokenMgrVersion/src/main/java/Main.java
deleted file mode 100644
index 21e322d..0000000
--- a/examples/GUIParsing/TokenMgrVersion/src/main/java/Main.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-public class Main {
-
- public static void main(String[] args) {
- CalcGUI gui = new CalcGUI();
- MyLexer lexer = new MyLexer(gui);
- while (true) {
- try {
- lexer.getNextToken();
- } catch (TokenMgrError e) {
- }
- }
- }
-}
diff --git a/examples/GUIParsing/TokenMgrVersion/src/main/java/MyLexer.java b/examples/GUIParsing/TokenMgrVersion/src/main/java/MyLexer.java
deleted file mode 100644
index 3e9f433..0000000
--- a/examples/GUIParsing/TokenMgrVersion/src/main/java/MyLexer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-/**
- * A subclass of CalcInputTokenManager so that we can do better error reporting via the GUI object.
- */
-class MyLexer extends CalcInputParserTokenManager {
-
- public MyLexer(CalcGUI guiObj) {
- super(guiObj.getCollector(), OPERAND);
- gui = guiObj;
- }
-
- /**
- * We redefined the lexical error reporting function so that it beeps and displays a message
- * through the GUI.
- */
- protected void LexicalError() {
- CalcGUI.Error("ERROR (click 0)");
- ReInit(gui.getCollector(), OPERAND);
- result = 0.0;
- }
-}
diff --git a/examples/GUIParsing/TokenMgrVersion/src/main/javacc/CalcInput.jj b/examples/GUIParsing/TokenMgrVersion/src/main/javacc/CalcInput.jj
deleted file mode 100644
index 00ce2e0..0000000
--- a/examples/GUIParsing/TokenMgrVersion/src/main/javacc/CalcInput.jj
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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
-{
- BUILD_PARSER = false;
- USER_CHAR_STREAM = true;
-// DEBUG_TOKEN_MANAGER = true; // (JavaCC - default false)
-}
-
-PARSER_BEGIN(CalcInputParser)
-
-public class CalcInputParser {}
-
-PARSER_END(CalcInputParser)
-
-/**
- * This example shows an elaborate example to construct a Finite Automaton,
- * where for every character there is a move.
- */
-TOKEN_MGR_DECLS:
-{
- /** A pointer to the GUI object. */
- static CalcGUI gui;
-
- /** Holds the result of the expression evaluation so far. */
- static double result = 0.0;
-
- /** Flag to indicate the very first operand so that the correct result is displayed in this case. */
- static boolean firstOperand = true;
-
- /** Shows the result. */
- private static void ShowResult()
- {
- if (firstOperand)
- {
- String s = input_stream.GetImage();
-// System.err.println("first operand; s = <" + s + ">");
- if (s.length() > 0)
- {
- if (s.length() > 1)
- {
- // remove the operator character
- s = s.substring(0, s.length() - 1);
- }
- result = Double.valueOf(s).doubleValue();
- }
- else
- {
- result = 0.0;
- }
- firstOperand = false;
-// } el m.err.println("not first operand");
- }
- gui.print(result);
- }
-}
-
-/**
- * The first operand
- */
- MORE :
-{
- < ["0"-"9"] >
-|
- "." : REQUIRED_DIGIT
-}
-
-/**
- * This state is entered when we need to get at least one digit (after a .)
- */
- MORE :
-{
- < ["0"-"9"] > : OPTIONAL_DIGIT
-}
-
-/**
- * FA for (["0"-"9"])*.
- */
- MORE :
-{
- < ["0"-"9"] >
-}
-
-/**
- * You can get an operator at any time (in any lexical state), except when a digit is required (after a .).
- * Then just go to a state where the next operand is scanned (for that particular operator).
- */
- SKIP :
-{
- < PLUS : "+" > { ShowResult(); } : SEEN_PLUS
-|
- < MINUS : "-" > { ShowResult(); } : SEEN_MINUS
-|
- < STAR : "*" > { ShowResult(); } : SEEN_STAR
-|
- < SLASH : "/" > { ShowResult(); } : SEEN_SLASH
-}
-
-/**
- * If you get a = in any state, just display the current result.
- */
- SKIP :
-{
- < EQ : "=" > { ShowResult(); } : OP_OR_OPERAND
-}
-
-/**
- * Here you can either give an operand (to start a new expression)
- * or give an operator that works on the current result.
- */
- SKIP :
-{
- "="
-}
-
- MORE :
-{
- < ["0"-"9"] > { firstOperand = true; } : OPERAND
-|
- "." { firstOperand = true; } : REQUIRED_DIGIT
-}
-
- MORE :
-{
- < ["0"-"9"] > : ADD_RIGHT_OPERAND
-|
- "." : ADD_REQUIRED_DIGIT
-}
-
- MORE :
-{
- < ["0"-"9"] > : DO_ADD
-}
-
- SKIP :
-{
- ""
- { result += Double.valueOf(input_stream.GetImage()).doubleValue(); } : OP_LOOP
-}
-
- MORE :
-{
- < ["0"-"9"] > : SUB_RIGHT_OPERAND
-|
- "." : SUB_REQUIRED_DIGIT
-}
-
- MORE :
-{
- < ["0"-"9"] > : DO_SUB
-}
-
- SKIP :
-{
- ""
- { result -= Double.valueOf(input_stream.GetImage()).doubleValue(); } : OP_LOOP
-}
-
- MORE :
-{
- < ["0"-"9"] > : MUL_RIGHT_OPERAND
-|
- "." : MUL_REQUIRED_DIGIT
-}
-
- MORE :
-{
- < ["0"-"9"] > : DO_MUL
-}
-
- SKIP :
-{
- ""
- { result *= Double.valueOf(input_stream.GetImage()).doubleValue(); } : OP_LOOP
-}
-
- MORE :
-{
- < ["0"-"9"] > : DIV_RIGHT_OPERAND
-|
- "." : DIV_REQUIRED_DIGIT
-}
-
- MORE :
-{
- < ["0"-"9"] > : DO_DIV
-}
-
- SKIP :
-{
- ""
- { result /= Double.valueOf(input_stream.GetImage()).doubleValue(); } : OP_LOOP
-}
diff --git a/examples/GUIParsing/pom.xml b/examples/GUIParsing/pom.xml
deleted file mode 100644
index 8356dee..0000000
--- a/examples/GUIParsing/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.javacc.generator.java
- examples
- 1.1.0-SNAPSHOT
-
-
- org.javacc.generator.java.examples
- guiparsing
- pom
-
- JavaCC Java code generator / examples / GUIParsing
-
-
- ParserVersion
- TokenMgrVersion
-
-
-
\ No newline at end of file
diff --git a/examples/Gwt/README b/examples/Gwt/README
deleted file mode 100644
index da73714..0000000
--- a/examples/Gwt/README
+++ /dev/null
@@ -1,29 +0,0 @@
-/* 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).
\ No newline at end of file
diff --git a/examples/Gwt/checkstyle-suppress.xml b/examples/Gwt/checkstyle-suppress.xml
deleted file mode 100644
index 67fe8cb..0000000
--- a/examples/Gwt/checkstyle-suppress.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/Gwt/pom.xml b/examples/Gwt/pom.xml
deleted file mode 100644
index 8ec94bc..0000000
--- a/examples/Gwt/pom.xml
+++ /dev/null
@@ -1,193 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.javacc.generator.java
- examples
- 1.1.0-SNAPSHOT
-
-
- org.javacc.generator.java.examples
- gwt
- jar
-
- JavaCC Java code generator / examples / Gwt
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-clean-plugin
-
-
- clear-res-test
- process-test-resources
-
- clean
-
-
- true
-
-
- files
-
- *.out
- *.err
-
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
-
- exec-test-1
- test
-
- java
-
-
- GwtSimpleParser
-
- ${project.basedir}/simple/out
- ${project.basedir}/simple/err
-
-
-
-
- unicode
- test
-
- java
-
-
- GwtUnicodeParser
-
- ${project.basedir}/unicode/out
- ${project.basedir}/unicode/err
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
- compare-simple
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-unicode
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 3.6.0
-
- google_checks.xml
- true
- true
- UTF-8
- target/generated-sources/java
- checkstyle.suppressions.file
- checkstyle-suppress.xml
- error
-
-
-
- validate
- generate-sources
-
- check
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/Gwt/simple/err b/examples/Gwt/simple/err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Gwt/simple/out b/examples/Gwt/simple/out
deleted file mode 100644
index ce01362..0000000
--- a/examples/Gwt/simple/out
+++ /dev/null
@@ -1 +0,0 @@
-hello
diff --git a/examples/Gwt/simple/ref b/examples/Gwt/simple/ref
deleted file mode 100644
index b6fc4c6..0000000
--- a/examples/Gwt/simple/ref
+++ /dev/null
@@ -1 +0,0 @@
-hello
\ No newline at end of file
diff --git a/examples/Gwt/src/main/javacc/GwtSimpleParser.jj b/examples/Gwt/src/main/javacc/GwtSimpleParser.jj
deleted file mode 100644
index 09658fc..0000000
--- a/examples/Gwt/src/main/javacc/GwtSimpleParser.jj
+++ /dev/null
@@ -1,100 +0,0 @@
-/* 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");
- }
-}
\ No newline at end of file
diff --git a/examples/Gwt/src/main/javacc/GwtUnicodeParser.jj b/examples/Gwt/src/main/javacc/GwtUnicodeParser.jj
deleted file mode 100644
index 43164a3..0000000
--- a/examples/Gwt/src/main/javacc/GwtUnicodeParser.jj
+++ /dev/null
@@ -1,100 +0,0 @@
-/* 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");
- }
-}
\ No newline at end of file
diff --git a/examples/Gwt/unicode/err b/examples/Gwt/unicode/err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Gwt/unicode/out b/examples/Gwt/unicode/out
deleted file mode 100644
index ce01362..0000000
--- a/examples/Gwt/unicode/out
+++ /dev/null
@@ -1 +0,0 @@
-hello
diff --git a/examples/Gwt/unicode/ref b/examples/Gwt/unicode/ref
deleted file mode 100644
index b6fc4c6..0000000
--- a/examples/Gwt/unicode/ref
+++ /dev/null
@@ -1 +0,0 @@
-hello
\ No newline at end of file
diff --git a/examples/Interpreter/README b/examples/Interpreter/README
deleted file mode 100644
index 09f7e08..0000000
--- a/examples/Interpreter/README
+++ /dev/null
@@ -1,45 +0,0 @@
-/* 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 is an interpreter for SPL (Stupid Programming Language). It builds
-jjtree's for a given SPL program and interprets it. It shows how you can
-implement simple loop and conditional constructs.
-
-Note how easy it is to annotate a grammar file to build useful tree nodes
-and then extend these nodes for purposes of interpreting, etc.
-
-This example will be improved as JJTree evolves.
-
-To run it :
-
- jjtree SPL.jjt
- javacc SPL.jj
- javac *.java
- java SPL fact.spl
- java SPL sqrt.spl
- java SPL odd.spl
diff --git a/examples/Interpreter/files/fact/ast-fact.exp_err b/examples/Interpreter/files/fact/ast-fact.exp_err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Interpreter/files/fact/ast-fact.exp_out b/examples/Interpreter/files/fact/ast-fact.exp_out
deleted file mode 100644
index 6bca0bf..0000000
--- a/examples/Interpreter/files/fact/ast-fact.exp_out
+++ /dev/null
@@ -1,9 +0,0 @@
-Executing: int n
-Executing: int fact
-Executing: read n
-Enter a value for 'n' (int) :
-Read this value for 'n' (int) : 4
-Executing: fact = 1 ;
-Executing: while ( n > 1 ) { fact = fact * n ; n = n - 1 ; }
-Executing: write fact
-Value of fact : 24
diff --git a/examples/Interpreter/files/fact/fact.in b/examples/Interpreter/files/fact/fact.in
deleted file mode 100644
index bf0d87a..0000000
--- a/examples/Interpreter/files/fact/fact.in
+++ /dev/null
@@ -1 +0,0 @@
-4
\ No newline at end of file
diff --git a/examples/Interpreter/files/fact/fact.spl b/examples/Interpreter/files/fact/fact.spl
deleted file mode 100644
index 38417a8..0000000
--- a/examples/Interpreter/files/fact/fact.spl
+++ /dev/null
@@ -1,14 +0,0 @@
-int n;
-int fact;
-
-read n;
-
-fact = 1;
-
-while (n > 1)
-{
- fact = fact * n;
- n = n - 1;
-}
-
-write fact;
diff --git a/examples/Interpreter/files/fact/vst-fact.exp_err b/examples/Interpreter/files/fact/vst-fact.exp_err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Interpreter/files/fact/vst-fact.exp_out b/examples/Interpreter/files/fact/vst-fact.exp_out
deleted file mode 100644
index 6bca0bf..0000000
--- a/examples/Interpreter/files/fact/vst-fact.exp_out
+++ /dev/null
@@ -1,9 +0,0 @@
-Executing: int n
-Executing: int fact
-Executing: read n
-Enter a value for 'n' (int) :
-Read this value for 'n' (int) : 4
-Executing: fact = 1 ;
-Executing: while ( n > 1 ) { fact = fact * n ; n = n - 1 ; }
-Executing: write fact
-Value of fact : 24
diff --git a/examples/Interpreter/files/odd/ast-odd.exp_err b/examples/Interpreter/files/odd/ast-odd.exp_err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Interpreter/files/odd/ast-odd.exp_out b/examples/Interpreter/files/odd/ast-odd.exp_out
deleted file mode 100644
index c38779c..0000000
--- a/examples/Interpreter/files/odd/ast-odd.exp_out
+++ /dev/null
@@ -1,9 +0,0 @@
-Executing: int num
-Executing: boolean odd
-Executing: num = 10 ;
-Executing: read num
-Enter a value for 'num' (int) :
-Read this value for 'num' (int) : 3
-Executing: if ( num % 2 != 0 ) odd = true ; else odd = false ;
-Executing: write odd
-Value of odd : true
diff --git a/examples/Interpreter/files/odd/odd.in b/examples/Interpreter/files/odd/odd.in
deleted file mode 100644
index e440e5c..0000000
--- a/examples/Interpreter/files/odd/odd.in
+++ /dev/null
@@ -1 +0,0 @@
-3
\ No newline at end of file
diff --git a/examples/Interpreter/files/odd/odd.spl b/examples/Interpreter/files/odd/odd.spl
deleted file mode 100644
index 5f81dd7..0000000
--- a/examples/Interpreter/files/odd/odd.spl
+++ /dev/null
@@ -1,13 +0,0 @@
-int num;
-boolean odd;
-
-num = 10;
-
-read num;
-
-if (num % 2 != 0)
- odd = true;
-else
- odd = false;
-
-write odd;
diff --git a/examples/Interpreter/files/odd/vst-odd.exp_err b/examples/Interpreter/files/odd/vst-odd.exp_err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Interpreter/files/odd/vst-odd.exp_out b/examples/Interpreter/files/odd/vst-odd.exp_out
deleted file mode 100644
index c38779c..0000000
--- a/examples/Interpreter/files/odd/vst-odd.exp_out
+++ /dev/null
@@ -1,9 +0,0 @@
-Executing: int num
-Executing: boolean odd
-Executing: num = 10 ;
-Executing: read num
-Enter a value for 'num' (int) :
-Read this value for 'num' (int) : 3
-Executing: if ( num % 2 != 0 ) odd = true ; else odd = false ;
-Executing: write odd
-Value of odd : true
diff --git a/examples/Interpreter/files/sqrt/ast-sqrt.exp_err b/examples/Interpreter/files/sqrt/ast-sqrt.exp_err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Interpreter/files/sqrt/ast-sqrt.exp_out b/examples/Interpreter/files/sqrt/ast-sqrt.exp_out
deleted file mode 100644
index 3a54659..0000000
--- a/examples/Interpreter/files/sqrt/ast-sqrt.exp_out
+++ /dev/null
@@ -1,9 +0,0 @@
-Executing: int val
-Executing: read val
-Enter a value for 'val' (int) :
-Read this value for 'val' (int) : 9
-Executing: int sqrt
-Executing: sqrt = 1 ;
-Executing: while ( sqrt * sqrt <= val && ( ( sqrt + 1 ) * ( sqrt + 1 ) ) <= val ) sqrt = sqrt + 1 ;
-Executing: write sqrt
-Value of sqrt : 3
diff --git a/examples/Interpreter/files/sqrt/sqrt.in b/examples/Interpreter/files/sqrt/sqrt.in
deleted file mode 100644
index f11c82a..0000000
--- a/examples/Interpreter/files/sqrt/sqrt.in
+++ /dev/null
@@ -1 +0,0 @@
-9
\ No newline at end of file
diff --git a/examples/Interpreter/files/sqrt/sqrt.spl b/examples/Interpreter/files/sqrt/sqrt.spl
deleted file mode 100644
index c82568a..0000000
--- a/examples/Interpreter/files/sqrt/sqrt.spl
+++ /dev/null
@@ -1,12 +0,0 @@
-
-int val;
-
-read val;
-int sqrt;
-
-sqrt = 1;
-
-while (sqrt * sqrt <= val && ((sqrt + 1) * (sqrt + 1)) <= val)
- sqrt = sqrt + 1;
-
-write sqrt
diff --git a/examples/Interpreter/files/sqrt/vst-sqrt.exp_err b/examples/Interpreter/files/sqrt/vst-sqrt.exp_err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/Interpreter/files/sqrt/vst-sqrt.exp_out b/examples/Interpreter/files/sqrt/vst-sqrt.exp_out
deleted file mode 100644
index 3a54659..0000000
--- a/examples/Interpreter/files/sqrt/vst-sqrt.exp_out
+++ /dev/null
@@ -1,9 +0,0 @@
-Executing: int val
-Executing: read val
-Enter a value for 'val' (int) :
-Read this value for 'val' (int) : 9
-Executing: int sqrt
-Executing: sqrt = 1 ;
-Executing: while ( sqrt * sqrt <= val && ( ( sqrt + 1 ) * ( sqrt + 1 ) ) <= val ) sqrt = sqrt + 1 ;
-Executing: write sqrt
-Value of sqrt : 3
diff --git a/examples/Interpreter/pom.xml b/examples/Interpreter/pom.xml
deleted file mode 100644
index c0eb391..0000000
--- a/examples/Interpreter/pom.xml
+++ /dev/null
@@ -1,324 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.javacc.generator.java
- examples
- 1.1.0-SNAPSHOT
-
-
- org.javacc.generator.java.examples
- Interpreter
- jar
-
- JavaCC Java code generator / examples / Interpreter
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-clean-plugin
-
-
- clear-res-test
- process-test-resources
-
- clean
-
-
- true
-
-
- files
-
- **/*.out
- **/*.err
-
-
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
-
-
- ast.fact
- test
-
- java
-
-
- ast.SPLMain
-
- ${project.basedir}/files/fact/fact.spl
- ${project.basedir}/files/fact/fact.in
- ${project.basedir}/files/fact/ast-fact.out
- ${project.basedir}/files/fact/ast-fact.err
-
-
-
-
- ast.odd
- test
-
- java
-
-
- ast.SPLMain
-
- ${project.basedir}/files/odd/odd.spl
- ${project.basedir}/files/odd/odd.in
- ${project.basedir}/files/odd/ast-odd.out
- ${project.basedir}/files/odd/ast-odd.err
-
-
-
-
- ast.sqrt
- test
-
- java
-
-
- ast.SPLMain
-
- ${project.basedir}/files/sqrt/sqrt.spl
- ${project.basedir}/files/sqrt/sqrt.in
- ${project.basedir}/files/sqrt/ast-sqrt.out
- ${project.basedir}/files/sqrt/ast-sqrt.err
-
-
-
-
-
- vst.fact
- test
-
- java
-
-
- vst.SPLMain
-
- ${project.basedir}/files/fact/fact.spl
- ${project.basedir}/files/fact/fact.in
- ${project.basedir}/files/fact/vst-fact.out
- ${project.basedir}/files/fact/vst-fact.err
-
-
-
-
- vst.odd
- test
-
- java
-
-
- vst.SPLMain
-
- ${project.basedir}/files/odd/odd.spl
- ${project.basedir}/files/odd/odd.in
- ${project.basedir}/files/odd/vst-odd.out
- ${project.basedir}/files/odd/vst-odd.err
-
-
-
-
- vst.sqrt
- test
-
- java
-
-
- vst.SPLMain
-
- ${project.basedir}/files/sqrt/sqrt.spl
- ${project.basedir}/files/sqrt/sqrt.in
- ${project.basedir}/files/sqrt/vst-sqrt.out
- ${project.basedir}/files/sqrt/vst-sqrt.err
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
-
- compare-ast.fact
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-ast.odd
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-ast.sqrt
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-vst.fact
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-vst.odd
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-vst.sqrt
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/Interpreter/src/main/java/ast/MyNode.java b/examples/Interpreter/src/main/java/ast/MyNode.java
deleted file mode 100644
index bbb07c9..0000000
--- a/examples/Interpreter/src/main/java/ast/MyNode.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Hashtable;
-
-/** Specialised node. */
-public abstract class MyNode {
-
- /** Symbol table: key = name, val = type */
- protected static Hashtable symtab = new Hashtable<>();
-
- /** "Stack" for calculations. */
- protected static Object[] stack = new Object[1024];
-
- /** Top of the "stack". */
- protected static int top = -1;
-
- /**
- * @throws UnsupportedOperationException if called
- */
- public void interpret() {
- // It better not come here. (well, we did!)
- throw new UnsupportedOperationException("UOE in " + this.getClass().getSimpleName());
- }
-
- protected static Writer out = new PrintWriter(System.out);
- protected static Reader in = new InputStreamReader(System.in);
-
- /**
- * @param in the input to set
- */
- public static void setIn(Reader in) {
- MyNode.in = in;
- }
-
- /**
- * @param out the output to set
- */
- public static void setOut(Writer out) {
- MyNode.out = out;
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/SPLMain.java b/examples/Interpreter/src/main/java/ast/SPLMain.java
deleted file mode 100644
index 32443c3..0000000
--- a/examples/Interpreter/src/main/java/ast/SPLMain.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/** Simple Programming Language parser. */
-public class SPLMain {
-
- /** Main entry point. */
- public static void main(String args[]) {
- InputStream spl = null;
- InputStream input = System.in;
- PrintStream output = System.out;
- PrintStream error = System.err;
- InputStream prevInput = null;
- PrintStream prevOutput = null;
- PrintStream prevError = null;
-
- try {
- SPLParser parser;
- switch (args.length) {
- case 1:
- output.println(
- "Simple Programming Language Interpreter (AST): Reading from file "
- + args[0]
- + " . . .");
- try {
- parser = new SPLParser(new FileInputStream(args[0]));
- } catch (FileNotFoundException e) {
- error.println(
- "Simple Programming Language Interpreter (AST): File "
- + args[0]
- + " not found.");
- return;
- }
- break;
- case 4:
- spl = new FileInputStream(args[0]);
- prevInput = input;
- input = new FileInputStream(args[1]);
- System.setIn(input);
- prevOutput = output;
- output = new PrintStream(args[2]);
- System.setOut(output);
- prevError = error;
- error = new PrintStream(args[3]);
- System.setErr(error);
- parser = new SPLParser(spl);
- break;
- default:
- output.println("Simple Programming Language Interpreter (AST): Usage :");
- output.println(" java SPLMain spl [in out err]");
- return;
- }
- parser.CompilationUnit();
- parser.jjtree.rootNode().interpret();
- } catch (ParseException e) {
- error.println(
- "Simple Programming Language Interpreter (AST): Encountered errors during parse.");
- e.printStackTrace();
- } catch (Exception e1) {
- error.println(
- "Simple Programming Language Interpreter (AST): Encountered errors during interpretation/tree building.");
- e1.printStackTrace();
- } finally {
- try {
- input.close();
- output.close();
- error.close();
- } catch (IOException e) {
- }
- if (prevInput != null) System.setIn(prevInput);
- if (prevOutput != null) System.setOut(prevOutput);
- if (prevError != null) System.setErr(prevError);
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STAddNode.java b/examples/Interpreter/src/main/java/ast/STAddNode.java
deleted file mode 100644
index cccca26..0000000
--- a/examples/Interpreter/src/main/java/ast/STAddNode.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-import ast.Node;
-
-public class STAddNode extends Node {
-
- public STAddNode(int id) {
- super(id);
- }
-
- public STAddNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // MultiplicativeExpression()
- jjtGetChild(0).interpret();
-
- // MultiplicativeExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() + ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STAndNode.java b/examples/Interpreter/src/main/java/ast/STAndNode.java
deleted file mode 100644
index ac8ec65..0000000
--- a/examples/Interpreter/src/main/java/ast/STAndNode.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STAndNode extends Node {
-
- public STAndNode(int id) {
- super(id);
- }
-
- public STAndNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // InclusiveOrExpression()
- jjtGetChild(0).interpret();
-
- if (!((Boolean) stack[top]).booleanValue()) {
- stack[top] = new Boolean(false);
- return;
- }
-
- // InclusiveOrExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() && ((Boolean) stack[top + 1]).booleanValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STAssignment.java b/examples/Interpreter/src/main/java/ast/STAssignment.java
deleted file mode 100644
index 9c10e62..0000000
--- a/examples/Interpreter/src/main/java/ast/STAssignment.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STAssignment extends Node {
-
- public STAssignment(int id) {
- super(id);
- }
-
- public STAssignment(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // Expression()
- jjtGetChild(1).interpret();
-
- // PrimaryExpression()
- // note that here we do not interpret the child!
- String name = ((STId) jjtGetChild(0)).name;
- symtab.put(name, stack[top]);
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STBitwiseAndNode.java b/examples/Interpreter/src/main/java/ast/STBitwiseAndNode.java
deleted file mode 100644
index 08c7e0b..0000000
--- a/examples/Interpreter/src/main/java/ast/STBitwiseAndNode.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STBitwiseAndNode extends Node {
-
- public STBitwiseAndNode(int id) {
- super(id);
- }
-
- public STBitwiseAndNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // EqualityExpression()
- jjtGetChild(0).interpret();
-
- // EqualityExpression()
- jjtGetChild(1).interpret();
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() & ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() & ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STBitwiseComplNode.java b/examples/Interpreter/src/main/java/ast/STBitwiseComplNode.java
deleted file mode 100644
index e32f391..0000000
--- a/examples/Interpreter/src/main/java/ast/STBitwiseComplNode.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STBitwiseComplNode extends Node {
-
- public STBitwiseComplNode(int id) {
- super(id);
- }
-
- public STBitwiseComplNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // UnaryExpression()
- jjtGetChild(0).interpret();
-
- stack[top] = new Integer(~((Integer) stack[top]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STBitwiseOrNode.java b/examples/Interpreter/src/main/java/ast/STBitwiseOrNode.java
deleted file mode 100644
index 489d5a5..0000000
--- a/examples/Interpreter/src/main/java/ast/STBitwiseOrNode.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STBitwiseOrNode extends Node {
-
- public STBitwiseOrNode(int id) {
- super(id);
- }
-
- public STBitwiseOrNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // ExclusiveOrExpression()
- jjtGetChild(0).interpret();
-
- // ExclusiveOrExpression()
- jjtGetChild(1).interpret();
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() | ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() | ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STBitwiseXorNode.java b/examples/Interpreter/src/main/java/ast/STBitwiseXorNode.java
deleted file mode 100644
index cbea9a9..0000000
--- a/examples/Interpreter/src/main/java/ast/STBitwiseXorNode.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STBitwiseXorNode extends Node {
-
- public STBitwiseXorNode(int id) {
- super(id);
- }
-
- public STBitwiseXorNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // AndExpression()
- jjtGetChild(0).interpret();
-
- // AndExpression()
- jjtGetChild(1).interpret();
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() ^ ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() ^ ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STBlock.java b/examples/Interpreter/src/main/java/ast/STBlock.java
deleted file mode 100644
index d639532..0000000
--- a/examples/Interpreter/src/main/java/ast/STBlock.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STBlock extends Node {
-
- public STBlock(int id) {
- super(id);
- }
-
- public STBlock(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- for (Node child : children)
- // Statement()
- child.interpret();
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STCompilationUnit.java b/examples/Interpreter/src/main/java/ast/STCompilationUnit.java
deleted file mode 100644
index d16f61b..0000000
--- a/examples/Interpreter/src/main/java/ast/STCompilationUnit.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STCompilationUnit extends Node {
-
- public STCompilationUnit(int id) {
- super(id);
- }
-
- public STCompilationUnit(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- for (Node child : children) {
-
- System.out.print("Executing:");
- Token first = child.jjtGetFirstToken();
- Token last = child.jjtGetLastToken();
- for (Token t = first; t != null; t = t.next) {
- System.out.print(" " + t);
- if (t == last) break;
- }
- System.out.println();
-
- // VarDeclaration() | Statement()
- child.interpret();
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STDivNode.java b/examples/Interpreter/src/main/java/ast/STDivNode.java
deleted file mode 100644
index d7e86e7..0000000
--- a/examples/Interpreter/src/main/java/ast/STDivNode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STDivNode extends Node {
-
- public STDivNode(int id) {
- super(id);
- }
-
- public STDivNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // UnaryExpression()
- jjtGetChild(0).interpret();
-
- // UnaryExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() / ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STEQNode.java b/examples/Interpreter/src/main/java/ast/STEQNode.java
deleted file mode 100644
index 7af2a66..0000000
--- a/examples/Interpreter/src/main/java/ast/STEQNode.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STEQNode extends Node {
-
- public STEQNode(int id) {
- super(id);
- }
-
- public STEQNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // RelationalExpression()
- jjtGetChild(0).interpret();
-
- // RelationalExpression()
- jjtGetChild(1).interpret();
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() == ((Boolean) stack[top + 1]).booleanValue());
- else
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() == ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STFalseNode.java b/examples/Interpreter/src/main/java/ast/STFalseNode.java
deleted file mode 100644
index d234df3..0000000
--- a/examples/Interpreter/src/main/java/ast/STFalseNode.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STFalseNode extends Node {
-
- public STFalseNode(int id) {
- super(id);
- }
-
- public STFalseNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- stack[++top] = new Boolean(false);
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STGENode.java b/examples/Interpreter/src/main/java/ast/STGENode.java
deleted file mode 100644
index 23cd2f8..0000000
--- a/examples/Interpreter/src/main/java/ast/STGENode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STGENode extends Node {
-
- public STGENode(int id) {
- super(id);
- }
-
- public STGENode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // AdditiveExpression()
- jjtGetChild(0).interpret();
-
- // AdditiveExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() >= ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STGTNode.java b/examples/Interpreter/src/main/java/ast/STGTNode.java
deleted file mode 100644
index 0a637b7..0000000
--- a/examples/Interpreter/src/main/java/ast/STGTNode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STGTNode extends Node {
-
- public STGTNode(int id) {
- super(id);
- }
-
- public STGTNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // AdditiveExpression()
- jjtGetChild(0).interpret();
-
- // AdditiveExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() > ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STId.java b/examples/Interpreter/src/main/java/ast/STId.java
deleted file mode 100644
index 5773a1d..0000000
--- a/examples/Interpreter/src/main/java/ast/STId.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STId extends Node {
-
- String name;
-
- public STId(int id) {
- super(id);
- }
-
- public STId(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- stack[++top] = symtab.get(name);
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STIfStatement.java b/examples/Interpreter/src/main/java/ast/STIfStatement.java
deleted file mode 100644
index 14fe5ab..0000000
--- a/examples/Interpreter/src/main/java/ast/STIfStatement.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STIfStatement extends Node {
-
- public STIfStatement(int id) {
- super(id);
- }
-
- public STIfStatement(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // Expression()
- jjtGetChild(0).interpret();
-
- if (((Boolean) stack[top--]).booleanValue()) {
- // Statement()
- jjtGetChild(1).interpret();
- } else if (jjtGetNumChildren() == 3) {
- // Statement()
- jjtGetChild(2).interpret();
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STIntConstNode.java b/examples/Interpreter/src/main/java/ast/STIntConstNode.java
deleted file mode 100644
index b2eed5a..0000000
--- a/examples/Interpreter/src/main/java/ast/STIntConstNode.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STIntConstNode extends Node {
-
- int val;
-
- public STIntConstNode(int id) {
- super(id);
- }
-
- public STIntConstNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- stack[++top] = new Integer(val);
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STLENode.java b/examples/Interpreter/src/main/java/ast/STLENode.java
deleted file mode 100644
index b639a92..0000000
--- a/examples/Interpreter/src/main/java/ast/STLENode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STLENode extends Node {
-
- public STLENode(int id) {
- super(id);
- }
-
- public STLENode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // AdditiveExpression()
- jjtGetChild(0).interpret();
-
- // AdditiveExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() <= ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STLTNode.java b/examples/Interpreter/src/main/java/ast/STLTNode.java
deleted file mode 100644
index acc2f8d..0000000
--- a/examples/Interpreter/src/main/java/ast/STLTNode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STLTNode extends Node {
-
- public STLTNode(int id) {
- super(id);
- }
-
- public STLTNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // AdditiveExpression()
- jjtGetChild(0).interpret();
-
- // AdditiveExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() < ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STModNode.java b/examples/Interpreter/src/main/java/ast/STModNode.java
deleted file mode 100644
index e99dce3..0000000
--- a/examples/Interpreter/src/main/java/ast/STModNode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STModNode extends Node {
-
- public STModNode(int id) {
- super(id);
- }
-
- public STModNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // UnaryExpression()
- jjtGetChild(0).interpret();
-
- // UnaryExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() % ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STMulNode.java b/examples/Interpreter/src/main/java/ast/STMulNode.java
deleted file mode 100644
index a2715b8..0000000
--- a/examples/Interpreter/src/main/java/ast/STMulNode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STMulNode extends Node {
-
- public STMulNode(int id) {
- super(id);
- }
-
- public STMulNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // UnaryExpression()
- jjtGetChild(0).interpret();
-
- // UnaryExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() * ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STNENode.java b/examples/Interpreter/src/main/java/ast/STNENode.java
deleted file mode 100644
index b4cc4d1..0000000
--- a/examples/Interpreter/src/main/java/ast/STNENode.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STNENode extends Node {
-
- public STNENode(int id) {
- super(id);
- }
-
- public STNENode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // RelationalExpression()
- jjtGetChild(0).interpret();
-
- // RelationalExpression()
- jjtGetChild(1).interpret();
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() != ((Boolean) stack[top + 1]).booleanValue());
- else
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() != ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STNotNode.java b/examples/Interpreter/src/main/java/ast/STNotNode.java
deleted file mode 100644
index 5f2224d..0000000
--- a/examples/Interpreter/src/main/java/ast/STNotNode.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STNotNode extends Node {
-
- public STNotNode(int id) {
- super(id);
- }
-
- public STNotNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // UnaryExpression()
- jjtGetChild(0).interpret();
-
- stack[top] = new Boolean(!((Boolean) stack[top]).booleanValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STOrNode.java b/examples/Interpreter/src/main/java/ast/STOrNode.java
deleted file mode 100644
index 1442eca..0000000
--- a/examples/Interpreter/src/main/java/ast/STOrNode.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STOrNode extends Node {
-
- public STOrNode(int id) {
- super(id);
- }
-
- public STOrNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // ConditionalAndExpression()
- jjtGetChild(0).interpret();
-
- if (((Boolean) stack[top]).booleanValue()) {
- stack[top] = new Boolean(true);
- return;
- }
-
- // ConditionalAndExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() || ((Boolean) stack[top + 1]).booleanValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STReadStatement.java b/examples/Interpreter/src/main/java/ast/STReadStatement.java
deleted file mode 100644
index 826f08c..0000000
--- a/examples/Interpreter/src/main/java/ast/STReadStatement.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-import java.io.IOException;
-
-public class STReadStatement extends Node {
-
- String name;
-
- public STReadStatement(int id) {
- super(id);
- }
-
- public STReadStatement(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- Object o = symtab.get(name);
- byte[] b = new byte[64];
-
- if (o == null) {
- System.out.flush();
- System.err.println("Undefined variable : " + name);
- System.err.flush();
- System.exit(1);
- }
-
- try {
- System.out.flush();
- if (o instanceof Boolean) {
- System.out.println("Enter a value for \'" + name + "\' (boolean) : ");
- System.in.read(b);
- Boolean bb = new Boolean((new String(b)).trim());
- System.out.println("Read this value for \'" + name + "\' (boolean) : " + bb);
- symtab.put(name, bb);
- } else if (o instanceof Integer) {
- System.out.println("Enter a value for \'" + name + "\' (int) : ");
- System.in.read(b);
- Integer bi = new Integer((new String(b)).trim());
- System.out.println("Read this value for \'" + name + "\' (int) : " + bi);
- symtab.put(name, bi);
- }
- } catch (IOException ioe) {
- ioe.printStackTrace();
- System.exit(2);
- } catch (NumberFormatException nfe) {
- nfe.printStackTrace();
- System.exit(4);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(32);
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STStatementExpression.java b/examples/Interpreter/src/main/java/ast/STStatementExpression.java
deleted file mode 100644
index bdedbec..0000000
--- a/examples/Interpreter/src/main/java/ast/STStatementExpression.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STStatementExpression extends Node {
-
- public STStatementExpression(int id) {
- super(id);
- }
-
- public STStatementExpression(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // Assignment()
- jjtGetChild(0).interpret();
-
- top--; // just throw away the value.
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STSubtractNode.java b/examples/Interpreter/src/main/java/ast/STSubtractNode.java
deleted file mode 100644
index e67d16b..0000000
--- a/examples/Interpreter/src/main/java/ast/STSubtractNode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STSubtractNode extends Node {
-
- public STSubtractNode(int id) {
- super(id);
- }
-
- public STSubtractNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- // MultiplicativeExpression()
- jjtGetChild(0).interpret();
-
- // MultiplicativeExpression()
- jjtGetChild(1).interpret();
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() - ((Integer) stack[top + 1]).intValue());
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STTrueNode.java b/examples/Interpreter/src/main/java/ast/STTrueNode.java
deleted file mode 100644
index 43d6640..0000000
--- a/examples/Interpreter/src/main/java/ast/STTrueNode.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STTrueNode extends Node {
-
- public STTrueNode(int id) {
- super(id);
- }
-
- public STTrueNode(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- stack[++top] = new Boolean(true);
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STVarDeclaration.java b/examples/Interpreter/src/main/java/ast/STVarDeclaration.java
deleted file mode 100644
index 2eba0cd..0000000
--- a/examples/Interpreter/src/main/java/ast/STVarDeclaration.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STVarDeclaration extends Node implements SPLParserConstants {
-
- int type;
- String name;
-
- public STVarDeclaration(int id) {
- super(id);
- }
-
- public STVarDeclaration(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- if (type == BOOL) {
- symtab.put(name, Boolean.FALSE);
- } else {
- symtab.put(name, Integer.valueOf(0));
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STWhileStatement.java b/examples/Interpreter/src/main/java/ast/STWhileStatement.java
deleted file mode 100644
index e79a15e..0000000
--- a/examples/Interpreter/src/main/java/ast/STWhileStatement.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-public class STWhileStatement extends Node {
-
- public STWhileStatement(int id) {
- super(id);
- }
-
- public STWhileStatement(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- do {
- // Expression()
- jjtGetChild(0).interpret();
-
- if (((Boolean) stack[top--]).booleanValue()) {
- // Statement()
- jjtGetChild(1).interpret();
- } else {
- break;
- }
- } while (true);
- }
-}
diff --git a/examples/Interpreter/src/main/java/ast/STWriteStatement.java b/examples/Interpreter/src/main/java/ast/STWriteStatement.java
deleted file mode 100644
index 75b3ec3..0000000
--- a/examples/Interpreter/src/main/java/ast/STWriteStatement.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package ast;
-
-import java.io.IOException;
-
-public class STWriteStatement extends Node {
-
- String name;
-
- public STWriteStatement(int id) {
- super(id);
- }
-
- public STWriteStatement(SPLParser p, int id) {
- super(p, id);
- }
-
- public void interpret() {
- Object o = symtab.get(name);
-
- if (o == null) {
- System.out.flush();
- System.err.println("Undefined variable : " + name);
- System.err.flush();
- System.exit(-1);
- } else {
- System.out.println("Value of " + name + " : " + o);
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/vst/InterpreterVisitor.java b/examples/Interpreter/src/main/java/vst/InterpreterVisitor.java
deleted file mode 100644
index 4a13b05..0000000
--- a/examples/Interpreter/src/main/java/vst/InterpreterVisitor.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package vst;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.Stack;
-
-public class InterpreterVisitor implements SPLParserVisitor {
-
- private final InputStream in;
- private final PrintStream out;
- private final PrintStream err;
-
- /** Symbol table: key = name, val = type */
- Hashtable symtab = new Hashtable<>();
-
- /** "Stack" for calculations. */
- Object[] stack = new Object[10];
-
- // Stack nodestack;
-
- /** Top of the "stack". */
- int top = -1;
-
- InterpreterVisitor(final InputStream in, final PrintStream out, final PrintStream err) {
- this.in = in;
- this.out = out;
- this.err = err;
- }
-
- @Override
- public void visit(final Node node, Object data) {}
-
- @Override
- public void visit(final ST_CompilationUnit node, Object data) {
- if (node.children != null) {
- for (Node child : node.children) {
- out.print("Executing:");
- final Token first = child.jjtGetFirstToken();
- final Token last = child.jjtGetLastToken();
- for (Token t = first; t != null; t = t.next) {
- out.print(" " + t);
- if (t == last) break;
- }
- out.println();
- // VarDeclaration() | Statement()
- child.jjtAccept(this, data);
- }
- }
- }
-
- @Override
- public void visit(final ST_VarDeclaration node, Object data) {
- if (node.type == SPLParserConstants.BOOL) {
- symtab.put(node.name, Boolean.FALSE);
- } else {
- symtab.put(node.name, Integer.valueOf(0));
- }
- }
-
- @Override
- public void visit(final ST_Assignment node, Object data) {
- // Expression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- // PrimaryExpression()
- // note that here we do not visit the child!
- final String name = ((ST_Id) node.jjtGetChild(0)).name;
- symtab.put(name, stack[top]);
- }
-
- @Override
- public void visit(final ST_OrNode node, Object data) {
- // ConditionalAndExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- if (((Boolean) stack[top]).booleanValue()) {
- stack[top] = new Boolean(true);
- return;
- }
-
- // ConditionalAndExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() || ((Boolean) stack[top + 1]).booleanValue());
- }
-
- @Override
- public void visit(final ST_AndNode node, Object data) {
- // InclusiveOrExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- if (!((Boolean) stack[top]).booleanValue()) {
- stack[top] = new Boolean(false);
- return;
- }
-
- // InclusiveOrExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() && ((Boolean) stack[top + 1]).booleanValue());
- }
-
- @Override
- public void visit(final ST_BitwiseOrNode node, Object data) {
- // ExclusiveOrExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // ExclusiveOrExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() | ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() | ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_BitwiseXorNode node, Object data) {
- // AndExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // AndExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() ^ ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() ^ ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_BitwiseAndNode node, Object data) {
- // EqualityExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // EqualityExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() & ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() & ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_EQNode node, Object data) {
- // RelationalExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // RelationalExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() == ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() == ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_NENode node, Object data) {
- // RelationalExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // RelationalExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- if (stack[top] instanceof Boolean)
- stack[--top] =
- new Boolean(
- ((Boolean) stack[top]).booleanValue() != ((Boolean) stack[top + 1]).booleanValue());
- else if (stack[top] instanceof Integer)
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() != ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_LTNode node, Object data) {
- // AdditiveExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // AdditiveExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() < ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_GTNode node, Object data) {
- // AdditiveExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // AdditiveExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() > ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_LENode node, Object data) {
- // AdditiveExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // AdditiveExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() <= ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_GENode node, Object data) {
- // AdditiveExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // AdditiveExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Boolean(((Integer) stack[top]).intValue() >= ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_AddNode node, Object data) {
- // MultiplicativeExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // MultiplicativeExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() + ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_SubtractNode node, Object data) {
- // MultiplicativeExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // MultiplicativeExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() - ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_MulNode node, Object data) {
- // UnaryExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // UnaryExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() * ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_DivNode node, Object data) {
- // UnaryExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // UnaryExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() / ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_ModNode node, Object data) {
- // UnaryExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- // UnaryExpression()
- node.jjtGetChild(1).jjtAccept(this, data);
-
- stack[--top] =
- new Integer(((Integer) stack[top]).intValue() % ((Integer) stack[top + 1]).intValue());
- }
-
- @Override
- public void visit(final ST_BitwiseComplNode node, Object data) {
- // UnaryExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- stack[top] = new Integer(~((Integer) stack[top]).intValue());
- }
-
- @Override
- public void visit(final ST_NotNode node, Object data) {
- // UnaryExpression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- stack[top] = new Boolean(!((Boolean) stack[top]).booleanValue());
- }
-
- @Override
- public void visit(final ST_Id node, Object data) {
- stack[++top] = symtab.get(node.name);
- }
-
- @Override
- public void visit(final ST_IntConstNode node, Object data) {
- stack[++top] = new Integer(node.val);
- }
-
- @Override
- public void visit(final ST_TrueNode node, Object data) {
- stack[++top] = new Boolean(true);
- }
-
- @Override
- public void visit(final ST_FalseNode node, Object data) {
- stack[++top] = new Boolean(false);
- }
-
- @Override
- public void visit(final ST_Block node, Object data) {
- for (Node child : node.children) {
- // Statement()
- child.jjtAccept(this, data);
- }
- }
-
- @Override
- public void visit(final ST_StatementExpression node, Object data) {
- // Assignment()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- top--; // just throw away the value.
- }
-
- @Override
- public void visit(final ST_IfStatement node, Object data) {
- // Expression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- if (((Boolean) stack[top--]).booleanValue()) {
- // Statement()
- node.jjtGetChild(1).jjtAccept(this, data);
- } else if (node.jjtGetNumChildren() == 3) {
- // Statement()
- node.jjtGetChild(2).jjtAccept(this, data);
- }
- }
-
- @Override
- public void visit(final ST_WhileStatement node, Object data) {
- do {
- // Expression()
- node.jjtGetChild(0).jjtAccept(this, data);
-
- if (((Boolean) stack[top--]).booleanValue()) {
- // Statement()
- node.jjtGetChild(1).jjtAccept(this, data);
- } else {
- break;
- }
- } while (true);
- }
-
- @Override
- public void visit(final ST_ReadStatement node, Object data) {
- final String name = node.name;
- final Object o = symtab.get(name);
- byte[] b = new byte[64];
-
- if (o == null) {
- out.flush();
- err.println("Undefined variable : " + name);
- err.flush();
- System.exit(1);
- }
-
- try {
- out.flush();
- if (o instanceof Boolean) {
- out.println("Enter a value for \'" + name + "\' (boolean) : ");
- in.read(b);
- Boolean bb = new Boolean((new String(b)).trim());
- out.println("Read this value for \'" + name + "\' (boolean) : " + bb);
- symtab.put(name, bb);
- } else if (o instanceof Integer) {
- out.println("Enter a value for \'" + name + "\' (int) : ");
- in.read(b);
- Integer bi = new Integer((new String(b)).trim());
- out.println("Read this value for \'" + name + "\' (int) : " + bi);
- symtab.put(name, bi);
- }
- } catch (IOException ioe) {
- ioe.printStackTrace();
- System.exit(2);
- } catch (NumberFormatException nfe) {
- nfe.printStackTrace();
- System.exit(4);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(32);
- }
- }
-
- @Override
- public void visit(final ST_WriteStatement node, Object data) {
- final String name = node.name;
- final Object o = symtab.get(name);
-
- if (o == null) {
- out.flush();
- err.println("Undefined variable : " + name);
- err.flush();
- System.exit(-1);
- } else {
- out.println("Value of " + name + " : " + o);
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/vst/SPLMain.java b/examples/Interpreter/src/main/java/vst/SPLMain.java
deleted file mode 100644
index 771a2c4..0000000
--- a/examples/Interpreter/src/main/java/vst/SPLMain.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package vst;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/** Simple Programming Language parser. */
-public class SPLMain {
-
- /** Main entry point. */
- public static void main(String args[]) {
- InputStream spl = null;
- InputStream input = System.in;
- PrintStream output = System.out;
- PrintStream error = System.err;
- InputStream prevInput = null;
- PrintStream prevOutput = null;
- PrintStream prevError = null;
-
- try {
- SPLParser parser;
- switch (args.length) {
- case 1:
- output.println(
- "Simple Programming Language Interpreter (VST): Reading from file "
- + args[0]
- + " . . .");
- try {
- parser = new SPLParser(new FileInputStream(args[0]));
- } catch (FileNotFoundException e) {
- error.println(
- "Simple Programming Language Interpreter (VST): File "
- + args[0]
- + " not found.");
- return;
- }
- break;
- case 4:
- spl = new FileInputStream(args[0]);
- prevInput = input;
- input = new FileInputStream(args[1]);
- System.setIn(input);
- prevOutput = output;
- output = new PrintStream(args[2]);
- System.setOut(output);
- prevError = error;
- error = new PrintStream(args[3]);
- System.setErr(error);
- parser = new SPLParser(spl);
- break;
- default:
- output.println("Simple Programming Language Interpreter (VST): Usage :");
- output.println(" java SPLMain spl [in out err]");
- return;
- }
- parser.CompilationUnit();
- final InterpreterVisitor vis = new InterpreterVisitor(input, output, error);
- parser.jjtree.rootNode().jjtAccept(vis, new Object());
- } catch (ParseException e) {
- error.println(
- "Simple Programming Language Interpreter (VST): Encountered errors during parse.");
- e.printStackTrace();
- } catch (Exception e1) {
- error.println(
- "Simple Programming Language Interpreter (VST): Encountered errors during interpretation/tree building.");
- e1.printStackTrace();
- } finally {
- try {
- input.close();
- output.close();
- error.close();
- } catch (IOException e) {
- }
- if (prevInput != null) System.setIn(prevInput);
- if (prevOutput != null) System.setOut(prevOutput);
- if (prevError != null) System.setErr(prevError);
- }
- }
-}
diff --git a/examples/Interpreter/src/main/java/vst/ST_Id.java b/examples/Interpreter/src/main/java/vst/ST_Id.java
deleted file mode 100644
index ddc4bb7..0000000
--- a/examples/Interpreter/src/main/java/vst/ST_Id.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package vst;
-
-public class ST_Id extends Node {
-
- String name;
-
- public ST_Id(int id) {
- super(id);
- }
-
- public ST_Id(SPLParser p, int id) {
- super(p, id);
- }
-
- /** Accept the visitor. */
- public void jjtAccept(SPLParserVisitor visitor, Object data) {
- visitor.visit(this, data);
- }
-}
diff --git a/examples/Interpreter/src/main/java/vst/ST_IntConstNode.java b/examples/Interpreter/src/main/java/vst/ST_IntConstNode.java
deleted file mode 100644
index a13e25f..0000000
--- a/examples/Interpreter/src/main/java/vst/ST_IntConstNode.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package vst;
-
-public class ST_IntConstNode extends Node {
-
- int val;
-
- public ST_IntConstNode(int id) {
- super(id);
- }
-
- public ST_IntConstNode(SPLParser p, int id) {
- super(p, id);
- }
-
- /** Accept the visitor. */
- public void jjtAccept(SPLParserVisitor visitor, Object data) {
- visitor.visit(this, data);
- }
-}
diff --git a/examples/Interpreter/src/main/java/vst/ST_ReadStatement.java b/examples/Interpreter/src/main/java/vst/ST_ReadStatement.java
deleted file mode 100644
index 8c2c56d..0000000
--- a/examples/Interpreter/src/main/java/vst/ST_ReadStatement.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package vst;
-
-class ST_ReadStatement extends Node {
-
- String name;
-
- public ST_ReadStatement(int id) {
- super(id);
- }
-
- public ST_ReadStatement(SPLParser p, int id) {
- super(p, id);
- }
-
- /** Accept the visitor. */
- public void jjtAccept(SPLParserVisitor visitor, Object data) {
- visitor.visit(this, data);
- }
-}
diff --git a/examples/Interpreter/src/main/java/vst/ST_VarDeclaration.java b/examples/Interpreter/src/main/java/vst/ST_VarDeclaration.java
deleted file mode 100644
index 9fbf2d6..0000000
--- a/examples/Interpreter/src/main/java/vst/ST_VarDeclaration.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package vst;
-
-public class ST_VarDeclaration extends Node {
-
- int type;
- String name;
-
- public ST_VarDeclaration(int id) {
- super(id);
- }
-
- public ST_VarDeclaration(SPLParser p, int id) {
- super(p, id);
- }
-
- /** Accept the visitor. */
- public void jjtAccept(SPLParserVisitor visitor, Object data) {
- visitor.visit(this, data);
- }
-}
diff --git a/examples/Interpreter/src/main/java/vst/ST_WriteStatement.java b/examples/Interpreter/src/main/java/vst/ST_WriteStatement.java
deleted file mode 100644
index 610fc06..0000000
--- a/examples/Interpreter/src/main/java/vst/ST_WriteStatement.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package vst;
-
-class ST_WriteStatement extends Node {
-
- String name;
-
- public ST_WriteStatement(int id) {
- super(id);
- }
-
- public ST_WriteStatement(SPLParser p, int id) {
- super(p, id);
- }
-
- /** Accept the visitor. */
- public void jjtAccept(SPLParserVisitor visitor, Object data) {
- visitor.visit(this, data);
- }
-}
diff --git a/examples/Interpreter/src/main/jjtree/AST.jjt b/examples/Interpreter/src/main/jjtree/AST.jjt
deleted file mode 100644
index e75c99e..0000000
--- a/examples/Interpreter/src/main/jjtree/AST.jjt
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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 {
- SINGLE_TREE_FILE = false; // as some node files are customized
-
- MULTI = true;
-// NODE_DEFAULT_VOID = false; // (JJTree - default false)
- NODE_EXTENDS = "MyNode";
- NODE_PACKAGE = "ast";
- NODE_PREFIX = "ST";
- TRACK_TOKENS = true;
-}
-
-PARSER_BEGIN(SPLParser)
-package ast;
-
-class SPLParser
-{
-}
-
-PARSER_END(SPLParser)
-
-
-SKIP : /* WHITE SPACE */
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| "\f"
-}
-
-TOKEN : /* Types */
-{
- < INT : "int" >
- |
- < BOOL : "boolean" >
-}
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL : ()+ >
-}
-
-/** Compilation unit. */
-void CompilationUnit() :
-{}
-{
- (
- VarDeclaration() ";"
- |
- Statement()
- )*
-
-}
-
-/** Variable declaration. */
-void VarDeclaration() :
-{ Token t; }
-{
- (
- "boolean"
- { jjtThis.type = BOOL; }
- |
- "int"
- { jjtThis.type = INT; }
- )
- t =
- { jjtThis.name = t.image; }
-}
-
-/** Expression. */
-void Expression() #void :
-{}
-{
- LOOKAHEAD( PrimaryExpression() "=" )
- Assignment()
-|
- ConditionalOrExpression()
-}
-
-/** Assignment. */
-void Assignment() #Assignment(2) :
-{}
-{
- PrimaryExpression() "=" Expression()
-}
-
-/** Conditional or expression. */
-void ConditionalOrExpression() #void :
-{}
-{
- ConditionalAndExpression()
- ( "||" ConditionalAndExpression() #OrNode(2) )*
-}
-
-/** Conditional and expression. */
-void ConditionalAndExpression() #void :
-{}
-{
- InclusiveOrExpression()
- ( "&&" InclusiveOrExpression() #AndNode(2) )*
-}
-
-/** Inclusive or expression. */
-void InclusiveOrExpression() #void :
-{}
-{
- ExclusiveOrExpression()
- ( "|" ExclusiveOrExpression() #BitwiseOrNode(2) )*
-}
-
-/** Exclusive or expression. */
-void ExclusiveOrExpression() #void :
-{}
-{
- AndExpression()
- ( "^" AndExpression() #BitwiseXorNode(2) )*
-}
-
-/** And expression. */
-void AndExpression() #void :
-{}
-{
- EqualityExpression()
- ( "&" EqualityExpression() #BitwiseAndNode(2) )*
-}
-
-/** Equality expression. */
-void EqualityExpression() #void :
-{}
-{
- RelationalExpression()
- (
- "==" RelationalExpression() #EQNode(2)
- |
- "!=" RelationalExpression() #NENode(2)
- )*
-}
-
-/** Relational expression. */
-void RelationalExpression() #void :
-{}
-{
- AdditiveExpression()
- (
- "<" AdditiveExpression() #LTNode(2)
- |
- ">" AdditiveExpression() #GTNode(2)
- |
- "<=" AdditiveExpression() #LENode(2)
- |
- ">=" AdditiveExpression() #GENode(2)
- )*
-}
-
-/** Additive expression. */
-void AdditiveExpression() #void :
-{}
-{
- MultiplicativeExpression()
- (
- "+" MultiplicativeExpression() #AddNode(2)
- |
- "-" MultiplicativeExpression() #SubtractNode(2)
- )*
-}
-
-/** Multiplicative expression. */
-void MultiplicativeExpression() #void :
-{}
-{
- UnaryExpression()
- (
- "*" UnaryExpression() #MulNode(2)
- |
- "/" UnaryExpression() #DivNode(2)
- |
- "%" UnaryExpression() #ModNode(2)
- )*
-}
-
-/** Unary expression. */
-void UnaryExpression() #void :
-{}
-{
- "~" UnaryExpression() #BitwiseComplNode(1)
-|
- "!" UnaryExpression() #NotNode(1)
-|
- PrimaryExpression()
-}
-
-/** Primary expression. */
-void PrimaryExpression() #void :
-{}
-{
- Literal()
-|
- Id()
-|
- "(" Expression() ")"
-}
-
-/** An Id. */
-void Id() :
-{ Token t; }
-{
- t =
- { jjtThis.name = t.image; }
-}
-
-/** A literal. */
-void Literal() #void :
-{ Token t; }
-{
- (
- t =
- { jjtThis.val = Integer.parseInt(t.image); }
- ) #IntConstNode
-|
- BooleanLiteral()
-}
-
-/** A boolean literal. */
-void BooleanLiteral() #void :
-{}
-{
- "true" #TrueNode
-|
- "false" #FalseNode
-}
-
-/** A statement. */
-void Statement() #void :
-{}
-{
- ";"
-|
- LOOKAHEAD(2)
- LabeledStatement()
-|
- Block()
-|
- StatementExpression()
-|
- IfStatement()
-|
- WhileStatement()
-|
- IOStatement()
-}
-
-/** A labeled statement. */
-void LabeledStatement() #void :
-{}
-{
- ":" Statement()
-}
-
-/** A block. */
-void Block() :
-{}
-{
- "{" ( Statement() )* "}"
-}
-
-/** A statement expression. */
-void StatementExpression() :
-/*
- * The last expansion of this production accepts more than the legal
- * SPL expansions for StatementExpression.
- */
-{}
-{
- Assignment() ";"
-}
-
-/** An if statement. */
-void IfStatement() :
-/*
- * The disambiguating algorithm of JavaCC automatically binds dangling
- * else's to the innermost if statement. The LOOKAHEAD specification
- * is to tell JavaCC that we know what we are doing.
- */
-{}
-{
- "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
-}
-
-/** A while statement. */
-void WhileStatement() :
-{}
-{
- "while" "(" Expression() ")" Statement()
-}
-
-/** An IO statement. */
-void IOStatement() #void :
-{}
-{
- ReadStatement()
-|
- WriteStatement()
-}
-
-/** A read statement. */
-void ReadStatement() :
-{ Token t; }
-{
- "read" t =
- { jjtThis.name = t.image; }
-}
-
-/** A write statement. */
-void WriteStatement() :
-{ Token t; }
-{
- "write" t =
- { jjtThis.name = t.image; }
-}
-
-TOKEN : /* IDENTIFIERS */
-{
- < IDENTIFIER : ( | )* >
-|
- < #LETTER : [ "a"-"z", "A"-"Z" ] >
-|
- < #DIGIT : [ "0"-"9"] >
-}
diff --git a/examples/Interpreter/src/main/jjtree/VST.jjt b/examples/Interpreter/src/main/jjtree/VST.jjt
deleted file mode 100644
index 4abca8e..0000000
--- a/examples/Interpreter/src/main/jjtree/VST.jjt
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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 {
- SINGLE_TREE_FILE = false; // as some node files are customized
-
- MULTI = true;
-// NODE_EXTENDS = "MyNode";
- NODE_PACKAGE = "vst";
- TRACK_TOKENS = true;
-
-// DEBUG_PARSER = true;
-// DEBUG_TOKEN_MANAGER = true;
-// ERROR_REPORTING = false;
-
-// NODE_DEFAULT_VOID = false;
- NODE_PREFIX = "ST_";
- VISITOR = true;
- VISITOR_DATA_TYPE = "Object";
- VISITOR_RETURN_TYPE = "void";
-}
-
-PARSER_BEGIN(SPLParser)
-package vst;
-
-class SPLParser
-{
-}
-
-PARSER_END(SPLParser)
-
-
-SKIP : /* WHITE SPACE */
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| "\f"
-}
-
-TOKEN : /* Types */
-{
- < INT : "int" >
- |
- < BOOL : "boolean" >
-}
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL : ()+ >
-}
-
-/** Compilation unit. */
-void CompilationUnit() :
-{}
-{
- (
- VarDeclaration() ";"
- |
- Statement()
- )*
-
-}
-
-/** Variable declaration. */
-void VarDeclaration() #VarDeclaration :
-{ Token t; }
-{
- (
- "boolean"
- { jjtThis.type = BOOL; }
- |
- "int"
- { jjtThis.type = INT; }
- )
- t =
- { jjtThis.name = t.image; }
-}
-
-/** Expression. */
-void Expression() #void :
-{}
-{
- LOOKAHEAD( PrimaryExpression() "=" )
- Assignment()
-|
- ConditionalOrExpression()
-}
-
-/** Assignment. */
-void Assignment() #Assignment(2) :
-{}
-{
- PrimaryExpression() "=" Expression()
-}
-
-/** Conditional or expression. */
-void ConditionalOrExpression() #void :
-{}
-{
- ConditionalAndExpression()
- ( "||" ConditionalAndExpression() #OrNode(2) )*
-}
-
-/** Conditional and expression. */
-void ConditionalAndExpression() #void :
-{}
-{
- InclusiveOrExpression()
- ( "&&" InclusiveOrExpression() #AndNode(2) )*
-}
-
-/** Inclusive or expression. */
-void InclusiveOrExpression() #void :
-{}
-{
- ExclusiveOrExpression()
- ( "|" ExclusiveOrExpression() #BitwiseOrNode(2) )*
-}
-
-/** Exclusive or expression. */
-void ExclusiveOrExpression() #void :
-{}
-{
- AndExpression()
- ( "^" AndExpression() #BitwiseXorNode(2) )*
-}
-
-/** And expression. */
-void AndExpression() #void :
-{}
-{
- EqualityExpression()
- ( "&" EqualityExpression() #BitwiseAndNode(2) )*
-}
-
-/** Equality expression. */
-void EqualityExpression() #void :
-{}
-{
- RelationalExpression()
- (
- "==" RelationalExpression() #EQNode(2)
- |
- "!=" RelationalExpression() #NENode(2)
- )*
-}
-
-/** Relational expression. */
-void RelationalExpression() #void :
-{}
-{
- AdditiveExpression()
- (
- "<" AdditiveExpression() #LTNode(2)
- |
- ">" AdditiveExpression() #GTNode(2)
- |
- "<=" AdditiveExpression() #LENode(2)
- |
- ">=" AdditiveExpression() #GENode(2)
- )*
-}
-
-/** Additive expression. */
-void AdditiveExpression() #void :
-{}
-{
- MultiplicativeExpression()
- (
- "+" MultiplicativeExpression() #AddNode(2)
-
- |
- "-" MultiplicativeExpression() #SubtractNode(2)
- )*
-}
-
-/** Multiplicative expression. */
-void MultiplicativeExpression() #void :
-{}
-{
- UnaryExpression()
- (
- "*" UnaryExpression() #MulNode(2)
- |
- "/" UnaryExpression() #DivNode(2)
- |
- "%" UnaryExpression() #ModNode(2)
- )*
-}
-
-/** Unary expression. */
-void UnaryExpression() #void :
-{}
-{
- "~" UnaryExpression() #BitwiseComplNode(1)
-|
- "!" UnaryExpression() #NotNode(1)
-|
- PrimaryExpression()
-}
-
-/** Primary expression. */
-void PrimaryExpression() #void :
-{}
-{
- Literal()
-|
- Id()
-|
- "(" Expression() ")"
-}
-
-/** An Id. */
-void Id() :
-{ Token t; }
-{
- t =
- { jjtThis.name = t.image; }
-}
-
-/** A literal. */
-void Literal() #void :
-{ Token t; }
-{
- (
- t =
- { jjtThis.val = Integer.parseInt(t.image); }
- ) #IntConstNode
-|
- BooleanLiteral()
-}
-
-/** A boolean literal. */
-void BooleanLiteral() #void :
-{}
-{
- "true" #TrueNode
-|
- "false" #FalseNode
-}
-
-/** A statement. */
-void Statement() #void :
-{}
-{
- ";"
-|
- LOOKAHEAD(2)
- LabeledStatement()
-|
- Block()
-|
- StatementExpression()
-|
- IfStatement()
-|
- WhileStatement()
-|
- IOStatement()
-}
-
-/** A labeled statement. */
-void LabeledStatement() #void :
-{}
-{
- ":" Statement()
-}
-
-/** A block. */
-void Block() :
-{}
-{
- "{" ( Statement() )* "}"
-}
-
-/** A statement expression. */
-void StatementExpression() :
-/*
- * The last expansion of this production accepts more than the legal
- * SPL expansions for StatementExpression.
- */
-{}
-{
- Assignment() ";"
-}
-
-/** An if statement. */
-void IfStatement() :
-/*
- * The disambiguating algorithm of JavaCC automatically binds dangling
- * else's to the innermost if statement. The LOOKAHEAD specification
- * is to tell JavaCC that we know what we are doing.
- */
-{}
-{
- "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
-}
-
-/** A while statement. */
-void WhileStatement() :
-{}
-{
- "while" "(" Expression() ")" Statement()
-}
-
-/** An IO statement. */
-void IOStatement() #void :
-{}
-{
- ReadStatement()
-|
- WriteStatement()
-}
-
-/** A read statement. */
-void ReadStatement() :
-{ Token t; }
-{
- "read" t =
- { jjtThis.name = t.image; }
-}
-
-/** A write statement. */
-void WriteStatement() :
-{ Token t; }
-{
- "write" t =
- { jjtThis.name = t.image; }
-}
-
-TOKEN : /* IDENTIFIERS */
-{
- < IDENTIFIER : ( | )* >
-|
- < #LETTER : [ "a"-"z", "A"-"Z" ] >
-|
- < #DIGIT : [ "0"-"9"] >
-}
diff --git a/examples/JJTree/README b/examples/JJTree/README
deleted file mode 100644
index 421a2fd..0000000
--- a/examples/JJTree/README
+++ /dev/null
@@ -1,196 +0,0 @@
-/* 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.
- */
-
-JJTreeExamples
-
-This directory contains some simple JJTree input files intended to
-illustrate some of the basic ideas. All of them are based on a
-grammar to recognize arithmetic expressions built out of identifiers
-and constants.
-
-eg1.jjt
-
-This example is just the JavaCC grammar, with a little extra code in
-the parser's main method to call the dump method on the generated
-tree. It illustrates how the default behavior of JJTree will produce
-a tree of non-terminals.
-
-eg2.jjt
-
-This example is the same grammar as eg1.jjt with modifications to
-customize the generated tree. It illustrates how unnecessary
-intermediate nodes can be suppressed and how actions in the grammar
-can attach extra information to the nodes.
-
-eg3.jjt
-
-This example is a modification of eg2.jjt with the NODE_DEFAULT_VOID
-option set. This instructs JJTree to treat all undecorated
-non-terminals as if they were decorated as #void. The default JJTree
-behavior is to treat such non-terminals as if they were decorated
-with the name of the non-terminal.
-
-eg4.jjt
-
-This is a modification of eg3.jjt with the VISITOR option set. This
-instructs JJTree to insert a jjtAccept() method into all nodes it
-generates, and to produce a visitor class. The visitor is used to
-dump the tree.
-
-Here are some instructions on how to run the examples using the Ant build scripts,
-and the output you can expect to see.
-
-eg1.jjt
--------
-
-The only bit of JJTree-specific code is an action in the start
-production that dumps the constructed parse tree when the parse is
-complete. It uses JJTree simple mode.
-
-The input file is eg1.jjt.
-
-$ ant eg1
-Buildfile: build.xml
-
-eg1:
- [mkdir] Created dir: /home/tom/javacc/javacc/examples/JJTreeExamples/eg1
- [copy] Copying 1 file to /home/tom/javacc/javacc/examples/JJTreeExamples/eg1
- [jjtree] Java Compiler Compiler Version 3.2 (Tree Builder)
- [jjtree] (type "jjtree" with no arguments for help)
- [jjtree] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg1.jjt . . .
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg1/Node.java" does not exist. Will create one.
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg1/SimpleNode.java" does not exist. Will create one.
- [jjtree] Annotated grammar generated successfully in /home/tom/javacc/javacc/examples/JJTreeExamples/eg1/eg1.jj
- [javacc] Java Compiler Compiler Version 3.2 (Parser Generator)
- [javacc] (type "javacc" with no arguments for help)
- [javacc] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg1/eg1.jj . . .
- [javacc] File "TokenMgrError.java" does not exist. Will create one.
- [javacc] File "ParseException.java" does not exist. Will create one.
- [javacc] File "Token.java" does not exist. Will create one.
- [javacc] File "SimpleCharStream.java" does not exist. Will create one.
- [javacc] Parser generated successfully.
- [javac] Compiling 11 source files to /home/tom/javacc/javacc/examples/JJTreeExamples/eg1
- [echo] *******
- [echo] ******* Now cd into the eg1 directory and run 'java eg1' ******
- [echo] *******
-
-BUILD SUCCESSFUL
-Total time: 3 seconds
-[tom@hal JJTreeExamples]$ cd eg1
-[tom@hal eg1]$ java eg1
-Reading from standard input...
-(a + b) * (c + 1);
-Start
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Identifier
- MultiplicativeExpression
- UnaryExpression
- Identifier
- UnaryExpression
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Identifier
- MultiplicativeExpression
- UnaryExpression
- Integer
-Thank you.
-
-eg2.jjt
--------
-
-This is a modification of the first example to illustrate how the
-parse tree can be customized:
-
-$ ant eg2
-Buildfile: build.xml
-
-eg2:
- [mkdir] Created dir: /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
- [copy] Copying 1 file to /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
- [copy] Copying 1 file to /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
- [jjtree] Java Compiler Compiler Version 3.2 (Tree Builder)
- [jjtree] (type "jjtree" with no arguments for help)
- [jjtree] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg2.jjt . . .
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/Node.java" does not exist. Will create one.
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/SimpleNode.java" does not exist. Will create one.
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTStart.java" does not exist. Will create one.
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTAdd.java" does not exist. Will create one.
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTMult.java" does not exist. Will create one.
- [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTInteger.java" does not exist. Will create one.
- [jjtree] Annotated grammar generated successfully in /home/tom/javacc/javacc/examples/JJTreeExamples/eg2/eg2.jj
- [javacc] Java Compiler Compiler Version 3.2 (Parser Generator)
- [javacc] (type "javacc" with no arguments for help)
- [javacc] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg2/eg2.jj . . .
- [javacc] File "TokenMgrError.java" does not exist. Will create one.
- [javacc] File "ParseException.java" does not exist. Will create one.
- [javacc] File "Token.java" does not exist. Will create one.
- [javacc] File "SimpleCharStream.java" does not exist. Will create one.
- [javacc] Parser generated successfully.
- [javac] Compiling 16 source files to /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
- [echo] *******
- [echo] ******* Now cd into the eg2 directory and run 'java eg2' ******
- [echo] *******
-
-BUILD SUCCESSFUL
-Total time: 3 seconds
-[tom@hal JJTreeExamples]$ cd eg2
-[tom@hal eg2]$ java eg2
-Reading from standard input...
-(a + b) * (c + 1);
-Start
- Mult
- Add
- Identifier: a
- Identifier: b
- Add
- Identifier: c
- Integer
-Thank you.
-
-Look at eg2.jjt to see how node annotations can be used to restructure
-the parse tree, and at ASTMyID.java to see how you can write your own
-node classes that maintain more information from the input stream.
-
-eg3.jjt
--------
-
-This example can be run in the same manner as you ran eg2.jjt.
-
-eg4.jjt
--------
-
-This example again can be run in the same manner as you ran eg2.jjt.
diff --git a/examples/JJTree/files/eg1.err b/examples/JJTree/files/eg1.err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/JJTree/files/eg1.in b/examples/JJTree/files/eg1.in
deleted file mode 100644
index 3490a8c..0000000
--- a/examples/JJTree/files/eg1.in
+++ /dev/null
@@ -1 +0,0 @@
-(a + b) * (c + 1);
\ No newline at end of file
diff --git a/examples/JJTree/files/eg1.out b/examples/JJTree/files/eg1.out
deleted file mode 100644
index d783c47..0000000
--- a/examples/JJTree/files/eg1.out
+++ /dev/null
@@ -1,23 +0,0 @@
-Start
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Identifier
- MultiplicativeExpression
- UnaryExpression
- Identifier
- UnaryExpression
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Identifier
- MultiplicativeExpression
- UnaryExpression
- Integer
-Thank you.
diff --git a/examples/JJTree/files/eg1.ref b/examples/JJTree/files/eg1.ref
deleted file mode 100644
index d783c47..0000000
--- a/examples/JJTree/files/eg1.ref
+++ /dev/null
@@ -1,23 +0,0 @@
-Start
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Identifier
- MultiplicativeExpression
- UnaryExpression
- Identifier
- UnaryExpression
- Expression
- AdditiveExpression
- MultiplicativeExpression
- UnaryExpression
- Identifier
- MultiplicativeExpression
- UnaryExpression
- Integer
-Thank you.
diff --git a/examples/JJTree/files/eg2.err b/examples/JJTree/files/eg2.err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/JJTree/files/eg2.in b/examples/JJTree/files/eg2.in
deleted file mode 100644
index 3490a8c..0000000
--- a/examples/JJTree/files/eg2.in
+++ /dev/null
@@ -1 +0,0 @@
-(a + b) * (c + 1);
\ No newline at end of file
diff --git a/examples/JJTree/files/eg2.out b/examples/JJTree/files/eg2.out
deleted file mode 100644
index b174554..0000000
--- a/examples/JJTree/files/eg2.out
+++ /dev/null
@@ -1,9 +0,0 @@
-Start
- Mult
- Add
- Identifier: a
- Identifier: b
- Add
- Identifier: c
- Integer
-Thank you.
diff --git a/examples/JJTree/files/eg2.ref b/examples/JJTree/files/eg2.ref
deleted file mode 100644
index b174554..0000000
--- a/examples/JJTree/files/eg2.ref
+++ /dev/null
@@ -1,9 +0,0 @@
-Start
- Mult
- Add
- Identifier: a
- Identifier: b
- Add
- Identifier: c
- Integer
-Thank you.
diff --git a/examples/JJTree/files/eg3.err b/examples/JJTree/files/eg3.err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/JJTree/files/eg3.in b/examples/JJTree/files/eg3.in
deleted file mode 100644
index 3490a8c..0000000
--- a/examples/JJTree/files/eg3.in
+++ /dev/null
@@ -1 +0,0 @@
-(a + b) * (c + 1);
\ No newline at end of file
diff --git a/examples/JJTree/files/eg3.out b/examples/JJTree/files/eg3.out
deleted file mode 100644
index b174554..0000000
--- a/examples/JJTree/files/eg3.out
+++ /dev/null
@@ -1,9 +0,0 @@
-Start
- Mult
- Add
- Identifier: a
- Identifier: b
- Add
- Identifier: c
- Integer
-Thank you.
diff --git a/examples/JJTree/files/eg3.ref b/examples/JJTree/files/eg3.ref
deleted file mode 100644
index b174554..0000000
--- a/examples/JJTree/files/eg3.ref
+++ /dev/null
@@ -1,9 +0,0 @@
-Start
- Mult
- Add
- Identifier: a
- Identifier: b
- Add
- Identifier: c
- Integer
-Thank you.
diff --git a/examples/JJTree/files/eg4.err b/examples/JJTree/files/eg4.err
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/JJTree/files/eg4.in b/examples/JJTree/files/eg4.in
deleted file mode 100644
index 3490a8c..0000000
--- a/examples/JJTree/files/eg4.in
+++ /dev/null
@@ -1 +0,0 @@
-(a + b) * (c + 1);
\ No newline at end of file
diff --git a/examples/JJTree/files/eg4.out b/examples/JJTree/files/eg4.out
deleted file mode 100644
index b174554..0000000
--- a/examples/JJTree/files/eg4.out
+++ /dev/null
@@ -1,9 +0,0 @@
-Start
- Mult
- Add
- Identifier: a
- Identifier: b
- Add
- Identifier: c
- Integer
-Thank you.
diff --git a/examples/JJTree/files/eg4.ref b/examples/JJTree/files/eg4.ref
deleted file mode 100644
index b174554..0000000
--- a/examples/JJTree/files/eg4.ref
+++ /dev/null
@@ -1,9 +0,0 @@
-Start
- Mult
- Add
- Identifier: a
- Identifier: b
- Add
- Identifier: c
- Integer
-Thank you.
diff --git a/examples/JJTree/pom.xml b/examples/JJTree/pom.xml
deleted file mode 100644
index f5781ad..0000000
--- a/examples/JJTree/pom.xml
+++ /dev/null
@@ -1,218 +0,0 @@
-
-
-
- 4.0.0
-
- org.javacc.generator.java
- examples
- 1.1.0-SNAPSHOT
-
-
- org.javacc.generator.java.examples
- jjtree
- jar
-
- JavaCC Java code generator / examples / JJTree
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
-
- run-eg1
- test
-
- java
-
-
- eg1.Eg1
-
- ${project.basedir}/files/eg1.in
- ${project.basedir}/files/eg1.out
- ${project.basedir}/files/eg1.err
-
-
-
-
- run-eg2
- test
-
- java
-
-
- eg2.Eg2
-
- ${project.basedir}/files/eg2.in
- ${project.basedir}/files/eg2.out
- ${project.basedir}/files/eg2.err
-
-
-
-
- run-eg3
- test
-
- java
-
-
- eg3.Eg3
-
- ${project.basedir}/files/eg3.in
- ${project.basedir}/files/eg3.out
- ${project.basedir}/files/eg3.err
-
-
-
-
- run-eg4
- test
-
- java
-
-
- eg4.Eg4
-
- ${project.basedir}/files/eg4.in
- ${project.basedir}/files/eg4.out
- ${project.basedir}/files/eg4.err
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
- compare-eg1
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-eg2
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-eg3
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compare-eg4
- test
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/JJTree/src/main/java/eg2/ASTMyID.java b/examples/JJTree/src/main/java/eg2/ASTMyID.java
deleted file mode 100644
index 9c1f94f..0000000
--- a/examples/JJTree/src/main/java/eg2/ASTMyID.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package eg2;
-
-/** An ID. */
-public class ASTMyID extends Node {
- private String name;
-
- /**
- * Constructor.
- *
- * @param id the id
- */
- public ASTMyID(int id) {
- super(id);
- }
-
- /**
- * Set the name.
- *
- * @param n the name
- */
- public void setName(String n) {
- name = n;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.javacc.examples.jjtree.eg2.SimpleNode#toString()
- */
- public String toString() {
- return "Identifier: " + name;
- }
-}
diff --git a/examples/JJTree/src/main/java/eg3/ASTMyID.java b/examples/JJTree/src/main/java/eg3/ASTMyID.java
deleted file mode 100644
index 69157fc..0000000
--- a/examples/JJTree/src/main/java/eg3/ASTMyID.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package eg3;
-
-import eg3.Node;
-import eg3.ASTMyID;
-
-/** An ID. */
-public class ASTMyID extends Node {
- private String name;
-
- /**
- * Constructor.
- *
- * @param id the id
- */
- public ASTMyID(int id) {
- super(id);
- }
-
- /**
- * Set the name.
- *
- * @param n the name
- */
- public void setName(String n) {
- name = n;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.javacc.examples.jjtree.eg2.Node#toString()
- */
- public String toString() {
- return "Identifier: " + name;
- }
-}
diff --git a/examples/JJTree/src/main/java/eg4/ASTMyID.java b/examples/JJTree/src/main/java/eg4/ASTMyID.java
deleted file mode 100644
index d82f778..0000000
--- a/examples/JJTree/src/main/java/eg4/ASTMyID.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package eg4;
-
-import eg4.Node;
-
-/** An ID. */
-public class ASTMyID extends Node {
- private String name;
-
- /**
- * Constructor.
- *
- * @param id the id
- */
- public ASTMyID(int id) {
- super(id);
- }
-
- /**
- * Set the name.
- *
- * @param n the name
- */
- public void setName(String n) {
- name = n;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.javacc.examples.jjtree.eg2.Node#toString()
- */
- public String toString() {
- return "Identifier: " + name;
- }
-}
diff --git a/examples/JJTree/src/main/java/eg4/ASTMyOtherID.java b/examples/JJTree/src/main/java/eg4/ASTMyOtherID.java
deleted file mode 100644
index b5ddf34..0000000
--- a/examples/JJTree/src/main/java/eg4/ASTMyOtherID.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package eg4;
-
-import eg4.Eg4;
-import eg4.Eg4Visitor;
-import eg4.Node;
-
-public class ASTMyOtherID extends Node {
-
- private String name;
-
- public ASTMyOtherID(int id) {
- super(id);
- }
-
- public ASTMyOtherID(Eg4 p, int id) {
- super(p, id);
- }
-
- /**
- * Set the name.
- *
- * @param n the name
- */
- public void setName(String n) {
- name = n;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.javacc.examples.jjtree.eg2.Node#toString()
- */
- public String toString() {
- return "Identifier: " + name;
- }
-
- /** Accept the visitor. */
- public Object jjtAccept(Eg4Visitor visitor, Object data) {
- return visitor.visit(this, data);
- }
-}
diff --git a/examples/JJTree/src/main/java/eg4/Eg4DumpVisitor.java b/examples/JJTree/src/main/java/eg4/Eg4DumpVisitor.java
deleted file mode 100644
index b3ca05e..0000000
--- a/examples/JJTree/src/main/java/eg4/Eg4DumpVisitor.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package eg4;
-
-import eg4.ASTAdd;
-import eg4.ASTInteger;
-import eg4.ASTMult;
-import eg4.ASTStart;
-import eg4.Eg4Visitor;
-import eg4.Node;
-
-/**
- * This is an example of how the Visitor pattern might be used to implement the dumping code that
- * comes with Node. It's a bit long-winded, but it does illustrate a couple of the main points.
- *
- *
- * - the visitor can maintain state between the nodes that it visits (for example the current
- * indentation level).
- *
- if you don't implement a jjtAccept() method for a subclass of Node, then Node's acceptor
- * will get called.
- *
- the utility method childrenAccept() can be useful when implementing preorder or postorder
- * tree walks.
- *
- */
-public class Eg4DumpVisitor implements Eg4Visitor {
-
- private int indent = 0;
-
- private String indentString() {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < indent; ++i) {
- sb.append(' ');
- }
- return sb.toString();
- }
-
- public Object visit(Node node, Object data) {
- System.out.println(indentString() + node + ": acceptor not unimplemented in subclass?");
- ++indent;
- data = node.childrenAccept(this, data);
- --indent;
- return data;
- }
-
- public Object visit(ASTStart node, Object data) {
- System.out.println(indentString() + node);
- ++indent;
- data = node.childrenAccept(this, data);
- --indent;
- return data;
- }
-
- public Object visit(ASTAdd node, Object data) {
- System.out.println(indentString() + node);
- ++indent;
- data = node.childrenAccept(this, data);
- --indent;
- return data;
- }
-
- public Object visit(ASTMult node, Object data) {
- System.out.println(indentString() + node);
- ++indent;
- data = node.childrenAccept(this, data);
- --indent;
- return data;
- }
-
- public Object visit(ASTMyOtherID node, Object data) {
- System.out.println(indentString() + node);
- ++indent;
- data = node.childrenAccept(this, data);
- --indent;
- return data;
- }
-
- public Object visit(ASTInteger node, Object data) {
- System.out.println(indentString() + node);
- ++indent;
- data = node.childrenAccept(this, data);
- --indent;
- return data;
- }
-}
diff --git a/examples/JJTree/src/main/java/eg4/MyVisException.java b/examples/JJTree/src/main/java/eg4/MyVisException.java
deleted file mode 100644
index 8940c01..0000000
--- a/examples/JJTree/src/main/java/eg4/MyVisException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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.
- */
-package eg4;
-
-public class MyVisException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-}
diff --git a/examples/JJTree/src/main/jjtree/eg1.jjt b/examples/JJTree/src/main/jjtree/eg1.jjt
deleted file mode 100644
index ed0c479..0000000
--- a/examples/JJTree/src/main/jjtree/eg1.jjt
+++ /dev/null
@@ -1,809 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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
-{
- NODE_PACKAGE = "eg1";
-}
-
-PARSER_BEGIN(Eg1)
-package eg1;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/** An Arithmetic Grammar. */
-public class Eg1 {
-
- /** Main entry point. */
- public static void main(String args[]) throws FileNotFoundException {
- InputStream input = System.in;
- PrintStream output = System.out;
- PrintStream error = System.err;
- InputStream prevInput = null;
- PrintStream prevOutput = null;
- PrintStream prevError = null;
- if (args.length == 3) {
- prevInput = input;
- input = new FileInputStream(args[0]);
- prevOutput = output;
- output = new PrintStream(args[1]);
- prevError = error;
- error = new PrintStream(args[2]);
- System.setIn(input);
- System.setOut(output);
- System.setErr(error);
- }
- Eg1 t = new Eg1(input);
- try {
- Node n = Eg1.Start();
- n.dump("");
- output.println("Thank you.");
- } catch (Exception e) {
- error.println("Oops.");
- error.println(e.getMessage());
- e.printStackTrace();
- } finally {
- if (prevInput != null) System.setIn(prevInput);
- if (prevOutput != null) System.setOut(prevOutput);
- if (prevError != null) System.setErr(prevError);
- }
- }
-}
-
-PARSER_END(Eg1)
-
-SKIP :
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
-}
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL:
- (["l","L"])?
- | (["l","L"])?
- | (["l","L"])?
- >
-|
- < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
-|
- < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-|
- < #OCTAL_LITERAL: "0" (["0"-"7"])* >
-}
-
-TOKEN : /* IDENTIFIERS */
-{
-// < IDENTIFIER: (|)* >
- < IDENTIFIER: (|)* >
-|
- < #LETTER: ["_","a"-"z","A"-"Z"] >
-|
- < #DIGIT: ["0"-"9"] >
-}
-
-/** Main production. */
-Node Start() : {}
-{
- Expression() ";"
- { return jjtThis; }
-}
-
-/** An Expression. */
-void Expression() : {}
-{
- AdditiveExpression()
-}
-
-/** An Additive Expression. */
-void AdditiveExpression() : {}
-{
- MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
-}
-
-/** A Multiplicative Expression. */
-void MultiplicativeExpression() : {}
-{
- UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
-}
-
-/** A Unary Expression. */
-void UnaryExpression() : {}
-{
- "(" Expression() ")" | Identifier() | Integer()
-}
-
-/** An Identifier. */
-void Identifier() : {}
-{
-
-}
-
-/** An Integer. */
-void Integer() : {}
-{
-
-}
-
-TOKEN :
-{
- < IDENTIFIER2 : ()* >
-|
- < #LETTER2 :
- [ // all chars for which Character.isIdentifierStart is true
- "$",
- "A"-"Z",
- "_",
- "a"-"z",
- "\u00a2"-"\u00a5",
- "\u00aa",
- "\u00b5",
- "\u00ba",
- "\u00c0"-"\u00d6",
- "\u00d8"-"\u00f6",
- "\u00f8"-"\u021f",
- "\u0222"-"\u0233",
- "\u0250"-"\u02ad",
- "\u02b0"-"\u02b8",
- "\u02bb"-"\u02c1",
- "\u02d0"-"\u02d1",
- "\u02e0"-"\u02e4",
- "\u02ee",
- "\u037a",
- "\u0386",
- "\u0388"-"\u038a",
- "\u038c",
- "\u038e"-"\u03a1",
- "\u03a3"-"\u03ce",
- "\u03d0"-"\u03d7",
- "\u03da"-"\u03f3",
- "\u0400"-"\u0481",
- "\u048c"-"\u04c4",
- "\u04c7"-"\u04c8",
- "\u04cb"-"\u04cc",
- "\u04d0"-"\u04f5",
- "\u04f8"-"\u04f9",
- "\u0531"-"\u0556",
- "\u0559",
- "\u0561"-"\u0587",
- "\u05d0"-"\u05ea",
- "\u05f0"-"\u05f2",
- "\u0621"-"\u063a",
- "\u0640"-"\u064a",
- "\u0671"-"\u06d3",
- "\u06d5",
- "\u06e5"-"\u06e6",
- "\u06fa"-"\u06fc",
- "\u0710",
- "\u0712"-"\u072c",
- "\u0780"-"\u07a5",
- "\u0905"-"\u0939",
- "\u093d",
- "\u0950",
- "\u0958"-"\u0961",
- "\u0985"-"\u098c",
- "\u098f"-"\u0990",
- "\u0993"-"\u09a8",
- "\u09aa"-"\u09b0",
- "\u09b2",
- "\u09b6"-"\u09b9",
- "\u09dc"-"\u09dd",
- "\u09df"-"\u09e1",
- "\u09f0"-"\u09f3",
- "\u0a05"-"\u0a0a",
- "\u0a0f"-"\u0a10",
- "\u0a13"-"\u0a28",
- "\u0a2a"-"\u0a30",
- "\u0a32"-"\u0a33",
- "\u0a35"-"\u0a36",
- "\u0a38"-"\u0a39",
- "\u0a59"-"\u0a5c",
- "\u0a5e",
- "\u0a72"-"\u0a74",
- "\u0a85"-"\u0a8b",
- "\u0a8d",
- "\u0a8f"-"\u0a91",
- "\u0a93"-"\u0aa8",
- "\u0aaa"-"\u0ab0",
- "\u0ab2"-"\u0ab3",
- "\u0ab5"-"\u0ab9",
- "\u0abd",
- "\u0ad0",
- "\u0ae0",
- "\u0b05"-"\u0b0c",
- "\u0b0f"-"\u0b10",
- "\u0b13"-"\u0b28",
- "\u0b2a"-"\u0b30",
- "\u0b32"-"\u0b33",
- "\u0b36"-"\u0b39",
- "\u0b3d",
- "\u0b5c"-"\u0b5d",
- "\u0b5f"-"\u0b61",
- "\u0b85"-"\u0b8a",
- "\u0b8e"-"\u0b90",
- "\u0b92"-"\u0b95",
- "\u0b99"-"\u0b9a",
- "\u0b9c",
- "\u0b9e"-"\u0b9f",
- "\u0ba3"-"\u0ba4",
- "\u0ba8"-"\u0baa",
- "\u0bae"-"\u0bb5",
- "\u0bb7"-"\u0bb9",
- "\u0c05"-"\u0c0c",
- "\u0c0e"-"\u0c10",
- "\u0c12"-"\u0c28",
- "\u0c2a"-"\u0c33",
- "\u0c35"-"\u0c39",
- "\u0c60"-"\u0c61",
- "\u0c85"-"\u0c8c",
- "\u0c8e"-"\u0c90",
- "\u0c92"-"\u0ca8",
- "\u0caa"-"\u0cb3",
- "\u0cb5"-"\u0cb9",
- "\u0cde",
- "\u0ce0"-"\u0ce1",
- "\u0d05"-"\u0d0c",
- "\u0d0e"-"\u0d10",
- "\u0d12"-"\u0d28",
- "\u0d2a"-"\u0d39",
- "\u0d60"-"\u0d61",
- "\u0d85"-"\u0d96",
- "\u0d9a"-"\u0db1",
- "\u0db3"-"\u0dbb",
- "\u0dbd",
- "\u0dc0"-"\u0dc6",
- "\u0e01"-"\u0e30",
- "\u0e32"-"\u0e33",
- "\u0e3f"-"\u0e46",
- "\u0e81"-"\u0e82",
- "\u0e84",
- "\u0e87"-"\u0e88",
- "\u0e8a",
- "\u0e8d",
- "\u0e94"-"\u0e97",
- "\u0e99"-"\u0e9f",
- "\u0ea1"-"\u0ea3",
- "\u0ea5",
- "\u0ea7",
- "\u0eaa"-"\u0eab",
- "\u0ead"-"\u0eb0",
- "\u0eb2"-"\u0eb3",
- "\u0ebd",
- "\u0ec0"-"\u0ec4",
- "\u0ec6",
- "\u0edc"-"\u0edd",
- "\u0f00",
- "\u0f40"-"\u0f47",
- "\u0f49"-"\u0f6a",
- "\u0f88"-"\u0f8b",
- "\u1000"-"\u1021",
- "\u1023"-"\u1027",
- "\u1029"-"\u102a",
- "\u1050"-"\u1055",
- "\u10a0"-"\u10c5",
- "\u10d0"-"\u10f6",
- "\u1100"-"\u1159",
- "\u115f"-"\u11a2",
- "\u11a8"-"\u11f9",
- "\u1200"-"\u1206",
- "\u1208"-"\u1246",
- "\u1248",
- "\u124a"-"\u124d",
- "\u1250"-"\u1256",
- "\u1258",
- "\u125a"-"\u125d",
- "\u1260"-"\u1286",
- "\u1288",
- "\u128a"-"\u128d",
- "\u1290"-"\u12ae",
- "\u12b0",
- "\u12b2"-"\u12b5",
- "\u12b8"-"\u12be",
- "\u12c0",
- "\u12c2"-"\u12c5",
- "\u12c8"-"\u12ce",
- "\u12d0"-"\u12d6",
- "\u12d8"-"\u12ee",
- "\u12f0"-"\u130e",
- "\u1310",
- "\u1312"-"\u1315",
- "\u1318"-"\u131e",
- "\u1320"-"\u1346",
- "\u1348"-"\u135a",
- "\u13a0"-"\u13f4",
- "\u1401"-"\u166c",
- "\u166f"-"\u1676",
- "\u1681"-"\u169a",
- "\u16a0"-"\u16ea",
- "\u1780"-"\u17b3",
- "\u17db",
- "\u1820"-"\u1877",
- "\u1880"-"\u18a8",
- "\u1e00"-"\u1e9b",
- "\u1ea0"-"\u1ef9",
- "\u1f00"-"\u1f15",
- "\u1f18"-"\u1f1d",
- "\u1f20"-"\u1f45",
- "\u1f48"-"\u1f4d",
- "\u1f50"-"\u1f57",
- "\u1f59",
- "\u1f5b",
- "\u1f5d",
- "\u1f5f"-"\u1f7d",
- "\u1f80"-"\u1fb4",
- "\u1fb6"-"\u1fbc",
- "\u1fbe",
- "\u1fc2"-"\u1fc4",
- "\u1fc6"-"\u1fcc",
- "\u1fd0"-"\u1fd3",
- "\u1fd6"-"\u1fdb",
- "\u1fe0"-"\u1fec",
- "\u1ff2"-"\u1ff4",
- "\u1ff6"-"\u1ffc",
- "\u203f"-"\u2040",
- "\u207f",
- "\u20a0"-"\u20af",
- "\u2102",
- "\u2107",
- "\u210a"-"\u2113",
- "\u2115",
- "\u2119"-"\u211d",
- "\u2124",
- "\u2126",
- "\u2128",
- "\u212a"-"\u212d",
- "\u212f"-"\u2131",
- "\u2133"-"\u2139",
- "\u2160"-"\u2183",
- "\u3005"-"\u3007",
- "\u3021"-"\u3029",
- "\u3031"-"\u3035",
- "\u3038"-"\u303a",
- "\u3041"-"\u3094",
- "\u309d"-"\u309e",
- "\u30a1"-"\u30fe",
- "\u3105"-"\u312c",
- "\u3131"-"\u318e",
- "\u31a0"-"\u31b7",
- "\u3400"-"\u4db5",
- "\u4e00"-"\u9fa5",
- "\ua000"-"\ua48c",
- "\uac00"-"\ud7a3",
- "\uf900"-"\ufa2d",
- "\ufb00"-"\ufb06",
- "\ufb13"-"\ufb17",
- "\ufb1d",
- "\ufb1f"-"\ufb28",
- "\ufb2a"-"\ufb36",
- "\ufb38"-"\ufb3c",
- "\ufb3e",
- "\ufb40"-"\ufb41",
- "\ufb43"-"\ufb44",
- "\ufb46"-"\ufbb1",
- "\ufbd3"-"\ufd3d",
- "\ufd50"-"\ufd8f",
- "\ufd92"-"\ufdc7",
- "\ufdf0"-"\ufdfb",
- "\ufe33"-"\ufe34",
- "\ufe4d"-"\ufe4f",
- "\ufe69",
- "\ufe70"-"\ufe72",
- "\ufe74",
- "\ufe76"-"\ufefc",
- "\uff04",
- "\uff21"-"\uff3a",
- "\uff3f",
- "\uff41"-"\uff5a",
- "\uff65"-"\uffbe",
- "\uffc2"-"\uffc7",
- "\uffca"-"\uffcf",
- "\uffd2"-"\uffd7",
- "\uffda"-"\uffdc",
- "\uffe0"-"\uffe1",
- "\uffe5"-"\uffe6"
- ]
- >
-|
- < #PART_LETTER2 :
- [ // all chars for which Character.isIdentifierPart is true
- "\u0000"-"\u0008",
- "\u000e"-"\u001b",
- "$",
- "0"-"9",
- "A"-"Z",
- "_",
- "a"-"z",
- "\u007f"-"\u009f",
- "\u00a2"-"\u00a5",
- "\u00aa",
- "\u00b5",
- "\u00ba",
- "\u00c0"-"\u00d6",
- "\u00d8"-"\u00f6",
- "\u00f8"-"\u021f",
- "\u0222"-"\u0233",
- "\u0250"-"\u02ad",
- "\u02b0"-"\u02b8",
- "\u02bb"-"\u02c1",
- "\u02d0"-"\u02d1",
- "\u02e0"-"\u02e4",
- "\u02ee",
- "\u0300"-"\u034e",
- "\u0360"-"\u0362",
- "\u037a",
- "\u0386",
- "\u0388"-"\u038a",
- "\u038c",
- "\u038e"-"\u03a1",
- "\u03a3"-"\u03ce",
- "\u03d0"-"\u03d7",
- "\u03da"-"\u03f3",
- "\u0400"-"\u0481",
- "\u0483"-"\u0486",
- "\u048c"-"\u04c4",
- "\u04c7"-"\u04c8",
- "\u04cb"-"\u04cc",
- "\u04d0"-"\u04f5",
- "\u04f8"-"\u04f9",
- "\u0531"-"\u0556",
- "\u0559",
- "\u0561"-"\u0587",
- "\u0591"-"\u05a1",
- "\u05a3"-"\u05b9",
- "\u05bb"-"\u05bd",
- "\u05bf",
- "\u05c1"-"\u05c2",
- "\u05c4",
- "\u05d0"-"\u05ea",
- "\u05f0"-"\u05f2",
- "\u0621"-"\u063a",
- "\u0640"-"\u0655",
- "\u0660"-"\u0669",
- "\u0670"-"\u06d3",
- "\u06d5"-"\u06dc",
- "\u06df"-"\u06e8",
- "\u06ea"-"\u06ed",
- "\u06f0"-"\u06fc",
- "\u070f"-"\u072c",
- "\u0730"-"\u074a",
- "\u0780"-"\u07b0",
- "\u0901"-"\u0903",
- "\u0905"-"\u0939",
- "\u093c"-"\u094d",
- "\u0950"-"\u0954",
- "\u0958"-"\u0963",
- "\u0966"-"\u096f",
- "\u0981"-"\u0983",
- "\u0985"-"\u098c",
- "\u098f"-"\u0990",
- "\u0993"-"\u09a8",
- "\u09aa"-"\u09b0",
- "\u09b2",
- "\u09b6"-"\u09b9",
- "\u09bc",
- "\u09be"-"\u09c4",
- "\u09c7"-"\u09c8",
- "\u09cb"-"\u09cd",
- "\u09d7",
- "\u09dc"-"\u09dd",
- "\u09df"-"\u09e3",
- "\u09e6"-"\u09f3",
- "\u0a02",
- "\u0a05"-"\u0a0a",
- "\u0a0f"-"\u0a10",
- "\u0a13"-"\u0a28",
- "\u0a2a"-"\u0a30",
- "\u0a32"-"\u0a33",
- "\u0a35"-"\u0a36",
- "\u0a38"-"\u0a39",
- "\u0a3c",
- "\u0a3e"-"\u0a42",
- "\u0a47"-"\u0a48",
- "\u0a4b"-"\u0a4d",
- "\u0a59"-"\u0a5c",
- "\u0a5e",
- "\u0a66"-"\u0a74",
- "\u0a81"-"\u0a83",
- "\u0a85"-"\u0a8b",
- "\u0a8d",
- "\u0a8f"-"\u0a91",
- "\u0a93"-"\u0aa8",
- "\u0aaa"-"\u0ab0",
- "\u0ab2"-"\u0ab3",
- "\u0ab5"-"\u0ab9",
- "\u0abc"-"\u0ac5",
- "\u0ac7"-"\u0ac9",
- "\u0acb"-"\u0acd",
- "\u0ad0",
- "\u0ae0",
- "\u0ae6"-"\u0aef",
- "\u0b01"-"\u0b03",
- "\u0b05"-"\u0b0c",
- "\u0b0f"-"\u0b10",
- "\u0b13"-"\u0b28",
- "\u0b2a"-"\u0b30",
- "\u0b32"-"\u0b33",
- "\u0b36"-"\u0b39",
- "\u0b3c"-"\u0b43",
- "\u0b47"-"\u0b48",
- "\u0b4b"-"\u0b4d",
- "\u0b56"-"\u0b57",
- "\u0b5c"-"\u0b5d",
- "\u0b5f"-"\u0b61",
- "\u0b66"-"\u0b6f",
- "\u0b82"-"\u0b83",
- "\u0b85"-"\u0b8a",
- "\u0b8e"-"\u0b90",
- "\u0b92"-"\u0b95",
- "\u0b99"-"\u0b9a",
- "\u0b9c",
- "\u0b9e"-"\u0b9f",
- "\u0ba3"-"\u0ba4",
- "\u0ba8"-"\u0baa",
- "\u0bae"-"\u0bb5",
- "\u0bb7"-"\u0bb9",
- "\u0bbe"-"\u0bc2",
- "\u0bc6"-"\u0bc8",
- "\u0bca"-"\u0bcd",
- "\u0bd7",
- "\u0be7"-"\u0bef",
- "\u0c01"-"\u0c03",
- "\u0c05"-"\u0c0c",
- "\u0c0e"-"\u0c10",
- "\u0c12"-"\u0c28",
- "\u0c2a"-"\u0c33",
- "\u0c35"-"\u0c39",
- "\u0c3e"-"\u0c44",
- "\u0c46"-"\u0c48",
- "\u0c4a"-"\u0c4d",
- "\u0c55"-"\u0c56",
- "\u0c60"-"\u0c61",
- "\u0c66"-"\u0c6f",
- "\u0c82"-"\u0c83",
- "\u0c85"-"\u0c8c",
- "\u0c8e"-"\u0c90",
- "\u0c92"-"\u0ca8",
- "\u0caa"-"\u0cb3",
- "\u0cb5"-"\u0cb9",
- "\u0cbe"-"\u0cc4",
- "\u0cc6"-"\u0cc8",
- "\u0cca"-"\u0ccd",
- "\u0cd5"-"\u0cd6",
- "\u0cde",
- "\u0ce0"-"\u0ce1",
- "\u0ce6"-"\u0cef",
- "\u0d02"-"\u0d03",
- "\u0d05"-"\u0d0c",
- "\u0d0e"-"\u0d10",
- "\u0d12"-"\u0d28",
- "\u0d2a"-"\u0d39",
- "\u0d3e"-"\u0d43",
- "\u0d46"-"\u0d48",
- "\u0d4a"-"\u0d4d",
- "\u0d57",
- "\u0d60"-"\u0d61",
- "\u0d66"-"\u0d6f",
- "\u0d82"-"\u0d83",
- "\u0d85"-"\u0d96",
- "\u0d9a"-"\u0db1",
- "\u0db3"-"\u0dbb",
- "\u0dbd",
- "\u0dc0"-"\u0dc6",
- "\u0dca",
- "\u0dcf"-"\u0dd4",
- "\u0dd6",
- "\u0dd8"-"\u0ddf",
- "\u0df2"-"\u0df3",
- "\u0e01"-"\u0e3a",
- "\u0e3f"-"\u0e4e",
- "\u0e50"-"\u0e59",
- "\u0e81"-"\u0e82",
- "\u0e84",
- "\u0e87"-"\u0e88",
- "\u0e8a",
- "\u0e8d",
- "\u0e94"-"\u0e97",
- "\u0e99"-"\u0e9f",
- "\u0ea1"-"\u0ea3",
- "\u0ea5",
- "\u0ea7",
- "\u0eaa"-"\u0eab",
- "\u0ead"-"\u0eb9",
- "\u0ebb"-"\u0ebd",
- "\u0ec0"-"\u0ec4",
- "\u0ec6",
- "\u0ec8"-"\u0ecd",
- "\u0ed0"-"\u0ed9",
- "\u0edc"-"\u0edd",
- "\u0f00",
- "\u0f18"-"\u0f19",
- "\u0f20"-"\u0f29",
- "\u0f35",
- "\u0f37",
- "\u0f39",
- "\u0f3e"-"\u0f47",
- "\u0f49"-"\u0f6a",
- "\u0f71"-"\u0f84",
- "\u0f86"-"\u0f8b",
- "\u0f90"-"\u0f97",
- "\u0f99"-"\u0fbc",
- "\u0fc6",
- "\u1000"-"\u1021",
- "\u1023"-"\u1027",
- "\u1029"-"\u102a",
- "\u102c"-"\u1032",
- "\u1036"-"\u1039",
- "\u1040"-"\u1049",
- "\u1050"-"\u1059",
- "\u10a0"-"\u10c5",
- "\u10d0"-"\u10f6",
- "\u1100"-"\u1159",
- "\u115f"-"\u11a2",
- "\u11a8"-"\u11f9",
- "\u1200"-"\u1206",
- "\u1208"-"\u1246",
- "\u1248",
- "\u124a"-"\u124d",
- "\u1250"-"\u1256",
- "\u1258",
- "\u125a"-"\u125d",
- "\u1260"-"\u1286",
- "\u1288",
- "\u128a"-"\u128d",
- "\u1290"-"\u12ae",
- "\u12b0",
- "\u12b2"-"\u12b5",
- "\u12b8"-"\u12be",
- "\u12c0",
- "\u12c2"-"\u12c5",
- "\u12c8"-"\u12ce",
- "\u12d0"-"\u12d6",
- "\u12d8"-"\u12ee",
- "\u12f0"-"\u130e",
- "\u1310",
- "\u1312"-"\u1315",
- "\u1318"-"\u131e",
- "\u1320"-"\u1346",
- "\u1348"-"\u135a",
- "\u1369"-"\u1371",
- "\u13a0"-"\u13f4",
- "\u1401"-"\u166c",
- "\u166f"-"\u1676",
- "\u1681"-"\u169a",
- "\u16a0"-"\u16ea",
- "\u1780"-"\u17d3",
- "\u17db",
- "\u17e0"-"\u17e9",
- "\u180b"-"\u180e",
- "\u1810"-"\u1819",
- "\u1820"-"\u1877",
- "\u1880"-"\u18a9",
- "\u1e00"-"\u1e9b",
- "\u1ea0"-"\u1ef9",
- "\u1f00"-"\u1f15",
- "\u1f18"-"\u1f1d",
- "\u1f20"-"\u1f45",
- "\u1f48"-"\u1f4d",
- "\u1f50"-"\u1f57",
- "\u1f59",
- "\u1f5b",
- "\u1f5d",
- "\u1f5f"-"\u1f7d",
- "\u1f80"-"\u1fb4",
- "\u1fb6"-"\u1fbc",
- "\u1fbe",
- "\u1fc2"-"\u1fc4",
- "\u1fc6"-"\u1fcc",
- "\u1fd0"-"\u1fd3",
- "\u1fd6"-"\u1fdb",
- "\u1fe0"-"\u1fec",
- "\u1ff2"-"\u1ff4",
- "\u1ff6"-"\u1ffc",
- "\u200c"-"\u200f",
- "\u202a"-"\u202e",
- "\u203f"-"\u2040",
- "\u206a"-"\u206f",
- "\u207f",
- "\u20a0"-"\u20af",
- "\u20d0"-"\u20dc",
- "\u20e1",
- "\u2102",
- "\u2107",
- "\u210a"-"\u2113",
- "\u2115",
- "\u2119"-"\u211d",
- "\u2124",
- "\u2126",
- "\u2128",
- "\u212a"-"\u212d",
- "\u212f"-"\u2131",
- "\u2133"-"\u2139",
- "\u2160"-"\u2183",
- "\u3005"-"\u3007",
- "\u3021"-"\u302f",
- "\u3031"-"\u3035",
- "\u3038"-"\u303a",
- "\u3041"-"\u3094",
- "\u3099"-"\u309a",
- "\u309d"-"\u309e",
- "\u30a1"-"\u30fe",
- "\u3105"-"\u312c",
- "\u3131"-"\u318e",
- "\u31a0"-"\u31b7",
- "\u3400"-"\u4db5",
- "\u4e00"-"\u9fa5",
- "\ua000"-"\ua48c",
- "\uac00"-"\ud7a3",
- "\uf900"-"\ufa2d",
- "\ufb00"-"\ufb06",
- "\ufb13"-"\ufb17",
- "\ufb1d"-"\ufb28",
- "\ufb2a"-"\ufb36",
- "\ufb38"-"\ufb3c",
- "\ufb3e",
- "\ufb40"-"\ufb41",
- "\ufb43"-"\ufb44",
- "\ufb46"-"\ufbb1",
- "\ufbd3"-"\ufd3d",
- "\ufd50"-"\ufd8f",
- "\ufd92"-"\ufdc7",
- "\ufdf0"-"\ufdfb",
- "\ufe20"-"\ufe23",
- "\ufe33"-"\ufe34",
- "\ufe4d"-"\ufe4f",
- "\ufe69",
- "\ufe70"-"\ufe72",
- "\ufe74",
- "\ufe76"-"\ufefc",
- "\ufeff",
- "\uff04",
- "\uff10"-"\uff19",
- "\uff21"-"\uff3a",
- "\uff3f",
- "\uff41"-"\uff5a",
- "\uff65"-"\uffbe",
- "\uffc2"-"\uffc7",
- "\uffca"-"\uffcf",
- "\uffd2"-"\uffd7",
- "\uffda"-"\uffdc",
- "\uffe0"-"\uffe1",
- "\uffe5"-"\uffe6",
- "\ufff9"-"\ufffb"
- ]
- >
-}
-
diff --git a/examples/JJTree/src/main/jjtree/eg2.jjt b/examples/JJTree/src/main/jjtree/eg2.jjt
deleted file mode 100644
index 6cc6c39..0000000
--- a/examples/JJTree/src/main/jjtree/eg2.jjt
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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
-{
- KEEP_LINE_COLUMN = false;
-
- SINGLE_TREE_FILE = false; // as some node files are customized
-
- MULTI = true;
- NODE_PACKAGE = "eg2";
-}
-
-PARSER_BEGIN(Eg2)
-package eg2;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/** An Arithmetic Grammar. */
-public class Eg2 {
-
- /** Main entry point. */
- public static void main(String args[]) throws FileNotFoundException {
- InputStream input = System.in;
- PrintStream output = System.out;
- PrintStream error = System.err;
- InputStream prevInput = null;
- PrintStream prevOutput = null;
- PrintStream prevError = null;
- if (args.length == 3) {
- prevInput = input;
- input = new FileInputStream(args[0]);
- prevOutput = output;
- output = new PrintStream(args[1]);
- prevError = error;
- error = new PrintStream(args[2]);
- System.setIn(input);
- System.setOut(output);
- System.setErr(error);
- }
- Eg2 t = new Eg2(input);
- try {
- ASTStart n = t.Start();
- n.dump("");
- System.out.println("Thank you.");
- } catch (Exception e) {
- error.println("Oops.");
- error.println(e.getMessage());
- e.printStackTrace();
- } finally {
- if (prevInput != null) System.setIn(prevInput);
- if (prevOutput != null) System.setOut(prevOutput);
- if (prevError != null) System.setErr(prevError);
- }
- }
-}
-
-PARSER_END(Eg2)
-
-SKIP :
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
-}
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL:
- (["l","L"])?
- | (["l","L"])?
- | (["l","L"])?
- >
-|
- < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
-|
- < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-|
- < #OCTAL_LITERAL: "0" (["0"-"7"])* >
-}
-
-TOKEN : /* IDENTIFIERS */
-{
- < IDENTIFIER: (|)* >
-|
- < #LETTER: ["_","a"-"z","A"-"Z"] >
-|
- < #DIGIT: ["0"-"9"] >
-}
-
-/** Main production. */
-ASTStart Start() : {}
-{
- Expression() ";"
- { return jjtThis; }
-}
-
-/** An Expression. */
-void Expression() #void : {}
-{
- AdditiveExpression()
-}
-
-/** An Additive Expression. */
-void AdditiveExpression() #void : {}
-{
- (
- MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
- ) #Add(>1)
-}
-
-/** A Multiplicative Expression. */
-void MultiplicativeExpression() #void : {}
-{
- (
- UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
- ) #Mult(>1)
-}
-
-/** A Unary Expression. */
-void UnaryExpression() #void : {}
-{
- "(" Expression() ")" | MyID() | Integer()
-}
-
-/** An Identifier. */
-void MyID() :
-{
- Token t;
-}
-{
- t=
- {
- jjtThis.setName(t.image);
- }
-}
-
-/** An Integer. */
-void Integer() : {}
-{
-
-}
diff --git a/examples/JJTree/src/main/jjtree/eg3.jjt b/examples/JJTree/src/main/jjtree/eg3.jjt
deleted file mode 100644
index b135a54..0000000
--- a/examples/JJTree/src/main/jjtree/eg3.jjt
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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
-{
- SINGLE_TREE_FILE = false; // as some node files are customized
-
- MULTI = true;
- NODE_DEFAULT_VOID = true;
- NODE_PACKAGE = "eg3";
- SINGLE_TREE_FILE = false;
-}
-
-PARSER_BEGIN(Eg3)
-package eg3;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/** An Arithmetic Grammar. */
-public class Eg3 {
- /** Main entry point. */
- public static void main(String args[]) throws FileNotFoundException {
- InputStream input = System.in;
- PrintStream output = System.out;
- PrintStream error = System.err;
- InputStream prevInput = null;
- PrintStream prevOutput = null;
- PrintStream prevError = null;
- if (args.length == 3) {
- prevInput = input;
- input = new FileInputStream(args[0]);
- prevOutput = output;
- output = new PrintStream(args[1]);
- prevError = error;
- error = new PrintStream(args[2]);
- System.setIn(input);
- System.setOut(output);
- System.setErr(error);
- }
- Eg3 t = new Eg3(input);
- try {
- ASTStart n = t.Start();
- n.dump("");
- output.println("Thank you.");
- } catch (Exception e) {
- error.println("Oops.");
- error.println(e.getMessage());
- e.printStackTrace();
- } finally {
- if (prevInput != null) System.setIn(prevInput);
- if (prevOutput != null) System.setOut(prevOutput);
- if (prevError != null) System.setErr(prevError);
- }
- }
-}
-
-PARSER_END(Eg3)
-
-SKIP :
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
-}
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL:
- (["l","L"])?
- | (["l","L"])?
- | (["l","L"])?
- >
-|
- < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
-|
- < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-|
- < #OCTAL_LITERAL: "0" (["0"-"7"])* >
-}
-
-TOKEN : /* IDENTIFIERS */
-{
- < IDENTIFIER: (|)* >
-|
- < #LETTER: ["_","a"-"z","A"-"Z"] >
-|
- < #DIGIT: ["0"-"9"] >
-}
-
-/** Main production. */
-ASTStart Start() #Start : {}
-{
- Expression() ";"
- { return jjtThis; }
-}
-
-/** An Expression. */
-void Expression() : {}
-{
- AdditiveExpression()
-}
-
-/** An Additive Expression. */
-void AdditiveExpression() : {}
-{
- (
- MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
- ) #Add(>1)
-}
-
-/** A Multiplicative Expression. */
-void MultiplicativeExpression() : {}
-{
- (
- UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
- ) #Mult(>1)
-}
-
-/** A Unary Expression. */
-void UnaryExpression() : {}
-{
- "(" Expression() ")" | Identifier() | Integer()
-}
-
-/** An Identifier. */
-void Identifier() #MyID :
-{
- Token t;
-}
-{
- t=
- {
- jjtThis.setName(t.image);
- }
-}
-
-/** An Integer. */
-void Integer() #Integer : {}
-{
-
-}
diff --git a/examples/JJTree/src/main/jjtree/eg4.jjt b/examples/JJTree/src/main/jjtree/eg4.jjt
deleted file mode 100644
index c35dc0d..0000000
--- a/examples/JJTree/src/main/jjtree/eg4.jjt
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Sreeni Viswanadha .
- * Copyright (c) 2024-2025, Marc Mazas .
- * 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 names of the copyright holders 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
-{
- STATIC = false;
-
- SINGLE_TREE_FILE = false; // as some node files are customized
-
- MULTI = true;
- NODE_DEFAULT_VOID = true;
- NODE_PACKAGE = "eg4";
- VISITOR = true;
-// VISITOR_EXCEPTION = "MyVisException"; // test
-}
-
-PARSER_BEGIN(Eg4)
-package eg4;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/** An Arithmetic Grammar. */
-public class Eg4 {
-
- /** Main entry point. */
- public static void main(String args[]) throws FileNotFoundException {
- InputStream input = System.in;
- PrintStream output = System.out;
- PrintStream error = System.err;
- InputStream prevInput = null;
- PrintStream prevOutput = null;
- PrintStream prevError = null;
- if (args.length == 3) {
- prevInput = input; input = new FileInputStream(args[0]);
- prevOutput = output; output = new PrintStream(args[1]);
- prevError = error; error = new PrintStream(args[2]);
- System.setIn(input);
- System.setOut(output);
- System.setErr(error);
- }
- Eg4 t = new Eg4(input);
- try {
- ASTStart n = t.Start();
- Eg4Visitor v = new Eg4DumpVisitor();
- n.jjtAccept(v, null);
- output.println("Thank you.");
- } catch (Exception e) {
- error.println("Oops.");
- error.println(e.getMessage());
- e.printStackTrace();
- } finally {
- if (prevInput != null) System.setIn(prevInput);
- if (prevOutput != null) System.setOut(prevOutput);
- if (prevError != null) System.setErr(prevError);
- }
- }
-}
-
-PARSER_END(Eg4)
-
-
-SKIP :
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
-}
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL:
- (["l","L"])?
- | (["l","L"])?
- | (["l","L"])?
- >
-|
- < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
-|
- < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-|
- < #OCTAL_LITERAL: "0" (["0"-"7"])* >
-}
-
-TOKEN : /* IDENTIFIERS */
-{
- < IDENTIFIER: (|)* >
-|
- < #LETTER: ["_","a"-"z","A"-"Z"] >
-|
- < #DIGIT: ["0"-"9"] >
-}
-
-/** Main production. */
-ASTStart Start() #Start : {}
-{
- Expression() ";"
- { return jjtThis; }
-}
-
-
-/** An Expression. */
-void Expression() : {}
-{
- AdditiveExpression()
-}
-
-/** An Additive Expression. */
-void AdditiveExpression() : {}
-{
- (
- MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
- ) #Add(>1)
-}
-
-/** A Multiplicative Expression. */
-void MultiplicativeExpression() : {}
-{
- (
- UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
- ) #Mult(>1)
-}
-
-/** A Unary Expression. */
-void UnaryExpression() : {}
-{
- "(" Expression() ")" | Identifier() | Integer()
-}
-
-/** An Identifier. */
-void Identifier() #MyOtherID :
-{
- Token t;
-}
-{
- t=
- {
- jjtThis.setName(t.image);
- }
-}
-
-/** An Integer. */
-void Integer() #Integer : {}
-{
-
-}
diff --git a/examples/JavaCC/Java1.5.jj b/examples/JavaCC/Java1.5.jj
deleted file mode 100644
index 28e40cb..0000000
--- a/examples/JavaCC/Java1.5.jj
+++ /dev/null
@@ -1,2113 +0,0 @@
-/* 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 {
- JAVA_UNICODE_ESCAPE = true;
- ERROR_REPORTING = false;
- STATIC = false;
- COMMON_TOKEN_ACTION = false;
- TOKEN_FACTORY = "MyToken";
- JDK_VERSION = "1.5";
-}
-
-PARSER_BEGIN(JavaParser)
-
-import java.io.*;
-
-/**
- * Grammar to parse Java version 1.5
- * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
- */
-public class JavaParser
-{
- /**
- * Class to hold modifiers.
- */
- static public final class ModifierSet
- {
- /* Definitions of the bits in the modifiers field. */
- public static final int PUBLIC = 0x0001;
- public static final int PROTECTED = 0x0002;
- public static final int PRIVATE = 0x0004;
- public static final int ABSTRACT = 0x0008;
- public static final int STATIC = 0x0010;
- public static final int FINAL = 0x0020;
- public static final int SYNCHRONIZED = 0x0040;
- public static final int NATIVE = 0x0080;
- public static final int TRANSIENT = 0x0100;
- public static final int VOLATILE = 0x0200;
- public static final int STRICTFP = 0x1000;
-
- /** A set of accessors that indicate whether the specified modifier
- is in the set. */
-
- public boolean isPublic(int modifiers)
- {
- return (modifiers & PUBLIC) != 0;
- }
-
- public boolean isProtected(int modifiers)
- {
- return (modifiers & PROTECTED) != 0;
- }
-
- public boolean isPrivate(int modifiers)
- {
- return (modifiers & PRIVATE) != 0;
- }
-
- public boolean isStatic(int modifiers)
- {
- return (modifiers & STATIC) != 0;
- }
-
- public boolean isAbstract(int modifiers)
- {
- return (modifiers & ABSTRACT) != 0;
- }
-
- public boolean isFinal(int modifiers)
- {
- return (modifiers & FINAL) != 0;
- }
-
- public boolean isNative(int modifiers)
- {
- return (modifiers & NATIVE) != 0;
- }
-
- public boolean isStrictfp(int modifiers)
- {
- return (modifiers & STRICTFP) != 0;
- }
-
- public boolean isSynchronized(int modifiers)
- {
- return (modifiers & SYNCHRONIZED) != 0;
- }
-
- public boolean isTransient(int modifiers)
- {
- return (modifiers & TRANSIENT) != 0;
- }
-
- public boolean isVolatile(int modifiers)
- {
- return (modifiers & VOLATILE) != 0;
- }
-
- /**
- * Removes the given modifier.
- */
- static int removeModifier(int modifiers, int mod)
- {
- return modifiers & ~mod;
- }
- }
-
- public JavaParser(String fileName)
- {
- this(System.in);
- try { ReInit(new FileInputStream(new File(fileName))); }
- catch(Exception e) { e.printStackTrace(); }
- }
-
- public static void main(String args[]) {
- JavaParser parser;
- if (args.length == 0) {
- System.out.println("Java Parser Version 1.1: Reading from standard input . . .");
- parser = new JavaParser(System.in);
- } else if (args.length == 1) {
- System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . .");
- try {
- parser = new JavaParser(new java.io.FileInputStream(args[0]));
- } catch (java.io.FileNotFoundException e) {
- System.out.println("Java Parser Version 1.1: File " + args[0] + " not found.");
- return;
- }
- } else {
- System.out.println("Java Parser Version 1.1: Usage is one of:");
- System.out.println(" java JavaParser < inputfile");
- System.out.println("OR");
- System.out.println(" java JavaParser inputfile");
- return;
- }
- try {
- parser.CompilationUnit();
- System.out.println("Java Parser Version 1.1: Java program parsed successfully.");
- } catch (ParseException e) {
- System.out.println(e.getMessage());
- System.out.println("Java Parser Version 1.1: Encountered errors during parse.");
- }
- }
-
-}
-
-PARSER_END(JavaParser)
-
-/* WHITE SPACE */
-
-SKIP :
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| "\f"
-}
-
-/* COMMENTS */
-
-MORE :
-{
- <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
-|
- "/*" : IN_MULTI_LINE_COMMENT
-}
-
-SPECIAL_TOKEN :
-{
-
-}
-
-
-SPECIAL_TOKEN :
-{
- : DEFAULT
-}
-
-
-SPECIAL_TOKEN :
-{
- : DEFAULT
-}
-
-
-MORE :
-{
- < ~[] >
-}
-
-/* RESERVED WORDS AND LITERALS */
-
-TOKEN :
-{
- < ABSTRACT: "abstract" >
-| < ASSERT: "assert" >
-| < BOOLEAN: "boolean" >
-| < BREAK: "break" >
-| < BYTE: "byte" >
-| < CASE: "case" >
-| < CATCH: "catch" >
-| < CHAR: "char" >
-| < CLASS: "class" >
-| < CONST: "const" >
-| < CONTINUE: "continue" >
-| < _DEFAULT: "default" >
-| < DO: "do" >
-| < DOUBLE: "double" >
-| < ELSE: "else" >
-| < ENUM: "enum" >
-| < EXTENDS: "extends" >
-| < FALSE: "false" >
-| < FINAL: "final" >
-| < FINALLY: "finally" >
-| < FLOAT: "float" >
-| < FOR: "for" >
-| < GOTO: "goto" >
-| < IF: "if" >
-| < IMPLEMENTS: "implements" >
-| < IMPORT: "import" >
-| < INSTANCEOF: "instanceof" >
-| < INT: "int" >
-| < INTERFACE: "interface" >
-| < LONG: "long" >
-| < NATIVE: "native" >
-| < NEW: "new" >
-| < NULL: "null" >
-| < PACKAGE: "package">
-| < PRIVATE: "private" >
-| < PROTECTED: "protected" >
-| < PUBLIC: "public" >
-| < RETURN: "return" >
-| < SHORT: "short" >
-| < STATIC: "static" >
-| < STRICTFP: "strictfp" >
-| < SUPER: "super" >
-| < SWITCH: "switch" >
-| < SYNCHRONIZED: "synchronized" >
-| < THIS: "this" >
-| < THROW: "throw" >
-| < THROWS: "throws" >
-| < TRANSIENT: "transient" >
-| < TRUE: "true" >
-| < TRY: "try" >
-| < VOID: "void" >
-| < VOLATILE: "volatile" >
-| < WHILE: "while" >
-}
-
-/* LITERALS */
-
-TOKEN :
-{
- < INTEGER_LITERAL:
- (["l","L"])?
- | (["l","L"])?
- | (["l","L"])?
- >
-|
- < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
-|
- < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-|
- < #OCTAL_LITERAL: "0" (["0"-"7"])* >
-|
- < FLOATING_POINT_LITERAL:
-
- |
- >
-|
- < #DECIMAL_FLOATING_POINT_LITERAL:
- (["0"-"9"])+ "." (["0"-"9"])* ()? (["f","F","d","D"])?
- | "." (["0"-"9"])+ ()? (["f","F","d","D"])?
- | (["0"-"9"])+ (["f","F","d","D"])?
- | (["0"-"9"])+ ()? ["f","F","d","D"]
- >
-|
- < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
-|
- < #HEXADECIMAL_FLOATING_POINT_LITERAL:
- "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? (["f","F","d","D"])?
- | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ (["f","F","d","D"])?
- >
-|
- < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ >
-|
- < CHARACTER_LITERAL:
- "'"
- ( (~["'","\\","\n","\r"])
- | ("\\"
- ( ["n","t","b","r","f","\\","'","\""]
- | ["0"-"7"] ( ["0"-"7"] )?
- | ["0"-"3"] ["0"-"7"] ["0"-"7"]
- )
- )
- )
- "'"
- >
-|
- < STRING_LITERAL:
- "\""
- ( (~["\"","\\","\n","\r"])
- | ("\\"
- ( ["n","t","b","r","f","\\","'","\""]
- | ["0"-"7"] ( ["0"-"7"] )?
- | ["0"-"3"] ["0"-"7"] ["0"-"7"]
- )
- )
- )*
- "\""
- >
-}
-
-/* IDENTIFIERS */
-
-TOKEN :
-{
- < IDENTIFIER: ()* >
-|
- < #LETTER:
- [ // all chars for which Character.isIdentifierStart is true
- "$",
- "A"-"Z",
- "_",
- "a"-"z",
- "\u00a2"-"\u00a5",
- "\u00aa",
- "\u00b5",
- "\u00ba",
- "\u00c0"-"\u00d6",
- "\u00d8"-"\u00f6",
- "\u00f8"-"\u021f",
- "\u0222"-"\u0233",
- "\u0250"-"\u02ad",
- "\u02b0"-"\u02b8",
- "\u02bb"-"\u02c1",
- "\u02d0"-"\u02d1",
- "\u02e0"-"\u02e4",
- "\u02ee",
- "\u037a",
- "\u0386",
- "\u0388"-"\u038a",
- "\u038c",
- "\u038e"-"\u03a1",
- "\u03a3"-"\u03ce",
- "\u03d0"-"\u03d7",
- "\u03da"-"\u03f3",
- "\u0400"-"\u0481",
- "\u048c"-"\u04c4",
- "\u04c7"-"\u04c8",
- "\u04cb"-"\u04cc",
- "\u04d0"-"\u04f5",
- "\u04f8"-"\u04f9",
- "\u0531"-"\u0556",
- "\u0559",
- "\u0561"-"\u0587",
- "\u05d0"-"\u05ea",
- "\u05f0"-"\u05f2",
- "\u0621"-"\u063a",
- "\u0640"-"\u064a",
- "\u0671"-"\u06d3",
- "\u06d5",
- "\u06e5"-"\u06e6",
- "\u06fa"-"\u06fc",
- "\u0710",
- "\u0712"-"\u072c",
- "\u0780"-"\u07a5",
- "\u0905"-"\u0939",
- "\u093d",
- "\u0950",
- "\u0958"-"\u0961",
- "\u0985"-"\u098c",
- "\u098f"-"\u0990",
- "\u0993"-"\u09a8",
- "\u09aa"-"\u09b0",
- "\u09b2",
- "\u09b6"-"\u09b9",
- "\u09dc"-"\u09dd",
- "\u09df"-"\u09e1",
- "\u09f0"-"\u09f3",
- "\u0a05"-"\u0a0a",
- "\u0a0f"-"\u0a10",
- "\u0a13"-"\u0a28",
- "\u0a2a"-"\u0a30",
- "\u0a32"-"\u0a33",
- "\u0a35"-"\u0a36",
- "\u0a38"-"\u0a39",
- "\u0a59"-"\u0a5c",
- "\u0a5e",
- "\u0a72"-"\u0a74",
- "\u0a85"-"\u0a8b",
- "\u0a8d",
- "\u0a8f"-"\u0a91",
- "\u0a93"-"\u0aa8",
- "\u0aaa"-"\u0ab0",
- "\u0ab2"-"\u0ab3",
- "\u0ab5"-"\u0ab9",
- "\u0abd",
- "\u0ad0",
- "\u0ae0",
- "\u0b05"-"\u0b0c",
- "\u0b0f"-"\u0b10",
- "\u0b13"-"\u0b28",
- "\u0b2a"-"\u0b30",
- "\u0b32"-"\u0b33",
- "\u0b36"-"\u0b39",
- "\u0b3d",
- "\u0b5c"-"\u0b5d",
- "\u0b5f"-"\u0b61",
- "\u0b85"-"\u0b8a",
- "\u0b8e"-"\u0b90",
- "\u0b92"-"\u0b95",
- "\u0b99"-"\u0b9a",
- "\u0b9c",
- "\u0b9e"-"\u0b9f",
- "\u0ba3"-"\u0ba4",
- "\u0ba8"-"\u0baa",
- "\u0bae"-"\u0bb5",
- "\u0bb7"-"\u0bb9",
- "\u0c05"-"\u0c0c",
- "\u0c0e"-"\u0c10",
- "\u0c12"-"\u0c28",
- "\u0c2a"-"\u0c33",
- "\u0c35"-"\u0c39",
- "\u0c60"-"\u0c61",
- "\u0c85"-"\u0c8c",
- "\u0c8e"-"\u0c90",
- "\u0c92"-"\u0ca8",
- "\u0caa"-"\u0cb3",
- "\u0cb5"-"\u0cb9",
- "\u0cde",
- "\u0ce0"-"\u0ce1",
- "\u0d05"-"\u0d0c",
- "\u0d0e"-"\u0d10",
- "\u0d12"-"\u0d28",
- "\u0d2a"-"\u0d39",
- "\u0d60"-"\u0d61",
- "\u0d85"-"\u0d96",
- "\u0d9a"-"\u0db1",
- "\u0db3"-"\u0dbb",
- "\u0dbd",
- "\u0dc0"-"\u0dc6",
- "\u0e01"-"\u0e30",
- "\u0e32"-"\u0e33",
- "\u0e3f"-"\u0e46",
- "\u0e81"-"\u0e82",
- "\u0e84",
- "\u0e87"-"\u0e88",
- "\u0e8a",
- "\u0e8d",
- "\u0e94"-"\u0e97",
- "\u0e99"-"\u0e9f",
- "\u0ea1"-"\u0ea3",
- "\u0ea5",
- "\u0ea7",
- "\u0eaa"-"\u0eab",
- "\u0ead"-"\u0eb0",
- "\u0eb2"-"\u0eb3",
- "\u0ebd",
- "\u0ec0"-"\u0ec4",
- "\u0ec6",
- "\u0edc"-"\u0edd",
- "\u0f00",
- "\u0f40"-"\u0f47",
- "\u0f49"-"\u0f6a",
- "\u0f88"-"\u0f8b",
- "\u1000"-"\u1021",
- "\u1023"-"\u1027",
- "\u1029"-"\u102a",
- "\u1050"-"\u1055",
- "\u10a0"-"\u10c5",
- "\u10d0"-"\u10f6",
- "\u1100"-"\u1159",
- "\u115f"-"\u11a2",
- "\u11a8"-"\u11f9",
- "\u1200"-"\u1206",
- "\u1208"-"\u1246",
- "\u1248",
- "\u124a"-"\u124d",
- "\u1250"-"\u1256",
- "\u1258",
- "\u125a"-"\u125d",
- "\u1260"-"\u1286",
- "\u1288",
- "\u128a"-"\u128d",
- "\u1290"-"\u12ae",
- "\u12b0",
- "\u12b2"-"\u12b5",
- "\u12b8"-"\u12be",
- "\u12c0",
- "\u12c2"-"\u12c5",
- "\u12c8"-"\u12ce",
- "\u12d0"-"\u12d6",
- "\u12d8"-"\u12ee",
- "\u12f0"-"\u130e",
- "\u1310",
- "\u1312"-"\u1315",
- "\u1318"-"\u131e",
- "\u1320"-"\u1346",
- "\u1348"-"\u135a",
- "\u13a0"-"\u13f4",
- "\u1401"-"\u166c",
- "\u166f"-"\u1676",
- "\u1681"-"\u169a",
- "\u16a0"-"\u16ea",
- "\u1780"-"\u17b3",
- "\u17db",
- "\u1820"-"\u1877",
- "\u1880"-"\u18a8",
- "\u1e00"-"\u1e9b",
- "\u1ea0"-"\u1ef9",
- "\u1f00"-"\u1f15",
- "\u1f18"-"\u1f1d",
- "\u1f20"-"\u1f45",
- "\u1f48"-"\u1f4d",
- "\u1f50"-"\u1f57",
- "\u1f59",
- "\u1f5b",
- "\u1f5d",
- "\u1f5f"-"\u1f7d",
- "\u1f80"-"\u1fb4",
- "\u1fb6"-"\u1fbc",
- "\u1fbe",
- "\u1fc2"-"\u1fc4",
- "\u1fc6"-"\u1fcc",
- "\u1fd0"-"\u1fd3",
- "\u1fd6"-"\u1fdb",
- "\u1fe0"-"\u1fec",
- "\u1ff2"-"\u1ff4",
- "\u1ff6"-"\u1ffc",
- "\u203f"-"\u2040",
- "\u207f",
- "\u20a0"-"\u20af",
- "\u2102",
- "\u2107",
- "\u210a"-"\u2113",
- "\u2115",
- "\u2119"-"\u211d",
- "\u2124",
- "\u2126",
- "\u2128",
- "\u212a"-"\u212d",
- "\u212f"-"\u2131",
- "\u2133"-"\u2139",
- "\u2160"-"\u2183",
- "\u3005"-"\u3007",
- "\u3021"-"\u3029",
- "\u3031"-"\u3035",
- "\u3038"-"\u303a",
- "\u3041"-"\u3094",
- "\u309d"-"\u309e",
- "\u30a1"-"\u30fe",
- "\u3105"-"\u312c",
- "\u3131"-"\u318e",
- "\u31a0"-"\u31b7",
- "\u3400"-"\u4db5",
- "\u4e00"-"\u9fa5",
- "\ua000"-"\ua48c",
- "\uac00"-"\ud7a3",
- "\uf900"-"\ufa2d",
- "\ufb00"-"\ufb06",
- "\ufb13"-"\ufb17",
- "\ufb1d",
- "\ufb1f"-"\ufb28",
- "\ufb2a"-"\ufb36",
- "\ufb38"-"\ufb3c",
- "\ufb3e",
- "\ufb40"-"\ufb41",
- "\ufb43"-"\ufb44",
- "\ufb46"-"\ufbb1",
- "\ufbd3"-"\ufd3d",
- "\ufd50"-"\ufd8f",
- "\ufd92"-"\ufdc7",
- "\ufdf0"-"\ufdfb",
- "\ufe33"-"\ufe34",
- "\ufe4d"-"\ufe4f",
- "\ufe69",
- "\ufe70"-"\ufe72",
- "\ufe74",
- "\ufe76"-"\ufefc",
- "\uff04",
- "\uff21"-"\uff3a",
- "\uff3f",
- "\uff41"-"\uff5a",
- "\uff65"-"\uffbe",
- "\uffc2"-"\uffc7",
- "\uffca"-"\uffcf",
- "\uffd2"-"\uffd7",
- "\uffda"-"\uffdc",
- "\uffe0"-"\uffe1",
- "\uffe5"-"\uffe6"
- ]
- >
-|
- < #PART_LETTER:
- [ // all chars for which Character.isIdentifierPart is true
- "\u0000"-"\u0008",
- "\u000e"-"\u001b",
- "$",
- "0"-"9",
- "A"-"Z",
- "_",
- "a"-"z",
- "\u007f"-"\u009f",
- "\u00a2"-"\u00a5",
- "\u00aa",
- "\u00b5",
- "\u00ba",
- "\u00c0"-"\u00d6",
- "\u00d8"-"\u00f6",
- "\u00f8"-"\u021f",
- "\u0222"-"\u0233",
- "\u0250"-"\u02ad",
- "\u02b0"-"\u02b8",
- "\u02bb"-"\u02c1",
- "\u02d0"-"\u02d1",
- "\u02e0"-"\u02e4",
- "\u02ee",
- "\u0300"-"\u034e",
- "\u0360"-"\u0362",
- "\u037a",
- "\u0386",
- "\u0388"-"\u038a",
- "\u038c",
- "\u038e"-"\u03a1",
- "\u03a3"-"\u03ce",
- "\u03d0"-"\u03d7",
- "\u03da"-"\u03f3",
- "\u0400"-"\u0481",
- "\u0483"-"\u0486",
- "\u048c"-"\u04c4",
- "\u04c7"-"\u04c8",
- "\u04cb"-"\u04cc",
- "\u04d0"-"\u04f5",
- "\u04f8"-"\u04f9",
- "\u0531"-"\u0556",
- "\u0559",
- "\u0561"-"\u0587",
- "\u0591"-"\u05a1",
- "\u05a3"-"\u05b9",
- "\u05bb"-"\u05bd",
- "\u05bf",
- "\u05c1"-"\u05c2",
- "\u05c4",
- "\u05d0"-"\u05ea",
- "\u05f0"-"\u05f2",
- "\u0621"-"\u063a",
- "\u0640"-"\u0655",
- "\u0660"-"\u0669",
- "\u0670"-"\u06d3",
- "\u06d5"-"\u06dc",
- "\u06df"-"\u06e8",
- "\u06ea"-"\u06ed",
- "\u06f0"-"\u06fc",
- "\u070f"-"\u072c",
- "\u0730"-"\u074a",
- "\u0780"-"\u07b0",
- "\u0901"-"\u0903",
- "\u0905"-"\u0939",
- "\u093c"-"\u094d",
- "\u0950"-"\u0954",
- "\u0958"-"\u0963",
- "\u0966"-"\u096f",
- "\u0981"-"\u0983",
- "\u0985"-"\u098c",
- "\u098f"-"\u0990",
- "\u0993"-"\u09a8",
- "\u09aa"-"\u09b0",
- "\u09b2",
- "\u09b6"-"\u09b9",
- "\u09bc",
- "\u09be"-"\u09c4",
- "\u09c7"-"\u09c8",
- "\u09cb"-"\u09cd",
- "\u09d7",
- "\u09dc"-"\u09dd",
- "\u09df"-"\u09e3",
- "\u09e6"-"\u09f3",
- "\u0a02",
- "\u0a05"-"\u0a0a",
- "\u0a0f"-"\u0a10",
- "\u0a13"-"\u0a28",
- "\u0a2a"-"\u0a30",
- "\u0a32"-"\u0a33",
- "\u0a35"-"\u0a36",
- "\u0a38"-"\u0a39",
- "\u0a3c",
- "\u0a3e"-"\u0a42",
- "\u0a47"-"\u0a48",
- "\u0a4b"-"\u0a4d",
- "\u0a59"-"\u0a5c",
- "\u0a5e",
- "\u0a66"-"\u0a74",
- "\u0a81"-"\u0a83",
- "\u0a85"-"\u0a8b",
- "\u0a8d",
- "\u0a8f"-"\u0a91",
- "\u0a93"-"\u0aa8",
- "\u0aaa"-"\u0ab0",
- "\u0ab2"-"\u0ab3",
- "\u0ab5"-"\u0ab9",
- "\u0abc"-"\u0ac5",
- "\u0ac7"-"\u0ac9",
- "\u0acb"-"\u0acd",
- "\u0ad0",
- "\u0ae0",
- "\u0ae6"-"\u0aef",
- "\u0b01"-"\u0b03",
- "\u0b05"-"\u0b0c",
- "\u0b0f"-"\u0b10",
- "\u0b13"-"\u0b28",
- "\u0b2a"-"\u0b30",
- "\u0b32"-"\u0b33",
- "\u0b36"-"\u0b39",
- "\u0b3c"-"\u0b43",
- "\u0b47"-"\u0b48",
- "\u0b4b"-"\u0b4d",
- "\u0b56"-"\u0b57",
- "\u0b5c"-"\u0b5d",
- "\u0b5f"-"\u0b61",
- "\u0b66"-"\u0b6f",
- "\u0b82"-"\u0b83",
- "\u0b85"-"\u0b8a",
- "\u0b8e"-"\u0b90",
- "\u0b92"-"\u0b95",
- "\u0b99"-"\u0b9a",
- "\u0b9c",
- "\u0b9e"-"\u0b9f",
- "\u0ba3"-"\u0ba4",
- "\u0ba8"-"\u0baa",
- "\u0bae"-"\u0bb5",
- "\u0bb7"-"\u0bb9",
- "\u0bbe"-"\u0bc2",
- "\u0bc6"-"\u0bc8",
- "\u0bca"-"\u0bcd",
- "\u0bd7",
- "\u0be7"-"\u0bef",
- "\u0c01"-"\u0c03",
- "\u0c05"-"\u0c0c",
- "\u0c0e"-"\u0c10",
- "\u0c12"-"\u0c28",
- "\u0c2a"-"\u0c33",
- "\u0c35"-"\u0c39",
- "\u0c3e"-"\u0c44",
- "\u0c46"-"\u0c48",
- "\u0c4a"-"\u0c4d",
- "\u0c55"-"\u0c56",
- "\u0c60"-"\u0c61",
- "\u0c66"-"\u0c6f",
- "\u0c82"-"\u0c83",
- "\u0c85"-"\u0c8c",
- "\u0c8e"-"\u0c90",
- "\u0c92"-"\u0ca8",
- "\u0caa"-"\u0cb3",
- "\u0cb5"-"\u0cb9",
- "\u0cbe"-"\u0cc4",
- "\u0cc6"-"\u0cc8",
- "\u0cca"-"\u0ccd",
- "\u0cd5"-"\u0cd6",
- "\u0cde",
- "\u0ce0"-"\u0ce1",
- "\u0ce6"-"\u0cef",
- "\u0d02"-"\u0d03",
- "\u0d05"-"\u0d0c",
- "\u0d0e"-"\u0d10",
- "\u0d12"-"\u0d28",
- "\u0d2a"-"\u0d39",
- "\u0d3e"-"\u0d43",
- "\u0d46"-"\u0d48",
- "\u0d4a"-"\u0d4d",
- "\u0d57",
- "\u0d60"-"\u0d61",
- "\u0d66"-"\u0d6f",
- "\u0d82"-"\u0d83",
- "\u0d85"-"\u0d96",
- "\u0d9a"-"\u0db1",
- "\u0db3"-"\u0dbb",
- "\u0dbd",
- "\u0dc0"-"\u0dc6",
- "\u0dca",
- "\u0dcf"-"\u0dd4",
- "\u0dd6",
- "\u0dd8"-"\u0ddf",
- "\u0df2"-"\u0df3",
- "\u0e01"-"\u0e3a",
- "\u0e3f"-"\u0e4e",
- "\u0e50"-"\u0e59",
- "\u0e81"-"\u0e82",
- "\u0e84",
- "\u0e87"-"\u0e88",
- "\u0e8a",
- "\u0e8d",
- "\u0e94"-"\u0e97",
- "\u0e99"-"\u0e9f",
- "\u0ea1"-"\u0ea3",
- "\u0ea5",
- "\u0ea7",
- "\u0eaa"-"\u0eab",
- "\u0ead"-"\u0eb9",
- "\u0ebb"-"\u0ebd",
- "\u0ec0"-"\u0ec4",
- "\u0ec6",
- "\u0ec8"-"\u0ecd",
- "\u0ed0"-"\u0ed9",
- "\u0edc"-"\u0edd",
- "\u0f00",
- "\u0f18"-"\u0f19",
- "\u0f20"-"\u0f29",
- "\u0f35",
- "\u0f37",
- "\u0f39",
- "\u0f3e"-"\u0f47",
- "\u0f49"-"\u0f6a",
- "\u0f71"-"\u0f84",
- "\u0f86"-"\u0f8b",
- "\u0f90"-"\u0f97",
- "\u0f99"-"\u0fbc",
- "\u0fc6",
- "\u1000"-"\u1021",
- "\u1023"-"\u1027",
- "\u1029"-"\u102a",
- "\u102c"-"\u1032",
- "\u1036"-"\u1039",
- "\u1040"-"\u1049",
- "\u1050"-"\u1059",
- "\u10a0"-"\u10c5",
- "\u10d0"-"\u10f6",
- "\u1100"-"\u1159",
- "\u115f"-"\u11a2",
- "\u11a8"-"\u11f9",
- "\u1200"-"\u1206",
- "\u1208"-"\u1246",
- "\u1248",
- "\u124a"-"\u124d",
- "\u1250"-"\u1256",
- "\u1258",
- "\u125a"-"\u125d",
- "\u1260"-"\u1286",
- "\u1288",
- "\u128a"-"\u128d",
- "\u1290"-"\u12ae",
- "\u12b0",
- "\u12b2"-"\u12b5",
- "\u12b8"-"\u12be",
- "\u12c0",
- "\u12c2"-"\u12c5",
- "\u12c8"-"\u12ce",
- "\u12d0"-"\u12d6",
- "\u12d8"-"\u12ee",
- "\u12f0"-"\u130e",
- "\u1310",
- "\u1312"-"\u1315",
- "\u1318"-"\u131e",
- "\u1320"-"\u1346",
- "\u1348"-"\u135a",
- "\u1369"-"\u1371",
- "\u13a0"-"\u13f4",
- "\u1401"-"\u166c",
- "\u166f"-"\u1676",
- "\u1681"-"\u169a",
- "\u16a0"-"\u16ea",
- "\u1780"-"\u17d3",
- "\u17db",
- "\u17e0"-"\u17e9",
- "\u180b"-"\u180e",
- "\u1810"-"\u1819",
- "\u1820"-"\u1877",
- "\u1880"-"\u18a9",
- "\u1e00"-"\u1e9b",
- "\u1ea0"-"\u1ef9",
- "\u1f00"-"\u1f15",
- "\u1f18"-"\u1f1d",
- "\u1f20"-"\u1f45",
- "\u1f48"-"\u1f4d",
- "\u1f50"-"\u1f57",
- "\u1f59",
- "\u1f5b",
- "\u1f5d",
- "\u1f5f"-"\u1f7d",
- "\u1f80"-"\u1fb4",
- "\u1fb6"-"\u1fbc",
- "\u1fbe",
- "\u1fc2"-"\u1fc4",
- "\u1fc6"-"\u1fcc",
- "\u1fd0"-"\u1fd3",
- "\u1fd6"-"\u1fdb",
- "\u1fe0"-"\u1fec",
- "\u1ff2"-"\u1ff4",
- "\u1ff6"-"\u1ffc",
- "\u200c"-"\u200f",
- "\u202a"-"\u202e",
- "\u203f"-"\u2040",
- "\u206a"-"\u206f",
- "\u207f",
- "\u20a0"-"\u20af",
- "\u20d0"-"\u20dc",
- "\u20e1",
- "\u2102",
- "\u2107",
- "\u210a"-"\u2113",
- "\u2115",
- "\u2119"-"\u211d",
- "\u2124",
- "\u2126",
- "\u2128",
- "\u212a"-"\u212d",
- "\u212f"-"\u2131",
- "\u2133"-"\u2139",
- "\u2160"-"\u2183",
- "\u3005"-"\u3007",
- "\u3021"-"\u302f",
- "\u3031"-"\u3035",
- "\u3038"-"\u303a",
- "\u3041"-"\u3094",
- "\u3099"-"\u309a",
- "\u309d"-"\u309e",
- "\u30a1"-"\u30fe",
- "\u3105"-"\u312c",
- "\u3131"-"\u318e",
- "\u31a0"-"\u31b7",
- "\u3400"-"\u4db5",
- "\u4e00"-"\u9fa5",
- "\ua000"-"\ua48c",
- "\uac00"-"\ud7a3",
- "\uf900"-"\ufa2d",
- "\ufb00"-"\ufb06",
- "\ufb13"-"\ufb17",
- "\ufb1d"-"\ufb28",
- "\ufb2a"-"\ufb36",
- "\ufb38"-"\ufb3c",
- "\ufb3e",
- "\ufb40"-"\ufb41",
- "\ufb43"-"\ufb44",
- "\ufb46"-"\ufbb1",
- "\ufbd3"-"\ufd3d",
- "\ufd50"-"\ufd8f",
- "\ufd92"-"\ufdc7",
- "\ufdf0"-"\ufdfb",
- "\ufe20"-"\ufe23",
- "\ufe33"-"\ufe34",
- "\ufe4d"-"\ufe4f",
- "\ufe69",
- "\ufe70"-"\ufe72",
- "\ufe74",
- "\ufe76"-"\ufefc",
- "\ufeff",
- "\uff04",
- "\uff10"-"\uff19",
- "\uff21"-"\uff3a",
- "\uff3f",
- "\uff41"-"\uff5a",
- "\uff65"-"\uffbe",
- "\uffc2"-"\uffc7",
- "\uffca"-"\uffcf",
- "\uffd2"-"\uffd7",
- "\uffda"-"\uffdc",
- "\uffe0"-"\uffe1",
- "\uffe5"-"\uffe6",
- "\ufff9"-"\ufffb"
- ]
- >
-}
-
-/* SEPARATORS */
-
-TOKEN :
-{
- < LPAREN: "(" >
-| < RPAREN: ")" >
-| < LBRACE: "{" >
-| < RBRACE: "}" >
-| < LBRACKET: "[" >
-| < RBRACKET: "]" >
-| < SEMICOLON: ";" >
-| < COMMA: "," >
-| < DOT: "." >
-| < AT: "@" >
-}
-
-/* OPERATORS */
-
-TOKEN :
-{
- < ASSIGN: "=" >
-| < LT: "<" >
-| < BANG: "!" >
-| < TILDE: "~" >
-| < HOOK: "?" >
-| < COLON: ":" >
-| < EQ: "==" >
-| < LE: "<=" >
-| < GE: ">=" >
-| < NE: "!=" >
-| < SC_OR: "||" >
-| < SC_AND: "&&" >
-| < INCR: "++" >
-| < DECR: "--" >
-| < PLUS: "+" >
-| < MINUS: "-" >
-| < STAR: "*" >
-| < SLASH: "/" >
-| < BIT_AND: "&" >
-| < BIT_OR: "|" >
-| < XOR: "^" >
-| < REM: "%" >
-| < LSHIFT: "<<" >
-| < PLUSASSIGN: "+=" >
-| < MINUSASSIGN: "-=" >
-| < STARASSIGN: "*=" >
-| < SLASHASSIGN: "/=" >
-| < ANDASSIGN: "&=" >
-| < ORASSIGN: "|=" >
-| < XORASSIGN: "^=" >
-| < REMASSIGN: "%=" >
-| < LSHIFTASSIGN: "<<=" >
-| < RSIGNEDSHIFTASSIGN: ">>=" >
-| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
-| < ELLIPSIS: "..." >
-}
-
-/* >'s need special attention due to generics syntax. */
-TOKEN :
-{
- < RUNSIGNEDSHIFT: ">>>" >
- {
- matchedToken.kind = GT;
- ((MyToken)matchedToken).realKind = RUNSIGNEDSHIFT;
- input_stream.backup(2);
- matchedToken.image = ">";
- }
-| < RSIGNEDSHIFT: ">>" >
- {
- matchedToken.kind = GT;
- ((MyToken)matchedToken).realKind = RSIGNEDSHIFT;
- input_stream.backup(1);
- matchedToken.image = ">";
- }
-| < GT: ">" >
-}
-
-
-/*****************************************
- * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
- *****************************************/
-
-/*
- * Program structuring syntax follows.
- */
-
-void CompilationUnit():
-{}
-{
- [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ]
- ( ImportDeclaration() )*
- ( TypeDeclaration() )+
- ( < "\u001a" > )?
- ( )?
-
-}
-
-void PackageDeclaration():
-{}
-{
- Modifiers() "package" Name() ";"
-}
-
-void ImportDeclaration():
-{}
-{
- "import" [ "static" ] Name() [ "." "*" ] ";"
-}
-
-/*
- * Modifiers. We match all modifiers in a single rule to reduce the chances of
- * syntax errors for simple modifier mistakes. It will also enable us to give
- * better error messages.
- */
-
-int Modifiers():
-{
- int modifiers = 0;
-}
-{
- (
- LOOKAHEAD(2)
- (
- "public" { modifiers |= ModifierSet.PUBLIC; }
- |
- "static" { modifiers |= ModifierSet.STATIC; }
- |
- "protected" { modifiers |= ModifierSet.PROTECTED; }
- |
- "private" { modifiers |= ModifierSet.PRIVATE; }
- |
- "final" { modifiers |= ModifierSet.FINAL; }
- |
- "abstract" { modifiers |= ModifierSet.ABSTRACT; }
- |
- "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; }
- |
- "native" { modifiers |= ModifierSet.NATIVE; }
- |
- "transient" { modifiers |= ModifierSet.TRANSIENT; }
- |
- "volatile" { modifiers |= ModifierSet.VOLATILE; }
- |
- "strictfp" { modifiers |= ModifierSet.STRICTFP; }
- |
- Annotation()
- )
- )*
-
- {
- return modifiers;
- }
-}
-
-/*
- * Declaration syntax follows.
- */
-void TypeDeclaration():
-{
- int modifiers;
-}
-{
- ";"
-|
- modifiers = Modifiers()
- (
- ClassOrInterfaceDeclaration(modifiers)
- |
- EnumDeclaration(modifiers)
- |
- AnnotationTypeDeclaration(modifiers)
- )
-}
-
-
-void ClassOrInterfaceDeclaration(int modifiers):
-{
- boolean isInterface = false;
-}
-{
- ( "class" | "interface" { isInterface = true; } )
-
- [ TypeParameters() ]
- [ ExtendsList(isInterface) ]
- [ ImplementsList(isInterface) ]
- ClassOrInterfaceBody(isInterface)
-}
-
-void ExtendsList(boolean isInterface):
-{
- boolean extendsMoreThanOne = false;
-}
-{
- "extends" ClassOrInterfaceType()
- ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*
- {
- if (extendsMoreThanOne && !isInterface)
- throw new ParseException("A class cannot extend more than one other class");
- }
-}
-
-void ImplementsList(boolean isInterface):
-{}
-{
- "implements" ClassOrInterfaceType()
- ( "," ClassOrInterfaceType() )*
- {
- if (isInterface)
- throw new ParseException("An interface cannot implement other interfaces");
- }
-}
-
-void EnumDeclaration(int modifiers):
-{}
-{
- "enum"
- [ ImplementsList(false) ]
- EnumBody()
-}
-
-void EnumBody():
-{}
-{
- "{"
- [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ]
- [ "," ]
- [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ]
- "}"
-}
-
-void EnumConstant():
-{}
-{
- Modifiers() [ Arguments() ] [ ClassOrInterfaceBody(false) ]
-}
-
-void TypeParameters():
-{}
-{
- "<" TypeParameter() ( "," TypeParameter() )* ">"
-}
-
-void TypeParameter():
-{}
-{
- [ TypeBound() ]
-}
-
-void TypeBound():
-{}
-{
- "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*
-}
-
-void ClassOrInterfaceBody(boolean isInterface):
-{}
-{
- "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"
-}
-
-void ClassOrInterfaceBodyDeclaration(boolean isInterface):
-{
- boolean isNestedInterface = false;
- int modifiers;
-}
-{
- LOOKAHEAD(2)
- Initializer()
- {
- if (isInterface)
- throw new ParseException("An interface cannot have initializers");
- }
-|
- modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do
- // more checks, pass the modifiers down to the member
- (
- ClassOrInterfaceDeclaration(modifiers)
- |
- EnumDeclaration(modifiers)
- |
- LOOKAHEAD( [ TypeParameters() ] "(" )
- ConstructorDeclaration()
- |
- LOOKAHEAD( Type() ( "[" "]" )* ( "," | "=" | ";" ) )
- FieldDeclaration(modifiers)
- |
- MethodDeclaration(modifiers)
- |
- AnnotationTypeDeclaration(modifiers)
- )
-|
- ";"
-}
-
-void FieldDeclaration(int modifiers):
-{}
-{
- // Modifiers are already matched in the caller
- Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
-}
-
-void VariableDeclarator():
-{}
-{
- VariableDeclaratorId() [ "=" VariableInitializer() ]
-}
-
-void VariableDeclaratorId():
-{}
-{
- ( "[" "]" )*
-}
-
-void VariableInitializer():
-{}
-{
- ArrayInitializer()
-|
- Expression()
-}
-
-void ArrayInitializer():
-{}
-{
- "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
-}
-
-void MethodDeclaration(int modifiers):
-{}
-{
- // Modifiers already matched in the caller!
- [ TypeParameters() ]
- ResultType()
- MethodDeclarator() [ "throws" NameList() ]
- ( Block() | ";" )
-}
-
-void MethodDeclarator():
-{}
-{
- FormalParameters() ( "[" "]" )*
-}
-
-void FormalParameters():
-{}
-{
- "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
-}
-
-void FormalParameter():
-{}
-{
- // danson, added
- // [ "final" | Annotation() ]
- // See Java Language Specification, 3rd Edition, section 8.4.1
- Modifiers() [ "final" | Annotation() ] Type() [ "..." ] VariableDeclaratorId()
-}
-
-void ConstructorDeclaration():
-{}
-{
- [ TypeParameters() ]
- // Modifiers matched in the caller
- FormalParameters() [ "throws" NameList() ]
- "{"
- [ LOOKAHEAD(ExplicitConstructorInvocation())
- ExplicitConstructorInvocation()
- ]
- ( BlockStatement() )*
- "}"
-}
-
-void ExplicitConstructorInvocation():
-{}
-{
- ( "." )* [ LOOKAHEAD(2) "this" "." ]
- [ TypeArguments() ] ("this"|"super") Arguments() ";"
-}
-
-void Initializer():
-{}
-{
- [ "static" ] Block()
-}
-
-
-/*
- * Type, name and expression syntax follows.
- */
-
-void Type():
-{}
-{
- LOOKAHEAD(2) ReferenceType()
- |
- PrimitiveType()
-}
-
-void ReferenceType():
-{}
-{
- PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+
- |
- ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*
-}
-
-void ClassOrInterfaceType():
-{}
-{
- [ LOOKAHEAD(2) TypeArguments() ]
- ( LOOKAHEAD(2) "."