@@ -102,6 +102,25 @@ public class CCJSqlParser extends AbstractJSqlParser<CCJSqlParser> {
102102 public Node getASTRoot() {
103103 return jjtree.rootNode();
104104 }
105+
106+ private static class ObjectNames {
107+
108+ private final List<String> names;
109+ private final List<String> delimiters;
110+
111+ public ObjectNames(List<String> names, List<String> delimiters) {
112+ this.names = names;
113+ this.delimiters = delimiters;
114+ }
115+
116+ public List<String> getNames() {
117+ return names;
118+ }
119+
120+ public List<String> getDelimiters() {
121+ return delimiters;
122+ }
123+ }
105124}
106125
107126PARSER_END(CCJSqlParser)
@@ -1886,33 +1905,38 @@ MergeOperation MergeWhenNotMatched() : {
18861905 { return mi; }
18871906}
18881907
1889- List<String> RelObjectNameList () : {
1908+ ObjectNames RelObjectNames () : {
18901909 String token = null;
1910+ Token delimiter = null;
18911911 List<String> data = new ArrayList<String>();
1912+ List<String> delimiters = new ArrayList<String>();
18921913} {
18931914 token = RelObjectNameExt() { data.add(token); }
1894- ( LOOKAHEAD (2) ("." | ":") ("." { data.add(null); })* token = RelObjectNameExt2() { data.add(token); } ) *
1915+ (
1916+ LOOKAHEAD (2) ( delimiter = "." | delimiter = ":" ) { delimiters.add(delimiter.image); } (( delimiter = "." | delimiter = ":" ) { data.add(null); delimiters.add(delimiter.image); })*
1917+ token = RelObjectNameExt2() { data.add(token); }
1918+ ) *
18951919
1896- { return data; }
1920+ { return new ObjectNames( data, delimiters) ; }
18971921}
18981922
18991923// See: http://technet.microsoft.com/en-us/library/ms187879%28v=sql.105%29.aspx
19001924
19011925Column Column() #Column :
19021926{
1903- List<String> data = new ArrayList<String>() ;
1927+ ObjectNames data = null ;
19041928 ArrayConstructor arrayConstructor = null;
19051929 Token tk = null;
19061930}
19071931{
1908- data = RelObjectNameList ()
1932+ data = RelObjectNames ()
19091933 [ LOOKAHEAD(2) <K_COMMENT> tk=<S_CHAR_LITERAL> ]
19101934 // @todo: we better should return a SEQUENCE instead of a COLUMN
1911- [ "." <K_NEXTVAL> { data.add("nextval"); } ]
1935+ [ "." <K_NEXTVAL> { data.getNames(). add("nextval"); } ]
19121936
19131937 [ LOOKAHEAD(2) arrayConstructor = ArrayConstructor(false) ]
19141938 {
1915- Column col = new Column(data);
1939+ Column col = new Column(data.getNames(), data.getDelimiters() );
19161940 if (tk != null) { col.withCommentText(tk.image); }
19171941 if (arrayConstructor!=null) {
19181942 col.setArrayConstructor(arrayConstructor);
@@ -2004,13 +2028,13 @@ String RelObjectNameExt2():
20042028Table Table() #TableName :
20052029{
20062030 //String serverName = null, databaseName = null, schemaName = null, tableName = null;
2007- List<String> data = new ArrayList<String>() ;
2031+ ObjectNames data = null ;
20082032}
20092033{
2010- data = RelObjectNameList ()
2034+ data = RelObjectNames ()
20112035
20122036 {
2013- Table table = new Table(data);
2037+ Table table = new Table(data.getNames() );
20142038 linkAST(table,jjtThis);
20152039 return table;
20162040 }
@@ -4545,13 +4569,13 @@ ConnectByRootOperator ConnectByRootOperator() #ConnectByRootOperator: {
45454569}
45464570
45474571NextValExpression NextValExpression() : {
4548- List<String> data = new ArrayList<String>() ;
4572+ ObjectNames data = null ;
45494573 Token token;
45504574}
45514575{
4552- token=<K_NEXTVAL> data = RelObjectNameList ()
4576+ token=<K_NEXTVAL> data = RelObjectNames ()
45534577 {
4554- return new NextValExpression(data, token.image);
4578+ return new NextValExpression(data.getNames() , token.image);
45554579 }
45564580}
45574581
@@ -5350,7 +5374,7 @@ EqualsTo VariableExpression(): {
53505374
53515375Execute Execute(): {
53525376 Token token;
5353- List<String> funcName;
5377+ ObjectNames funcName;
53545378 ExpressionList expressionList = null;
53555379 Execute execute = new Execute();
53565380 List<Expression> namedExprList;
@@ -5361,7 +5385,7 @@ Execute Execute(): {
53615385 | <K_EXECUTE> { execute.setExecType(Execute.ExecType.EXECUTE); }
53625386 | <K_CALL> { execute.setExecType(Execute.ExecType.CALL); } )
53635387
5364- funcName=RelObjectNameList () { execute.setName(funcName); }
5388+ funcName=RelObjectNames () { execute.setName(funcName.getNames() ); }
53655389
53665390 (
53675391 LOOKAHEAD(2) expressionList=ExpressionList() { execute.setExprList(expressionList); }
@@ -5483,13 +5507,13 @@ Function SpecialStringFunctionWithNamedParameters() :
54835507Function SimpleFunction():
54845508{
54855509 Function function = new Function();
5486- List<String> name;
5510+ ObjectNames name;
54875511 Expression expr=null;
54885512 Expression attributeExpression = null;
54895513 Column attributeColumn = null;
54905514}
54915515{
5492- name = RelObjectNameList ()
5516+ name = RelObjectNames ()
54935517 "("
54945518 [
54955519 (
@@ -5508,7 +5532,7 @@ Function SimpleFunction():
55085532 ]
55095533 ")"
55105534 {
5511- function.setName(name);
5535+ function.setName(name.getNames() );
55125536 if (expr!=null) {
55135537 function.setParameters(expr);
55145538 }
@@ -5533,7 +5557,7 @@ Function InternalFunction(boolean escaped):
55335557{
55345558 Token prefixToken = null;
55355559 Function retval = new Function();
5536- List<String> funcName;
5560+ ObjectNames funcName;
55375561 ExpressionList expressionList = null;
55385562 KeepExpression keep = null;
55395563 Expression expr = null;
@@ -5544,7 +5568,7 @@ Function InternalFunction(boolean escaped):
55445568}
55455569{
55465570 [ LOOKAHEAD(2) prefixToken = <K_APPROXIMATE> ]
5547- funcName = RelObjectNameList () { if (prefixToken!=null) funcName.add(0, prefixToken.image ); }
5571+ funcName = RelObjectNames () { if (prefixToken!=null) funcName.getNames() .add(0, prefixToken.image ); }
55485572
55495573 "("
55505574 [
@@ -5601,7 +5625,7 @@ Function InternalFunction(boolean escaped):
56015625 {
56025626 retval.setEscaped(escaped);
56035627 retval.setParameters(expressionList);
5604- retval.setName(funcName);
5628+ retval.setName(funcName.getNames() );
56055629 retval.setKeep(keep);
56065630 return retval;
56075631 }
@@ -5698,10 +5722,10 @@ List<Index.ColumnParams> ColumnNamesWithParamsList() : {
56985722}
56995723
57005724Index Index(): {
5701- List<String> name;
5725+ ObjectNames name;
57025726}
57035727{
5704- name= RelObjectNameList () { return new Index().withName(name).withType(""); }
5728+ name= RelObjectNames () { return new Index().withName(name.getNames() ).withType(""); }
57055729}
57065730
57075731CreateIndex CreateIndex():
@@ -7311,7 +7335,7 @@ Grant Grant():
73117335 ArrayList<String> privileges = new ArrayList<String>();
73127336 List<String> users;
73137337 Token tk = null;
7314- List<String> objName;
7338+ ObjectNames objName;
73157339}
73167340{
73177341 <K_GRANT>
@@ -7320,7 +7344,7 @@ Grant Grant():
73207344 [readGrantTypes(privileges) (<K_COMMA> readGrantTypes(privileges))*]
73217345 <K_ON>
73227346 (
7323- objName=RelObjectNameList () { grant.setObjectName(objName); }
7347+ objName=RelObjectNames () { grant.setObjectName(objName.getNames() ); }
73247348 )
73257349 )
73267350 |
@@ -7365,13 +7389,13 @@ void readGrantTypes(ArrayList<String> privileges):
73657389
73667390Sequence Sequence() #Sequence :
73677391{
7368- List<String> data = new ArrayList<String>() ;
7392+ ObjectNames data = null ;
73697393 String serverName = null, databaseName = null, schemaName = null, sequenceName = null;
73707394}
73717395{
7372- data = RelObjectNameList ()
7396+ data = RelObjectNames ()
73737397 {
7374- Sequence sequence = new Sequence(data);
7398+ Sequence sequence = new Sequence(data.getNames() );
73757399 linkAST(sequence,jjtThis);
73767400 return sequence;
73777401 }
@@ -7575,29 +7599,29 @@ CreateSynonym CreateSynonym(boolean isUsingOrReplace):
75757599 CreateSynonym createSynonym = new CreateSynonym();
75767600 Synonym synonym;
75777601 boolean publicSynonym = false;
7578- List<String> data = new ArrayList<String>() ;
7602+ ObjectNames data = null ;
75797603}
75807604{
75817605 [<K_PUBLIC> { publicSynonym = true; } ]
75827606 <K_SYNONYM> synonym=Synonym() { createSynonym.setSynonym(synonym); }
7583- <K_FOR> data = RelObjectNameList ()
7607+ <K_FOR> data = RelObjectNames ()
75847608 {
75857609 createSynonym.setOrReplace(isUsingOrReplace);
75867610 createSynonym.setPublicSynonym(publicSynonym);
7587- createSynonym.setForList(data);
7611+ createSynonym.setForList(data.getNames() );
75887612 return createSynonym;
75897613 }
75907614}
75917615
75927616Synonym Synonym() #Synonym :
75937617{
7594- List<String> data = new ArrayList<String>() ;
7618+ ObjectNames data = null ;
75957619 String serverName = null, databaseName = null, schemaName = null, sequenceName = null;
75967620}
75977621{
7598- data = RelObjectNameList ()
7622+ data = RelObjectNames ()
75997623 {
7600- Synonym synonym = new Synonym(data);
7624+ Synonym synonym = new Synonym(data.getNames() );
76017625 linkAST(synonym,jjtThis);
76027626 return synonym;
76037627 }
0 commit comments