Skip to content

Commit b31e634

Browse files
committed
Replace PostgreSQL grammar to support COLLATE
1 parent 0f335b2 commit b31e634

File tree

13 files changed

+121582
-51929
lines changed

13 files changed

+121582
-51929
lines changed

headless-services/commons/jpql/grammars/PostgreSqlLexer.g4

Lines changed: 1674 additions & 930 deletions
Large diffs are not rendered by default.

headless-services/commons/jpql/grammars/PostgreSqlParser.g4

Lines changed: 5134 additions & 1479 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
PostgreSQL grammar.
3+
The MIT License (MIT).
4+
Copyright (c) 2021-2023, Oleksii Kovalov ([email protected]).
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+
*/
21+
package org.springframework.ide.vscode.parser.postgresql;
22+
23+
import java.util.BitSet;
24+
import org.antlr.v4.runtime.*;
25+
import org.antlr.v4.runtime.atn.*;
26+
import org.antlr.v4.runtime.dfa.*;
27+
28+
public class LexerDispatchingErrorListener implements ANTLRErrorListener
29+
{
30+
Lexer _parent;
31+
32+
public LexerDispatchingErrorListener(Lexer parent)
33+
{
34+
_parent = parent;
35+
}
36+
37+
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e)
38+
{
39+
ProxyErrorListener foo = new ProxyErrorListener(_parent.getErrorListeners());
40+
foo.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
41+
}
42+
43+
public void reportAmbiguity(Parser recognizer,
44+
DFA dfa,
45+
int startIndex,
46+
int stopIndex,
47+
boolean exact,
48+
BitSet ambigAlts,
49+
ATNConfigSet configs)
50+
{
51+
ProxyErrorListener foo = new ProxyErrorListener(_parent.getErrorListeners());
52+
foo.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
53+
}
54+
55+
public void reportAttemptingFullContext(Parser recognizer,
56+
DFA dfa,
57+
int startIndex,
58+
int stopIndex,
59+
BitSet conflictingAlts,
60+
ATNConfigSet configs)
61+
{
62+
ProxyErrorListener foo = new ProxyErrorListener(_parent.getErrorListeners());
63+
foo.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
64+
}
65+
66+
public void reportContextSensitivity(Parser recognizer,
67+
DFA dfa,
68+
int startIndex,
69+
int stopIndex,
70+
int prediction,
71+
ATNConfigSet configs)
72+
{
73+
ProxyErrorListener foo = new ProxyErrorListener(_parent.getErrorListeners());
74+
foo.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
75+
}
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
PostgreSQL grammar.
3+
The MIT License (MIT).
4+
Copyright (c) 2021-2023, Oleksii Kovalov ([email protected]).
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+
*/
21+
package org.springframework.ide.vscode.parser.postgresql;
22+
23+
import java.util.BitSet;
24+
import org.antlr.v4.runtime.*;
25+
import org.antlr.v4.runtime.atn.*;
26+
import org.antlr.v4.runtime.dfa.*;
27+
28+
public class ParserDispatchingErrorListener implements ANTLRErrorListener
29+
{
30+
Parser _parent;
31+
32+
public ParserDispatchingErrorListener(Parser parent)
33+
{
34+
_parent = parent;
35+
}
36+
37+
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e)
38+
{
39+
var foo = new ProxyErrorListener(_parent.getErrorListeners());
40+
foo.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
41+
}
42+
43+
public void reportAmbiguity(Parser recognizer,
44+
DFA dfa,
45+
int startIndex,
46+
int stopIndex,
47+
boolean exact,
48+
BitSet ambigAlts,
49+
ATNConfigSet configs)
50+
{
51+
ProxyErrorListener foo = new ProxyErrorListener(_parent.getErrorListeners());
52+
foo.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
53+
}
54+
55+
public void reportAttemptingFullContext(Parser recognizer,
56+
DFA dfa,
57+
int startIndex,
58+
int stopIndex,
59+
BitSet conflictingAlts,
60+
ATNConfigSet configs)
61+
{
62+
ProxyErrorListener foo = new ProxyErrorListener(_parent.getErrorListeners());
63+
foo.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
64+
}
65+
66+
public void reportContextSensitivity(Parser recognizer,
67+
DFA dfa,
68+
int startIndex,
69+
int stopIndex,
70+
int prediction,
71+
ATNConfigSet configs)
72+
{
73+
ProxyErrorListener foo = new ProxyErrorListener(_parent.getErrorListeners());
74+
foo.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
75+
}
76+
}

0 commit comments

Comments
 (0)