提交 e1bbb559 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Inline Parser.getKeywordOrIdentifier()

上级 0cc472a5
...@@ -279,7 +279,10 @@ public class ParserUtil { ...@@ -279,7 +279,10 @@ public class ParserUtil {
*/ */
switch (s.charAt(0)) { switch (s.charAt(0)) {
case 'A': case 'A':
return getKeywordOrIdentifier(s, "ALL", ALL); if ("ALL".equals(s)) {
return ALL;
}
return IDENTIFIER;
case 'C': case 'C':
if ("CHECK".equals(s)) { if ("CHECK".equals(s)) {
return CHECK; return CHECK;
...@@ -295,12 +298,17 @@ public class ParserUtil { ...@@ -295,12 +298,17 @@ public class ParserUtil {
} }
return IDENTIFIER; return IDENTIFIER;
case 'D': case 'D':
return getKeywordOrIdentifier(s, "DISTINCT", DISTINCT); if ("DISTINCT".equals(s)) {
return DISTINCT;
}
return IDENTIFIER;
case 'E': case 'E':
if ("EXCEPT".equals(s)) { if ("EXCEPT".equals(s)) {
return EXCEPT; return EXCEPT;
} else if ("EXISTS".equals(s)) {
return EXISTS;
} }
return getKeywordOrIdentifier(s, "EXISTS", EXISTS); return IDENTIFIER;
case 'F': case 'F':
if ("FETCH".equals(s)) { if ("FETCH".equals(s)) {
return FETCH; return FETCH;
...@@ -312,12 +320,20 @@ public class ParserUtil { ...@@ -312,12 +320,20 @@ public class ParserUtil {
return FOREIGN; return FOREIGN;
} else if ("FULL".equals(s)) { } else if ("FULL".equals(s)) {
return FULL; return FULL;
} else if ("FALSE".equals(s)) {
return FALSE;
} }
return getKeywordOrIdentifier(s, "FALSE", FALSE); return IDENTIFIER;
case 'G': case 'G':
return getKeywordOrIdentifier(s, "GROUP", GROUP); if ("GROUP".equals(s)) {
return GROUP;
}
return IDENTIFIER;
case 'H': case 'H':
return getKeywordOrIdentifier(s, "HAVING", HAVING); if ("HAVING".equals(s)) {
return HAVING;
}
return IDENTIFIER;
case 'I': case 'I':
if ("INNER".equals(s)) { if ("INNER".equals(s)) {
return INNER; return INNER;
...@@ -333,7 +349,10 @@ public class ParserUtil { ...@@ -333,7 +349,10 @@ public class ParserUtil {
} }
return IDENTIFIER; return IDENTIFIER;
case 'J': case 'J':
return getKeywordOrIdentifier(s, "JOIN", JOIN); if ("JOIN".equals(s)) {
return JOIN;
}
return IDENTIFIER;
case 'L': case 'L':
if ("LIMIT".equals(s)) { if ("LIMIT".equals(s)) {
return LIMIT; return LIMIT;
...@@ -347,25 +366,38 @@ public class ParserUtil { ...@@ -347,25 +366,38 @@ public class ParserUtil {
} }
return IDENTIFIER; return IDENTIFIER;
case 'M': case 'M':
return getKeywordOrIdentifier(s, "MINUS", MINUS); if ("MINUS".equals(s)) {
return MINUS;
}
return IDENTIFIER;
case 'N': case 'N':
if ("NOT".equals(s)) { if ("NOT".equals(s)) {
return NOT; return NOT;
} else if ("NATURAL".equals(s)) { } else if ("NATURAL".equals(s)) {
return NATURAL; return NATURAL;
} else if ("NULL".equals(s)) {
return NULL;
} }
return getKeywordOrIdentifier(s, "NULL", NULL); return IDENTIFIER;
case 'O': case 'O':
if ("OFFSET".equals(s)) { if ("OFFSET".equals(s)) {
return OFFSET; return OFFSET;
} else if ("ON".equals(s)) { } else if ("ON".equals(s)) {
return ON; return ON;
} else if ("ORDER".equals(s)) {
return ORDER;
} }
return getKeywordOrIdentifier(s, "ORDER", ORDER); return IDENTIFIER;
case 'P': case 'P':
return getKeywordOrIdentifier(s, "PRIMARY", PRIMARY); if ("PRIMARY".equals(s)) {
return PRIMARY;
}
return IDENTIFIER;
case 'R': case 'R':
return getKeywordOrIdentifier(s, "ROWNUM", ROWNUM); if ("ROWNUM".equals(s)) {
return ROWNUM;
}
return IDENTIFIER;
case 'S': case 'S':
if ("SELECT".equals(s)) { if ("SELECT".equals(s)) {
return SELECT; return SELECT;
...@@ -389,24 +421,20 @@ public class ParserUtil { ...@@ -389,24 +421,20 @@ public class ParserUtil {
case 'U': case 'U':
if ("UNIQUE".equals(s)) { if ("UNIQUE".equals(s)) {
return UNIQUE; return UNIQUE;
} else if ("UNION".equals(s)) {
return UNION;
} }
return getKeywordOrIdentifier(s, "UNION", UNION); return IDENTIFIER;
case 'W': case 'W':
if ("WITH".equals(s)) { if ("WITH".equals(s)) {
return WITH; return WITH;
} else if ("WHERE".equals(s)) {
return WHERE;
} }
return getKeywordOrIdentifier(s, "WHERE", WHERE); return IDENTIFIER;
default: default:
return IDENTIFIER; return IDENTIFIER;
} }
} }
private static int getKeywordOrIdentifier(String s1, String s2,
int keywordType) {
if (s1.equals(s2)) {
return keywordType;
}
return IDENTIFIER;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论