omextra 0.0.0.dev424__py3-none-any.whl → 0.0.0.dev426__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. omextra/.omlish-manifests.json +14 -0
  2. omextra/__about__.py +3 -1
  3. omextra/defs.py +216 -0
  4. omextra/dynamic.py +219 -0
  5. omextra/formats/__init__.py +0 -0
  6. omextra/formats/json/Json.g4 +77 -0
  7. omextra/formats/json/__init__.py +0 -0
  8. omextra/formats/json/_antlr/JsonLexer.py +109 -0
  9. omextra/formats/json/_antlr/JsonListener.py +61 -0
  10. omextra/formats/json/_antlr/JsonParser.py +457 -0
  11. omextra/formats/json/_antlr/JsonVisitor.py +42 -0
  12. omextra/formats/json/_antlr/__init__.py +0 -0
  13. omextra/io/__init__.py +0 -0
  14. omextra/io/trampoline.py +289 -0
  15. omextra/specs/__init__.py +0 -0
  16. omextra/specs/irc/__init__.py +0 -0
  17. omextra/specs/irc/messages/__init__.py +0 -0
  18. omextra/specs/irc/messages/base.py +50 -0
  19. omextra/specs/irc/messages/formats.py +92 -0
  20. omextra/specs/irc/messages/messages.py +775 -0
  21. omextra/specs/irc/messages/parsing.py +99 -0
  22. omextra/specs/irc/numerics/__init__.py +0 -0
  23. omextra/specs/irc/numerics/formats.py +97 -0
  24. omextra/specs/irc/numerics/numerics.py +865 -0
  25. omextra/specs/irc/numerics/types.py +59 -0
  26. omextra/specs/irc/protocol/LICENSE +11 -0
  27. omextra/specs/irc/protocol/__init__.py +61 -0
  28. omextra/specs/irc/protocol/consts.py +6 -0
  29. omextra/specs/irc/protocol/errors.py +30 -0
  30. omextra/specs/irc/protocol/message.py +21 -0
  31. omextra/specs/irc/protocol/nuh.py +55 -0
  32. omextra/specs/irc/protocol/parsing.py +158 -0
  33. omextra/specs/irc/protocol/rendering.py +153 -0
  34. omextra/specs/irc/protocol/tags.py +102 -0
  35. omextra/specs/irc/protocol/utils.py +30 -0
  36. omextra/specs/proto/Protobuf3.g4 +396 -0
  37. omextra/specs/proto/__init__.py +0 -0
  38. omextra/specs/proto/_antlr/Protobuf3Lexer.py +340 -0
  39. omextra/specs/proto/_antlr/Protobuf3Listener.py +448 -0
  40. omextra/specs/proto/_antlr/Protobuf3Parser.py +3909 -0
  41. omextra/specs/proto/_antlr/Protobuf3Visitor.py +257 -0
  42. omextra/specs/proto/_antlr/__init__.py +0 -0
  43. omextra/specs/proto/nodes.py +54 -0
  44. omextra/specs/proto/parsing.py +98 -0
  45. omextra/sql/__init__.py +0 -0
  46. omextra/sql/parsing/Minisql.g4 +292 -0
  47. omextra/sql/parsing/__init__.py +0 -0
  48. omextra/sql/parsing/_antlr/MinisqlLexer.py +322 -0
  49. omextra/sql/parsing/_antlr/MinisqlListener.py +511 -0
  50. omextra/sql/parsing/_antlr/MinisqlParser.py +3763 -0
  51. omextra/sql/parsing/_antlr/MinisqlVisitor.py +292 -0
  52. omextra/sql/parsing/_antlr/__init__.py +0 -0
  53. omextra/sql/parsing/parsing.py +120 -0
  54. omextra/text/__init__.py +0 -0
  55. omextra/text/antlr/__init__.py +0 -0
  56. omextra/text/antlr/cli/__init__.py +0 -0
  57. omextra/text/antlr/cli/__main__.py +11 -0
  58. omextra/text/antlr/cli/cli.py +62 -0
  59. omextra/text/antlr/cli/consts.py +7 -0
  60. omextra/text/antlr/cli/gen.py +193 -0
  61. {omextra-0.0.0.dev424.dist-info → omextra-0.0.0.dev426.dist-info}/METADATA +2 -3
  62. omextra-0.0.0.dev426.dist-info/RECORD +67 -0
  63. omextra/.manifests.json +0 -1
  64. omextra-0.0.0.dev424.dist-info/RECORD +0 -9
  65. {omextra-0.0.0.dev424.dist-info → omextra-0.0.0.dev426.dist-info}/WHEEL +0 -0
  66. {omextra-0.0.0.dev424.dist-info → omextra-0.0.0.dev426.dist-info}/entry_points.txt +0 -0
  67. {omextra-0.0.0.dev424.dist-info → omextra-0.0.0.dev426.dist-info}/licenses/LICENSE +0 -0
  68. {omextra-0.0.0.dev424.dist-info → omextra-0.0.0.dev426.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,257 @@
1
+ # type: ignore
2
+ # ruff: noqa
3
+ # flake8: noqa
4
+ # @omlish-generated
5
+ # Generated from Protobuf3.g4 by ANTLR 4.13.2
6
+ from omlish.text.antlr._runtime._all import *
7
+ if "." in __name__:
8
+ from .Protobuf3Parser import Protobuf3Parser
9
+ else:
10
+ from Protobuf3Parser import Protobuf3Parser
11
+
12
+ # This class defines a complete generic visitor for a parse tree produced by Protobuf3Parser.
13
+
14
+ class Protobuf3Visitor(ParseTreeVisitor):
15
+
16
+ # Visit a parse tree produced by Protobuf3Parser#proto.
17
+ def visitProto(self, ctx:Protobuf3Parser.ProtoContext):
18
+ return self.visitChildren(ctx)
19
+
20
+
21
+ # Visit a parse tree produced by Protobuf3Parser#syntax.
22
+ def visitSyntax(self, ctx:Protobuf3Parser.SyntaxContext):
23
+ return self.visitChildren(ctx)
24
+
25
+
26
+ # Visit a parse tree produced by Protobuf3Parser#syntaxExtra.
27
+ def visitSyntaxExtra(self, ctx:Protobuf3Parser.SyntaxExtraContext):
28
+ return self.visitChildren(ctx)
29
+
30
+
31
+ # Visit a parse tree produced by Protobuf3Parser#importStmt.
32
+ def visitImportStmt(self, ctx:Protobuf3Parser.ImportStmtContext):
33
+ return self.visitChildren(ctx)
34
+
35
+
36
+ # Visit a parse tree produced by Protobuf3Parser#packageStmt.
37
+ def visitPackageStmt(self, ctx:Protobuf3Parser.PackageStmtContext):
38
+ return self.visitChildren(ctx)
39
+
40
+
41
+ # Visit a parse tree produced by Protobuf3Parser#option.
42
+ def visitOption(self, ctx:Protobuf3Parser.OptionContext):
43
+ return self.visitChildren(ctx)
44
+
45
+
46
+ # Visit a parse tree produced by Protobuf3Parser#optionName.
47
+ def visitOptionName(self, ctx:Protobuf3Parser.OptionNameContext):
48
+ return self.visitChildren(ctx)
49
+
50
+
51
+ # Visit a parse tree produced by Protobuf3Parser#optionBody.
52
+ def visitOptionBody(self, ctx:Protobuf3Parser.OptionBodyContext):
53
+ return self.visitChildren(ctx)
54
+
55
+
56
+ # Visit a parse tree produced by Protobuf3Parser#optionBodyVariable.
57
+ def visitOptionBodyVariable(self, ctx:Protobuf3Parser.OptionBodyVariableContext):
58
+ return self.visitChildren(ctx)
59
+
60
+
61
+ # Visit a parse tree produced by Protobuf3Parser#topLevelDef.
62
+ def visitTopLevelDef(self, ctx:Protobuf3Parser.TopLevelDefContext):
63
+ return self.visitChildren(ctx)
64
+
65
+
66
+ # Visit a parse tree produced by Protobuf3Parser#message.
67
+ def visitMessage(self, ctx:Protobuf3Parser.MessageContext):
68
+ return self.visitChildren(ctx)
69
+
70
+
71
+ # Visit a parse tree produced by Protobuf3Parser#messageBody.
72
+ def visitMessageBody(self, ctx:Protobuf3Parser.MessageBodyContext):
73
+ return self.visitChildren(ctx)
74
+
75
+
76
+ # Visit a parse tree produced by Protobuf3Parser#messageBodyContent.
77
+ def visitMessageBodyContent(self, ctx:Protobuf3Parser.MessageBodyContentContext):
78
+ return self.visitChildren(ctx)
79
+
80
+
81
+ # Visit a parse tree produced by Protobuf3Parser#enumDef.
82
+ def visitEnumDef(self, ctx:Protobuf3Parser.EnumDefContext):
83
+ return self.visitChildren(ctx)
84
+
85
+
86
+ # Visit a parse tree produced by Protobuf3Parser#enumBody.
87
+ def visitEnumBody(self, ctx:Protobuf3Parser.EnumBodyContext):
88
+ return self.visitChildren(ctx)
89
+
90
+
91
+ # Visit a parse tree produced by Protobuf3Parser#enumField.
92
+ def visitEnumField(self, ctx:Protobuf3Parser.EnumFieldContext):
93
+ return self.visitChildren(ctx)
94
+
95
+
96
+ # Visit a parse tree produced by Protobuf3Parser#enumValueOption.
97
+ def visitEnumValueOption(self, ctx:Protobuf3Parser.EnumValueOptionContext):
98
+ return self.visitChildren(ctx)
99
+
100
+
101
+ # Visit a parse tree produced by Protobuf3Parser#extend.
102
+ def visitExtend(self, ctx:Protobuf3Parser.ExtendContext):
103
+ return self.visitChildren(ctx)
104
+
105
+
106
+ # Visit a parse tree produced by Protobuf3Parser#service.
107
+ def visitService(self, ctx:Protobuf3Parser.ServiceContext):
108
+ return self.visitChildren(ctx)
109
+
110
+
111
+ # Visit a parse tree produced by Protobuf3Parser#rpc.
112
+ def visitRpc(self, ctx:Protobuf3Parser.RpcContext):
113
+ return self.visitChildren(ctx)
114
+
115
+
116
+ # Visit a parse tree produced by Protobuf3Parser#reserved.
117
+ def visitReserved(self, ctx:Protobuf3Parser.ReservedContext):
118
+ return self.visitChildren(ctx)
119
+
120
+
121
+ # Visit a parse tree produced by Protobuf3Parser#ranges.
122
+ def visitRanges(self, ctx:Protobuf3Parser.RangesContext):
123
+ return self.visitChildren(ctx)
124
+
125
+
126
+ # Visit a parse tree produced by Protobuf3Parser#rangeRule.
127
+ def visitRangeRule(self, ctx:Protobuf3Parser.RangeRuleContext):
128
+ return self.visitChildren(ctx)
129
+
130
+
131
+ # Visit a parse tree produced by Protobuf3Parser#fieldNames.
132
+ def visitFieldNames(self, ctx:Protobuf3Parser.FieldNamesContext):
133
+ return self.visitChildren(ctx)
134
+
135
+
136
+ # Visit a parse tree produced by Protobuf3Parser#typeRule.
137
+ def visitTypeRule(self, ctx:Protobuf3Parser.TypeRuleContext):
138
+ return self.visitChildren(ctx)
139
+
140
+
141
+ # Visit a parse tree produced by Protobuf3Parser#simpleType.
142
+ def visitSimpleType(self, ctx:Protobuf3Parser.SimpleTypeContext):
143
+ return self.visitChildren(ctx)
144
+
145
+
146
+ # Visit a parse tree produced by Protobuf3Parser#fieldNumber.
147
+ def visitFieldNumber(self, ctx:Protobuf3Parser.FieldNumberContext):
148
+ return self.visitChildren(ctx)
149
+
150
+
151
+ # Visit a parse tree produced by Protobuf3Parser#field.
152
+ def visitField(self, ctx:Protobuf3Parser.FieldContext):
153
+ return self.visitChildren(ctx)
154
+
155
+
156
+ # Visit a parse tree produced by Protobuf3Parser#fieldOptions.
157
+ def visitFieldOptions(self, ctx:Protobuf3Parser.FieldOptionsContext):
158
+ return self.visitChildren(ctx)
159
+
160
+
161
+ # Visit a parse tree produced by Protobuf3Parser#fieldOption.
162
+ def visitFieldOption(self, ctx:Protobuf3Parser.FieldOptionContext):
163
+ return self.visitChildren(ctx)
164
+
165
+
166
+ # Visit a parse tree produced by Protobuf3Parser#oneof.
167
+ def visitOneof(self, ctx:Protobuf3Parser.OneofContext):
168
+ return self.visitChildren(ctx)
169
+
170
+
171
+ # Visit a parse tree produced by Protobuf3Parser#oneofField.
172
+ def visitOneofField(self, ctx:Protobuf3Parser.OneofFieldContext):
173
+ return self.visitChildren(ctx)
174
+
175
+
176
+ # Visit a parse tree produced by Protobuf3Parser#mapField.
177
+ def visitMapField(self, ctx:Protobuf3Parser.MapFieldContext):
178
+ return self.visitChildren(ctx)
179
+
180
+
181
+ # Visit a parse tree produced by Protobuf3Parser#keyType.
182
+ def visitKeyType(self, ctx:Protobuf3Parser.KeyTypeContext):
183
+ return self.visitChildren(ctx)
184
+
185
+
186
+ # Visit a parse tree produced by Protobuf3Parser#reservedWord.
187
+ def visitReservedWord(self, ctx:Protobuf3Parser.ReservedWordContext):
188
+ return self.visitChildren(ctx)
189
+
190
+
191
+ # Visit a parse tree produced by Protobuf3Parser#fullIdent.
192
+ def visitFullIdent(self, ctx:Protobuf3Parser.FullIdentContext):
193
+ return self.visitChildren(ctx)
194
+
195
+
196
+ # Visit a parse tree produced by Protobuf3Parser#messageName.
197
+ def visitMessageName(self, ctx:Protobuf3Parser.MessageNameContext):
198
+ return self.visitChildren(ctx)
199
+
200
+
201
+ # Visit a parse tree produced by Protobuf3Parser#enumName.
202
+ def visitEnumName(self, ctx:Protobuf3Parser.EnumNameContext):
203
+ return self.visitChildren(ctx)
204
+
205
+
206
+ # Visit a parse tree produced by Protobuf3Parser#messageOrEnumName.
207
+ def visitMessageOrEnumName(self, ctx:Protobuf3Parser.MessageOrEnumNameContext):
208
+ return self.visitChildren(ctx)
209
+
210
+
211
+ # Visit a parse tree produced by Protobuf3Parser#fieldName.
212
+ def visitFieldName(self, ctx:Protobuf3Parser.FieldNameContext):
213
+ return self.visitChildren(ctx)
214
+
215
+
216
+ # Visit a parse tree produced by Protobuf3Parser#oneofName.
217
+ def visitOneofName(self, ctx:Protobuf3Parser.OneofNameContext):
218
+ return self.visitChildren(ctx)
219
+
220
+
221
+ # Visit a parse tree produced by Protobuf3Parser#mapName.
222
+ def visitMapName(self, ctx:Protobuf3Parser.MapNameContext):
223
+ return self.visitChildren(ctx)
224
+
225
+
226
+ # Visit a parse tree produced by Protobuf3Parser#serviceName.
227
+ def visitServiceName(self, ctx:Protobuf3Parser.ServiceNameContext):
228
+ return self.visitChildren(ctx)
229
+
230
+
231
+ # Visit a parse tree produced by Protobuf3Parser#rpcName.
232
+ def visitRpcName(self, ctx:Protobuf3Parser.RpcNameContext):
233
+ return self.visitChildren(ctx)
234
+
235
+
236
+ # Visit a parse tree produced by Protobuf3Parser#messageType.
237
+ def visitMessageType(self, ctx:Protobuf3Parser.MessageTypeContext):
238
+ return self.visitChildren(ctx)
239
+
240
+
241
+ # Visit a parse tree produced by Protobuf3Parser#messageOrEnumType.
242
+ def visitMessageOrEnumType(self, ctx:Protobuf3Parser.MessageOrEnumTypeContext):
243
+ return self.visitChildren(ctx)
244
+
245
+
246
+ # Visit a parse tree produced by Protobuf3Parser#emptyStmt.
247
+ def visitEmptyStmt(self, ctx:Protobuf3Parser.EmptyStmtContext):
248
+ return self.visitChildren(ctx)
249
+
250
+
251
+ # Visit a parse tree produced by Protobuf3Parser#constant.
252
+ def visitConstant(self, ctx:Protobuf3Parser.ConstantContext):
253
+ return self.visitChildren(ctx)
254
+
255
+
256
+
257
+ del Protobuf3Parser
File without changes
@@ -0,0 +1,54 @@
1
+ import enum
2
+ import typing as ta
3
+
4
+ from omlish import dataclasses as dc
5
+
6
+
7
+ ##
8
+
9
+
10
+ class SimpleType(enum.Enum):
11
+ DOUBLE = 'double'
12
+ FLOAT = 'float'
13
+ INT32 = 'int32'
14
+ INT64 = 'int64'
15
+ UINT32 = 'uint32'
16
+ UINT64 = 'uint64'
17
+ SINT32 = 'sint32'
18
+ SINT64 = 'sint64'
19
+ FIXED32 = 'fixed32'
20
+ FIXED64 = 'fixed64'
21
+ SFIXED32 = 'sfixed32'
22
+ SFIXED64 = 'sfixed64'
23
+ BOOL = 'bool'
24
+ STRING = 'string'
25
+ BYTES = 'bytes'
26
+
27
+
28
+ class TypeRef(dc.Frozen):
29
+ name: str
30
+
31
+
32
+ Type: ta.TypeAlias = SimpleType | TypeRef
33
+
34
+
35
+ ##
36
+
37
+
38
+ class Field(dc.Frozen):
39
+ name: str
40
+ type: Type
41
+ num: int
42
+ repeated: bool = False
43
+
44
+
45
+ class Message(dc.Frozen):
46
+ name: str
47
+ fields: ta.Sequence[Field]
48
+
49
+
50
+ ##
51
+
52
+
53
+ class ProtoFile(dc.Frozen):
54
+ messages: ta.Sequence[Message] | None = None
@@ -0,0 +1,98 @@
1
+ # ruff: noqa: N802 N803
2
+ import typing as ta
3
+
4
+ from omlish import check
5
+ from omlish.text.antlr import runtime as antlr4
6
+ from omlish.text.antlr.errors import SilentRaisingErrorListener
7
+
8
+ from . import nodes as no
9
+ from ._antlr.Protobuf3Lexer import Protobuf3Lexer # type: ignore
10
+ from ._antlr.Protobuf3Parser import Protobuf3Parser # type: ignore
11
+ from ._antlr.Protobuf3Visitor import Protobuf3Visitor # type: ignore
12
+
13
+
14
+ ##
15
+
16
+
17
+ class _ParseVisitor(Protobuf3Visitor):
18
+ def visit(self, ctx: antlr4.ParserRuleContext):
19
+ check.isinstance(ctx, antlr4.ParserRuleContext)
20
+ node = ctx.accept(self)
21
+ return node
22
+
23
+ def aggregateResult(self, aggregate, nextResult):
24
+ if aggregate is not None:
25
+ check.none(nextResult)
26
+ return aggregate
27
+ else:
28
+ check.none(aggregate)
29
+ return nextResult
30
+
31
+ #
32
+
33
+ def visitField(self, ctx: Protobuf3Parser.FieldContext):
34
+ name = ctx.fieldName().getText()
35
+ type_: no.Type = check.isinstance(self.visitTypeRule(ctx.typeRule()), (no.SimpleType, no.TypeRef))
36
+ num = int(ctx.fieldNumber().getText())
37
+ repeated = ctx.REPEATED() is not None
38
+ return no.Field(
39
+ name=name,
40
+ type=type_,
41
+ num=num,
42
+ repeated=repeated,
43
+ )
44
+
45
+ def visitMessage(self, ctx: Protobuf3Parser.MessageContext):
46
+ name = ctx.messageName().getText()
47
+ fields: list[no.Field] = []
48
+ for mbc_ctx in ctx.messageBody().messageBodyContent():
49
+ mbc = self.visitMessageBodyContent(mbc_ctx)
50
+ if isinstance(mbc, no.Field):
51
+ fields.append(mbc)
52
+ return no.Message(
53
+ name=name,
54
+ fields=fields,
55
+ )
56
+
57
+ def visitMessageOrEnumType(self, ctx: Protobuf3Parser.MessageOrEnumTypeContext):
58
+ return no.TypeRef(ctx.getText())
59
+
60
+ def visitProto(self, ctx: Protobuf3Parser.ProtoContext):
61
+ messages: list[no.Message] = []
62
+ for ex_ctx in ctx.syntaxExtra():
63
+ ex = self.visitSyntaxExtra(ex_ctx)
64
+ if isinstance(ex, no.Message):
65
+ messages.append(ex)
66
+ return no.ProtoFile(
67
+ messages=messages,
68
+ )
69
+
70
+ def visitSimpleType(self, ctx: Protobuf3Parser.SimpleTypeContext):
71
+ return no.SimpleType(ctx.getText())
72
+
73
+
74
+ ##
75
+
76
+
77
+ def create_parser(buf: str) -> Protobuf3Parser:
78
+ lexer = Protobuf3Lexer(antlr4.InputStream(buf))
79
+ lexer.removeErrorListeners()
80
+ lexer.addErrorListener(SilentRaisingErrorListener())
81
+
82
+ stream = antlr4.CommonTokenStream(lexer)
83
+ stream.fill()
84
+
85
+ parser = Protobuf3Parser(stream)
86
+ parser.removeErrorListeners()
87
+ parser.addErrorListener(SilentRaisingErrorListener())
88
+
89
+ return parser
90
+
91
+
92
+ ##
93
+
94
+
95
+ def parse_proto(buf: str, **kwargs: ta.Any) -> ta.Any:
96
+ parser = create_parser(buf, **kwargs)
97
+ node = _ParseVisitor().visit(parser.proto())
98
+ return node
File without changes
@@ -0,0 +1,292 @@
1
+ grammar Minisql;
2
+
3
+
4
+ tokens {
5
+ DELIMITER
6
+ }
7
+
8
+
9
+ singleStmt
10
+ : select ';' EOF
11
+ ;
12
+
13
+ select
14
+ : cteSelect
15
+ ;
16
+
17
+ cteSelect
18
+ : (WITH cte (',' cte)*)? unionSelect
19
+ ;
20
+
21
+ cte
22
+ : ident AS '(' select ')'
23
+ ;
24
+
25
+ unionSelect
26
+ : primarySelect unionItem*
27
+ ;
28
+
29
+ unionItem
30
+ : UNION setQuantifier? primarySelect
31
+ ;
32
+
33
+ primarySelect
34
+ : SELECT setQuantifier? selectItem (',' selectItem)*
35
+ (FROM relation (',' relation)*)?
36
+ (WHERE where=booleanExpr)?
37
+ (GROUP BY groupBy)?
38
+ (HAVING having=booleanExpr)?
39
+ (ORDER BY sortItem (',' sortItem)*)?
40
+ ;
41
+
42
+ selectItem
43
+ : '*' #allSelectItem
44
+ | expr (AS? ident)? #exprSelectItem
45
+ ;
46
+
47
+ expr
48
+ : booleanExpr
49
+ ;
50
+
51
+ booleanExpr
52
+ : valueExpr predicate[$valueExpr.ctx]? #predicatedBooleanExpr
53
+ | op=NOT booleanExpr #unaryBooleanExpr
54
+ | booleanExpr op=(AND | OR) booleanExpr #binaryBooleanExpr
55
+ | booleanExpr '::' ident #castBooleanExpr
56
+ ;
57
+
58
+ predicate[ParserRuleContext value]
59
+ : cmpOp right=valueExpr #cmpPredicate
60
+ | IS NOT? NULL #isNullPredicate
61
+ | NOT? IN '(' expr (',' expr)* ')' #inListPredicate
62
+ | NOT? IN '(' select ')' #inSelectPredicate
63
+ | NOT? LIKE expr #likePredicate
64
+ ;
65
+
66
+ valueExpr
67
+ : primaryExpr #primaryValueExpr
68
+ | op=unaryOp valueExpr #unaryValueExpr
69
+ | left=valueExpr op=arithOp right=valueExpr #arithValueExpr
70
+ ;
71
+
72
+ primaryExpr
73
+ : qualifiedName '(' (expr (',' expr)*)? ')' over? #functionCallExpr
74
+ | qualifiedName '(' '*' ')' over? #starFunctionCallExpr
75
+ | CASE caseItem* (ELSE expr)? END #caseExpr
76
+ | '(' select ')' #selectExpr
77
+ | '(' expr ')' #parenExpr
78
+ | simpleExpr #simplePrimaryExpr
79
+ ;
80
+
81
+ simpleExpr
82
+ : qualifiedName
83
+ | number
84
+ | string
85
+ | null
86
+ | true
87
+ | false
88
+ ;
89
+
90
+ caseItem
91
+ : WHEN expr THEN expr
92
+ ;
93
+
94
+ over
95
+ : OVER '(' (ORDER BY sortItem (',' sortItem)*)? ')'
96
+ ;
97
+
98
+ sortItem
99
+ : expr direction=(ASC | DESC)?
100
+ ;
101
+
102
+ relation
103
+ : relation AS? ident #aliasedRelation
104
+ | left=relation
105
+ ty=joinType?
106
+ JOIN right=relation
107
+ (ON cond=booleanExpr)? #joinRelation
108
+ | '(' select ')' #selectRelation
109
+ | '(' relation ')' #parenRelation
110
+ | qualifiedName #tableRelation
111
+ ;
112
+
113
+ groupBy
114
+ : expr (',' expr)*
115
+ ;
116
+
117
+ qualifiedName
118
+ : ident ('.' ident)*
119
+ ;
120
+
121
+ identList
122
+ : ident (',' ident)*
123
+ ;
124
+
125
+ ident
126
+ : unquotedIdent
127
+ | quotedIdent
128
+ ;
129
+
130
+ quotedIdent
131
+ : QUOTED_IDENT
132
+ ;
133
+
134
+ number
135
+ : INTEGER_VALUE #integerNumber
136
+ | DECIMAL_VALUE #decimalNumber
137
+ | FLOAT_VALUE #floatNumber
138
+ ;
139
+
140
+ string
141
+ : STRING
142
+ ;
143
+
144
+ null
145
+ : NULL
146
+ ;
147
+
148
+ true
149
+ : TRUE
150
+ ;
151
+
152
+ false
153
+ : FALSE
154
+ ;
155
+
156
+ setQuantifier
157
+ : DISTINCT
158
+ | ALL
159
+ ;
160
+
161
+ joinType
162
+ : INNER
163
+ | LEFT
164
+ | LEFT OUTER
165
+ | RIGHT
166
+ | RIGHT OUTER
167
+ | FULL
168
+ | FULL OUTER
169
+ | CROSS
170
+ | NATURAL
171
+ ;
172
+
173
+ cmpOp
174
+ : '='
175
+ | '!='
176
+ | '<>'
177
+ | '<'
178
+ | '<='
179
+ | '>'
180
+ | '>='
181
+ ;
182
+
183
+ arithOp
184
+ : '+'
185
+ | '-'
186
+ | '*'
187
+ | '/'
188
+ | '%'
189
+ | '||'
190
+ ;
191
+
192
+ unaryOp
193
+ : '+'
194
+ | '-'
195
+ ;
196
+
197
+ unquotedIdent
198
+ : IDENT
199
+
200
+ | LEFT
201
+ | RIGHT
202
+
203
+ ;
204
+
205
+ ALL: 'all';
206
+ AND: 'and';
207
+ AS: 'as';
208
+ ASC: 'asc';
209
+ BY: 'by';
210
+ CASE: 'case';
211
+ CROSS: 'cross';
212
+ DESC: 'desc';
213
+ DISTINCT: 'distinct';
214
+ ELSE: 'else';
215
+ END: 'end';
216
+ FALSE: 'false';
217
+ FROM: 'from';
218
+ FULL: 'full';
219
+ GROUP: 'group';
220
+ HAVING: 'having';
221
+ IN: 'in';
222
+ INNER: 'inner';
223
+ IS: 'is';
224
+ JOIN: 'join';
225
+ LEFT: 'left';
226
+ LIKE: 'like';
227
+ NATURAL: 'natural';
228
+ NOT: 'not';
229
+ NULL: 'null';
230
+ ON: 'on';
231
+ OR: 'or';
232
+ ORDER: 'order';
233
+ OUTER: 'outer';
234
+ OVER: 'over';
235
+ RIGHT: 'right';
236
+ SELECT: 'select';
237
+ THEN: 'then';
238
+ TRUE: 'true';
239
+ UNION: 'union';
240
+ WHEN: 'when';
241
+ WHERE: 'where';
242
+ WITH: 'with';
243
+
244
+ STRING
245
+ : '\'' (~'\'' | '\'\'')* '\''
246
+ ;
247
+
248
+ INTEGER_VALUE
249
+ : DIGIT+
250
+ ;
251
+
252
+ DECIMAL_VALUE
253
+ : DIGIT+ '.' DIGIT*
254
+ | '.' DIGIT+
255
+ ;
256
+
257
+ FLOAT_VALUE
258
+ : DIGIT+ ('.' DIGIT*)? EXPONENT
259
+ | '.' DIGIT+ EXPONENT
260
+ ;
261
+
262
+ IDENT
263
+ : (LETTER | '_') (LETTER | DIGIT | '_' | '@' | ':' | '$')*
264
+ ;
265
+
266
+ QUOTED_IDENT
267
+ : '"' (~'"' | '""')* '"'
268
+ ;
269
+
270
+ fragment EXPONENT
271
+ : [Ee] [+-]? DIGIT+
272
+ ;
273
+
274
+ fragment DIGIT
275
+ : [0-9]
276
+ ;
277
+
278
+ fragment LETTER
279
+ : [A-Za-z]
280
+ ;
281
+
282
+ COMMENT
283
+ : '--' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN)
284
+ ;
285
+
286
+ BLOCK_COMMENT
287
+ : '/*' .*? '*/' -> channel(HIDDEN)
288
+ ;
289
+
290
+ WS
291
+ : [ \t\n\r]+ -> skip
292
+ ;
File without changes