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:
parent
93b1c5141a
commit
14c2534de7
@ -5,7 +5,7 @@ lexer grammar FlinkSqlLexer;
|
|||||||
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
|
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
|
||||||
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
|
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
|
||||||
LINE_COMMENT: (
|
LINE_COMMENT: (
|
||||||
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
|
('--' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
|
||||||
| '--' ('\r'? '\n' | EOF)
|
| '--' ('\r'? '\n' | EOF)
|
||||||
) -> channel(HIDDEN);
|
) -> channel(HIDDEN);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ SPACE: [ \t\r\n]+ -> channel(HIDDEN);
|
|||||||
SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel(MYSQLCOMMENT);
|
SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel(MYSQLCOMMENT);
|
||||||
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
|
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
|
||||||
LINE_COMMENT: (
|
LINE_COMMENT: (
|
||||||
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
|
('--' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
|
||||||
| '--' ('\r'? '\n' | EOF)
|
| '--' ('\r'? '\n' | EOF)
|
||||||
) -> channel(HIDDEN);
|
) -> channel(HIDDEN);
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
var FlinkSqlParserListener = require('./FlinkSqlParserListener').FlinkSqlParserListener;
|
var FlinkSqlParserListener = require('./FlinkSqlParserListener').FlinkSqlParserListener;
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
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
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
var SqlParserListener = require('./SqlParserListener').SqlParserListener;
|
var SqlParserListener = require('./SqlParserListener').SqlParserListener;
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
var HiveSqlListener = require('./HiveSqlListener').HiveSqlListener;
|
var HiveSqlListener = require('./HiveSqlListener').HiveSqlListener;
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
@ -4737,7 +4737,7 @@ PostgreSQLLexer.prototype.Operator_action = function(localctx , actionIndex) {
|
|||||||
switch (actionIndex) {
|
switch (actionIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
this.HandleLessLessGreaterGreater();
|
HandleLessLessGreaterGreater();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -4748,7 +4748,7 @@ PostgreSQLLexer.prototype.Operator_action = function(localctx , actionIndex) {
|
|||||||
PostgreSQLLexer.prototype.BeginDollarStringConstant_action = function(localctx , actionIndex) {
|
PostgreSQLLexer.prototype.BeginDollarStringConstant_action = function(localctx , actionIndex) {
|
||||||
switch (actionIndex) {
|
switch (actionIndex) {
|
||||||
case 1:
|
case 1:
|
||||||
this.pushTag();
|
pushTag();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "No registered action for:" + actionIndex;
|
throw "No registered action for:" + actionIndex;
|
||||||
@ -4758,7 +4758,7 @@ PostgreSQLLexer.prototype.BeginDollarStringConstant_action = function(localctx ,
|
|||||||
PostgreSQLLexer.prototype.NumericFail_action = function(localctx , actionIndex) {
|
PostgreSQLLexer.prototype.NumericFail_action = function(localctx , actionIndex) {
|
||||||
switch (actionIndex) {
|
switch (actionIndex) {
|
||||||
case 2:
|
case 2:
|
||||||
this.HandleNumericFail();
|
HandleNumericFail();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "No registered action for:" + actionIndex;
|
throw "No registered action for:" + actionIndex;
|
||||||
@ -4769,7 +4769,7 @@ PostgreSQLLexer.prototype.UnterminatedBlockComment_action = function(localctx ,
|
|||||||
switch (actionIndex) {
|
switch (actionIndex) {
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
this.UnterminatedBlockCommentDebugAssert();
|
UnterminatedBlockCommentDebugAssert();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -4798,7 +4798,7 @@ PostgreSQLLexer.prototype.AfterEscapeStringConstantWithNewlineMode_NotContinued_
|
|||||||
PostgreSQLLexer.prototype.EndDollarStringConstant_action = function(localctx , actionIndex) {
|
PostgreSQLLexer.prototype.EndDollarStringConstant_action = function(localctx , actionIndex) {
|
||||||
switch (actionIndex) {
|
switch (actionIndex) {
|
||||||
case 6:
|
case 6:
|
||||||
this.popTag();
|
popTag();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "No registered action for:" + actionIndex;
|
throw "No registered action for:" + actionIndex;
|
||||||
@ -4822,11 +4822,11 @@ PostgreSQLLexer.prototype.sempred = function(localctx, ruleIndex, predIndex) {
|
|||||||
PostgreSQLLexer.prototype.Operator_sempred = function(localctx, predIndex) {
|
PostgreSQLLexer.prototype.Operator_sempred = function(localctx, predIndex) {
|
||||||
switch(predIndex) {
|
switch(predIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return this.checkLA('-');
|
return checkLA('-');
|
||||||
case 1:
|
case 1:
|
||||||
return this.checkLA('*');
|
return checkLA('*');
|
||||||
case 2:
|
case 2:
|
||||||
return this.checkLA('*');
|
return checkLA('*');
|
||||||
default:
|
default:
|
||||||
throw "No predicate with index:" + predIndex;
|
throw "No predicate with index:" + predIndex;
|
||||||
}
|
}
|
||||||
@ -4835,11 +4835,11 @@ PostgreSQLLexer.prototype.Operator_sempred = function(localctx, predIndex) {
|
|||||||
PostgreSQLLexer.prototype.OperatorEndingWithPlusMinus_sempred = function(localctx, predIndex) {
|
PostgreSQLLexer.prototype.OperatorEndingWithPlusMinus_sempred = function(localctx, predIndex) {
|
||||||
switch(predIndex) {
|
switch(predIndex) {
|
||||||
case 3:
|
case 3:
|
||||||
return this.checkLA('-');
|
return checkLA('-');
|
||||||
case 4:
|
case 4:
|
||||||
return this.checkLA('*');
|
return checkLA('*');
|
||||||
case 5:
|
case 5:
|
||||||
return this.checkLA('-');
|
return checkLA('-');
|
||||||
default:
|
default:
|
||||||
throw "No predicate with index:" + predIndex;
|
throw "No predicate with index:" + predIndex;
|
||||||
}
|
}
|
||||||
@ -4848,10 +4848,10 @@ PostgreSQLLexer.prototype.OperatorEndingWithPlusMinus_sempred = function(localct
|
|||||||
PostgreSQLLexer.prototype.IdentifierStartChar_sempred = function(localctx, predIndex) {
|
PostgreSQLLexer.prototype.IdentifierStartChar_sempred = function(localctx, predIndex) {
|
||||||
switch(predIndex) {
|
switch(predIndex) {
|
||||||
case 6:
|
case 6:
|
||||||
return this.charIsLetter();
|
return charIsLetter();
|
||||||
case 7:
|
case 7:
|
||||||
return
|
return
|
||||||
this.CheckIfUtf32Letter()
|
CheckIfUtf32Letter()
|
||||||
;
|
;
|
||||||
default:
|
default:
|
||||||
throw "No predicate with index:" + predIndex;
|
throw "No predicate with index:" + predIndex;
|
||||||
@ -4861,7 +4861,7 @@ PostgreSQLLexer.prototype.IdentifierStartChar_sempred = function(localctx, predI
|
|||||||
PostgreSQLLexer.prototype.EndDollarStringConstant_sempred = function(localctx, predIndex) {
|
PostgreSQLLexer.prototype.EndDollarStringConstant_sempred = function(localctx, predIndex) {
|
||||||
switch(predIndex) {
|
switch(predIndex) {
|
||||||
case 8:
|
case 8:
|
||||||
return this.isTag();
|
return isTag();
|
||||||
default:
|
default:
|
||||||
throw "No predicate with index:" + predIndex;
|
throw "No predicate with index:" + predIndex;
|
||||||
}
|
}
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
var PostgreSQLParserListener = require('./PostgreSQLParserListener').PostgreSQLParserListener;
|
var PostgreSQLParserListener = require('./PostgreSQLParserListener').PostgreSQLParserListener;
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
var PlSqlParserListener = require('./PlSqlParserListener').PlSqlParserListener;
|
var PlSqlParserListener = require('./PlSqlParserListener').PlSqlParserListener;
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
var SparkSqlListener = require('./SparkSqlListener').SparkSqlListener;
|
var SparkSqlListener = require('./SparkSqlListener').SparkSqlListener;
|
||||||
|
@ -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
|
// jshint ignore: start
|
||||||
var antlr4 = require('antlr4/index');
|
var antlr4 = require('antlr4/index');
|
||||||
|
|
||||||
|
@ -220,4 +220,23 @@ describe('FlinkSQL Syntax Tests', () => {
|
|||||||
const result = parser.validate(sql);
|
const result = parser.validate(sql);
|
||||||
expect(result.length).toBe(0);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,4 +15,22 @@ describe('Generic SQL Syntax Tests', () => {
|
|||||||
const result = parser.validate(sql);
|
const result = parser.validate(sql);
|
||||||
expect(result.length).toBe(0);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user