Rename root to program

This commit is contained in:
Salvatore Ravidà 2022-12-15 19:58:20 +01:00 committed by Ziv
parent a15da8e275
commit f79202a5b7
7 changed files with 31 additions and 38 deletions

View File

@ -12,7 +12,7 @@ superClass = PostgreSQLParserBase;
@members @members
{ {
} }
root program
: stmtblock EOF : stmtblock EOF
; ;

View File

@ -1115,7 +1115,7 @@ EndDollarStringConstant
AfterEscapeStringConstantWithNewlineMode_Continued AfterEscapeStringConstantWithNewlineMode_Continued
rule names: rule names:
root program
plsqlroot plsqlroot
stmtblock stmtblock
stmtmulti stmtmulti

View File

@ -7771,7 +7771,7 @@ var symbolicNames = [ null, "Dollar", "OPEN_PAREN", "CLOSE_PAREN", "OPEN_BRACKET
"AfterEscapeStringConstantWithNewlineMode_NotContinued", "AfterEscapeStringConstantWithNewlineMode_NotContinued",
"DollarText", "EndDollarStringConstant", "AfterEscapeStringConstantWithNewlineMode_Continued" ]; "DollarText", "EndDollarStringConstant", "AfterEscapeStringConstantWithNewlineMode_Continued" ];
var ruleNames = [ "root", "plsqlroot", "stmtblock", "stmtmulti", "stmt", var ruleNames = [ "program", "plsqlroot", "stmtblock", "stmtmulti", "stmt",
"plsqlconsolecommand", "callstmt", "createrolestmt", "plsqlconsolecommand", "callstmt", "createrolestmt",
"opt_with", "optrolelist", "alteroptrolelist", "alteroptroleelem", "opt_with", "optrolelist", "alteroptrolelist", "alteroptroleelem",
"createoptroleelem", "createuserstmt", "alterrolestmt", "createoptroleelem", "createuserstmt", "alterrolestmt",
@ -8588,7 +8588,7 @@ PostgreSQLParser.DollarText = 553;
PostgreSQLParser.EndDollarStringConstant = 554; PostgreSQLParser.EndDollarStringConstant = 554;
PostgreSQLParser.AfterEscapeStringConstantWithNewlineMode_Continued = 555; PostgreSQLParser.AfterEscapeStringConstantWithNewlineMode_Continued = 555;
PostgreSQLParser.RULE_root = 0; PostgreSQLParser.RULE_program = 0;
PostgreSQLParser.RULE_plsqlroot = 1; PostgreSQLParser.RULE_plsqlroot = 1;
PostgreSQLParser.RULE_stmtblock = 2; PostgreSQLParser.RULE_stmtblock = 2;
PostgreSQLParser.RULE_stmtmulti = 3; PostgreSQLParser.RULE_stmtmulti = 3;
@ -9394,7 +9394,7 @@ PostgreSQLParser.RULE_make_execsql_stmt = 802;
PostgreSQLParser.RULE_opt_returning_clause_into = 803; PostgreSQLParser.RULE_opt_returning_clause_into = 803;
function RootContext(parser, parent, invokingState) { function ProgramContext(parser, parent, invokingState) {
if(parent===undefined) { if(parent===undefined) {
parent = null; parent = null;
} }
@ -9403,36 +9403,36 @@ function RootContext(parser, parent, invokingState) {
} }
antlr4.ParserRuleContext.call(this, parent, invokingState); antlr4.ParserRuleContext.call(this, parent, invokingState);
this.parser = parser; this.parser = parser;
this.ruleIndex = PostgreSQLParser.RULE_root; this.ruleIndex = PostgreSQLParser.RULE_program;
return this; return this;
} }
RootContext.prototype = Object.create(antlr4.ParserRuleContext.prototype); ProgramContext.prototype = Object.create(antlr4.ParserRuleContext.prototype);
RootContext.prototype.constructor = RootContext; ProgramContext.prototype.constructor = ProgramContext;
RootContext.prototype.stmtblock = function() { ProgramContext.prototype.stmtblock = function() {
return this.getTypedRuleContext(StmtblockContext,0); return this.getTypedRuleContext(StmtblockContext,0);
}; };
RootContext.prototype.EOF = function() { ProgramContext.prototype.EOF = function() {
return this.getToken(PostgreSQLParser.EOF, 0); return this.getToken(PostgreSQLParser.EOF, 0);
}; };
RootContext.prototype.enterRule = function(listener) { ProgramContext.prototype.enterRule = function(listener) {
if(listener instanceof PostgreSQLParserListener ) { if(listener instanceof PostgreSQLParserListener ) {
listener.enterRoot(this); listener.enterProgram(this);
} }
}; };
RootContext.prototype.exitRule = function(listener) { ProgramContext.prototype.exitRule = function(listener) {
if(listener instanceof PostgreSQLParserListener ) { if(listener instanceof PostgreSQLParserListener ) {
listener.exitRoot(this); listener.exitProgram(this);
} }
}; };
RootContext.prototype.accept = function(visitor) { ProgramContext.prototype.accept = function(visitor) {
if ( visitor instanceof PostgreSQLParserVisitor ) { if ( visitor instanceof PostgreSQLParserVisitor ) {
return visitor.visitRoot(this); return visitor.visitProgram(this);
} else { } else {
return visitor.visitChildren(this); return visitor.visitChildren(this);
} }
@ -9441,12 +9441,12 @@ RootContext.prototype.accept = function(visitor) {
PostgreSQLParser.RootContext = RootContext; PostgreSQLParser.ProgramContext = ProgramContext;
PostgreSQLParser.prototype.root = function() { PostgreSQLParser.prototype.program = function() {
var localctx = new RootContext(this, this._ctx, this.state); var localctx = new ProgramContext(this, this._ctx, this.state);
this.enterRule(localctx, 0, PostgreSQLParser.RULE_root); this.enterRule(localctx, 0, PostgreSQLParser.RULE_program);
try { try {
this.enterOuterAlt(localctx, 1); this.enterOuterAlt(localctx, 1);
this.state = 1608; this.state = 1608;

View File

@ -11,12 +11,12 @@ function PostgreSQLParserListener() {
PostgreSQLParserListener.prototype = Object.create(antlr4.tree.ParseTreeListener.prototype); PostgreSQLParserListener.prototype = Object.create(antlr4.tree.ParseTreeListener.prototype);
PostgreSQLParserListener.prototype.constructor = PostgreSQLParserListener; PostgreSQLParserListener.prototype.constructor = PostgreSQLParserListener;
// Enter a parse tree produced by PostgreSQLParser#root. // Enter a parse tree produced by PostgreSQLParser#program.
PostgreSQLParserListener.prototype.enterRoot = function(ctx) { PostgreSQLParserListener.prototype.enterProgram = function(ctx) {
}; };
// Exit a parse tree produced by PostgreSQLParser#root. // Exit a parse tree produced by PostgreSQLParser#program.
PostgreSQLParserListener.prototype.exitRoot = function(ctx) { PostgreSQLParserListener.prototype.exitProgram = function(ctx) {
}; };

View File

@ -12,8 +12,8 @@ function PostgreSQLParserVisitor() {
PostgreSQLParserVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype); PostgreSQLParserVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype);
PostgreSQLParserVisitor.prototype.constructor = PostgreSQLParserVisitor; PostgreSQLParserVisitor.prototype.constructor = PostgreSQLParserVisitor;
// Visit a parse tree produced by PostgreSQLParser#root. // Visit a parse tree produced by PostgreSQLParser#program.
PostgreSQLParserVisitor.prototype.visitRoot = function(ctx) { PostgreSQLParserVisitor.prototype.visitProgram = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };

View File

@ -16,7 +16,7 @@ export class PostgreSQLParserBase extends antlr4.Parser {
GetParsedSqlTree( script, line) { GetParsedSqlTree( script, line) {
const ph = this.getPostgreSQLParser(script); const ph = this.getPostgreSQLParser(script);
return ph.root(); return ph.program();
} }
ParseRoutineBody( _localctx) { ParseRoutineBody( _localctx) {
@ -58,7 +58,7 @@ export class PostgreSQLParserBase extends antlr4.Parser {
func_as.func_as().Definition = ph.plsqlroot(); func_as.func_as().Definition = ph.plsqlroot();
break; break;
case 'sql': case 'sql':
func_as.func_as().Definition = ph.root(); func_as.func_as().Definition = ph.program();
break; break;
} }
} }

View File

@ -23,8 +23,7 @@ export default abstract class BasicParser<C = any> {
parser.removeErrorListeners(); parser.removeErrorListeners();
parser.addErrorListener(new ParserErrorListener(errorListener)); parser.addErrorListener(new ParserErrorListener(errorListener));
// Note : needed by pgsql const parserTree = parser.program();
const parserTree = parser.program? parser.program() : parser.root();
return parserTree; return parserTree;
} }
@ -38,12 +37,7 @@ export default abstract class BasicParser<C = any> {
parser.removeErrorListeners(); parser.removeErrorListeners();
parser.addErrorListener(new ParserErrorCollector(syntaxErrors)); parser.addErrorListener(new ParserErrorCollector(syntaxErrors));
// Note : needed by pgsql parser.program();
if (parser.program) {
parser.program();
} else {
parser.root();
}
return lexerError.concat(syntaxErrors); return lexerError.concat(syntaxErrors);
} }
@ -95,8 +89,7 @@ export default abstract class BasicParser<C = any> {
const parser = this.createParser(input); const parser = this.createParser(input);
this._parser = parser; this._parser = parser;
// Note : needed by pgsql const tree = parser.program();
const tree = parser.program? parser.program() : parser.root();
return tree.toStringTree(parser.ruleNames); return tree.toStringTree(parser.ruleNames);
} }