adds build support for split lexer parser ANTLR grammar. Adds program RuleNameList...
authorThomas Walker Lynch <xtujpz@reasoningtechnology.com>
Thu, 5 Sep 2024 07:37:08 +0000 (07:37 +0000)
committerThomas Walker Lynch <xtujpz@reasoningtechnology.com>
Thu, 5 Sep 2024 07:37:08 +0000 (07:37 +0000)
19 files changed:
README.md
developer/ANTLR/LexerAdaptor.java [new file with mode: 0644]
developer/ANTLR/grammar_rules.g4 [deleted file]
developer/executor/Arithmetic_Echo [new file with mode: 0755]
developer/executor/RuleNameList [new file with mode: 0755]
developer/executor/env_build
developer/executor/makefile-project.mk
developer/executor/makefile-top.mk
developer/javac/ANTLR_Syntax.java [deleted file]
developer/javac/ANTLR_Syntax_PrintVisitor.java [deleted file]
developer/javac/ANTLRv4_Syntax.java [new file with mode: 0644]
developer/javac/ANTLRv4_Syntax_PrintVisitor.java [new file with mode: 0644]
developer/javac/ANTLRv4_Syntax_PrintVisitor_fully_corrected.java [new file with mode: 0644]
developer/javac/PrintRuleNameListRegx.java [deleted file]
developer/javac/RuleNameList.java [new file with mode: 0644]
developer/javac/RuleNameListRegx.java [new file with mode: 0644]
developer/ologist/grammar_source.txt
developer/test/transcript_RuleNameList.sh [new file with mode: 0644]
ologist/log.md

index 59bdd0b..6d0d30a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,28 +1,26 @@
 
 # Project management
 
-Please read documents in the ./lector directory for information
-about managing this project and using the tools, if any.
+As you are reading this you might be a GQL_to_Cypter-ologist.  Please read
+documents in the ./ologist directory for project information, and the
+documents in the developer/ologist directory for documents on building
+the project.
 
-For developers, get started by typing:
+The project top level is for project management and imported tools. Developers
+do development work in the `developer` directory.
+
+For developers, from the top of the project get started by typing:
 ```
-> . developer_init
+> . executor/env_dev
 ``
 
-That is similar to the `activate` of Python.
+This will setup the environment and `cd` to the developer directory.  (`env_dev`
+is analogous to the Python virtual environment `activate`.)
 
 # About
 
-This is a transpiler from GQL to Cypher.
-
-The `syntax_recognizer` accepts a GQL query and then outputs a 
-the syntax found as an XML file.
-
-# State of development
+This is a project to develope a transpiler from GQL to Cypher.
 
-Working on the `syntax_recognizer`.
 
 
 
-<!--  LocalWords:  subdirectories transpiles Cypher transpiler
- -->
diff --git a/developer/ANTLR/LexerAdaptor.java b/developer/ANTLR/LexerAdaptor.java
new file mode 100644 (file)
index 0000000..338000e
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ [The "BSD licence"]
+ Copyright (c) 2005-2007 Terence Parr
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. 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.
+ 3. The name of the author may not be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 org.antlr.parser.antlr4;
+
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.misc.Interval;
+
+public abstract class LexerAdaptor extends Lexer {
+
+    /**
+     *  Generic type for OPTIONS, TOKENS and CHANNELS
+     */
+    private static final int PREQUEL_CONSTRUCT = -10;
+    private static final int OPTIONS_CONSTRUCT = -11;
+
+    public LexerAdaptor(CharStream input) {
+        super(input);
+    }
+
+    /**
+     * Track whether we are inside of a rule and whether it is lexical parser. _currentRuleType==Token.INVALID_TYPE
+     * means that we are outside of a rule. At the first sign of a rule name reference and _currentRuleType==invalid, we
+     * can assume that we are starting a parser rule. Similarly, seeing a token reference when not already in rule means
+     * starting a token rule. The terminating ';' of a rule, flips this back to invalid type.
+     *
+     * This is not perfect logic but works. For example, "grammar T;" means that we start and stop a lexical rule for
+     * the "T;". Dangerous but works.
+     *
+     * The whole point of this state information is to distinguish between [..arg actions..] and [charsets]. Char sets
+     * can only occur in lexical rules and arg actions cannot occur.
+     */
+    private int _currentRuleType = Token.INVALID_TYPE;
+
+    private boolean insideOptionsBlock = false;
+
+    public int getCurrentRuleType() {
+        return _currentRuleType;
+    }
+
+    public void setCurrentRuleType(int ruleType) {
+        this._currentRuleType = ruleType;
+    }
+
+    protected void handleBeginArgument() {
+        if (inLexerRule()) {
+            pushMode(ANTLRv4Lexer.LexerCharSet);
+            more();
+        } else {
+            pushMode(ANTLRv4Lexer.Argument);
+        }
+    }
+
+    protected void handleEndArgument() {
+        popMode();
+        if (_modeStack.size() > 0) {
+            setType(ANTLRv4Lexer.ARGUMENT_CONTENT);
+        }
+    }
+
+    protected void handleEndAction() {
+        int oldMode = _mode;
+        int newMode = popMode();
+        boolean isActionWithinAction = _modeStack.size() > 0
+            && newMode == ANTLRv4Lexer.TargetLanguageAction
+            && oldMode == newMode;
+
+        if (isActionWithinAction) {
+            setType(ANTLRv4Lexer.ACTION_CONTENT);
+        }
+    }
+
+    @Override
+    public Token emit() {
+        if ((_type == ANTLRv4Lexer.OPTIONS || _type == ANTLRv4Lexer.TOKENS || _type == ANTLRv4Lexer.CHANNELS)
+                && getCurrentRuleType() == Token.INVALID_TYPE) { // enter prequel construct ending with an RBRACE
+            setCurrentRuleType(PREQUEL_CONSTRUCT);
+        } else if (_type == ANTLRv4Lexer.OPTIONS && getCurrentRuleType() == ANTLRv4Lexer.TOKEN_REF)
+        {
+            setCurrentRuleType(OPTIONS_CONSTRUCT);
+        } else if (_type == ANTLRv4Lexer.RBRACE && getCurrentRuleType() == PREQUEL_CONSTRUCT) { // exit prequel construct
+            setCurrentRuleType(Token.INVALID_TYPE);
+        } else if (_type == ANTLRv4Lexer.RBRACE && getCurrentRuleType() == OPTIONS_CONSTRUCT)
+        { // exit options
+            setCurrentRuleType(ANTLRv4Lexer.TOKEN_REF);
+        } else if (_type == ANTLRv4Lexer.AT && getCurrentRuleType() == Token.INVALID_TYPE) { // enter action
+            setCurrentRuleType(ANTLRv4Lexer.AT);
+        } else if (_type == ANTLRv4Lexer.SEMI && getCurrentRuleType() == OPTIONS_CONSTRUCT)
+        { // ';' in options { .... }. Don't change anything.
+        } else if (_type == ANTLRv4Lexer.END_ACTION && getCurrentRuleType() == ANTLRv4Lexer.AT) { // exit action
+            setCurrentRuleType(Token.INVALID_TYPE);
+        } else if (_type == ANTLRv4Lexer.ID) {
+            String firstChar = _input.getText(Interval.of(_tokenStartCharIndex, _tokenStartCharIndex));
+            if (Character.isUpperCase(firstChar.charAt(0))) {
+                _type = ANTLRv4Lexer.TOKEN_REF;
+            } else {
+                _type = ANTLRv4Lexer.RULE_REF;
+            }
+
+            if (getCurrentRuleType() == Token.INVALID_TYPE) { // if outside of rule def
+                setCurrentRuleType(_type); // set to inside lexer or parser rule
+            }
+        } else if (_type == ANTLRv4Lexer.SEMI) { // exit rule def
+            setCurrentRuleType(Token.INVALID_TYPE);
+        }
+
+        return super.emit();
+    }
+
+    private boolean inLexerRule() {
+        return getCurrentRuleType() == ANTLRv4Lexer.TOKEN_REF;
+    }
+
+    @SuppressWarnings("unused")
+    private boolean inParserRule() { // not used, but added for clarity
+        return getCurrentRuleType() == ANTLRv4Lexer.RULE_REF;
+    }
+
+    @Override
+    public void reset() {
+        setCurrentRuleType(Token.INVALID_TYPE);
+        insideOptionsBlock = false;
+        super.reset();
+    }   
+}
diff --git a/developer/ANTLR/grammar_rules.g4 b/developer/ANTLR/grammar_rules.g4
deleted file mode 100644 (file)
index d02b7ab..0000000
+++ /dev/null
@@ -1,3330 +0,0 @@
-grammar GQL_20240412;
-
-options { caseInsensitive = true; }
-
-// 6 <GQL-program>
-
-gqlProgram
-: programActivity sessionCloseCommand? EOF
-| sessionCloseCommand EOF
-;
-
-programActivity
-: sessionActivity
-| transactionActivity
-;
-
-sessionActivity
-: sessionResetCommand+
-| sessionSetCommand+ sessionResetCommand*
-;
-
-transactionActivity
-: startTransactionCommand (procedureSpecification endTransactionCommand?)?
-| procedureSpecification endTransactionCommand?
-| endTransactionCommand
-;
-
-endTransactionCommand
-: rollbackCommand
-| commitCommand
-;
-
-// 7.1 <session set command>
-
-sessionSetCommand
-: SESSION SET (sessionSetSchemaClause | sessionSetGraphClause | sessionSetTimeZoneClause | sessionSetParameterClause)
-;
-
-sessionSetSchemaClause
-: SCHEMA schemaReference
-;
-
-sessionSetGraphClause
-: PROPERTY? GRAPH graphExpression
-;
-
-sessionSetTimeZoneClause
-: TIME ZONE setTimeZoneValue
-;
-
-setTimeZoneValue
-: timeZoneString
-;
-
-sessionSetParameterClause
-: sessionSetGraphParameterClause
-| sessionSetBindingTableParameterClause
-| sessionSetValueParameterClause
-;
-
-sessionSetGraphParameterClause
-: PROPERTY? GRAPH sessionSetParameterName optTypedGraphInitializer
-;
-
-sessionSetBindingTableParameterClause
-: BINDING? TABLE sessionSetParameterName optTypedBindingTableInitializer
-;
-
-sessionSetValueParameterClause
-: VALUE sessionSetParameterName optTypedValueInitializer
-;
-
-sessionSetParameterName
-: (IF NOT EXISTS)? sessionParameterSpecification
-;
-
-// 7.2 <session reset command>
-
-sessionResetCommand
-: SESSION RESET sessionResetArguments?
-;
-
-sessionResetArguments
-: ALL? (PARAMETERS | CHARACTERISTICS)
-| SCHEMA
-| PROPERTY? GRAPH
-| TIME ZONE
-| PARAMETER? sessionParameterSpecification
-;
-
-// 7.3 <session close command>
-
-sessionCloseCommand
-: SESSION CLOSE
-;
-
-// 7.4 <session parameter specification>
-
-sessionParameterSpecification
-: GENERAL_PARAMETER_REFERENCE
-;
-
-// 8.1 <start transaction command>
-
-startTransactionCommand
-: START TRANSACTION transactionCharacteristics?
-;
-
-// 8.2 <transaction characteristics>
-
-transactionCharacteristics
-: transactionMode (COMMA transactionMode)*
-;
-
-transactionMode
-: transactionAccessMode
-;
-
-transactionAccessMode
-: READ ONLY
-| READ WRITE
-;
-
-// 8.3 <rollback command>
-
-rollbackCommand
-: ROLLBACK
-;
-
-// 8.4 <commit command>
-
-commitCommand
-: COMMIT
-;
-
-// 9.1 <nested procedure specification>
-
-nestedProcedureSpecification
-: LEFT_BRACE procedureSpecification RIGHT_BRACE
-;
-
-// <catalog-modifying procedure specification>, <data-modifying procedure specification> and <query specification> are
-// identical productions. The specification distinguishes them in the BNF, but in the implementation, the distinction
-// has to be made sematically, in code, based on the kind of statements contained in the <procedure specification>.
-procedureSpecification
-: procedureBody
-//    : catalogModifyingProcedureSpecification
-//    | dataModifyingProcedureSpecification
-//    | querySpecification
-;
-
-//catalogModifyingProcedureSpecification
-//    : procedureBody
-//    ;
-
-nestedDataModifyingProcedureSpecification
-: LEFT_BRACE procedureBody RIGHT_BRACE
-;
-
-//dataModifyingProcedureSpecification
-//    : procedureBody
-//    ;
-
-nestedQuerySpecification
-: LEFT_BRACE procedureBody RIGHT_BRACE
-;
-
-//querySpecification
-//    : procedureBody
-//    ;
-
-// 9.2 <procedure body>
-
-procedureBody
-: atSchemaClause? bindingVariableDefinitionBlock? statementBlock
-;
-
-bindingVariableDefinitionBlock
-: bindingVariableDefinition+
-;
-
-bindingVariableDefinition
-: graphVariableDefinition
-| bindingTableVariableDefinition
-| valueVariableDefinition
-;
-
-statementBlock
-: statement nextStatement*
-;
-
-statement
-: linearCatalogModifyingStatement
-| linearDataModifyingStatement
-| compositeQueryStatement
-;
-
-nextStatement
-: NEXT yieldClause? statement
-;
-
-// 10.1 <graph variable definition>
-
-graphVariableDefinition
-: PROPERTY? GRAPH bindingVariable optTypedGraphInitializer
-;
-
-optTypedGraphInitializer
-: (typed? graphReferenceValueType)? graphInitializer
-;
-
-graphInitializer
-: EQUALS_OPERATOR graphExpression
-;
-
-// 10.2 <binding table variable definition>
-
-bindingTableVariableDefinition
-: BINDING? TABLE bindingVariable optTypedBindingTableInitializer
-;
-
-optTypedBindingTableInitializer
-: (typed? bindingTableReferenceValueType)? bindingTableInitializer
-;
-
-bindingTableInitializer
-: EQUALS_OPERATOR bindingTableExpression
-;
-
-// 10.3 <value variable definition>
-
-valueVariableDefinition
-: VALUE bindingVariable optTypedValueInitializer
-;
-
-optTypedValueInitializer
-: (typed? valueType)? valueInitializer
-;
-
-valueInitializer
-: EQUALS_OPERATOR valueExpression
-;
-
-// 11.1 <graph expression>
-
-graphExpression
-: objectExpressionPrimary
-| graphReference
-| objectNameOrBindingVariable
-| currentGraph
-;
-
-currentGraph
-: CURRENT_PROPERTY_GRAPH
-| CURRENT_GRAPH
-;
-
-// 11.2 <binding table expression>
-
-bindingTableExpression
-: nestedBindingTableQuerySpecification
-| objectExpressionPrimary
-| bindingTableReference
-| objectNameOrBindingVariable
-;
-
-nestedBindingTableQuerySpecification
-: nestedQuerySpecification
-;
-
-// 11.3 <object expression primary>
-
-objectExpressionPrimary
-: VARIABLE valueExpressionPrimary
-| parenthesizedValueExpression
-| nonParenthesizedValueExpressionPrimarySpecialCase
-;
-
-// 12.1 <linear catalog-modifying statement>
-
-linearCatalogModifyingStatement
-: simpleCatalogModifyingStatement+
-;
-
-simpleCatalogModifyingStatement
-: primitiveCatalogModifyingStatement
-| callCatalogModifyingProcedureStatement
-;
-
-primitiveCatalogModifyingStatement
-: createSchemaStatement
-| dropSchemaStatement
-| createGraphStatement
-| dropGraphStatement
-| createGraphTypeStatement
-| dropGraphTypeStatement
-;
-
-// 12.2 <insert schema statement>
-
-createSchemaStatement
-: CREATE SCHEMA (IF NOT EXISTS)? catalogSchemaParentAndName
-;
-
-// 12.3 <drop schema statement>
-
-dropSchemaStatement
-: DROP SCHEMA (IF EXISTS)? catalogSchemaParentAndName
-;
-
-// 12.4 <insert graph statement>
-
-createGraphStatement
-: CREATE (PROPERTY? GRAPH (IF NOT EXISTS)? | OR REPLACE PROPERTY? GRAPH) catalogGraphParentAndName (openGraphType | ofGraphType) graphSource?
-;
-
-openGraphType
-: typed? ANY (PROPERTY? GRAPH)?
-;
-
-ofGraphType
-: graphTypeLikeGraph
-| typed? graphTypeReference
-| typed? (PROPERTY? GRAPH)? nestedGraphTypeSpecification
-;
-
-graphTypeLikeGraph
-: LIKE graphExpression
-;
-
-graphSource
-: AS COPY OF graphExpression
-;
-
-// 12.5 <drop graph statement>
-
-dropGraphStatement
-: DROP PROPERTY? GRAPH (IF EXISTS)? catalogGraphParentAndName
-;
-
-// 12.6 <graph type statement>
-
-createGraphTypeStatement
-: CREATE (PROPERTY? GRAPH TYPE (IF NOT EXISTS)? | OR REPLACE PROPERTY? GRAPH TYPE) catalogGraphTypeParentAndName graphTypeSource
-;
-
-graphTypeSource
-: AS? copyOfGraphType
-| graphTypeLikeGraph
-| AS? nestedGraphTypeSpecification
-;
-
-copyOfGraphType
-: COPY OF graphTypeReference
-;
-
-// 12.7 <drop graph statement>
-
-dropGraphTypeStatement
-: DROP PROPERTY? GRAPH TYPE (IF EXISTS)? catalogGraphTypeParentAndName
-;
-
-// 12.8 <call catalog-modifying statement>
-
-callCatalogModifyingProcedureStatement
-: callProcedureStatement
-;
-
-// 13.1 <linear data-modifying statement>
-
-linearDataModifyingStatement
-: focusedLinearDataModifyingStatement
-| ambientLinearDataModifyingStatement
-;
-
-focusedLinearDataModifyingStatement
-: focusedLinearDataModifyingStatementBody
-| focusedNestedDataModifyingProcedureSpecification
-;
-
-focusedLinearDataModifyingStatementBody
-: useGraphClause simpleLinearDataAccessingStatement primitiveResultStatement?
-;
-
-focusedNestedDataModifyingProcedureSpecification
-: useGraphClause nestedDataModifyingProcedureSpecification
-;
-
-ambientLinearDataModifyingStatement
-: ambientLinearDataModifyingStatementBody
-| nestedDataModifyingProcedureSpecification
-;
-
-ambientLinearDataModifyingStatementBody
-: simpleLinearDataAccessingStatement primitiveResultStatement?
-;
-
-simpleLinearDataAccessingStatement
-: simpleQueryStatement* simpleDataModifyingStatement+
-;
-
-// Subsumed by previous rule to enforce 13.1 SR 5
-//simpleDataAccessingStatement
-//    : simpleQueryStatement
-//    | simpleDataModifyingStatement
-//    ;
-
-simpleDataModifyingStatement
-: primitiveDataModifyingStatement
-| callDataModifyingProcedureStatement
-;
-
-primitiveDataModifyingStatement
-: insertStatement
-| setStatement
-| removeStatement
-| deleteStatement
-;
-
-// 13.2 <insertStatement>
-
-insertStatement
-: INSERT insertGraphPattern
-;
-
-// 13.3 <set statement>
-
-setStatement
-: SET setItemList
-;
-
-setItemList
-: setItem (COMMA setItem)*
-;
-
-setItem
-: setPropertyItem
-| setAllPropertiesItem
-| setLabelItem
-;
-
-setPropertyItem
-: bindingVariableReference PERIOD propertyName EQUALS_OPERATOR valueExpression
-;
-
-setAllPropertiesItem
-: bindingVariableReference EQUALS_OPERATOR LEFT_BRACE propertyKeyValuePairList? RIGHT_BRACE
-;
-
-setLabelItem
-: bindingVariableReference isOrColon labelName
-;
-
-// 13.4 <remove statement>
-
-removeStatement
-: REMOVE removeItemList
-;
-
-removeItemList
-: removeItem (COMMA removeItem)*
-;
-
-removeItem
-: removePropertyItem
-| removeLabelItem
-;
-
-removePropertyItem
-: bindingVariableReference PERIOD propertyName
-;
-
-removeLabelItem
-: bindingVariableReference isOrColon labelName
-;
-
-// 13.5 <delete statement>
-
-deleteStatement
-: (DETACH | NODETACH)? DELETE deleteItemList
-;
-
-deleteItemList
-: deleteItem (COMMA deleteItem)*
-;
-
-deleteItem
-: valueExpression
-;
-
-// 13.6 <call data-modifying procedure statement>
-
-callDataModifyingProcedureStatement
-: callProcedureStatement
-;
-
-// 14.1 <composite query statement>
-
-compositeQueryStatement
-: compositeQueryExpression
-;
-
-// 14.2 <composite query expression>
-
-compositeQueryExpression
-: compositeQueryExpression queryConjunction compositeQueryPrimary
-| compositeQueryPrimary
-;
-
-queryConjunction
-: setOperator
-| OTHERWISE
-;
-
-setOperator
-: UNION setQuantifier?
-| EXCEPT setQuantifier?
-| INTERSECT setQuantifier?
-;
-
-compositeQueryPrimary
-: linearQueryStatement
-;
-
-// 14.3 <linear query statement> and <simple query statement>
-
-linearQueryStatement
-: focusedLinearQueryStatement
-| ambientLinearQueryStatement
-;
-
-focusedLinearQueryStatement
-: focusedLinearQueryStatementPart* focusedLinearQueryAndPrimitiveResultStatementPart
-| focusedPrimitiveResultStatement
-| focusedNestedQuerySpecification
-| selectStatement
-;
-
-focusedLinearQueryStatementPart
-: useGraphClause simpleLinearQueryStatement
-;
-
-focusedLinearQueryAndPrimitiveResultStatementPart
-: useGraphClause simpleLinearQueryStatement primitiveResultStatement
-;
-
-focusedPrimitiveResultStatement
-: useGraphClause primitiveResultStatement
-;
-
-focusedNestedQuerySpecification
-: useGraphClause nestedQuerySpecification
-;
-
-ambientLinearQueryStatement
-: simpleLinearQueryStatement? primitiveResultStatement
-| nestedQuerySpecification
-;
-
-simpleLinearQueryStatement
-: simpleQueryStatement+
-;
-
-simpleQueryStatement
-: primitiveQueryStatement
-| callQueryStatement
-;
-
-primitiveQueryStatement
-: matchStatement
-| letStatement
-| forStatement
-| filterStatement
-| orderByAndPageStatement
-;
-
-// 14.4 <match statement>
-
-matchStatement
-: simpleMatchStatement
-| optionalMatchStatement
-;
-
-simpleMatchStatement
-: MATCH graphPatternBindingTable
-;
-
-optionalMatchStatement
-: OPTIONAL optionalOperand
-;
-
-optionalOperand
-: simpleMatchStatement
-| LEFT_BRACE matchStatementBlock RIGHT_BRACE
-| LEFT_PAREN matchStatementBlock RIGHT_PAREN
-;
-
-matchStatementBlock
-: matchStatement+
-;
-
-// 14.5 <call query statement>
-
-callQueryStatement
-: callProcedureStatement
-;
-
-// 14.6 <filter statement>
-
-filterStatement
-: FILTER (whereClause | searchCondition)
-;
-
-// 14.7 <let statement>
-
-letStatement
-: LET letVariableDefinitionList
-;
-
-letVariableDefinitionList
-: letVariableDefinition (COMMA letVariableDefinition)*
-;
-
-letVariableDefinition
-: valueVariableDefinition
-| bindingVariable EQUALS_OPERATOR valueExpression
-;
-
-// 14.8 <for statement>
-
-forStatement
-: FOR forItem forOrdinalityOrOffset?
-;
-
-forItem
-: forItemAlias forItemSource
-;
-
-forItemAlias
-: bindingVariable IN
-;
-
-forItemSource
-: valueExpression
-;
-
-forOrdinalityOrOffset
-: WITH (ORDINALITY | OFFSET) bindingVariable
-;
-
-// 14.9 <order by and page statement>
-
-orderByAndPageStatement
-: orderByClause offsetClause? limitClause?
-| offsetClause limitClause?
-| limitClause
-;
-
-// 14.10 <primitive result statement>
-
-primitiveResultStatement
-: returnStatement orderByAndPageStatement?
-| FINISH
-;
-
-// 14.11 <return statement>
-
-returnStatement
-: RETURN returnStatementBody
-;
-
-returnStatementBody
-: setQuantifier? (ASTERISK | returnItemList) groupByClause?
-| NO BINDINGS
-;
-
-returnItemList
-: returnItem (COMMA returnItem)*
-;
-
-returnItem
-: aggregatingValueExpression returnItemAlias?
-;
-
-returnItemAlias
-: AS identifier
-;
-
-// 14.12 <select statement>
-
-selectStatement
-: SELECT setQuantifier? (ASTERISK | selectItemList) (selectStatementBody whereClause? groupByClause? havingClause? orderByClause? offsetClause? limitClause?)?
-;
-
-selectItemList
-: selectItem (COMMA selectItem)*
-;
-
-selectItem
-: aggregatingValueExpression selectItemAlias?
-;
-
-selectItemAlias
-: AS identifier
-;
-
-havingClause
-: HAVING searchCondition
-;
-
-selectStatementBody
-: FROM (selectGraphMatchList | selectQuerySpecification)
-;
-
-selectGraphMatchList
-: selectGraphMatch (COMMA selectGraphMatch)*
-;
-
-selectGraphMatch
-: graphExpression matchStatement
-;
-
-selectQuerySpecification
-: nestedQuerySpecification
-| graphExpression nestedQuerySpecification
-;
-
-// 15.1 <call procedure statement> and <procedure call>
-
-callProcedureStatement
-: OPTIONAL? CALL procedureCall
-;
-
-procedureCall
-: inlineProcedureCall
-| namedProcedureCall
-;
-
-// 15.2 <inline procedure call>
-
-inlineProcedureCall
-: variableScopeClause? nestedProcedureSpecification
-;
-
-variableScopeClause
-: LEFT_PAREN bindingVariableReferenceList? RIGHT_PAREN
-;
-
-bindingVariableReferenceList
-: bindingVariableReference (COMMA bindingVariableReference)*
-;
-
-// 15.3 <named procedure call>
-
-namedProcedureCall
-: procedureReference LEFT_PAREN procedureArgumentList? RIGHT_PAREN yieldClause?
-;
-
-procedureArgumentList
-: procedureArgument (COMMA procedureArgument)*
-;
-
-procedureArgument
-: valueExpression
-;
-
-// 16.1 <at schema clasue>
-
-atSchemaClause
-: AT schemaReference
-;
-
-// 16.2 <use graph clause>
-
-useGraphClause
-: USE graphExpression
-;
-
-// 16.3 <graph pattern binding table>
-
-graphPatternBindingTable
-: graphPattern graphPatternYieldClause?
-;
-
-graphPatternYieldClause
-: YIELD graphPatternYieldItemList
-;
-
-graphPatternYieldItemList
-: graphPatternYieldItem (COMMA graphPatternYieldItem)*
-| NO BINDINGS
-;
-
-// <elemement variable reference> and <path variable reference> are identical productions, both consisting
-// of a single non-terminal <binding variable reference>. Thus <graph pattern yield item> is ambiguous
-// from a parsing standpoint. So here we simply use bindingVariableReference. Post parsing code must
-// apply the semantics assocaited with each type of <binding variable reference>.
-graphPatternYieldItem
-: bindingVariableReference
-//    : elementVariableReference
-//    | pathVariableReference
-;
-
-// 16.4 <graph pattern>
-
-graphPattern
-: matchMode? pathPatternList keepClause? graphPatternWhereClause?
-;
-
-matchMode
-: repeatableElementsMatchMode
-| differentEdgesMatchMode
-;
-
-repeatableElementsMatchMode
-: REPEATABLE elementBindingsOrElements
-;
-
-differentEdgesMatchMode
-: DIFFERENT edgeBindingsOrEdges
-;
-
-elementBindingsOrElements
-: ELEMENT BINDINGS?
-| ELEMENTS
-;
-
-edgeBindingsOrEdges
-: edgeSynonym BINDINGS?
-| edgesSynonym
-;
-
-pathPatternList
-: pathPattern (COMMA pathPattern)*
-;
-
-pathPattern
-: pathVariableDeclaration? pathPatternPrefix? pathPatternExpression
-;
-
-pathVariableDeclaration
-: pathVariable EQUALS_OPERATOR
-;
-
-keepClause
-: KEEP pathPatternPrefix
-;
-
-graphPatternWhereClause
-: WHERE searchCondition
-;
-
-// 16.5 <insert graph pattern>
-
-insertGraphPattern
-: insertPathPatternList
-;
-
-insertPathPatternList
-: insertPathPattern (COMMA insertPathPattern)*
-;
-
-insertPathPattern
-: insertNodePattern (insertEdgePattern insertNodePattern)*
-;
-
-insertNodePattern
-: LEFT_PAREN insertElementPatternFiller? RIGHT_PAREN
-;
-
-insertEdgePattern
-: insertEdgePointingLeft
-| insertEdgePointingRight
-| insertEdgeUndirected
-;
-
-insertEdgePointingLeft
-: LEFT_ARROW_BRACKET insertElementPatternFiller? RIGHT_BRACKET_MINUS
-;
-
-insertEdgePointingRight
-: MINUS_LEFT_BRACKET insertElementPatternFiller? BRACKET_RIGHT_ARROW
-;
-
-insertEdgeUndirected
-: TILDE_LEFT_BRACKET insertElementPatternFiller? RIGHT_BRACKET_TILDE
-;
-
-insertElementPatternFiller
-: elementVariableDeclaration labelAndPropertySetSpecification?
-| elementVariableDeclaration? labelAndPropertySetSpecification
-;
-
-labelAndPropertySetSpecification
-: isOrColon labelSetSpecification elementPropertySpecification?
-| (isOrColon labelSetSpecification)? elementPropertySpecification
-;
-
-// 16.6 <path pattern prefix>
-
-pathPatternPrefix
-: pathModePrefix
-| pathSearchPrefix
-;
-
-pathModePrefix
-: pathMode pathOrPaths?
-;
-
-pathMode
-: WALK
-| TRAIL
-| SIMPLE
-| ACYCLIC
-;
-
-pathSearchPrefix
-: allPathSearch
-| anyPathSearch
-| shortestPathSearch
-;
-
-allPathSearch
-: ALL pathMode? pathOrPaths?
-;
-
-pathOrPaths
-: PATH
-| PATHS
-;
-
-anyPathSearch
-: ANY numberOfPaths? pathMode? pathOrPaths?
-;
-
-numberOfPaths
-: nonNegativeIntegerSpecification
-;
-
-shortestPathSearch
-: allShortestPathSearch
-| anyShortestPathSearch
-| countedShortestPathSearch
-| countedShortestGroupSearch
-;
-
-allShortestPathSearch
-: ALL SHORTEST pathMode? pathOrPaths?
-;
-
-anyShortestPathSearch
-: ANY SHORTEST pathMode? pathOrPaths?
-;
-
-countedShortestPathSearch
-: SHORTEST numberOfPaths pathMode? pathOrPaths?
-;
-
-countedShortestGroupSearch
-: SHORTEST numberOfGroups? pathMode? pathOrPaths? (GROUP | GROUPS)
-;
-
-numberOfGroups
-: nonNegativeIntegerSpecification
-;
-
-// 16.7 <path pattern expression>
-
-pathPatternExpression
-: pathTerm                                              #ppePathTerm
-| pathTerm (MULTISET_ALTERNATION_OPERATOR pathTerm)+    #ppeMultisetAlternation
-| pathTerm (VERTICAL_BAR pathTerm)+                     #ppePatternUnion
-;
-
-pathTerm
-: pathFactor+
-;
-
-pathFactor
-: pathPrimary                           #pfPathPrimary
-| pathPrimary graphPatternQuantifier    #pfQuantifiedPathPrimary
-| pathPrimary QUESTION_MARK             #pfQuestionedPathPrimary
-;
-
-pathPrimary
-: elementPattern                        #ppElementPattern
-| parenthesizedPathPatternExpression    #ppParenthesizedPathPatternExpression
-| simplifiedPathPatternExpression       #ppSimplifiedPathPatternExpression
-;
-
-elementPattern
-: nodePattern
-| edgePattern
-;
-
-nodePattern
-: LEFT_PAREN elementPatternFiller RIGHT_PAREN
-;
-
-elementPatternFiller
-: elementVariableDeclaration? isLabelExpression? elementPatternPredicate?
-;
-
-elementVariableDeclaration
-: TEMP? elementVariable
-;
-
-isLabelExpression
-: isOrColon labelExpression
-;
-
-isOrColon
-: IS
-| COLON
-;
-
-elementPatternPredicate
-: elementPatternWhereClause
-| elementPropertySpecification
-;
-
-elementPatternWhereClause
-: WHERE searchCondition
-;
-
-elementPropertySpecification
-: LEFT_BRACE propertyKeyValuePairList RIGHT_BRACE
-;
-
-propertyKeyValuePairList
-: propertyKeyValuePair (COMMA propertyKeyValuePair)*
-;
-
-propertyKeyValuePair
-: propertyName COLON valueExpression
-;
-
-edgePattern
-: fullEdgePattern
-| abbreviatedEdgePattern
-;
-
-fullEdgePattern
-: fullEdgePointingLeft
-| fullEdgeUndirected
-| fullEdgePointingRight
-| fullEdgeLeftOrUndirected
-| fullEdgeUndirectedOrRight
-| fullEdgeLeftOrRight
-| fullEdgeAnyDirection
-;
-
-fullEdgePointingLeft
-: LEFT_ARROW_BRACKET elementPatternFiller RIGHT_BRACKET_MINUS
-;
-
-fullEdgeUndirected
-: TILDE_LEFT_BRACKET elementPatternFiller RIGHT_BRACKET_TILDE
-;
-
-fullEdgePointingRight
-: MINUS_LEFT_BRACKET elementPatternFiller BRACKET_RIGHT_ARROW
-;
-
-fullEdgeLeftOrUndirected
-: LEFT_ARROW_TILDE_BRACKET elementPatternFiller RIGHT_BRACKET_TILDE
-;
-
-fullEdgeUndirectedOrRight
-: TILDE_LEFT_BRACKET elementPatternFiller BRACKET_TILDE_RIGHT_ARROW
-;
-
-fullEdgeLeftOrRight
-: LEFT_ARROW_BRACKET elementPatternFiller BRACKET_RIGHT_ARROW
-;
-
-fullEdgeAnyDirection
-: MINUS_LEFT_BRACKET elementPatternFiller RIGHT_BRACKET_MINUS
-;
-
-abbreviatedEdgePattern
-: LEFT_ARROW
-| TILDE
-| RIGHT_ARROW
-| LEFT_ARROW_TILDE
-| TILDE_RIGHT_ARROW
-| LEFT_MINUS_RIGHT
-| MINUS_SIGN
-;
-
-parenthesizedPathPatternExpression
-: LEFT_PAREN subpathVariableDeclaration? pathModePrefix? pathPatternExpression parenthesizedPathPatternWhereClause? RIGHT_PAREN
-;
-
-subpathVariableDeclaration
-: subpathVariable EQUALS_OPERATOR
-;
-
-parenthesizedPathPatternWhereClause
-: WHERE searchCondition
-;
-
-// 16.8 <label expression>
-
-labelExpression
-: EXCLAMATION_MARK labelExpression                  #labelExpressionNegation
-| labelExpression AMPERSAND labelExpression         #labelExpressionConjunction
-| labelExpression VERTICAL_BAR labelExpression      #labelExpressionDisjunction
-| labelName                                         #labelExpressionName
-| PERCENT                                           #labelExpressionWildcard
-| LEFT_PAREN labelExpression RIGHT_PAREN            #labelExpressionParenthesized
-;
-
-// 16.9 <path variable reference>
-
-pathVariableReference
-: bindingVariableReference
-;
-
-// 16.10 <element variable reference>
-
-elementVariableReference
-: bindingVariableReference
-;
-
-// 16.11 <graph pattern quantifier>
-
-graphPatternQuantifier
-: ASTERISK
-| PLUS_SIGN
-| fixedQuantifier
-| generalQuantifier
-;
-
-fixedQuantifier
-: LEFT_BRACE unsignedInteger RIGHT_BRACE
-;
-
-generalQuantifier
-: LEFT_BRACE lowerBound? COMMA upperBound? RIGHT_BRACE
-;
-
-lowerBound
-: unsignedInteger
-;
-
-upperBound
-: unsignedInteger
-;
-
-// 16.12 <simplified path pattern expression>
-
-simplifiedPathPatternExpression
-: simplifiedDefaultingLeft
-| simplifiedDefaultingUndirected
-| simplifiedDefaultingRight
-| simplifiedDefaultingLeftOrUndirected
-| simplifiedDefaultingUndirectedOrRight
-| simplifiedDefaultingLeftOrRight
-| simplifiedDefaultingAnyDirection
-;
-
-simplifiedDefaultingLeft
-: LEFT_MINUS_SLASH simplifiedContents SLASH_MINUS
-;
-
-simplifiedDefaultingUndirected
-: TILDE_SLASH simplifiedContents SLASH_TILDE
-;
-
-simplifiedDefaultingRight
-: MINUS_SLASH simplifiedContents SLASH_MINUS_RIGHT
-;
-
-simplifiedDefaultingLeftOrUndirected
-: LEFT_TILDE_SLASH simplifiedContents SLASH_TILDE
-;
-
-simplifiedDefaultingUndirectedOrRight
-: TILDE_SLASH simplifiedContents SLASH_TILDE_RIGHT
-;
-
-simplifiedDefaultingLeftOrRight
-: LEFT_MINUS_SLASH simplifiedContents SLASH_MINUS_RIGHT
-;
-
-simplifiedDefaultingAnyDirection
-: MINUS_SLASH simplifiedContents SLASH_MINUS
-;
-
-simplifiedContents
-: simplifiedTerm
-| simplifiedPathUnion
-| simplifiedMultisetAlternation
-;
-
-simplifiedPathUnion
-: simplifiedTerm VERTICAL_BAR simplifiedTerm (VERTICAL_BAR simplifiedTerm)*
-;
-
-simplifiedMultisetAlternation
-: simplifiedTerm MULTISET_ALTERNATION_OPERATOR simplifiedTerm (MULTISET_ALTERNATION_OPERATOR simplifiedTerm)*
-;
-
-simplifiedTerm
-: simplifiedFactorLow                        #simplifiedFactorLowLabel
-| simplifiedTerm simplifiedFactorLow      #simplifiedConcatenationLabel
-;
-
-simplifiedFactorLow
-: simplifiedFactorHigh                                     #simplifiedFactorHighLabel
-| simplifiedFactorLow AMPERSAND simplifiedFactorHigh #simplifiedConjunctionLabel
-;
-
-simplifiedFactorHigh
-: simplifiedTertiary
-| simplifiedQuantified
-| simplifiedQuestioned
-;
-
-simplifiedQuantified
-: simplifiedTertiary graphPatternQuantifier
-;
-
-simplifiedQuestioned
-: simplifiedTertiary QUESTION_MARK
-;
-
-simplifiedTertiary
-: simplifiedDirectionOverride
-| simplifiedSecondary
-;
-
-simplifiedDirectionOverride
-: simplifiedOverrideLeft
-| simplifiedOverrideUndirected
-| simplifiedOverrideRight
-| simplifiedOverrideLeftOrUndirected
-| simplifiedOverrideUndirectedOrRight
-| simplifiedOverrideLeftOrRight
-| simplifiedOverrideAnyDirection
-;
-
-simplifiedOverrideLeft
-: LEFT_ANGLE_BRACKET simplifiedSecondary
-;
-
-simplifiedOverrideUndirected
-: TILDE simplifiedSecondary
-;
-
-simplifiedOverrideRight
-: simplifiedSecondary RIGHT_ANGLE_BRACKET
-;
-
-simplifiedOverrideLeftOrUndirected
-: LEFT_ARROW_TILDE simplifiedSecondary
-;
-
-simplifiedOverrideUndirectedOrRight
-: TILDE simplifiedSecondary RIGHT_ANGLE_BRACKET
-;
-
-simplifiedOverrideLeftOrRight
-: LEFT_ANGLE_BRACKET simplifiedSecondary RIGHT_ANGLE_BRACKET
-;
-
-simplifiedOverrideAnyDirection
-: MINUS_SIGN simplifiedSecondary
-;
-
-simplifiedSecondary
-: simplifiedPrimary
-| simplifiedNegation
-;
-
-simplifiedNegation
-: EXCLAMATION_MARK simplifiedPrimary
-;
-
-simplifiedPrimary
-: labelName
-| LEFT_PAREN simplifiedContents RIGHT_PAREN
-;
-
-// 16.13 <where clause>
-
-whereClause
-: WHERE searchCondition
-;
-
-// 16.14 <yield clause>
-
-yieldClause
-: YIELD yieldItemList
-;
-
-yieldItemList
-: yieldItem (COMMA yieldItem)*
-;
-
-yieldItem
-: (yieldItemName yieldItemAlias?)
-;
-
-yieldItemName
-: fieldName
-;
-
-yieldItemAlias
-: AS bindingVariable
-;
-
-// 16.15 <group by clasue>
-
-groupByClause
-: GROUP BY groupingElementList
-;
-
-groupingElementList
-: groupingElement (COMMA groupingElement)*
-| emptyGroupingSet
-;
-
-groupingElement
-: bindingVariableReference
-;
-
-emptyGroupingSet
-: LEFT_PAREN RIGHT_PAREN
-;
-
-// 16.16 <order by clasue>
-
-orderByClause
-: ORDER BY sortSpecificationList
-;
-
-// 16.17 <sort specification list>
-
-sortSpecificationList
-: sortSpecification (COMMA sortSpecification)*
-;
-
-sortSpecification
-: sortKey orderingSpecification? nullOrdering?
-;
-
-sortKey
-: aggregatingValueExpression
-;
-
-orderingSpecification
-: ASC
-| ASCENDING
-| DESC
-| DESCENDING
-;
-
-nullOrdering
-: NULLS FIRST
-| NULLS LAST
-;
-
-// 16.18 <limit clause>
-
-limitClause
-: LIMIT nonNegativeIntegerSpecification
-;
-
-// 16.19 <offset clause>
-
-offsetClause
-: offsetSynonym nonNegativeIntegerSpecification
-;
-
-offsetSynonym
-: OFFSET
-| SKIP_RESERVED_WORD
-;
-
-// 17.1 <schema reference> and <catalog schema parent name>
-
-schemaReference
-: absoluteCatalogSchemaReference
-| relativeCatalogSchemaReference
-| referenceParameterSpecification
-;
-
-absoluteCatalogSchemaReference
-: SOLIDUS
-| absoluteDirectoryPath schemaName
-;
-
-catalogSchemaParentAndName
-: absoluteDirectoryPath schemaName
-;
-
-relativeCatalogSchemaReference
-: predefinedSchemaReference
-| relativeDirectoryPath schemaName
-;
-
-predefinedSchemaReference
-: HOME_SCHEMA
-| CURRENT_SCHEMA
-| PERIOD
-;
-
-absoluteDirectoryPath
-: SOLIDUS simpleDirectoryPath?
-;
-
-relativeDirectoryPath
-: DOUBLE_PERIOD (SOLIDUS DOUBLE_PERIOD)* SOLIDUS simpleDirectoryPath?
-;
-
-simpleDirectoryPath
-: (directoryName SOLIDUS)+
-;
-
-// 17.2 <graph reference> and <catalog graph parent and name>
-
-graphReference
-: catalogObjectParentReference graphName
-| delimitedGraphName
-| homeGraph
-| referenceParameterSpecification
-;
-
-catalogGraphParentAndName
-: catalogObjectParentReference? graphName
-;
-
-homeGraph
-: HOME_PROPERTY_GRAPH
-| HOME_GRAPH
-;
-
-// 17.3 <graph type reference> and <catalog graph type parent and name>
-
-graphTypeReference
-: catalogGraphTypeParentAndName
-| referenceParameterSpecification
-;
-
-catalogGraphTypeParentAndName
-: catalogObjectParentReference? graphTypeName
-;
-
-// 17.4 <binding table reference> and <catalog binding table parent name>
-
-bindingTableReference
-: catalogObjectParentReference bindingTableName
-| delimitedBindingTableName
-| referenceParameterSpecification
-;
-
-// 17.5 <procedure reference> and <catalog procedure parent and name>
-
-procedureReference
-: catalogProcedureParentAndName
-| referenceParameterSpecification
-;
-
-catalogProcedureParentAndName
-: catalogObjectParentReference? procedureName
-;
-
-// 17.6 <catalog object parent reference>
-
-catalogObjectParentReference
-: schemaReference SOLIDUS? (objectName PERIOD)*
-|  (objectName PERIOD)+
-;
-
-// 17.7 <reference parameter specification>
-
-referenceParameterSpecification
-: SUBSTITUTED_PARAMETER_REFERENCE
-;
-
-// 18.1 <nested graph type specification>
-
-nestedGraphTypeSpecification
-: LEFT_BRACE graphTypeSpecificationBody RIGHT_BRACE
-;
-
-graphTypeSpecificationBody
-: elementTypeList
-;
-
-elementTypeList
-: elementTypeSpecification (COMMA elementTypeSpecification)*
-;
-
-elementTypeSpecification
-: nodeTypeSpecification
-| edgeTypeSpecification
-;
-
-// 18.2 <node type specification>
-
-nodeTypeSpecification
-: nodeTypePattern
-| nodeTypePhrase
-;
-
-nodeTypePattern
-: (nodeSynonym TYPE? nodeTypeName)? LEFT_PAREN localNodeTypeAlias? nodeTypeFiller? RIGHT_PAREN
-;
-
-nodeTypePhrase
-: nodeSynonym TYPE? nodeTypePhraseFiller (AS localNodeTypeAlias)?
-;
-
-nodeTypePhraseFiller
-: nodeTypeName nodeTypeFiller?
-| nodeTypeFiller
-;
-
-nodeTypeFiller
-: nodeTypeKeyLabelSet nodeTypeImpliedContent?
-| nodeTypeImpliedContent
-;
-
-localNodeTypeAlias
-: regularIdentifier
-;
-
-nodeTypeImpliedContent
-: nodeTypeLabelSet
-| nodeTypePropertyTypes
-| nodeTypeLabelSet nodeTypePropertyTypes
-;
-
-nodeTypeKeyLabelSet
-: labelSetPhrase? IMPLIES
-;
-
-nodeTypeLabelSet
-: labelSetPhrase
-;
-
-nodeTypePropertyTypes
-: propertyTypesSpecification
-;
-
-// 18.3 <edge type specification>
-
-edgeTypeSpecification
-: edgeTypePattern
-| edgeTypePhrase
-;
-
-edgeTypePattern
-: (edgeKind? edgeSynonym TYPE? edgeTypeName)? (edgeTypePatternDirected | edgeTypePatternUndirected)
-;
-
-edgeTypePhrase
-: edgeKind edgeSynonym TYPE? edgeTypePhraseFiller endpointPairPhrase
-;
-
-edgeTypePhraseFiller
-: edgeTypeName edgeTypeFiller?
-| edgeTypeFiller
-;
-
-edgeTypeFiller
-: edgeTypeKeyLabelSet edgeTypeImpliedContent?
-| edgeTypeImpliedContent
-;
-
-edgeTypeImpliedContent
-: edgeTypeLabelSet
-| edgeTypePropertyTypes
-| edgeTypeLabelSet edgeTypePropertyTypes
-;
-
-edgeTypeKeyLabelSet
-: labelSetPhrase? IMPLIES
-;
-
-edgeTypeLabelSet
-: labelSetPhrase
-;
-
-edgeTypePropertyTypes
-: propertyTypesSpecification
-;
-
-edgeTypePatternDirected
-: edgeTypePatternPointingRight
-| edgeTypePatternPointingLeft
-;
-
-edgeTypePatternPointingRight
-: sourceNodeTypeReference arcTypePointingRight destinationNodeTypeReference
-;
-
-edgeTypePatternPointingLeft
-: destinationNodeTypeReference arcTypePointingLeft sourceNodeTypeReference
-;
-
-edgeTypePatternUndirected
-: sourceNodeTypeReference arcTypeUndirected destinationNodeTypeReference
-;
-
-arcTypePointingRight
-: MINUS_LEFT_BRACKET edgeTypeFiller BRACKET_RIGHT_ARROW
-;
-
-arcTypePointingLeft
-: LEFT_ARROW_BRACKET edgeTypeFiller RIGHT_BRACKET_MINUS
-;
-
-arcTypeUndirected
-: TILDE_LEFT_BRACKET edgeTypeFiller RIGHT_BRACKET_TILDE
-;
-
-sourceNodeTypeReference
-: LEFT_PAREN sourceNodeTypeAlias RIGHT_PAREN
-| LEFT_PAREN nodeTypeFiller? RIGHT_PAREN
-;
-
-destinationNodeTypeReference
-: LEFT_PAREN destinationNodeTypeAlias RIGHT_PAREN
-| LEFT_PAREN nodeTypeFiller? RIGHT_PAREN
-;
-
-edgeKind
-: DIRECTED
-| UNDIRECTED
-;
-
-endpointPairPhrase
-: CONNECTING endpointPair
-;
-
-endpointPair
-: endpointPairDirected
-| endpointPairUndirected
-;
-
-endpointPairDirected
-: endpointPairPointingRight
-| endpointPairPointingLeft
-;
-
-endpointPairPointingRight
-: LEFT_PAREN sourceNodeTypeAlias connectorPointingRight destinationNodeTypeAlias RIGHT_PAREN
-;
-
-endpointPairPointingLeft
-: LEFT_PAREN destinationNodeTypeAlias LEFT_ARROW sourceNodeTypeAlias RIGHT_PAREN
-;
-
-endpointPairUndirected
-: LEFT_PAREN sourceNodeTypeAlias connectorUndirected destinationNodeTypeAlias RIGHT_PAREN
-;
-
-connectorPointingRight
-: TO
-| RIGHT_ARROW
-;
-
-connectorUndirected
-: TO
-| TILDE
-;
-
-sourceNodeTypeAlias
-: regularIdentifier
-;
-
-destinationNodeTypeAlias
-: regularIdentifier
-;
-
-// 18.4 <label set phrase> and <label set specification>
-
-labelSetPhrase
-: LABEL labelName
-| LABELS labelSetSpecification
-| isOrColon labelSetSpecification
-;
-
-labelSetSpecification
-: labelName (AMPERSAND labelName)*
-;
-
-// 18.5 <property types specification>
-
-propertyTypesSpecification
-: LEFT_BRACE propertyTypeList? RIGHT_BRACE
-;
-
-propertyTypeList
-: propertyType (COMMA propertyType)*
-;
-
-// 18.6 <property type>
-
-propertyType
-: propertyName typed? propertyValueType
-;
-
-// 18.7 <property value type>
-
-propertyValueType
-: valueType
-;
-
-// 18.8 <binding table type>
-
-bindingTableType
-: BINDING? TABLE fieldTypesSpecification
-;
-
-// 18.9 <value type>
-
-valueType
-: predefinedType                                                                                                                              #predefinedTypeLabel
-// <constructed value type>
-| pathValueType                                                                                                                               #pathValueTypeLabel
-| listValueTypeName LEFT_ANGLE_BRACKET valueType RIGHT_ANGLE_BRACKET (LEFT_BRACKET maxLength RIGHT_BRACKET)? notNull?     #listValueTypeAlt1
-| valueType listValueTypeName (LEFT_BRACKET maxLength RIGHT_BRACKET)? notNull?                                                    #listValueTypeAlt2
-| listValueTypeName (LEFT_BRACKET maxLength RIGHT_BRACKET)? notNull?                                                                #listValueTypeAlt3
-| recordType                                                                                                                                   #recordTypeLabel
-// <dynamic union type>
-| ANY VALUE? notNull?                                                                                                                        #openDynamicUnionTypeLabel
-| ANY? PROPERTY VALUE notNull?                                                                                                             #dynamicPropertyValueTypeLabel
-// <closed dynamic union type>
-| ANY VALUE? LEFT_ANGLE_BRACKET valueType (VERTICAL_BAR valueType)* RIGHT_ANGLE_BRACKET                                         #closedDynamicUnionTypeAtl1
-| valueType VERTICAL_BAR valueType                                                                                                        #closedDynamicUnionTypeAtl2
-;
-
-typed
-: DOUBLE_COLON
-| TYPED
-;
-
-predefinedType
-: booleanType
-| characterStringType
-| byteStringType
-| numericType
-| temporalType
-| referenceValueType
-| immaterialValueType
-;
-
-booleanType
-: (BOOL | BOOLEAN) notNull?
-;
-
-characterStringType
-: STRING (LEFT_PAREN (minLength COMMA)? maxLength RIGHT_PAREN)? notNull?
-| CHAR (LEFT_PAREN fixedLength RIGHT_PAREN)? notNull?
-| VARCHAR (LEFT_PAREN maxLength RIGHT_PAREN)? notNull?
-;
-
-byteStringType
-: BYTES (LEFT_PAREN (minLength COMMA)? maxLength RIGHT_PAREN)? notNull?
-| BINARY (LEFT_PAREN fixedLength RIGHT_PAREN)? notNull?
-| VARBINARY (LEFT_PAREN maxLength RIGHT_PAREN)? notNull?
-;
-
-minLength
-: unsignedInteger
-;
-
-maxLength
-: unsignedInteger
-;
-
-fixedLength
-: unsignedInteger
-;
-
-numericType
-: exactNumericType
-| approximateNumericType
-;
-
-exactNumericType
-: binaryExactNumericType
-| decimalExactNumericType
-;
-
-binaryExactNumericType
-: signedBinaryExactNumericType
-| unsignedBinaryExactNumericType
-;
-
-signedBinaryExactNumericType
-: INT8 notNull?
-| INT16 notNull?
-| INT32 notNull?
-| INT64 notNull?
-| INT128 notNull?
-| INT256 notNull?
-| SMALLINT notNull?
-| INT (LEFT_PAREN precision RIGHT_PAREN)? notNull?
-| BIGINT notNull?
-| SIGNED? verboseBinaryExactNumericType
-;
-
-unsignedBinaryExactNumericType
-: UINT8 notNull?
-| UINT16 notNull?
-| UINT32 notNull?
-| UINT64 notNull?
-| UINT128 notNull?
-| UINT256 notNull?
-| USMALLINT notNull?
-| UINT (LEFT_PAREN precision RIGHT_PAREN)? notNull?
-| UBIGINT notNull?
-| UNSIGNED verboseBinaryExactNumericType
-;
-
-verboseBinaryExactNumericType
-: INTEGER8 notNull?
-| INTEGER16 notNull?
-| INTEGER32 notNull?
-| INTEGER64 notNull?
-| INTEGER128 notNull?
-| INTEGER256 notNull?
-| SMALL INTEGER notNull?
-| INTEGER (LEFT_PAREN precision RIGHT_PAREN)? notNull?
-| BIG INTEGER notNull?
-;
-
-decimalExactNumericType
-: (DECIMAL | DEC) (LEFT_PAREN precision (COMMA scale)? RIGHT_PAREN notNull?)?
-;
-
-precision
-: unsignedDecimalInteger
-;
-
-scale
-: unsignedDecimalInteger
-;
-
-approximateNumericType
-: FLOAT16 notNull?
-| FLOAT32 notNull?
-| FLOAT64 notNull?
-| FLOAT128 notNull?
-| FLOAT256 notNull?
-| FLOAT (LEFT_PAREN precision (COMMA scale)? RIGHT_PAREN)? notNull?
-| REAL notNull?
-| DOUBLE PRECISION? notNull?
-;
-
-temporalType
-: temporalInstantType
-| temporalDurationType
-;
-
-temporalInstantType
-: datetimeType
-| localdatetimeType
-| dateType
-| timeType
-| localtimeType
-;
-
-datetimeType
-: ZONED DATETIME notNull?
-| TIMESTAMP WITH TIME ZONE notNull?
-;
-
-localdatetimeType
-: LOCAL DATETIME notNull?
-| TIMESTAMP (WITHOUT TIME ZONE)? notNull?
-;
-
-dateType
-: DATE notNull?
-;
-
-timeType
-: ZONED TIME notNull?
-| TIME WITH TIME ZONE notNull?
-;
-
-localtimeType
-: LOCAL TIME notNull?
-| TIME WITHOUT TIME ZONE notNull?
-;
-
-temporalDurationType
-: DURATION LEFT_PAREN temporalDurationQualifier RIGHT_PAREN notNull?
-;
-
-temporalDurationQualifier
-: YEAR TO MONTH
-| DAY TO SECOND
-;
-
-referenceValueType
-: graphReferenceValueType
-| bindingTableReferenceValueType
-| nodeReferenceValueType
-| edgeReferenceValueType
-;
-
-immaterialValueType
-: nullType
-| emptyType
-;
-
-nullType
-: NULL
-;
-
-emptyType
-: NULL notNull
-| NOTHING
-;
-
-graphReferenceValueType
-: openGraphReferenceValueType
-| closedGraphReferenceValueType
-;
-
-closedGraphReferenceValueType
-: PROPERTY? GRAPH nestedGraphTypeSpecification notNull?
-;
-
-openGraphReferenceValueType
-: ANY PROPERTY? GRAPH notNull?
-;
-
-bindingTableReferenceValueType
-: bindingTableType notNull?
-;
-
-nodeReferenceValueType
-: openNodeReferenceValueType
-| closedNodeReferenceValueType
-;
-
-closedNodeReferenceValueType
-: nodeTypeSpecification notNull?
-;
-
-openNodeReferenceValueType
-: ANY? nodeSynonym notNull?
-;
-
-edgeReferenceValueType
-: openEdgeReferenceValueType
-| closedEdgeReferenceValueType
-;
-
-closedEdgeReferenceValueType
-: edgeTypeSpecification notNull?
-;
-
-openEdgeReferenceValueType
-: ANY? edgeSynonym notNull?
-;
-
-pathValueType
-: PATH notNull?
-;
-
-listValueTypeName
-: GROUP? listValueTypeNameSynonym
-;
-
-listValueTypeNameSynonym
-: LIST
-| ARRAY
-;
-
-recordType
-: ANY? RECORD notNull?
-| RECORD? fieldTypesSpecification notNull?
-;
-
-fieldTypesSpecification
-: LEFT_BRACE fieldTypeList? RIGHT_BRACE
-;
-
-fieldTypeList
-: fieldType (COMMA fieldType)*
-;
-
-notNull
-:  NOT NULL
-;
-
-// 18.10 <field type>
-
-fieldType
-: fieldName typed? valueType
-;
-
-// 19.1 <search condition>
-
-searchCondition
-: booleanValueExpression
-;
-
-// 19.2 <predicate>
-
-predicate
-: existsPredicate
-| nullPredicate
-| valueTypePredicate
-| directedPredicate
-| labeledPredicate
-| sourceDestinationPredicate
-| all_differentPredicate
-| samePredicate
-| property_existsPredicate
-;
-
-// 19.3 <comparison predicate>
-
-// The <comparison predicate> productions moved to valueExpression
-// to avoid left mutually recursive productions.
-
-comparisonPredicatePart2
-: compOp valueExpression
-;
-
-compOp
-: EQUALS_OPERATOR
-| NOT_EQUALS_OPERATOR
-| LEFT_ANGLE_BRACKET
-| RIGHT_ANGLE_BRACKET
-| LESS_THAN_OR_EQUALS_OPERATOR
-| GREATER_THAN_OR_EQUALS_OPERATOR
-;
-
-// 19.4 <exists predicate>
-
-existsPredicate
-: EXISTS (LEFT_BRACE graphPattern RIGHT_BRACE | LEFT_PAREN graphPattern RIGHT_PAREN | LEFT_BRACE matchStatementBlock RIGHT_BRACE | LEFT_PAREN matchStatementBlock RIGHT_PAREN | nestedQuerySpecification)
-;
-
-// 19.5 <null predicate>
-
-nullPredicate
-: valueExpressionPrimary nullPredicatePart2
-;
-
-nullPredicatePart2
-: IS NOT? NULL
-;
-
-// 19.6 <value type predicate>
-
-valueTypePredicate
-: valueExpressionPrimary valueTypePredicatePart2
-;
-
-valueTypePredicatePart2
-: IS NOT? typed valueType
-;
-
-// 19.7 <normalized predicate>
-
-normalizedPredicatePart2
-: IS NOT? normalForm? NORMALIZED
-;
-
-// 19.8 <directed predicate>
-
-directedPredicate
-: elementVariableReference directedPredicatePart2
-;
-
-directedPredicatePart2
-: IS NOT? DIRECTED
-;
-
-// 19.9 <labled predicate>
-
-labeledPredicate
-: elementVariableReference labeledPredicatePart2
-;
-
-labeledPredicatePart2
-: isLabeledOrColon labelExpression
-;
-
-isLabeledOrColon
-: IS NOT? LABELED
-| COLON
-;
-
-// 19.10 <source/destination predicate>
-
-sourceDestinationPredicate
-: nodeReference sourcePredicatePart2
-| nodeReference destinationPredicatePart2
-;
-
-nodeReference
-: elementVariableReference
-;
-
-sourcePredicatePart2
-: IS NOT? SOURCE OF edgeReference
-;
-
-destinationPredicatePart2
-: IS NOT? DESTINATION OF edgeReference
-;
-
-edgeReference
-: elementVariableReference
-;
-
-// 19.11 <all different predicate>
-
-all_differentPredicate
-: ALL_DIFFERENT LEFT_PAREN elementVariableReference COMMA elementVariableReference (COMMA elementVariableReference)* RIGHT_PAREN
-;
-
-// 19.12 <same predicate>
-
-samePredicate
-: SAME LEFT_PAREN elementVariableReference COMMA elementVariableReference (COMMA elementVariableReference)* RIGHT_PAREN
-;
-
-// 19.13 <property exists predicate>
-
-property_existsPredicate
-: PROPERTY_EXISTS LEFT_PAREN elementVariableReference COMMA propertyName RIGHT_PAREN
-;
-
-// 20.1 <value expression>
-
-// This version of valueExpression sucks up rules broken out in the standard to a single production. This
-// eliminates ambiguity in multiple rules specifying valueExpressionPrimary.
-
-valueExpression
-// Numeric, datetime and duration types all support roughly the same expressions. So here
-// we define a rule that deals with all of them. It is up to the implementation to post
-// process the sytnax tree and flag invalid type and function combinations.
-: sign = (PLUS_SIGN | MINUS_SIGN) valueExpression                       #signedExprAlt
-| valueExpression operator = (ASTERISK | SOLIDUS) valueExpression       #multDivExprAlt
-| valueExpression operator = (PLUS_SIGN | MINUS_SIGN) valueExpression   #addSubtractExprAlt
-// Character strings, byte strings, lists and paths all support the same concatenation
-// operator. So here we define a rule that deals with all of them. Of course the types
-// cannot be combined. So it is up to implementation to post process the sytax tree
-// and flag invalid type and function combinations.
-| valueExpression CONCATENATION_OPERATOR valueExpression                #concatenationExprAlt
-// Boolean value expression included here.
-| NOT valueExpression                                                   #notExprAlt
-| valueExpression IS NOT? truthValue                                    #isNotExprAlt
-| valueExpression AND valueExpression                                   #conjunctiveExprAlt
-| valueExpression operator = (OR | XOR) valueExpression                 #disjunctiveExprAlt
-// The comparisonPredicate productions moved here to eliminate left mutual recursion.
-| valueExpression comparisonPredicatePart2                              #comparisonExprAlt
-| predicate                                                             #predicateExprAlt
-// The normalizedPredicate productions moved here to eliminate left mutual recursion.
-| valueExpression normalizedPredicatePart2                              #normalizedPredicateExprAlt
-| PROPERTY? GRAPH graphExpression                                       #propertyGraphExprAlt
-| BINDING? TABLE bindingTableExpression                                 #bindingTableExprAlt
-| valueFunction                                                         #valueFunctionExprAlt
-| valueExpressionPrimary                                                #primaryExprAlt
-;
-
-valueFunction
-: numericValueFunction
-| datetimeSubtraction
-| datetimeValueFunction
-| durationValueFunction
-| characterOrByteStringFunction
-| listValueFunction
-;
-
-booleanValueExpression
-: valueExpression
-;
-
-characterOrByteStringFunction
-: subCharacterOrByteString
-| trimSingleCharacterOrByteString
-| foldCharacterString
-| trimMultiCharacterCharacterString
-| normalizeCharacterString
-;
-
-subCharacterOrByteString
-: (LEFT | RIGHT) LEFT_PAREN valueExpression COMMA stringLength RIGHT_PAREN
-;
-
-trimSingleCharacterOrByteString
-: TRIM LEFT_PAREN trimOperands RIGHT_PAREN
-;
-
-foldCharacterString
-: (UPPER | LOWER) LEFT_PAREN valueExpression RIGHT_PAREN
-;
-
-trimMultiCharacterCharacterString
-: (BTRIM | LTRIM | RTRIM) LEFT_PAREN valueExpression (COMMA valueExpression)? RIGHT_PAREN
-;
-
-normalizeCharacterString
-: NORMALIZE LEFT_PAREN valueExpression (COMMA normalForm)? RIGHT_PAREN
-;
-
-nodeReferenceValueExpression
-: valueExpressionPrimary
-;
-
-edgeReferenceValueExpression
-: valueExpressionPrimary
-;
-
-aggregatingValueExpression
-: valueExpression
-;
-
-// 20.2 <value expression primary>
-
-valueExpressionPrimary
-: parenthesizedValueExpression
-| aggregateFunction
-| unsignedValueSpecification
-// List and Record literals are reduntantly/abiguously part of the literal production
-//    | listValueConstructor
-//    | recordConstructor
-| pathValueConstructor
-| valueExpressionPrimary PERIOD propertyName      // <propertyReference
-| valueQueryExpression
-| caseExpression
-| castSpecification
-| element_idFunction
-| letValueExpression
-| bindingVariableReference
-;
-
-parenthesizedValueExpression
-: LEFT_PAREN valueExpression RIGHT_PAREN
-;
-
-nonParenthesizedValueExpressionPrimary
-: nonParenthesizedValueExpressionPrimarySpecialCase
-| bindingVariableReference
-;
-
-nonParenthesizedValueExpressionPrimarySpecialCase
-: aggregateFunction
-| unsignedValueSpecification
-// List and Record literals are reduntantly/abiguously part of the literal production
-//    | listValueConstructor
-//    | recordConstructor
-| pathValueConstructor
-| valueExpressionPrimary PERIOD propertyName      // <property reference>
-| valueQueryExpression
-| caseExpression
-| castSpecification
-| element_idFunction
-| letValueExpression
-;
-
-// 20.3 <value specification>
-
-unsignedValueSpecification
-: unsignedLiteral
-| generalValueSpecification
-;
-
-nonNegativeIntegerSpecification
-: unsignedInteger
-| dynamicParameterSpecification
-;
-
-generalValueSpecification
-: dynamicParameterSpecification
-| SESSION_USER
-;
-
-// 20.4 <dynamic parameter specification>
-
-dynamicParameterSpecification
-: GENERAL_PARAMETER_REFERENCE
-;
-
-// 20.5 <let value expression>
-
-letValueExpression
-: LET letVariableDefinitionList IN valueExpression END
-;
-
-// 20.6 <value query expression>
-
-valueQueryExpression
-: VALUE nestedQuerySpecification
-;
-
-// 20.7 <case expression>
-
-caseExpression
-: caseAbbreviation
-| caseSpecification
-;
-
-caseAbbreviation
-: NULLIF LEFT_PAREN valueExpression COMMA valueExpression RIGHT_PAREN
-| COALESCE LEFT_PAREN valueExpression (COMMA valueExpression)+ RIGHT_PAREN
-;
-
-caseSpecification
-: simpleCase
-| searchedCase
-;
-
-simpleCase
-: CASE caseOperand simpleWhenClause+ elseClause? END
-;
-
-searchedCase
-: CASE searchedWhenClause+ elseClause? END
-;
-
-simpleWhenClause
-: WHEN whenOperandList THEN result
-;
-
-searchedWhenClause
-: WHEN searchCondition THEN result
-;
-
-elseClause
-: ELSE result
-;
-
-caseOperand
-: nonParenthesizedValueExpressionPrimary
-| elementVariableReference
-;
-
-whenOperandList
-: whenOperand (COMMA whenOperand)*
-;
-
-whenOperand
-: nonParenthesizedValueExpressionPrimary
-| comparisonPredicatePart2
-| nullPredicatePart2
-| valueTypePredicatePart2
-| normalizedPredicatePart2
-| directedPredicatePart2
-| labeledPredicatePart2
-| sourcePredicatePart2
-| destinationPredicatePart2
-;
-
-result
-: resultExpression
-| nullLiteral
-;
-
-resultExpression
-: valueExpression
-;
-
-// 20.8 <cast specification>
-
-castSpecification
-: CAST LEFT_PAREN castOperand AS castTarget RIGHT_PAREN
-;
-
-castOperand
-: valueExpression
-| nullLiteral
-;
-
-castTarget
-: valueType
-;
-
-// 20.9 <aggregate function>
-
-aggregateFunction
-: COUNT LEFT_PAREN ASTERISK RIGHT_PAREN
-| generalSetFunction
-| binarySetFunction
-;
-
-generalSetFunction
-: generalSetFunctionType LEFT_PAREN setQuantifier? valueExpression RIGHT_PAREN
-;
-
-binarySetFunction
-: binarySetFunctionType LEFT_PAREN dependentValueExpression COMMA independentValueExpression RIGHT_PAREN
-;
-
-generalSetFunctionType
-: AVG
-| COUNT
-| MAX
-| MIN
-| SUM
-| COLLECT_LIST
-| STDDEV_SAMP
-| STDDEV_POP
-;
-
-setQuantifier
-: DISTINCT
-| ALL
-;
-
-binarySetFunctionType
-: PERCENTILE_CONT
-| PERCENTILE_DISC
-;
-
-dependentValueExpression
-: setQuantifier? numericValueExpression
-;
-
-independentValueExpression
-: numericValueExpression
-;
-
-// 20.10 <element_id function>
-
-element_idFunction
-: ELEMENT_ID LEFT_PAREN elementVariableReference RIGHT_PAREN
-;
-
-// 20.11 <property reference>
-
-// 20.12 <binding variable reference>
-
-bindingVariableReference
-: bindingVariable
-;
-
-// The path value expression was combined with list and string value expressions.
-// See listStringOrPathValueExpression.
-
-pathValueExpression
-: valueExpression
-;
-
-// 20.14 <path value constructor>
-
-pathValueConstructor
-: pathValueConstructorByEnumeration
-;
-
-pathValueConstructorByEnumeration
-: PATH LEFT_BRACKET pathElementList RIGHT_BRACKET
-;
-
-pathElementList
-: pathElementListStart pathElementListStep*
-;
-
-pathElementListStart
-: nodeReferenceValueExpression
-;
-
-pathElementListStep
-: COMMA edgeReferenceValueExpression COMMA nodeReferenceValueExpression
-;
-
-// 20.15 <list value expression>
-
-// The list value expression was combined with path and string value expressions.
-// See listStringOrPathValueExpression.
-
-listValueExpression
-: valueExpression
-;
-
-// 20.16 <list value function>
-
-// Note: ByteString functions were moved to characterByteStringOrListFunction, some alternatives
-// apply to characterString, byteString and list. Breaking them out separately resulted in
-// ambiguity.
-
-listValueFunction
-: trimListFunction
-| elementsFunction
-;
-
-trimListFunction
-: TRIM LEFT_PAREN listValueExpression COMMA numericValueExpression RIGHT_PAREN
-;
-
-elementsFunction
-: ELEMENTS LEFT_PAREN pathValueExpression RIGHT_PAREN
-;
-
-// 20.17 <list value constructor>
-
-listValueConstructor
-: listValueConstructorByEnumeration
-;
-
-listValueConstructorByEnumeration
-: listValueTypeName? LEFT_BRACKET listElementList? RIGHT_BRACKET
-;
-
-listElementList
-: listElement (COMMA listElement)*
-;
-
-listElement
-: valueExpression
-;
-
-// 20.18 <record constructor>
-
-recordConstructor
-: RECORD? fieldsSpecification
-;
-
-fieldsSpecification
-: LEFT_BRACE fieldList? RIGHT_BRACE
-;
-
-fieldList
-: field (COMMA field)*
-;
-
-// 20.19 <field>
-
-field
-: fieldName COLON valueExpression
-;
-
-// 20.20 <boolean value expression>
-
-// Most of <boolean value expression> is incorporated in valueExpression
-
-truthValue
-: BOOLEAN_LITERAL
-;
-
-// 20.21 <numeric value expression>
-
-numericValueExpression
-: sign = (PLUS_SIGN | MINUS_SIGN) numericValueExpression
-| numericValueExpression operator = (ASTERISK | SOLIDUS) numericValueExpression
-| numericValueExpression operator = (PLUS_SIGN | MINUS_SIGN) numericValueExpression
-| valueExpressionPrimary
-| numericValueFunction
-;
-
-// 20.22 <numeric value function>
-
-numericValueFunction
-: lengthExpression
-| cardinalityExpression
-| absoluteValueExpression
-| modulusExpression
-| trigonometricFunction
-| generalLogarithmFunction
-| commonLogarithm
-| naturalLogarithm
-| exponentialFunction
-| powerFunction
-| squareRoot
-| floorFunction
-| ceilingFunction
-;
-
-lengthExpression
-: charLengthExpression
-| byteLengthExpression
-| pathLengthExpression
-;
-
-cardinalityExpression
-: CARDINALITY LEFT_PAREN cardinalityExpressionArgument RIGHT_PAREN
-| SIZE LEFT_PAREN listValueExpression RIGHT_PAREN
-;
-
-cardinalityExpressionArgument
-: valueExpression
-;
-
-charLengthExpression
-: (CHAR_LENGTH | CHARACTER_LENGTH) LEFT_PAREN characterStringValueExpression RIGHT_PAREN
-;
-
-byteLengthExpression
-: (BYTE_LENGTH | OCTET_LENGTH) LEFT_PAREN byteStringValueExpression RIGHT_PAREN
-;
-
-pathLengthExpression
-: PATH_LENGTH LEFT_PAREN pathValueExpression RIGHT_PAREN
-;
-
-// absoluteValueExpression applies to both numeric types and duration types. They have the same syntax.
-absoluteValueExpression
-: ABS LEFT_PAREN valueExpression RIGHT_PAREN
-;
-
-modulusExpression
-: MOD LEFT_PAREN numericValueExpressionDividend COMMA numericValueExpressionDivisor RIGHT_PAREN
-;
-
-numericValueExpressionDividend
-: numericValueExpression
-;
-
-numericValueExpressionDivisor
-: numericValueExpression
-;
-
-trigonometricFunction
-: trigonometricFunctionName LEFT_PAREN numericValueExpression RIGHT_PAREN
-;
-
-trigonometricFunctionName
-: SIN
-| COS
-| TAN
-| COT
-| SINH
-| COSH
-| TANH
-| ASIN
-| ACOS
-| ATAN
-| DEGREES
-| RADIANS
-;
-
-generalLogarithmFunction
-: LOG LEFT_PAREN generalLogarithmBase COMMA generalLogarithmArgument RIGHT_PAREN
-;
-
-generalLogarithmBase
-: numericValueExpression
-;
-
-generalLogarithmArgument
-: numericValueExpression
-;
-
-commonLogarithm
-: LOG10 LEFT_PAREN numericValueExpression RIGHT_PAREN
-;
-
-naturalLogarithm
-: LN LEFT_PAREN numericValueExpression RIGHT_PAREN
-;
-
-exponentialFunction
-: EXP LEFT_PAREN numericValueExpression RIGHT_PAREN
-;
-
-powerFunction
-: POWER LEFT_PAREN numericValueExpressionBase COMMA numericValueExpressionExponent RIGHT_PAREN
-;
-
-numericValueExpressionBase
-: numericValueExpression
-;
-
-numericValueExpressionExponent
-: numericValueExpression
-;
-
-squareRoot
-: SQRT LEFT_PAREN numericValueExpression RIGHT_PAREN
-;
-
-floorFunction
-: FLOOR LEFT_PAREN numericValueExpression RIGHT_PAREN
-;
-
-ceilingFunction
-: (CEIL | CEILING) LEFT_PAREN numericValueExpression RIGHT_PAREN
-;
-
-// 20.23 <string value expression>
-
-// The string value expressions were combined with list and path value expressions.
-
-characterStringValueExpression
-: valueExpression
-;
-
-byteStringValueExpression
-: valueExpression
-;
-
-// 20.24 <string value function>
-
-// Note: String functions were moved to characterByteStringOrListFunction, some alternatives
-// apply to characterString, byteString and list. Breaking them out separately resulted in
-// ambiguity.
-
-trimOperands
-: (trimSpecification? trimCharacterOrByteString? FROM)? trimCharacterOrByteStringSource
-;
-
-trimCharacterOrByteStringSource
-: valueExpression
-;
-
-trimSpecification
-: LEADING
-| TRAILING
-| BOTH
-;
-
-trimCharacterOrByteString
-: valueExpression
-;
-
-normalForm
-: NFC
-| NFD
-| NFKC
-| NFKD
-;
-
-stringLength
-: numericValueExpression
-;
-
-// 20.25 <byte string function>
-
-// Note: ByteString functions were moved to characterByteStringOrListFunction, some alternatives
-// apply to characterString, byteString and list. Breaking them out separately resulted in
-// ambiguity.
-
-// 20.26 <datetime value expression>
-
-// The implementation should enforce that the data type is a datetime value.
-datetimeValueExpression
-: valueExpression
-;
-
-// 20.27 <datetime value function>
-
-datetimeValueFunction
-: dateFunction
-| timeFunction
-| datetimeFunction
-| localtimeFunction
-| localdatetimeFunction
-;
-
-dateFunction
-: CURRENT_DATE
-| DATE LEFT_PAREN dateFunctionParameters? RIGHT_PAREN
-;
-
-timeFunction
-: CURRENT_TIME
-| ZONED_TIME LEFT_PAREN timeFunctionParameters? RIGHT_PAREN
-;
-
-localtimeFunction
-: LOCAL_TIME (LEFT_PAREN timeFunctionParameters? RIGHT_PAREN)?
-;
-
-datetimeFunction
-: CURRENT_TIMESTAMP
-| ZONED_DATETIME LEFT_PAREN datetimeFunctionParameters? RIGHT_PAREN
-;
-
-localdatetimeFunction
-: LOCAL_TIMESTAMP
-| LOCAL_DATETIME LEFT_PAREN datetimeFunctionParameters? RIGHT_PAREN
-;
-
-dateFunctionParameters
-: dateString
-| recordConstructor
-;
-
-timeFunctionParameters
-: timeString
-| recordConstructor
-;
-
-datetimeFunctionParameters
-: datetimeString
-| recordConstructor
-;
-
-// 20.28 <duration value expression>
-
-// The implemenation should enforce that the data type is a duration value.
-durationValueExpression
-: valueExpression
-;
-
-datetimeSubtraction
-: DURATION_BETWEEN LEFT_PAREN datetimeSubtractionParameters RIGHT_PAREN temporalDurationQualifier?
-;
-
-datetimeSubtractionParameters
-: datetimeValueExpression1 COMMA datetimeValueExpression2
-;
-
-datetimeValueExpression1
-: datetimeValueExpression
-;
-
-datetimeValueExpression2
-: datetimeValueExpression
-;
-
-// 20.29 <duration value function>
-
-durationValueFunction
-: durationFunction
-| absoluteValueExpression
-;
-
-durationFunction
-: DURATION LEFT_PAREN durationFunctionParameters RIGHT_PAREN
-;
-
-durationFunctionParameters
-: durationString
-| recordConstructor
-;
-
-// 21.1 Names and Variables
-
-objectName
-: identifier
-;
-
-objectNameOrBindingVariable
-: regularIdentifier
-;
-
-directoryName
-: identifier
-;
-
-schemaName
-: identifier
-;
-
-graphName
-: regularIdentifier
-| delimitedGraphName
-;
-
-delimitedGraphName
-// DELIMITED_IDENTIFIER
-: DOUBLE_QUOTED_CHARACTER_SEQUENCE
-| ACCENT_QUOTED_CHARACTER_SEQUENCE
-;
-
-graphTypeName
-: identifier
-;
-
-nodeTypeName
-: identifier
-;
-
-edgeTypeName
-: identifier
-;
-
-bindingTableName
-: regularIdentifier
-| delimitedBindingTableName
-;
-
-delimitedBindingTableName
-// DELIMITED_IDENTIFIER
-: DOUBLE_QUOTED_CHARACTER_SEQUENCE
-| ACCENT_QUOTED_CHARACTER_SEQUENCE
-;
-
-procedureName
-: identifier
-;
-
-labelName
-: identifier
-;
-
-propertyName
-: identifier
-;
-
-fieldName
-: identifier
-;
-
-elementVariable
-: bindingVariable
-;
-
-pathVariable
-: bindingVariable
-;
-
-subpathVariable
-: regularIdentifier
-;
-
-bindingVariable
-: regularIdentifier
-;
-
-// 21.2 <literal>
-
-unsignedLiteral
-: unsignedNumericLiteral
-| generalLiteral
-;
-
-generalLiteral
-: BOOLEAN_LITERAL
-| characterStringLiteral
-| BYTE_STRING_LITERAL
-| temporalLiteral
-| durationLiteral
-| nullLiteral
-| listLiteral
-| recordLiteral
-;
-
-temporalLiteral
-: dateLiteral
-| timeLiteral
-| datetimeLiteral
-//    | sqlDatetimeLiteral
-;
-
-dateLiteral
-: DATE dateString
-;
-
-timeLiteral
-: TIME timeString
-;
-
-datetimeLiteral
-: (DATETIME | TIMESTAMP) datetimeString
-;
-
-listLiteral
-: listValueConstructorByEnumeration
-;
-
-recordLiteral
-: recordConstructor
-;
-
-identifier
-: regularIdentifier
-// DELIMITED_IDENTIFIER
-| DOUBLE_QUOTED_CHARACTER_SEQUENCE
-| ACCENT_QUOTED_CHARACTER_SEQUENCE
-;
-
-regularIdentifier
-: REGULAR_IDENTIFIER
-| nonReservedWords
-;
-
-timeZoneString
-: characterStringLiteral
-;
-
-characterStringLiteral
-: SINGLE_QUOTED_CHARACTER_SEQUENCE
-| DOUBLE_QUOTED_CHARACTER_SEQUENCE
-;
-
-unsignedNumericLiteral
-: exactNumericLiteral
-| approximateNumericLiteral
-;
-
-exactNumericLiteral
-: UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION_WITH_EXACT_NUMBER_SUFFIX
-| UNSIGNED_DECIMAL_IN_COMMON_NOTATION_WITH_EXACT_NUMBER_SUFFIX
-| UNSIGNED_DECIMAL_IN_COMMON_NOTATION_WITHOUT_SUFFIX
-| UNSIGNED_DECIMAL_INTEGER_WITH_EXACT_NUMBER_SUFFIX
-| unsignedInteger
-;
-
-approximateNumericLiteral
-: UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION_WITH_APPROXIMATE_NUMBER_SUFFIX
-| UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION_WITHOUT_SUFFIX
-| UNSIGNED_DECIMAL_IN_COMMON_NOTATION_WITH_APPROXIMATE_NUMBER_SUFFIX
-| UNSIGNED_DECIMAL_INTEGER_WITH_APPROXIMATE_NUMBER_SUFFIX
-;
-
-unsignedInteger
-: UNSIGNED_DECIMAL_INTEGER
-| UNSIGNED_HEXADECIMAL_INTEGER
-| UNSIGNED_OCTAL_INTEGER
-| UNSIGNED_BINARY_INTEGER
-;
-
-unsignedDecimalInteger
-: UNSIGNED_DECIMAL_INTEGER
-;
-
-nullLiteral
-: NULL
-;
-
-dateString
-: characterStringLiteral
-;
-
-timeString
-: characterStringLiteral
-;
-
-datetimeString
-: characterStringLiteral
-;
-
-durationLiteral
-: DURATION durationString
-//    | sqlIntervalLiteral
-;
-
-durationString
-: characterStringLiteral
-;
-
-nodeSynonym
-: NODE
-| VERTEX
-;
-
-edgesSynonym
-: EDGES
-| RELATIONSHIPS
-;
-
-edgeSynonym
-: EDGE
-| RELATIONSHIP
-;
-
-// 21.1 Names and Variables
-
-IMPLIES
-: RIGHT_DOUBLE_ARROW
-| 'IMPLIES'
-;
-
-fragment PARAMETER_NAME
-: SEPARATED_IDENTIFIER
-;
-
-// 21.2 <literal>
-
-nonReservedWords
-: ACYCLIC
-| BINDING
-| BINDINGS
-| CONNECTING
-| DESTINATION
-| DIFFERENT
-| DIRECTED
-| EDGE
-| EDGES
-| ELEMENT
-| ELEMENTS
-| FIRST
-| GRAPH
-| GROUPS
-| KEEP
-| LABEL
-| LABELED
-| LABELS
-| LAST
-| NFC
-| NFD
-| NFKC
-| NFKD
-| NO
-| NODE
-| NORMALIZED
-| ONLY
-| ORDINALITY
-| PROPERTY
-| READ
-| RELATIONSHIP
-| RELATIONSHIPS
-| REPEATABLE
-| SHORTEST
-| SIMPLE
-| SOURCE
-| TABLE
-| TEMP
-| TO
-| TRAIL
-| TRANSACTION
-| TYPE
-| UNDIRECTED
-| VERTEX
-| WALK
-| WITHOUT
-| WRITE
-| ZONE
-;
-
-BOOLEAN_LITERAL
-: 'TRUE'
-| 'FALSE'
-| 'UNKNOWN'
-;
-
-SINGLE_QUOTED_CHARACTER_SEQUENCE
-: NO_ESCAPE? UNBROKEN_SINGLE_QUOTED_CHARACTER_SEQUENCE
-;
-
-DOUBLE_QUOTED_CHARACTER_SEQUENCE
-: NO_ESCAPE? UNBROKEN_DOUBLE_QUOTED_CHARACTER_SEQUENCE
-;
-
-ACCENT_QUOTED_CHARACTER_SEQUENCE
-:NO_ESCAPE? UNBROKEN_ACCENT_QUOTED_CHARACTER_SEQUENCE
-;
-
-NO_ESCAPE
-: COMMERCIAL_AT
-;
-
-fragment UNBROKEN_SINGLE_QUOTED_CHARACTER_SEQUENCE
-: QUOTE SINGLE_QUOTED_CHARACTER_REPRESENTATION* QUOTE
-;
-
-fragment UNBROKEN_DOUBLE_QUOTED_CHARACTER_SEQUENCE
-: DOUBLE_QUOTE DOUBLE_QUOTED_CHARACTER_REPRESENTATION* DOUBLE_QUOTE
-;
-
-fragment UNBROKEN_ACCENT_QUOTED_CHARACTER_SEQUENCE
-: GRAVE_ACCENT ACCENT_QUOTED_CHARACTER_REPRESENTATION* GRAVE_ACCENT
-;
-
-
-
-
-fragment ESCAPED_CHARACTER
-: ESCAPED_REVERSE_SOLIDUS
-| ESCAPED_QUOTE
-| ESCAPED_DOUBLE_QUOTE
-| ESCAPED_GRAVE_ACCENT
-| ESCAPED_TAB
-| ESCAPED_BACKSPACE
-| ESCAPED_NEW_LINE
-| ESCAPED_CARRIAGE_RETURN
-| ESCAPED_FORM_FEED
-| ESCAPED_UNICODE4_DIGIT_VALUE
-| ESCAPED_UNICODE6_DIGIT_VALUE
-;
-
-
-// Todo: Finish this. It is tricky how it interacts with <separator>
-BYTE_STRING_LITERAL
-
-UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION_WITH_EXACT_NUMBER_SUFFIX
-: UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION EXACT_NUMBER_SUFFIX
-;
-
-UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION_WITHOUT_SUFFIX
-: UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION
-;
-
-UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION_WITH_APPROXIMATE_NUMBER_SUFFIX
-: UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION APPROXIMATE_NUMBER_SUFFIX
-;
-
-UNSIGNED_DECIMAL_IN_COMMON_NOTATION_WITH_EXACT_NUMBER_SUFFIX
-: UNSIGNED_DECIMAL_IN_COMMON_NOTATION EXACT_NUMBER_SUFFIX
-;
-
-UNSIGNED_DECIMAL_IN_COMMON_NOTATION_WITHOUT_SUFFIX
-: UNSIGNED_DECIMAL_IN_COMMON_NOTATION
-;
-
-UNSIGNED_DECIMAL_IN_COMMON_NOTATION_WITH_APPROXIMATE_NUMBER_SUFFIX
-: UNSIGNED_DECIMAL_IN_COMMON_NOTATION APPROXIMATE_NUMBER_SUFFIX
-;
-
-UNSIGNED_DECIMAL_INTEGER_WITH_EXACT_NUMBER_SUFFIX
-: UNSIGNED_DECIMAL_INTEGER EXACT_NUMBER_SUFFIX
-;
-
-UNSIGNED_DECIMAL_INTEGER_WITH_APPROXIMATE_NUMBER_SUFFIX
-: UNSIGNED_DECIMAL_INTEGER APPROXIMATE_NUMBER_SUFFIX
-;
-
-UNSIGNED_DECIMAL_INTEGER
-
-fragment EXACT_NUMBER_SUFFIX
-: 'M'
-;
-
-fragment UNSIGNED_DECIMAL_IN_SCIENTIFIC_NOTATION
-: MANTISSA 'E' EXPONENT
-;
-
-fragment MANTISSA
-: UNSIGNED_DECIMAL_IN_COMMON_NOTATION
-| UNSIGNED_DECIMAL_INTEGER
-;
-
-fragment EXPONENT
-: SIGNED_DECIMAL_INTEGER
-;
-
-fragment UNSIGNED_DECIMAL_IN_COMMON_NOTATION
-: UNSIGNED_DECIMAL_INTEGER (PERIOD UNSIGNED_DECIMAL_INTEGER?)
-| PERIOD UNSIGNED_DECIMAL_INTEGER
-;
-
-fragment SIGNED_DECIMAL_INTEGER
-: (PLUS_SIGN | MINUS_SIGN)? UNSIGNED_DECIMAL_INTEGER
-;
-
-UNSIGNED_HEXADECIMAL_INTEGER
-
-UNSIGNED_OCTAL_INTEGER
-: '0o' ('_'? OCTAL_DIGIT)+
-;
-
-UNSIGNED_BINARY_INTEGER
-: '0b' ('_'? BINARY_DIGIT)+
-;
-
-fragment APPROXIMATE_NUMBER_SUFFIX
-: 'F'
-| 'D'
-;
-
-// 21.3 <token>, <separator>, and <identifier>
-
-// Reserved words
-
-// Prereserved words
-
-// Nonreserved words
-
-fragment SEPARATED_IDENTIFIER
-: DELIMITED_IDENTIFIER
-| EXTENDED_IDENTIFIER
-;
-
-REGULAR_IDENTIFIER
-: IDENTIFIER_START IDENTIFIER_EXTEND*
-;
-
-fragment EXTENDED_IDENTIFIER
-: IDENTIFIER_EXTEND+
-;
-
-fragment DELIMITED_IDENTIFIER
-: DOUBLE_QUOTED_CHARACTER_SEQUENCE
-| ACCENT_QUOTED_CHARACTER_SEQUENCE
-;
-
-SUBSTITUTED_PARAMETER_REFERENCE
-: DOUBLE_DOLLAR_SIGN PARAMETER_NAME
-;
-
-GENERAL_PARAMETER_REFERENCE
-: DOLLAR_SIGN PARAMETER_NAME
-;
-
-fragment IDENTIFIER_START
-: ID_Start
-| Pc
-;
-
-fragment IDENTIFIER_EXTEND
-: ID_Continue
-;
-
-fragment ID_Start
-: [\p{ID_Start}]
-;
-
-fragment ID_Continue
-: [\p{ID_Continue}]
-;
-
-
-
-// 21.4 GQL terminal characters
-
-
-
-
-fragment OCTAL_DIGIT
-: [0-7]
-;
-
-fragment BINARY_DIGIT
-: [0-1]
-;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/developer/executor/Arithmetic_Echo b/developer/executor/Arithmetic_Echo
new file mode 100755 (executable)
index 0000000..0ae8589
--- /dev/null
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -cp :/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm/Arithmetic_Echo.jar Arithmetic_Echo $@
diff --git a/developer/executor/RuleNameList b/developer/executor/RuleNameList
new file mode 100755 (executable)
index 0000000..3142104
--- /dev/null
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -cp :/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm/RuleNameList.jar RuleNameList $@
index 1e250cb..8779f1f 100755 (executable)
@@ -42,13 +42,14 @@ fi
 #
 
 export EXECUTOR_IN_FL="\
-  PrintRuleNameListRegx\
-  TerminalToCategory\
-  GrammarSplitter\
+  RuleNameListRegx\
+  RuleNameList\
+  ANTLRv4_RuleNameList\
   Arithmetic_Echo\
   Arithmetic_Echo__Test\
   Arithmetic_Syntax\
   Arithmetic_Syntax__Test\
+  ANTLRv4_Syntax\
   GQL_20240412_Syntax\
   GQL_20240412_Syntax__Test\
   "
@@ -142,3 +143,5 @@ for program_path in ${EXECUTOR_IN_FPL}; do
 done
 export JAR_OUT_FPL
 
+
+#  LocalWords:  ANTLRv PrintRuleNameListRegx
index eb56b83..e623b33 100644 (file)
@@ -33,7 +33,8 @@ all: $(EXECUTOR_IN_FPL)
 #-----------------------------------------------
 # A utility for viewing all the rules in a grammar
 
-PrintRuleNameListRegx: $(EXECUTOR_IN_DIR)/PrintRuleNameListRegx
+RuleNameListRegx: $(EXECUTOR_IN_DIR)/RuleNameListRegx
+RuleNameList: $(EXECUTOR_IN_DIR)/RuleNameList
 
 #-----------------------------------------------
 # Arithmetic
@@ -76,6 +77,23 @@ Arithmetic_Syntax__Test:\
        fi
        $(REMAKE) $(EXECUTOR_IN_DIR)/Arithmetic_Syntax__Test
 
+
+#-----------------------------------------------
+# Parsing/Analyzing ANTLR grammars
+#
+
+ANTLR_OUT_ANTLRv4_FPL:= $(shell ANTLR_OUT_FL ANTLRv4 -path $(ANTLR_OUT_DIR))
+ANTLRv4_Syntax:\
+  $(ANTLR_OUT_ANTLRv4_FPL)\
+  $(JAVA_COMP_IN_PRIMARY_DIR)/ANTLRv4_Syntax_PrintVisitor.java
+       @if [ -z "$(ANTLR_OUT_ANTLRv4_FPL)" ]; then \
+         echo "variable ANTLR_OUT_ANTLRv4_FPL empty."; \
+         exit 1; \
+       fi
+       $(REMAKE) $(EXECUTOR_IN_DIR)/ANTLRv4_Syntax
+
+
+
 #-----------------------------------------------
 #  GQL_20240412
 
@@ -129,15 +147,40 @@ java: $(JAVA_COMP_OUT_FPL)
 # $(ANTLR_OUT_DIR)/%Visitor.java: $(ANTLR_IN_PRIMARY_DIR)/%.g4
 #      $(JAVA_INTERP) -jar $(ANTLR_JAR) -Dlanguage=Java -visitor -o $(ANTLR_OUT_DIR_PARENT) $<
 
+#--------------------
+# for a single `<name>.g4` grammar file
 $(ANTLR_OUT_DIR)/%Lexer.java \
 $(ANTLR_OUT_DIR)/%Parser.java \
 $(ANTLR_OUT_DIR)/%BaseListener.java \
 $(ANTLR_OUT_DIR)/%Listener.java \
 $(ANTLR_OUT_DIR)/%BaseVisitor.java \
 $(ANTLR_OUT_DIR)/%Visitor.java: $(ANTLR_IN_PRIMARY_DIR)/%.g4
-       @echo "making grammar from:" $<
+       @echo "copiling grammar from:" $<
        $(JAVA_INTERP) -jar $(ANTLR_JAR) -Dlanguage=Java -visitor -o $(ANTLR_OUT_DIR_PARENT) $<
 
+#--------------------
+# For separate `<mame>Lexer.g4` and `<name>Parser.g4` files.
+# `make` prefers shorter pattern matches, so this should work.
+#
+
+$(ANTLR_OUT_DIR)/LexerAdaptor.java: $(ANTLR_IN_PRIMARY_DIR)/LexerAdaptor.java
+       cp $(ANTLR_IN_PRIMARY_DIR)/LexerAdaptor.java $(ANTLR_OUT_DIR)
+
+$(ANTLR_OUT_DIR)/%Lexer.java: $(ANTLR_IN_PRIMARY_DIR)/%Lexer.g4 $(ANTLR_OUT_DIR)/LexerAdaptor.java
+       @echo "making lexer grammar from:" $<
+       $(JAVA_INTERP) -jar $(ANTLR_JAR) -Dlanguage=Java -visitor -o $(ANTLR_OUT_DIR_PARENT) $<
+
+# Rule for all generated files from Parser.g4
+$(ANTLR_OUT_DIR)/%Parser.java \
+$(ANTLR_OUT_DIR)/%BaseListener.java \
+$(ANTLR_OUT_DIR)/%Listener.java \
+$(ANTLR_OUT_DIR)/%BaseVisitor.java \
+$(ANTLR_OUT_DIR)/%Visitor.java: $(ANTLR_IN_PRIMARY_DIR)/%Parser.g4
+       @echo "making other grammar files from:" $<
+       $(JAVA_INTERP) -jar $(ANTLR_JAR) -Dlanguage=Java -visitor -lib $(ANTLR_OUT_DIR) -o $(ANTLR_OUT_DIR_PARENT) $<
+
+#--------------------------------------------------------------------------------
+
 # Rule to build .class files from .java files
 $(JAVA_COMP_OUT_DIR)/%.class: $(JAVA_COMP_IN_PRIMARY_DIR)/%.java
        @echo "Compiling $<..."
@@ -153,6 +196,7 @@ $(JAVA_COMP_OUT_DIR)/%.jar: $(JAVA_COMP_OUT_DIR)/%.class
        $(JAVA_ARCHIVE) cf $@ -C $(JAVA_COMP_OUT_DIR) $*.class
        @echo "Created $@"
 
+#--------------------
 $(EXECUTOR_IN_DIR)/%: $(JVM_IN_DIR)/%.jar
        @echo "Creating script for $*..."
        @echo "#!/usr/bin/env bash" > $(EXECUTOR_IN_DIR)/$*
index f4dca5f..dc03a81 100644 (file)
@@ -46,8 +46,7 @@ clean:
        @echo "Use the command `clean <option>` instead of make.`"
 
 setup:
-       mkdir -p $(ANTLR_IN_PRIMARY_DIR) $(JAVA_COMP_IN_PRIMARY_DIR) $(JVM_IN_DIR)
-       mkdir -p $(EXECUTOR_IN_DIR) test deprecated experiment ologist temporary
+       mkdir -p $(ANTLR_IN_PRIMARY_DIR) $(JAVA_COMP_IN_PRIMARY_DIR) $(JVM_IN_DIR) $(EXECUTOR_IN_DIR) test deprecated experiment ologist temporary
 
 # Ensure tools are built before building the project programs
 tool-%: setup
diff --git a/developer/javac/ANTLR_Syntax.java b/developer/javac/ANTLR_Syntax.java
deleted file mode 100644 (file)
index 13c6bcc..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Accepts an ANTLR grammar file.
-
-Diagrams the ANTLR grammar file according to the ANTLR grammar grammar.
-
-*/
-import org.antlr.v4.runtime.*;
-import org.antlr.v4.runtime.tree.*;
-
-public class ANTLR_Syntax {
-
-  public static void main(String[] args) throws Exception {
-    try {
-
-      boolean pretty_print = false;
-      List<String> file_arg_list = new ArrayList<>();
-      boolean has_error = false;
-
-      // Parse the options and arguments
-      for (String arg : arg_array) {
-        if (arg.startsWith("-")) {
-          if (arg.equals("-pp")) {
-            pretty_print = true;
-          } else {
-            System.err.println("Unrecognized option: " + arg);
-            has_error = true;
-          }
-        } else {
-          file_arg_list.add(arg);
-        }
-      }
-
-      // If there were any errors, print usage and exit
-      if (has_error) {
-        System.err.println("Usage: java Arithmetic_Syntax [-pp] <input-file>");
-        System.exit(1);
-      }
-
-      // Ensure there is exactly one input file
-      if (file_arg_list.size() != 1) {
-        System.err.println("Usage: java Arithmetic_Syntax [-pp] <input-file>");
-        System.exit(1);
-      }
-
-      String input_file = file_arg_list.get(0);
-      String input = Files.readString(Paths.get(input_file));
-        
-      // Create a lexer and parser for the ANTLR grammar
-      ANTLRv4Lexer lexer = new ANTLRv4Lexer(input);
-      CommonTokenStream tokens = new CommonTokenStream(lexer);
-      ANTLRv4Parser parser = new ANTLRv4Parser(tokens);
-        
-      // Parse the input file
-      ParseTree tree = parser.grammarSpec(); // Start rule for the ANTLR grammar
-        
-      // Walk the tree and visit each node
-      ANTLR_Syntax_PrintVisitor visitor = new ANTLR_Syntax_PrintVisitor(prettyPrint);
-      String output = visitor.visit(tree);
-      System.out.println(output);
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-
-}
diff --git a/developer/javac/ANTLR_Syntax_PrintVisitor.java b/developer/javac/ANTLR_Syntax_PrintVisitor.java
deleted file mode 100644 (file)
index f0420d5..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
-import org.antlr.v4.runtime.tree.TerminalNode;
-
-public class ANTLR_Syntax_PrintVisitor extends ANTLRv4ParserBaseVisitor<String> {
-
-    private int indentLevel = 0;
-    private boolean prettyPrint = false;
-    private StringBuilder output = new StringBuilder();
-
-    public ANTLR_Syntax_PrintVisitor() {
-        this(false);
-    }
-
-    public ANTLR_Syntax_PrintVisitor(boolean prettyPrint) {
-        this.prettyPrint = prettyPrint;
-    }
-
-    private void appendIndented(String message) {
-        if (prettyPrint) {
-            for (int i = 0; i < indentLevel; i++) {
-                output.append("  ");
-            }
-        }
-        output.append(message).append("\n");
-    }
-
-    @Override
-    public String visitGrammarSpec(ANTLRv4Parser.GrammarSpecContext ctx) {
-        appendIndented("grammarSpec");
-        indentLevel++;
-        visitChildren(ctx);
-        indentLevel--;
-        return output.toString();
-    }
-
-    @Override
-    public String visitTerminal(TerminalNode node) {
-        appendIndented(node.getText());
-        return output.toString();
-    }
-
-    // Override other visit methods as needed for specific rules
-
-}
diff --git a/developer/javac/ANTLRv4_Syntax.java b/developer/javac/ANTLRv4_Syntax.java
new file mode 100644 (file)
index 0000000..4b861ef
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+Takes an 'ANTLRv4' grammar source file.  Parses it. Outputs an annotated
+version of the source file while labeling what parts of the grammar the syntax
+objects belong to.  Note the -pp option.
+
+*/
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.tree.*;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ANTLRv4_Syntax {
+
+  public static void main(String[] arg_array) throws IOException {
+    boolean pretty_print = false;
+    List<String> file_arg_list = new ArrayList<>();
+    boolean has_error = false;
+
+    // Parse the options and arguments
+    for (String arg : arg_array) {
+      if (arg.startsWith("-")) {
+        if (arg.equals("-pp")) {
+          pretty_print = true;
+        } else {
+          System.err.println("Unrecognized option: " + arg);
+          has_error = true;
+        }
+      } else {
+        file_arg_list.add(arg);
+      }
+    }
+
+    // If there were any errors, print usage and exit
+    if (has_error) {
+      System.err.println("Usage: java ANTLRv4_Syntax [-pp] <input-file>");
+      System.exit(1);
+    }
+
+    // Ensure there is exactly one input file
+    if (file_arg_list.size() != 1) {
+      System.err.println("Usage: java ANTLRv4_Syntax [-pp] <input-file>");
+      System.exit(1);
+    }
+
+    String input_file = file_arg_list.get(0);
+    String input = Files.readString(Paths.get(input_file));
+
+    try {
+      ANTLRv4Lexer lexer = new ANTLRv4Lexer(CharStreams.fromString(input));
+      CommonTokenStream tokens = new CommonTokenStream(lexer);
+      ANTLRv4Parser parser = new ANTLRv4Parser(tokens);
+      ParseTree tree = parser.grammarSpec();
+
+      ANTLRv4_Syntax_PrintVisitor visitor = new ANTLRv4_Syntax_PrintVisitor(parser.getRuleNames(), pretty_print);
+      String output = visitor.visit(tree);
+      System.out.println(output);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/developer/javac/ANTLRv4_Syntax_PrintVisitor.java b/developer/javac/ANTLRv4_Syntax_PrintVisitor.java
new file mode 100644 (file)
index 0000000..e8aa2b3
--- /dev/null
@@ -0,0 +1,939 @@
+
+
+import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
+
+public class ANTLRv4_Syntax_PrintVisitor extends ANTLRv4BaseVisitor<String>{
+
+  private final String[] rule_names;
+  private final boolean pretty_print;
+
+  public ANTLRv4_Syntax_PrintVisitor(
+String[] rule_names, boolean pretty_print)
+{
+
+  this.rule_names = rule_names;
+  this.pretty_print = pretty_print;
+  }
+
+
+  private String indent(
+int level)
+{
+
+  return "  ".repeat(
+level)
+;
+  }
+
+
+  @Override
+  public Void visitgrammarSpec
+  (
+ANTLRv4Parser.grammarSpec
+   Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("grammarSpec
+             ");
+             return visitChildren(ctx);
+             }}
+  @Override
+    public Void visitgrammarDecl
+    (ANTLRv4Parser.grammarDecl
+     Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"grammarDecl
+               ")
+;
+               return visitChildren(
+ctx)
+;
+               }
+}
+
+    @Override
+    public Void visitgrammarType
+    (
+ANTLRv4Parser.grammarType
+     Context ctx)
+ {
+{
+
+      // Logic to print the current rule's name
+      System.out.println("grammarType
+               ");
+               return visitChildren(ctx);
+               }}
+    @Override
+      public Void visitprequelConstruct
+      (ANTLRv4Parser.prequelConstruct
+       Context ctx) {{
+      // Logic to print the current rule's name
+      System.out.println(
+"prequelConstruct
+                 ")
+;
+                 return visitChildren(
+ctx)
+;
+                 }
+}
+
+      @Override
+      public Void visitoptionsSpec
+      (
+ANTLRv4Parser.optionsSpec
+       Context ctx)
+ {
+{
+
+        // Logic to print the current rule's name
+        System.out.println("optionsSpec
+                 ");
+                 return visitChildren(ctx);
+                 }}
+      @Override
+        public Void visitoption
+        (ANTLRv4Parser.option
+         Context ctx) {{
+        // Logic to print the current rule's name
+        System.out.println(
+"option
+                   ")
+;
+                   return visitChildren(
+ctx)
+;
+                   }
+}
+
+        @Override
+        public Void visitoptionValue
+        (
+ANTLRv4Parser.optionValue
+         Context ctx)
+ {
+{
+
+          // Logic to print the current rule's name
+          System.out.println("optionValue
+                   ");
+                   return visitChildren(ctx);
+                   }}
+        @Override
+          public Void visitdelegateGrammars
+          (ANTLRv4Parser.delegateGrammars
+           Context ctx) {{
+          // Logic to print the current rule's name
+          System.out.println(
+"delegateGrammars
+                     ")
+;
+                     return visitChildren(
+ctx)
+;
+                     }
+}
+
+          @Override
+          public Void visitdelegateGrammar
+          (
+ANTLRv4Parser.delegateGrammar
+           Context ctx)
+ {
+{
+
+            // Logic to print the current rule's name
+            System.out.println("delegateGrammar
+                     ");
+                     return visitChildren(ctx);
+                     }}
+          @Override
+            public Void visittokensSpec
+            (ANTLRv4Parser.tokensSpec
+             Context ctx) {{
+            // Logic to print the current rule's name
+            System.out.println(
+"tokensSpec
+                       ")
+;
+                       return visitChildren(
+ctx)
+;
+                       }
+}
+
+            @Override
+            public Void visitchannelsSpec
+            (
+ANTLRv4Parser.channelsSpec
+             Context ctx)
+ {
+{
+
+              // Logic to print the current rule's name
+              System.out.println("channelsSpec
+                       ");
+                       return visitChildren(ctx);
+                       }}
+            @Override
+              public Void visitidList
+              (ANTLRv4Parser.idList
+               Context ctx) {{
+              // Logic to print the current rule's name
+              System.out.println(
+"idList
+                         ")
+;
+                         return visitChildren(
+ctx)
+;
+                         }
+}
+
+              @Override
+              public Void visitaction_
+              (
+ANTLRv4Parser.action_
+               Context ctx)
+ {
+{
+
+                // Logic to print the current rule's name
+                System.out.println("action_
+                         ");
+                         return visitChildren(ctx);
+                         }}
+              @Override
+                public Void visitactionScopeName
+                (ANTLRv4Parser.actionScopeName
+                 Context ctx) {{
+                // Logic to print the current rule's name
+                System.out.println(
+"actionScopeName
+                           ")
+;
+                           return visitChildren(
+ctx)
+;
+                           }
+}
+
+                @Override
+                public Void visitactionBlock
+                (
+ANTLRv4Parser.actionBlock
+                 Context ctx)
+ {
+{
+
+                  // Logic to print the current rule's name
+                  System.out.println("actionBlock
+                           ");
+                           return visitChildren(ctx);
+                           }}
+                @Override
+                  public Void visitargActionBlock
+                  (ANTLRv4Parser.argActionBlock
+                   Context ctx) {{
+                  // Logic to print the current rule's name
+                  System.out.println(
+"argActionBlock
+                             ")
+;
+                             return visitChildren(
+ctx)
+;
+                             }
+}
+
+                  @Override
+                  public Void visitmodeSpec
+                  (
+ANTLRv4Parser.modeSpec
+                   Context ctx)
+ {
+{
+
+                    // Logic to print the current rule's name
+                    System.out.println("modeSpec
+                             ");
+                             return visitChildren(ctx);
+                             }}
+                  @Override
+                    public Void visitrules
+                    (ANTLRv4Parser.rules
+                     Context ctx) {{
+                    // Logic to print the current rule's name
+                    System.out.println(
+"rules
+                               ")
+;
+                               return visitChildren(
+ctx)
+;
+                               }
+}
+
+                    @Override
+                    public Void visitruleSpec
+                    (
+ANTLRv4Parser.ruleSpec
+                     Context ctx)
+ {
+{
+
+                      // Logic to print the current rule's name
+                      System.out.println("ruleSpec
+                               ");
+                               return visitChildren(ctx);
+                               }}
+                    @Override
+                      public Void visitparserRuleSpec
+                      (ANTLRv4Parser.parserRuleSpec
+                       Context ctx) {{
+                      // Logic to print the current rule's name
+                      System.out.println(
+"parserRuleSpec
+                                 ")
+;
+                                 return visitChildren(
+ctx)
+;
+                                 }
+}
+
+                      @Override
+                      public Void visitexceptionGroup
+                      (
+ANTLRv4Parser.exceptionGroup
+                       Context ctx)
+ {
+{
+
+                        // Logic to print the current rule's name
+                        System.out.println("exceptionGroup
+                                 ");
+                                 return visitChildren(ctx);
+                                 }}
+                      @Override
+                        public Void visitexceptionHandler
+                        (ANTLRv4Parser.exceptionHandler
+                         Context ctx) {{
+                        // Logic to print the current rule's name
+                        System.out.println(
+"exceptionHandler
+                                   ")
+;
+                                   return visitChildren(
+ctx)
+;
+                                   }
+}
+
+                        @Override
+                        public Void visitfinallyClause
+                        (
+ANTLRv4Parser.finallyClause
+                         Context ctx)
+ {
+{
+
+                          // Logic to print the current rule's name
+                          System.out.println("finallyClause
+                                   ");
+                                   return visitChildren(ctx);
+                                   }}
+                        @Override
+                          public Void visitrulePrequel
+                          (ANTLRv4Parser.rulePrequel
+                           Context ctx) {{
+                          // Logic to print the current rule's name
+                          System.out.println(
+"rulePrequel
+                                     ")
+;
+                                     return visitChildren(
+ctx)
+;
+                                     }
+}
+
+                          @Override
+                          public Void visitruleReturns
+                          (
+ANTLRv4Parser.ruleReturns
+                           Context ctx)
+ {
+{
+
+                            // Logic to print the current rule's name
+                            System.out.println("ruleReturns
+                                     ");
+                                     return visitChildren(ctx);
+                                     }}
+                          @Override
+                            public Void visitthrowsSpec
+                            (ANTLRv4Parser.throwsSpec
+                             Context ctx) {{
+                            // Logic to print the current rule's name
+                            System.out.println(
+"throwsSpec
+                                       ")
+;
+                                       return visitChildren(
+ctx)
+;
+                                       }
+}
+
+                            @Override
+                            public Void visitlocalsSpec
+                            (
+ANTLRv4Parser.localsSpec
+                             Context ctx)
+ {
+{
+
+                              // Logic to print the current rule's name
+                              System.out.println("localsSpec
+                                       ");
+                                       return visitChildren(ctx);
+                                       }}
+                            @Override
+                              public Void visitruleAction
+                              (ANTLRv4Parser.ruleAction
+                               Context ctx) {{
+                              // Logic to print the current rule's name
+                              System.out.println(
+"ruleAction
+                                         ")
+;
+                                         return visitChildren(
+ctx)
+;
+                                         }
+}
+
+                              @Override
+                              public Void visitruleModifiers
+                              (
+ANTLRv4Parser.ruleModifiers
+                               Context ctx)
+ {
+{
+
+                                // Logic to print the current rule's name
+                                System.out.println("ruleModifiers
+                                         ");
+                                         return visitChildren(ctx);
+                                         }}
+                              @Override
+                                public Void visitruleModifier
+                                (ANTLRv4Parser.ruleModifier
+                                 Context ctx) {{
+                                // Logic to print the current rule's name
+                                System.out.println(
+"ruleModifier
+                                           ")
+;
+                                           return visitChildren(
+ctx)
+;
+                                           }
+}
+
+                                @Override
+                                public Void visitruleBlock
+                                (
+ANTLRv4Parser.ruleBlock
+                                 Context ctx)
+ {
+{
+
+                                  // Logic to print the current rule's name
+                                  System.out.println("ruleBlock
+                                           ");
+                                           return visitChildren(ctx);
+                                           }}
+                                @Override
+                                  public Void visitruleAltList
+                                  (ANTLRv4Parser.ruleAltList
+                                   Context ctx) {{
+                                  // Logic to print the current rule's name
+                                  System.out.println(
+"ruleAltList
+                                             ")
+;
+                                             return visitChildren(
+ctx)
+;
+                                             }
+}
+
+                                  @Override
+                                  public Void visitlabeledAlt
+                                  (
+ANTLRv4Parser.labeledAlt
+                                   Context ctx)
+ {
+{
+
+                                    // Logic to print the current rule's name
+                                    System.out.println("labeledAlt
+                                             ");
+                                             return visitChildren(ctx);
+                                             }}
+                                  @Override
+                                    public Void visitlexerRuleSpec
+                                    (ANTLRv4Parser.lexerRuleSpec
+                                     Context ctx) {{
+                                    // Logic to print the current rule's name
+                                    System.out.println(
+"lexerRuleSpec
+                                               ")
+;
+                                               return visitChildren(
+ctx)
+;
+                                               }
+}
+
+                                    @Override
+                                    public Void visitlexerRuleBlock
+                                    (
+ANTLRv4Parser.lexerRuleBlock
+                                     Context ctx)
+ {
+{
+
+                                      // Logic to print the current rule's name
+                                      System.out.println("lexerRuleBlock
+                                               ");
+                                               return visitChildren(ctx);
+                                               }}
+                                    @Override
+                                      public Void visitlexerAltList
+                                      (ANTLRv4Parser.lexerAltList
+                                       Context ctx) {{
+                                      // Logic to print the current rule's name
+                                      System.out.println(
+"lexerAltList
+                                                 ")
+;
+                                                 return visitChildren(
+ctx)
+;
+                                                 }
+}
+
+                                      @Override
+                                      public Void visitlexerAlt
+                                      (
+ANTLRv4Parser.lexerAlt
+                                       Context ctx)
+ {
+{
+
+                                        // Logic to print the current rule's name
+                                        System.out.println("lexerAlt
+                                                 ");
+                                                 return visitChildren(ctx);
+                                                 }}
+                                      @Override
+                                        public Void visitlexerElements
+                                        (ANTLRv4Parser.lexerElements
+                                         Context ctx) {{
+                                        // Logic to print the current rule's name
+                                        System.out.println(
+"lexerElements
+                                                   ")
+;
+                                                   return visitChildren(
+ctx)
+;
+                                                   }
+}
+
+                                        @Override
+                                        public Void visitlexerElement
+                                        (
+ANTLRv4Parser.lexerElement
+                                         Context ctx)
+ {
+{
+
+                                          // Logic to print the current rule's name
+                                          System.out.println("lexerElement
+                                                   ");
+                                                   return visitChildren(ctx);
+                                                   }}
+                                        @Override
+                                          public Void visitlexerBlock
+                                          (ANTLRv4Parser.lexerBlock
+                                           Context ctx) {{
+                                          // Logic to print the current rule's name
+                                          System.out.println(
+"lexerBlock
+                                                     ")
+;
+                                                     return visitChildren(
+ctx)
+;
+                                                     }
+}
+
+                                          @Override
+                                          public Void visitlexerCommands
+                                          (
+ANTLRv4Parser.lexerCommands
+                                           Context ctx)
+ {
+{
+
+                                            // Logic to print the current rule's name
+                                            System.out.println("lexerCommands
+                                                     ");
+                                                     return visitChildren(ctx);
+                                                     }}
+                                          @Override
+                                            public Void visitlexerCommand
+                                            (ANTLRv4Parser.lexerCommand
+                                             Context ctx) {{
+                                            // Logic to print the current rule's name
+                                            System.out.println(
+"lexerCommand
+                                                       ")
+;
+                                                       return visitChildren(
+ctx)
+;
+                                                       }
+}
+
+                                            @Override
+                                            public Void visitlexerCommandName
+                                            (
+ANTLRv4Parser.lexerCommandName
+                                             Context ctx)
+ {
+{
+
+                                              // Logic to print the current rule's name
+                                              System.out.println("lexerCommandName
+                                                       ");
+                                                       return visitChildren(ctx);
+                                                       }}
+                                            @Override
+                                              public Void visitlexerCommandExpr
+                                              (ANTLRv4Parser.lexerCommandExpr
+                                               Context ctx) {{
+                                              // Logic to print the current rule's name
+                                              System.out.println(
+"lexerCommandExpr
+                                                         ")
+;
+                                                         return visitChildren(
+ctx)
+;
+                                                         }
+}
+
+                                              @Override
+                                              public Void visitaltList
+                                              (
+ANTLRv4Parser.altList
+                                               Context ctx)
+ {
+{
+
+                                                // Logic to print the current rule's name
+                                                System.out.println("altList
+                                                         ");
+                                                         return visitChildren(ctx);
+                                                         }}
+                                              @Override
+                                                public Void visitalternative
+                                                (ANTLRv4Parser.alternative
+                                                 Context ctx) {{
+                                                // Logic to print the current rule's name
+                                                System.out.println(
+"alternative
+                                                           ")
+;
+                                                           return visitChildren(
+ctx)
+;
+                                                           }
+}
+
+                                                @Override
+                                                public Void visitelement
+                                                (
+ANTLRv4Parser.element
+                                                 Context ctx)
+ {
+{
+
+                                                  // Logic to print the current rule's name
+                                                  System.out.println("element
+                                                           ");
+                                                           return visitChildren(ctx);
+                                                           }}
+                                                @Override
+                                                  public Void visitpredicateOptions
+                                                  (ANTLRv4Parser.predicateOptions
+                                                   Context ctx) {{
+                                                  // Logic to print the current rule's name
+                                                  System.out.println(
+"predicateOptions
+                                                             ")
+;
+                                                             return visitChildren(
+ctx)
+;
+                                                             }
+}
+
+                                                  @Override
+                                                  public Void visitpredicateOption
+                                                  (
+ANTLRv4Parser.predicateOption
+                                                   Context ctx)
+ {
+{
+
+                                                    // Logic to print the current rule's name
+                                                    System.out.println("predicateOption
+                                                             ");
+                                                             return visitChildren(ctx);
+                                                             }}
+                                                  @Override
+                                                    public Void visitlabeledElement
+                                                    (ANTLRv4Parser.labeledElement
+                                                     Context ctx) {{
+                                                    // Logic to print the current rule's name
+                                                    System.out.println(
+"labeledElement
+                                                               ")
+;
+                                                               return visitChildren(
+ctx)
+;
+                                                               }
+}
+
+                                                    @Override
+                                                    public Void visitebnf
+                                                    (
+ANTLRv4Parser.ebnf
+                                                     Context ctx)
+ {
+{
+
+                                                      // Logic to print the current rule's name
+                                                      System.out.println("ebnf
+                                                               ");
+                                                               return visitChildren(ctx);
+                                                               }}
+  @Override
+  public Void visitblockSuffix
+  (ANTLRv4Parser.blockSuffix
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"blockSuffix
+  ")
+;
+    return visitChildren(
+ctx)
+;
+  }
+}
+
+  @Override
+  public Void visitebnfSuffix
+  (
+ANTLRv4Parser.ebnfSuffix
+  Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("ebnfSuffix
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitlexerAtom
+  (ANTLRv4Parser.lexerAtom
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"lexerAtom
+  ")
+;
+    return visitChildren(
+ctx)
+;
+  }
+}
+
+  @Override
+  public Void visitatom
+  (
+ANTLRv4Parser.atom
+  Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("atom
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitnotSet
+  (ANTLRv4Parser.notSet
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"notSet
+  ")
+;
+    return visitChildren(
+ctx)
+;
+  }
+}
+
+  @Override
+  public Void visitblockSet
+  (
+ANTLRv4Parser.blockSet
+  Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("blockSet
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitsetElement
+  (ANTLRv4Parser.setElement
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"setElement
+  ")
+;
+    return visitChildren(
+ctx)
+;
+  }
+}
+
+  @Override
+  public Void visitblock
+  (
+ANTLRv4Parser.block
+  Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("block
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitruleref
+  (ANTLRv4Parser.ruleref
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"ruleref
+  ")
+;
+    return visitChildren(
+ctx)
+;
+  }
+}
+
+  @Override
+  public Void visitcharacterRange
+  (
+ANTLRv4Parser.characterRange
+  Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("characterRange
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitterminalDef
+  (ANTLRv4Parser.terminalDef
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"terminalDef
+  ")
+;
+    return visitChildren(
+ctx)
+;
+  }
+}
+
+  @Override
+  public Void visitelementOptions
+  (
+ANTLRv4Parser.elementOptions
+  Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("elementOptions
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitelementOption
+  (ANTLRv4Parser.elementOption
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println(
+"elementOption
+  ")
+;
+    return visitChildren(
+ctx)
+;
+  }
+}
+
+  @Override
+  public Void visitidentifier
+  (
+ANTLRv4Parser.identifier
+  Context ctx)
+ {
+{
+
+    // Logic to print the current rule's name
+    System.out.println("identifier
+  ");
+    return visitChildren(ctx);
+  }}
+
+}
diff --git a/developer/javac/ANTLRv4_Syntax_PrintVisitor_fully_corrected.java b/developer/javac/ANTLRv4_Syntax_PrintVisitor_fully_corrected.java
new file mode 100644 (file)
index 0000000..d7f084f
--- /dev/null
@@ -0,0 +1,605 @@
+
+
+import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
+
+public class ANTLRv4_Syntax_PrintVisitor extends ANTLRv4BaseVisitor<String>{
+  private final String[] rule_names;
+  private final boolean pretty_print;
+
+  public ANTLRv4_Syntax_PrintVisitor(String[] rule_names, boolean pretty_print){
+  this.rule_names = rule_names;
+  this.pretty_print = pretty_print;
+  }
+
+  private String indent(int level){
+  return "  ".repeat(level);
+  }
+
+  @Override
+  public Void visitgrammarSpec
+  (ANTLRv4Parser.grammarSpec
+   Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("grammarSpec
+             ");
+             return visitChildren(ctx);
+             }}
+  @Override
+    public Void visitgrammarDecl
+    (ANTLRv4Parser.grammarDecl
+     Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("grammarDecl
+               ");
+               return visitChildren(ctx);
+               }}
+    @Override
+    public Void visitgrammarType
+    (ANTLRv4Parser.grammarType
+     Context ctx) {{
+      // Logic to print the current rule's name
+      System.out.println("grammarType
+               ");
+               return visitChildren(ctx);
+               }}
+    @Override
+      public Void visitprequelConstruct
+      (ANTLRv4Parser.prequelConstruct
+       Context ctx) {{
+      // Logic to print the current rule's name
+      System.out.println("prequelConstruct
+                 ");
+                 return visitChildren(ctx);
+                 }}
+      @Override
+      public Void visitoptionsSpec
+      (ANTLRv4Parser.optionsSpec
+       Context ctx) {{
+        // Logic to print the current rule's name
+        System.out.println("optionsSpec
+                 ");
+                 return visitChildren(ctx);
+                 }}
+      @Override
+        public Void visitoption
+        (ANTLRv4Parser.option
+         Context ctx) {{
+        // Logic to print the current rule's name
+        System.out.println("option
+                   ");
+                   return visitChildren(ctx);
+                   }}
+        @Override
+        public Void visitoptionValue
+        (ANTLRv4Parser.optionValue
+         Context ctx) {{
+          // Logic to print the current rule's name
+          System.out.println("optionValue
+                   ");
+                   return visitChildren(ctx);
+                   }}
+        @Override
+          public Void visitdelegateGrammars
+          (ANTLRv4Parser.delegateGrammars
+           Context ctx) {{
+          // Logic to print the current rule's name
+          System.out.println("delegateGrammars
+                     ");
+                     return visitChildren(ctx);
+                     }}
+          @Override
+          public Void visitdelegateGrammar
+          (ANTLRv4Parser.delegateGrammar
+           Context ctx) {{
+            // Logic to print the current rule's name
+            System.out.println("delegateGrammar
+                     ");
+                     return visitChildren(ctx);
+                     }}
+          @Override
+            public Void visittokensSpec
+            (ANTLRv4Parser.tokensSpec
+             Context ctx) {{
+            // Logic to print the current rule's name
+            System.out.println("tokensSpec
+                       ");
+                       return visitChildren(ctx);
+                       }}
+            @Override
+            public Void visitchannelsSpec
+            (ANTLRv4Parser.channelsSpec
+             Context ctx) {{
+              // Logic to print the current rule's name
+              System.out.println("channelsSpec
+                       ");
+                       return visitChildren(ctx);
+                       }}
+            @Override
+              public Void visitidList
+              (ANTLRv4Parser.idList
+               Context ctx) {{
+              // Logic to print the current rule's name
+              System.out.println("idList
+                         ");
+                         return visitChildren(ctx);
+                         }}
+              @Override
+              public Void visitaction_
+              (ANTLRv4Parser.action_
+               Context ctx) {{
+                // Logic to print the current rule's name
+                System.out.println("action_
+                         ");
+                         return visitChildren(ctx);
+                         }}
+              @Override
+                public Void visitactionScopeName
+                (ANTLRv4Parser.actionScopeName
+                 Context ctx) {{
+                // Logic to print the current rule's name
+                System.out.println("actionScopeName
+                           ");
+                           return visitChildren(ctx);
+                           }}
+                @Override
+                public Void visitactionBlock
+                (ANTLRv4Parser.actionBlock
+                 Context ctx) {{
+                  // Logic to print the current rule's name
+                  System.out.println("actionBlock
+                           ");
+                           return visitChildren(ctx);
+                           }}
+                @Override
+                  public Void visitargActionBlock
+                  (ANTLRv4Parser.argActionBlock
+                   Context ctx) {{
+                  // Logic to print the current rule's name
+                  System.out.println("argActionBlock
+                             ");
+                             return visitChildren(ctx);
+                             }}
+                  @Override
+                  public Void visitmodeSpec
+                  (ANTLRv4Parser.modeSpec
+                   Context ctx) {{
+                    // Logic to print the current rule's name
+                    System.out.println("modeSpec
+                             ");
+                             return visitChildren(ctx);
+                             }}
+                  @Override
+                    public Void visitrules
+                    (ANTLRv4Parser.rules
+                     Context ctx) {{
+                    // Logic to print the current rule's name
+                    System.out.println("rules
+                               ");
+                               return visitChildren(ctx);
+                               }}
+                    @Override
+                    public Void visitruleSpec
+                    (ANTLRv4Parser.ruleSpec
+                     Context ctx) {{
+                      // Logic to print the current rule's name
+                      System.out.println("ruleSpec
+                               ");
+                               return visitChildren(ctx);
+                               }}
+                    @Override
+                      public Void visitparserRuleSpec
+                      (ANTLRv4Parser.parserRuleSpec
+                       Context ctx) {{
+                      // Logic to print the current rule's name
+                      System.out.println("parserRuleSpec
+                                 ");
+                                 return visitChildren(ctx);
+                                 }}
+                      @Override
+                      public Void visitexceptionGroup
+                      (ANTLRv4Parser.exceptionGroup
+                       Context ctx) {{
+                        // Logic to print the current rule's name
+                        System.out.println("exceptionGroup
+                                 ");
+                                 return visitChildren(ctx);
+                                 }}
+                      @Override
+                        public Void visitexceptionHandler
+                        (ANTLRv4Parser.exceptionHandler
+                         Context ctx) {{
+                        // Logic to print the current rule's name
+                        System.out.println("exceptionHandler
+                                   ");
+                                   return visitChildren(ctx);
+                                   }}
+                        @Override
+                        public Void visitfinallyClause
+                        (ANTLRv4Parser.finallyClause
+                         Context ctx) {{
+                          // Logic to print the current rule's name
+                          System.out.println("finallyClause
+                                   ");
+                                   return visitChildren(ctx);
+                                   }}
+                        @Override
+                          public Void visitrulePrequel
+                          (ANTLRv4Parser.rulePrequel
+                           Context ctx) {{
+                          // Logic to print the current rule's name
+                          System.out.println("rulePrequel
+                                     ");
+                                     return visitChildren(ctx);
+                                     }}
+                          @Override
+                          public Void visitruleReturns
+                          (ANTLRv4Parser.ruleReturns
+                           Context ctx) {{
+                            // Logic to print the current rule's name
+                            System.out.println("ruleReturns
+                                     ");
+                                     return visitChildren(ctx);
+                                     }}
+                          @Override
+                            public Void visitthrowsSpec
+                            (ANTLRv4Parser.throwsSpec
+                             Context ctx) {{
+                            // Logic to print the current rule's name
+                            System.out.println("throwsSpec
+                                       ");
+                                       return visitChildren(ctx);
+                                       }}
+                            @Override
+                            public Void visitlocalsSpec
+                            (ANTLRv4Parser.localsSpec
+                             Context ctx) {{
+                              // Logic to print the current rule's name
+                              System.out.println("localsSpec
+                                       ");
+                                       return visitChildren(ctx);
+                                       }}
+                            @Override
+                              public Void visitruleAction
+                              (ANTLRv4Parser.ruleAction
+                               Context ctx) {{
+                              // Logic to print the current rule's name
+                              System.out.println("ruleAction
+                                         ");
+                                         return visitChildren(ctx);
+                                         }}
+                              @Override
+                              public Void visitruleModifiers
+                              (ANTLRv4Parser.ruleModifiers
+                               Context ctx) {{
+                                // Logic to print the current rule's name
+                                System.out.println("ruleModifiers
+                                         ");
+                                         return visitChildren(ctx);
+                                         }}
+                              @Override
+                                public Void visitruleModifier
+                                (ANTLRv4Parser.ruleModifier
+                                 Context ctx) {{
+                                // Logic to print the current rule's name
+                                System.out.println("ruleModifier
+                                           ");
+                                           return visitChildren(ctx);
+                                           }}
+                                @Override
+                                public Void visitruleBlock
+                                (ANTLRv4Parser.ruleBlock
+                                 Context ctx) {{
+                                  // Logic to print the current rule's name
+                                  System.out.println("ruleBlock
+                                           ");
+                                           return visitChildren(ctx);
+                                           }}
+                                @Override
+                                  public Void visitruleAltList
+                                  (ANTLRv4Parser.ruleAltList
+                                   Context ctx) {{
+                                  // Logic to print the current rule's name
+                                  System.out.println("ruleAltList
+                                             ");
+                                             return visitChildren(ctx);
+                                             }}
+                                  @Override
+                                  public Void visitlabeledAlt
+                                  (ANTLRv4Parser.labeledAlt
+                                   Context ctx) {{
+                                    // Logic to print the current rule's name
+                                    System.out.println("labeledAlt
+                                             ");
+                                             return visitChildren(ctx);
+                                             }}
+                                  @Override
+                                    public Void visitlexerRuleSpec
+                                    (ANTLRv4Parser.lexerRuleSpec
+                                     Context ctx) {{
+                                    // Logic to print the current rule's name
+                                    System.out.println("lexerRuleSpec
+                                               ");
+                                               return visitChildren(ctx);
+                                               }}
+                                    @Override
+                                    public Void visitlexerRuleBlock
+                                    (ANTLRv4Parser.lexerRuleBlock
+                                     Context ctx) {{
+                                      // Logic to print the current rule's name
+                                      System.out.println("lexerRuleBlock
+                                               ");
+                                               return visitChildren(ctx);
+                                               }}
+                                    @Override
+                                      public Void visitlexerAltList
+                                      (ANTLRv4Parser.lexerAltList
+                                       Context ctx) {{
+                                      // Logic to print the current rule's name
+                                      System.out.println("lexerAltList
+                                                 ");
+                                                 return visitChildren(ctx);
+                                                 }}
+                                      @Override
+                                      public Void visitlexerAlt
+                                      (ANTLRv4Parser.lexerAlt
+                                       Context ctx) {{
+                                        // Logic to print the current rule's name
+                                        System.out.println("lexerAlt
+                                                 ");
+                                                 return visitChildren(ctx);
+                                                 }}
+                                      @Override
+                                        public Void visitlexerElements
+                                        (ANTLRv4Parser.lexerElements
+                                         Context ctx) {{
+                                        // Logic to print the current rule's name
+                                        System.out.println("lexerElements
+                                                   ");
+                                                   return visitChildren(ctx);
+                                                   }}
+                                        @Override
+                                        public Void visitlexerElement
+                                        (ANTLRv4Parser.lexerElement
+                                         Context ctx) {{
+                                          // Logic to print the current rule's name
+                                          System.out.println("lexerElement
+                                                   ");
+                                                   return visitChildren(ctx);
+                                                   }}
+                                        @Override
+                                          public Void visitlexerBlock
+                                          (ANTLRv4Parser.lexerBlock
+                                           Context ctx) {{
+                                          // Logic to print the current rule's name
+                                          System.out.println("lexerBlock
+                                                     ");
+                                                     return visitChildren(ctx);
+                                                     }}
+                                          @Override
+                                          public Void visitlexerCommands
+                                          (ANTLRv4Parser.lexerCommands
+                                           Context ctx) {{
+                                            // Logic to print the current rule's name
+                                            System.out.println("lexerCommands
+                                                     ");
+                                                     return visitChildren(ctx);
+                                                     }}
+                                          @Override
+                                            public Void visitlexerCommand
+                                            (ANTLRv4Parser.lexerCommand
+                                             Context ctx) {{
+                                            // Logic to print the current rule's name
+                                            System.out.println("lexerCommand
+                                                       ");
+                                                       return visitChildren(ctx);
+                                                       }}
+                                            @Override
+                                            public Void visitlexerCommandName
+                                            (ANTLRv4Parser.lexerCommandName
+                                             Context ctx) {{
+                                              // Logic to print the current rule's name
+                                              System.out.println("lexerCommandName
+                                                       ");
+                                                       return visitChildren(ctx);
+                                                       }}
+                                            @Override
+                                              public Void visitlexerCommandExpr
+                                              (ANTLRv4Parser.lexerCommandExpr
+                                               Context ctx) {{
+                                              // Logic to print the current rule's name
+                                              System.out.println("lexerCommandExpr
+                                                         ");
+                                                         return visitChildren(ctx);
+                                                         }}
+                                              @Override
+                                              public Void visitaltList
+                                              (ANTLRv4Parser.altList
+                                               Context ctx) {{
+                                                // Logic to print the current rule's name
+                                                System.out.println("altList
+                                                         ");
+                                                         return visitChildren(ctx);
+                                                         }}
+                                              @Override
+                                                public Void visitalternative
+                                                (ANTLRv4Parser.alternative
+                                                 Context ctx) {{
+                                                // Logic to print the current rule's name
+                                                System.out.println("alternative
+                                                           ");
+                                                           return visitChildren(ctx);
+                                                           }}
+                                                @Override
+                                                public Void visitelement
+                                                (ANTLRv4Parser.element
+                                                 Context ctx) {{
+                                                  // Logic to print the current rule's name
+                                                  System.out.println("element
+                                                           ");
+                                                           return visitChildren(ctx);
+                                                           }}
+                                                @Override
+                                                  public Void visitpredicateOptions
+                                                  (ANTLRv4Parser.predicateOptions
+                                                   Context ctx) {{
+                                                  // Logic to print the current rule's name
+                                                  System.out.println("predicateOptions
+                                                             ");
+                                                             return visitChildren(ctx);
+                                                             }}
+                                                  @Override
+                                                  public Void visitpredicateOption
+                                                  (ANTLRv4Parser.predicateOption
+                                                   Context ctx) {{
+                                                    // Logic to print the current rule's name
+                                                    System.out.println("predicateOption
+                                                             ");
+                                                             return visitChildren(ctx);
+                                                             }}
+                                                  @Override
+                                                    public Void visitlabeledElement
+                                                    (ANTLRv4Parser.labeledElement
+                                                     Context ctx) {{
+                                                    // Logic to print the current rule's name
+                                                    System.out.println("labeledElement
+                                                               ");
+                                                               return visitChildren(ctx);
+                                                               }}
+                                                    @Override
+                                                    public Void visitebnf
+                                                    (ANTLRv4Parser.ebnf
+                                                     Context ctx) {{
+                                                      // Logic to print the current rule's name
+                                                      System.out.println("ebnf
+                                                               ");
+                                                               return visitChildren(ctx);
+                                                               }}
+  @Override
+  public Void visitblockSuffix
+  (ANTLRv4Parser.blockSuffix
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("blockSuffix
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitebnfSuffix
+  (ANTLRv4Parser.ebnfSuffix
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("ebnfSuffix
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitlexerAtom
+  (ANTLRv4Parser.lexerAtom
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("lexerAtom
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitatom
+  (ANTLRv4Parser.atom
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("atom
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitnotSet
+  (ANTLRv4Parser.notSet
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("notSet
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitblockSet
+  (ANTLRv4Parser.blockSet
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("blockSet
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitsetElement
+  (ANTLRv4Parser.setElement
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("setElement
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitblock
+  (ANTLRv4Parser.block
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("block
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitruleref
+  (ANTLRv4Parser.ruleref
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("ruleref
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitcharacterRange
+  (ANTLRv4Parser.characterRange
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("characterRange
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitterminalDef
+  (ANTLRv4Parser.terminalDef
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("terminalDef
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitelementOptions
+  (ANTLRv4Parser.elementOptions
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("elementOptions
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitelementOption
+  (ANTLRv4Parser.elementOption
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("elementOption
+  ");
+    return visitChildren(ctx);
+  }}
+  @Override
+  public Void visitidentifier
+  (ANTLRv4Parser.identifier
+  Context ctx) {{
+    // Logic to print the current rule's name
+    System.out.println("identifier
+  ");
+    return visitChildren(ctx);
+  }}
+
+}
+} /* corrected closing brace */} /* corrected closing brace */} /* corrected closing brace */
\ No newline at end of file
diff --git a/developer/javac/PrintRuleNameListRegx.java b/developer/javac/PrintRuleNameListRegx.java
deleted file mode 100644 (file)
index 3a5d43c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Directly reads an ANTLR grammar file, a `.g4` file, and lists all the rules found in it.
-
-*/
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class PrintRuleNameListRegx {
-
-  public static void main(String[] args) {
-    if (args.length != 1) {
-      System.out.println("Usage: PrintRuleNameListRegx <path-to-g4-file>");
-      return;
-    }
-
-    String filePath = args[0];
-    Set<String> ruleNames = new HashSet<>();
-
-    try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
-      StringBuilder content = new StringBuilder();
-      String line;
-      while ((line = br.readLine()) != null) {
-        content.append(line).append("\n");
-      }
-
-      // Updated pattern to handle multi-line rules
-      Pattern rulePattern = Pattern.compile("(?m)^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:");
-
-      Matcher matcher = rulePattern.matcher(content.toString());
-      while (matcher.find()) {
-        ruleNames.add(matcher.group(1));
-      }
-
-      System.out.println("Extracted Rules:");
-      for (String rule : ruleNames) {
-        System.out.println(rule);
-      }
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
-  }
-}
diff --git a/developer/javac/RuleNameList.java b/developer/javac/RuleNameList.java
new file mode 100644 (file)
index 0000000..438d060
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Accepts an grammar source file and outputs the rule names found in the grammar.
+ * Accepts the same input structure as ANTLRv4_Syntax.java.
+ * Usage: java ANTLRv4_RuleNames <input-file>
+ */
+
+import org.antlr.v4.runtime.*;
+import java.util.List;
+
+public class RuleNameList {
+
+  public static void main(String[] args) {
+    if (args.length != 1) {
+      System.err.println("Usage: RuleNameList <grammar_name>");
+      System.exit(1);
+    }
+
+    String grammarName = args[0];
+
+    try {
+      // Dynamically load the appropriate lexer and parser
+      Class<?> lexerClass = Class.forName(grammarName + "Lexer");
+      Class<?> parserClass = Class.forName(grammarName + "Parser");
+
+      // Create instances of the lexer and parser
+      Lexer lexer = (Lexer) lexerClass.getConstructor(CharStream.class).newInstance(CharStreams.fromString(""));
+      CommonTokenStream tokens = new CommonTokenStream(lexer);
+      Parser parser = (Parser) parserClass.getConstructor(TokenStream.class).newInstance(tokens);
+
+      // Get the rule names from the parser
+      List<String> ruleNames = List.of(parser.getRuleNames());
+
+      // Print the rule names
+      System.out.println("Rule names found in the grammar:");
+      for (String ruleName : ruleNames) {
+        System.out.println(ruleName);
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/developer/javac/RuleNameListRegx.java b/developer/javac/RuleNameListRegx.java
new file mode 100644 (file)
index 0000000..3a5d43c
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+Directly reads an ANTLR grammar file, a `.g4` file, and lists all the rules found in it.
+
+*/
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class PrintRuleNameListRegx {
+
+  public static void main(String[] args) {
+    if (args.length != 1) {
+      System.out.println("Usage: PrintRuleNameListRegx <path-to-g4-file>");
+      return;
+    }
+
+    String filePath = args[0];
+    Set<String> ruleNames = new HashSet<>();
+
+    try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
+      StringBuilder content = new StringBuilder();
+      String line;
+      while ((line = br.readLine()) != null) {
+        content.append(line).append("\n");
+      }
+
+      // Updated pattern to handle multi-line rules
+      Pattern rulePattern = Pattern.compile("(?m)^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:");
+
+      Matcher matcher = rulePattern.matcher(content.toString());
+      while (matcher.find()) {
+        ruleNames.add(matcher.group(1));
+      }
+
+      System.out.println("Extracted Rules:");
+      for (String rule : ruleNames) {
+        System.out.println(rule);
+      }
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+  }
+}
index febae2f..18a3870 100644 (file)
@@ -5,6 +5,11 @@ GQL grammar came from:
 ANTLR grammar came from:
    Note the antlr gammar on this site, many grammars listed.
    https://github.com/antlr/grammars-v4
+   It came as four files:
+     ANTLRv4Lexer.g4
+     ANTLRv4Parser.g4
+     LexBasic.g4
+     LexerAdaptor.java
 
 Cypher movies example:
   https://github.com/neo4j-graph-examples/movies/blob/main/scripts/movies.cypher
diff --git a/developer/test/transcript_RuleNameList.sh b/developer/test/transcript_RuleNameList.sh
new file mode 100644 (file)
index 0000000..e2d089a
--- /dev/null
@@ -0,0 +1,139 @@
+2024-09-05T07:24:43Z[GQL_to_Cypher]
+Thomas-developer@Vivobook12§/var/user_data/Thomas-developer/GQL_to_Cypher/developer§
+> make Arithmetic_Echo
+mkdir -p ANTLR javac jvm executor test deprecated experiment ologist temporary
+/bin/make -f executor/makefile-tool.mk -r --no-print-directory all
+make[1]: Nothing to be done for 'all'.
+/bin/make -f executor/makefile-project.mk -r --no-print-directory Arithmetic_Echo
+copiling grammar from: ANTLR/Arithmetic.g4
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -jar /var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar -Dlanguage=Java -visitor -o javac ANTLR/Arithmetic.g4
+/bin/make -r --no-print-directory -f executor/makefile-project.mk executor/Arithmetic_Echo
+Compiling javac/Arithmetic_Echo.java...
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/javac -d jvm -sourcepath javac:javac/ANTLR javac/Arithmetic_Echo.java
+Created jvm/Arithmetic_Echo.class
+Building Arithmetic_Echo...
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/jar cf jvm/Arithmetic_Echo.jar -C jvm Arithmetic_Echo.class
+Created jvm/Arithmetic_Echo.jar
+Creating script for Arithmetic_Echo...
+chmod +x executor/Arithmetic_Echo
+Created script executor/Arithmetic_Echo
+
+ [cut]
+
+2024-09-05T07:26:04Z[GQL_to_Cypher]
+Thomas-developer@Vivobook12§/var/user_data/Thomas-developer/GQL_to_Cypher/developer§
+> make RuleNameList
+mkdir -p ANTLR javac jvm executor test deprecated experiment ologist temporary
+/bin/make -f executor/makefile-tool.mk -r --no-print-directory all
+make[1]: Nothing to be done for 'all'.
+/bin/make -f executor/makefile-project.mk -r --no-print-directory RuleNameList
+Compiling javac/RuleNameList.java...
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/javac -d jvm -sourcepath javac:javac/ANTLR javac/RuleNameList.java
+Created jvm/RuleNameList.class
+Building RuleNameList...
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/jar cf jvm/RuleNameList.jar -C jvm RuleNameList.class
+Created jvm/RuleNameList.jar
+Creating script for RuleNameList...
+chmod +x executor/RuleNameList
+Created script executor/RuleNameList
+
+2024-09-05T07:28:47Z[GQL_to_Cypher]
+Thomas-developer@Vivobook12§/var/user_data/Thomas-developer/GQL_to_Cypher/developer§
+> RuleNameList Arithmetic
+Rule names found in the grammar:
+program
+expression
+
+2024-09-05T07:29:09Z[GQL_to_Cypher]
+Thomas-developer@Vivobook12§/var/user_data/Thomas-developer/GQL_to_Cypher/developer§
+> make ANTLRv4_Syntax
+mkdir -p ANTLR javac jvm executor test deprecated experiment ologist temporary
+/bin/make -f executor/makefile-tool.mk -r --no-print-directory all
+make[1]: Nothing to be done for 'all'.
+/bin/make -f executor/makefile-project.mk -r --no-print-directory ANTLRv4_Syntax
+making lexer grammar from: ANTLR/ANTLRv4Lexer.g4
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -jar /var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar -Dlanguage=Java -visitor -o javac ANTLR/ANTLRv4Lexer.g4
+making other grammar files from: ANTLR/ANTLRv4Parser.g4
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -jar /var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar -Dlanguage=Java -visitor -lib javac/ANTLR -o javac ANTLR/ANTLRv4Parser.g4
+executor/makefile-project.mk:179: warning: pattern recipe did not update peer target 'javac/ANTLR/ANTLRv4Visitor.java'.
+executor/makefile-project.mk:179: warning: pattern recipe did not update peer target 'javac/ANTLR/ANTLRv4BaseVisitor.java'.
+executor/makefile-project.mk:179: warning: pattern recipe did not update peer target 'javac/ANTLR/ANTLRv4Listener.java'.
+executor/makefile-project.mk:179: warning: pattern recipe did not update peer target 'javac/ANTLR/ANTLRv4BaseListener.java'.
+/bin/make -r --no-print-directory -f executor/makefile-project.mk executor/ANTLRv4_Syntax
+Compiling javac/ANTLRv4_Syntax.java...
+
+ [ had errors, but we only need the grammar to be made ]
+
+2024-09-05T07:31:03Z[GQL_to_Cypher]
+Thomas-developer@Vivobook12§/var/user_data/Thomas-developer/GQL_to_Cypher/developer§
+> RuleNameList ANTLRv4
+Rule names found in the grammar:
+grammarSpec
+grammarDecl
+grammarType
+prequelConstruct
+optionsSpec
+option
+optionValue
+delegateGrammars
+delegateGrammar
+tokensSpec
+channelsSpec
+idList
+action_
+actionScopeName
+actionBlock
+argActionBlock
+modeSpec
+rules
+ruleSpec
+parserRuleSpec
+exceptionGroup
+exceptionHandler
+finallyClause
+rulePrequel
+ruleReturns
+throwsSpec
+localsSpec
+ruleAction
+ruleModifiers
+ruleModifier
+ruleBlock
+ruleAltList
+labeledAlt
+lexerRuleSpec
+lexerRuleBlock
+lexerAltList
+lexerAlt
+lexerElements
+lexerElement
+lexerBlock
+lexerCommands
+lexerCommand
+lexerCommandName
+lexerCommandExpr
+altList
+alternative
+element
+predicateOptions
+predicateOption
+labeledElement
+ebnf
+blockSuffix
+ebnfSuffix
+lexerAtom
+atom
+notSet
+blockSet
+setElement
+block
+ruleref
+characterRange
+terminalDef
+elementOptions
+elementOption
+identifier
+
+2024-09-05T07:31:24Z[GQL_to_Cypher]
+Thomas-developer@Vivobook12§/var/user_data/Thomas-developer/GQL_to_Cypher/developer§
+> 
index 9df41ca..e421a8e 100644 (file)
@@ -2,9 +2,30 @@ This is a project management log. This is not a code development log. (Git does
 a pretty good job of that already.)
 
 2024-07-25
+
   formal git project directory creation
 
   Preparation, studies, and discussion occur before this time.
   
+2024-09-05
+
+  Diligence to the project was spotty in August. 
+
+  Build environment appears to be stable. A toy grammar syntax parse, and echo,
+  and syntax 'diagramming' is working. Here 'diagramming' is a pretty print
+  annotation of the syntax parts.
+  
+  GQL turns out to have a great deal in common with Cypher. So, might start by
+  using the Cypher movie database for testing.  The ISO standard document should
+  clarify the differences.
+  
+  The AI could not deal with the GQL grammar due to its size, so would not
+  generate a print visitor. I am working on abstracting the grammar to reduce
+  the number of rules.
 
+  In said abstraction, all terminal symbols will be under single token
+  `terminal`. Currently these are then categorized, then differentiated. The
+  categories were created manually. I wonder if categories are necessary, but
+  they can't hurt, and as they are done I will keep them.
+