mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -61,7 +61,9 @@ public class Lexer {
|
||||
protected Keywords keywods = Keywords.DEFAULT_KEYWORDS;
|
||||
|
||||
protected String stringVal;
|
||||
|
||||
|
||||
protected int commentCount = 0;
|
||||
|
||||
protected List<String> comments = new ArrayList<String>(2);
|
||||
|
||||
protected boolean skipComment = true;
|
||||
@@ -95,6 +97,12 @@ public class Lexer {
|
||||
this(input, true);
|
||||
this.commentHandler = commentHandler;
|
||||
}
|
||||
|
||||
public Lexer(String input, CommentHandler commentHandler, String dbType){
|
||||
this(input, true);
|
||||
this.commentHandler = commentHandler;
|
||||
this.dbType = dbType;
|
||||
}
|
||||
|
||||
public boolean isKeepComments() {
|
||||
return keepComments;
|
||||
@@ -300,7 +308,7 @@ public class Lexer {
|
||||
|
||||
public final void nextToken() {
|
||||
bufPos = 0;
|
||||
if (comments != null) {
|
||||
if (comments != null && comments.size() > 0) {
|
||||
comments = null;
|
||||
}
|
||||
|
||||
@@ -1104,6 +1112,7 @@ public class Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
commentCount++;
|
||||
if (keepComments) {
|
||||
addComment(stringVal);
|
||||
}
|
||||
@@ -1153,6 +1162,7 @@ public class Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
commentCount++;
|
||||
if (keepComments) {
|
||||
addComment(stringVal);
|
||||
}
|
||||
@@ -1445,6 +1455,10 @@ public class Lexer {
|
||||
public boolean hasComment() {
|
||||
return comments != null;
|
||||
}
|
||||
|
||||
public int getCommentCount() {
|
||||
return commentCount;
|
||||
}
|
||||
|
||||
public void skipToEOF() {
|
||||
pos = text.length();
|
||||
|
||||
Reference in New Issue
Block a user