fix: remove space character in line comment rule (#69)

* fix: remove space character in line comment rule

* build: recompile grammars

* test: add cases for line comment
This commit is contained in:
Ziv 2023-01-09 11:01:10 +08:00 committed by GitHub
parent 93b1c5141a
commit 14c2534de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 8485 additions and 8450 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from /Users/yuwan/Desktop/yuwan/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');
var FlinkSqlParserListener = require('./FlinkSqlParserListener').FlinkSqlParserListener;

View File

@ -1,4 +1,4 @@
// Generated from /Users/yuwan/Desktop/yuwan/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/yuwan/Desktop/yuwan/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/generic/SqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/generic/SqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');
var SqlParserListener = require('./SqlParserListener').SqlParserListener;

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/generic/SqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/generic/SqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/generic/SqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/generic/SqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/hive/HiveSql.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/hive/HiveSql.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');
var HiveSqlListener = require('./HiveSqlListener').HiveSqlListener;

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/hive/HiveSqlLexer.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/hive/HiveSqlLexer.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/hive/HiveSql.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/hive/HiveSql.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/hive/HiveSql.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/hive/HiveSql.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/salvo/dt-sql-parser2/src/grammar/pgsql/PostgreSQLLexer.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/pgsql/PostgreSQLLexer.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');
@ -4737,7 +4737,7 @@ PostgreSQLLexer.prototype.Operator_action = function(localctx , actionIndex) {
switch (actionIndex) {
case 0:
this.HandleLessLessGreaterGreater();
HandleLessLessGreaterGreater();
break;
default:
@ -4748,7 +4748,7 @@ PostgreSQLLexer.prototype.Operator_action = function(localctx , actionIndex) {
PostgreSQLLexer.prototype.BeginDollarStringConstant_action = function(localctx , actionIndex) {
switch (actionIndex) {
case 1:
this.pushTag();
pushTag();
break;
default:
throw "No registered action for:" + actionIndex;
@ -4758,7 +4758,7 @@ PostgreSQLLexer.prototype.BeginDollarStringConstant_action = function(localctx ,
PostgreSQLLexer.prototype.NumericFail_action = function(localctx , actionIndex) {
switch (actionIndex) {
case 2:
this.HandleNumericFail();
HandleNumericFail();
break;
default:
throw "No registered action for:" + actionIndex;
@ -4769,7 +4769,7 @@ PostgreSQLLexer.prototype.UnterminatedBlockComment_action = function(localctx ,
switch (actionIndex) {
case 3:
this.UnterminatedBlockCommentDebugAssert();
UnterminatedBlockCommentDebugAssert();
break;
default:
@ -4798,7 +4798,7 @@ PostgreSQLLexer.prototype.AfterEscapeStringConstantWithNewlineMode_NotContinued_
PostgreSQLLexer.prototype.EndDollarStringConstant_action = function(localctx , actionIndex) {
switch (actionIndex) {
case 6:
this.popTag();
popTag();
break;
default:
throw "No registered action for:" + actionIndex;
@ -4822,11 +4822,11 @@ PostgreSQLLexer.prototype.sempred = function(localctx, ruleIndex, predIndex) {
PostgreSQLLexer.prototype.Operator_sempred = function(localctx, predIndex) {
switch(predIndex) {
case 0:
return this.checkLA('-');
return checkLA('-');
case 1:
return this.checkLA('*');
return checkLA('*');
case 2:
return this.checkLA('*');
return checkLA('*');
default:
throw "No predicate with index:" + predIndex;
}
@ -4835,11 +4835,11 @@ PostgreSQLLexer.prototype.Operator_sempred = function(localctx, predIndex) {
PostgreSQLLexer.prototype.OperatorEndingWithPlusMinus_sempred = function(localctx, predIndex) {
switch(predIndex) {
case 3:
return this.checkLA('-');
return checkLA('-');
case 4:
return this.checkLA('*');
return checkLA('*');
case 5:
return this.checkLA('-');
return checkLA('-');
default:
throw "No predicate with index:" + predIndex;
}
@ -4848,10 +4848,10 @@ PostgreSQLLexer.prototype.OperatorEndingWithPlusMinus_sempred = function(localct
PostgreSQLLexer.prototype.IdentifierStartChar_sempred = function(localctx, predIndex) {
switch(predIndex) {
case 6:
return this.charIsLetter();
return charIsLetter();
case 7:
return
this.CheckIfUtf32Letter()
CheckIfUtf32Letter()
;
default:
throw "No predicate with index:" + predIndex;
@ -4861,7 +4861,7 @@ PostgreSQLLexer.prototype.IdentifierStartChar_sempred = function(localctx, predI
PostgreSQLLexer.prototype.EndDollarStringConstant_sempred = function(localctx, predIndex) {
switch(predIndex) {
case 8:
return this.isTag();
return isTag();
default:
throw "No predicate with index:" + predIndex;
}

View File

@ -1,4 +1,4 @@
// Generated from /Users/salvo/dt-sql-parser2/src/grammar/pgsql/PostgreSQLParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/pgsql/PostgreSQLParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');
var PostgreSQLParserListener = require('./PostgreSQLParserListener').PostgreSQLParserListener;

View File

@ -1,4 +1,4 @@
// Generated from /Users/salvo/dt-sql-parser2/src/grammar/pgsql/PostgreSQLParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/pgsql/PostgreSQLParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/salvo/dt-sql-parser2/src/grammar/pgsql/PostgreSQLParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/pgsql/PostgreSQLParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/plsql/PlSqlLexer.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/plsql/PlSqlLexer.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/plsql/PlSqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/plsql/PlSqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');
var PlSqlParserListener = require('./PlSqlParserListener').PlSqlParserListener;

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/plsql/PlSqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/plsql/PlSqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/plsql/PlSqlParser.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/plsql/PlSqlParser.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');
var SparkSqlListener = require('./SparkSqlListener').SparkSqlListener;

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/spark/SparkSql.g4 by ANTLR 4.8
// jshint ignore: start
var antlr4 = require('antlr4/index');

View File

@ -220,4 +220,23 @@ describe('FlinkSQL Syntax Tests', () => {
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test invalid Double Line Comment statement', () => {
let sql = `-test comment\n`;
let result = parser.validate(sql);
expect(result.length).toBe(1);
});
test('Test valid Double Line Comment statement', () => {
const sql = `----test comment\n`;
const result = parser.validate(sql);
console.log('res:', result);
expect(result.length).toBe(0);
});
test('Test valid Hash Sign Line Comment statement', () => {
const sql = `#test comment\n`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
});

View File

@ -15,4 +15,22 @@ describe('Generic SQL Syntax Tests', () => {
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test invalid Double Line Comment statement', () => {
let sql = `-test comment\n`;
let result = parser.validate(sql);
expect(result.length).toBe(1);
});
test('Test valid Double Line Comment statement', () => {
const sql = `----test comment\n`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test valid Hash Sign Line Comment statement', () => {
const sql = `#test comment\n`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
});