omlish 0.0.0.dev56__py3-none-any.whl → 0.0.0.dev58__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. omlish/__about__.py +2 -2
  2. omlish/antlr/__init__.py +0 -0
  3. omlish/antlr/_runtime/BufferedTokenStream.py +305 -0
  4. omlish/antlr/_runtime/CommonTokenFactory.py +64 -0
  5. omlish/antlr/_runtime/CommonTokenStream.py +90 -0
  6. omlish/antlr/_runtime/FileStream.py +30 -0
  7. omlish/antlr/_runtime/InputStream.py +90 -0
  8. omlish/antlr/_runtime/IntervalSet.py +183 -0
  9. omlish/antlr/_runtime/LL1Analyzer.py +176 -0
  10. omlish/antlr/_runtime/Lexer.py +332 -0
  11. omlish/antlr/_runtime/ListTokenSource.py +147 -0
  12. omlish/antlr/_runtime/Parser.py +583 -0
  13. omlish/antlr/_runtime/ParserInterpreter.py +173 -0
  14. omlish/antlr/_runtime/ParserRuleContext.py +189 -0
  15. omlish/antlr/_runtime/PredictionContext.py +632 -0
  16. omlish/antlr/_runtime/Recognizer.py +150 -0
  17. omlish/antlr/_runtime/RuleContext.py +230 -0
  18. omlish/antlr/_runtime/StdinStream.py +14 -0
  19. omlish/antlr/_runtime/Token.py +158 -0
  20. omlish/antlr/_runtime/TokenStreamRewriter.py +258 -0
  21. omlish/antlr/_runtime/Utils.py +36 -0
  22. omlish/antlr/_runtime/__init__.py +24 -0
  23. omlish/antlr/_runtime/_pygrun.py +174 -0
  24. omlish/antlr/_runtime/atn/ATN.py +135 -0
  25. omlish/antlr/_runtime/atn/ATNConfig.py +162 -0
  26. omlish/antlr/_runtime/atn/ATNConfigSet.py +215 -0
  27. omlish/antlr/_runtime/atn/ATNDeserializationOptions.py +27 -0
  28. omlish/antlr/_runtime/atn/ATNDeserializer.py +449 -0
  29. omlish/antlr/_runtime/atn/ATNSimulator.py +50 -0
  30. omlish/antlr/_runtime/atn/ATNState.py +267 -0
  31. omlish/antlr/_runtime/atn/ATNType.py +20 -0
  32. omlish/antlr/_runtime/atn/LexerATNSimulator.py +573 -0
  33. omlish/antlr/_runtime/atn/LexerAction.py +301 -0
  34. omlish/antlr/_runtime/atn/LexerActionExecutor.py +146 -0
  35. omlish/antlr/_runtime/atn/ParserATNSimulator.py +1664 -0
  36. omlish/antlr/_runtime/atn/PredictionMode.py +502 -0
  37. omlish/antlr/_runtime/atn/SemanticContext.py +333 -0
  38. omlish/antlr/_runtime/atn/Transition.py +271 -0
  39. omlish/antlr/_runtime/atn/__init__.py +4 -0
  40. omlish/antlr/_runtime/dfa/DFA.py +136 -0
  41. omlish/antlr/_runtime/dfa/DFASerializer.py +76 -0
  42. omlish/antlr/_runtime/dfa/DFAState.py +129 -0
  43. omlish/antlr/_runtime/dfa/__init__.py +4 -0
  44. omlish/antlr/_runtime/error/DiagnosticErrorListener.py +110 -0
  45. omlish/antlr/_runtime/error/ErrorListener.py +75 -0
  46. omlish/antlr/_runtime/error/ErrorStrategy.py +712 -0
  47. omlish/antlr/_runtime/error/Errors.py +176 -0
  48. omlish/antlr/_runtime/error/__init__.py +4 -0
  49. omlish/antlr/_runtime/tree/Chunk.py +33 -0
  50. omlish/antlr/_runtime/tree/ParseTreeMatch.py +121 -0
  51. omlish/antlr/_runtime/tree/ParseTreePattern.py +75 -0
  52. omlish/antlr/_runtime/tree/ParseTreePatternMatcher.py +377 -0
  53. omlish/antlr/_runtime/tree/RuleTagToken.py +53 -0
  54. omlish/antlr/_runtime/tree/TokenTagToken.py +50 -0
  55. omlish/antlr/_runtime/tree/Tree.py +194 -0
  56. omlish/antlr/_runtime/tree/Trees.py +114 -0
  57. omlish/antlr/_runtime/tree/__init__.py +2 -0
  58. omlish/antlr/_runtime/xpath/XPath.py +272 -0
  59. omlish/antlr/_runtime/xpath/XPathLexer.py +98 -0
  60. omlish/antlr/_runtime/xpath/__init__.py +4 -0
  61. omlish/formats/json/cli.py +76 -7
  62. omlish/formats/props.py +6 -2
  63. {omlish-0.0.0.dev56.dist-info → omlish-0.0.0.dev58.dist-info}/METADATA +1 -1
  64. {omlish-0.0.0.dev56.dist-info → omlish-0.0.0.dev58.dist-info}/RECORD +68 -9
  65. {omlish-0.0.0.dev56.dist-info → omlish-0.0.0.dev58.dist-info}/LICENSE +0 -0
  66. {omlish-0.0.0.dev56.dist-info → omlish-0.0.0.dev58.dist-info}/WHEEL +0 -0
  67. {omlish-0.0.0.dev56.dist-info → omlish-0.0.0.dev58.dist-info}/entry_points.txt +0 -0
  68. {omlish-0.0.0.dev56.dist-info → omlish-0.0.0.dev58.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,301 @@
1
+ # type: ignore
2
+ # ruff: noqa
3
+ # flake8: noqa
4
+ #
5
+ # Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
6
+ # Use of this file is governed by the BSD 3-clause license that
7
+ # can be found in the LICENSE.txt file in the project root.
8
+ #
9
+
10
+ from enum import IntEnum
11
+
12
+ # need forward declaration
13
+ Lexer = None
14
+
15
+
16
+ class LexerActionType(IntEnum):
17
+
18
+ CHANNEL = 0 #The type of a {@link LexerChannelAction} action.
19
+ CUSTOM = 1 #The type of a {@link LexerCustomAction} action.
20
+ MODE = 2 #The type of a {@link LexerModeAction} action.
21
+ MORE = 3 #The type of a {@link LexerMoreAction} action.
22
+ POP_MODE = 4 #The type of a {@link LexerPopModeAction} action.
23
+ PUSH_MODE = 5 #The type of a {@link LexerPushModeAction} action.
24
+ SKIP = 6 #The type of a {@link LexerSkipAction} action.
25
+ TYPE = 7 #The type of a {@link LexerTypeAction} action.
26
+
27
+ class LexerAction(object):
28
+ __slots__ = ('actionType', 'isPositionDependent')
29
+
30
+ def __init__(self, action:LexerActionType):
31
+ self.actionType = action
32
+ self.isPositionDependent = False
33
+
34
+ def __hash__(self):
35
+ return hash(self.actionType)
36
+
37
+ def __eq__(self, other):
38
+ return self is other
39
+
40
+
41
+ #
42
+ # Implements the {@code skip} lexer action by calling {@link Lexer#skip}.
43
+ #
44
+ # <p>The {@code skip} command does not have any parameters, so this action is
45
+ # implemented as a singleton instance exposed by {@link #INSTANCE}.</p>
46
+ class LexerSkipAction(LexerAction):
47
+
48
+ # Provides a singleton instance of this parameterless lexer action.
49
+ INSTANCE = None
50
+
51
+ def __init__(self):
52
+ super().__init__(LexerActionType.SKIP)
53
+
54
+ def execute(self, lexer:Lexer):
55
+ lexer.skip()
56
+
57
+ def __str__(self):
58
+ return "skip"
59
+
60
+ LexerSkipAction.INSTANCE = LexerSkipAction()
61
+
62
+ # Implements the {@code type} lexer action by calling {@link Lexer#setType}
63
+ # with the assigned type.
64
+ class LexerTypeAction(LexerAction):
65
+ __slots__ = 'type'
66
+
67
+ def __init__(self, type:int):
68
+ super().__init__(LexerActionType.TYPE)
69
+ self.type = type
70
+
71
+ def execute(self, lexer:Lexer):
72
+ lexer.type = self.type
73
+
74
+ def __hash__(self):
75
+ return hash((self.actionType, self.type))
76
+
77
+ def __eq__(self, other):
78
+ if self is other:
79
+ return True
80
+ elif not isinstance(other, LexerTypeAction):
81
+ return False
82
+ else:
83
+ return self.type == other.type
84
+
85
+ def __str__(self):
86
+ return "type(" + str(self.type) + ")"
87
+
88
+
89
+ # Implements the {@code pushMode} lexer action by calling
90
+ # {@link Lexer#pushMode} with the assigned mode.
91
+ class LexerPushModeAction(LexerAction):
92
+ __slots__ = 'mode'
93
+
94
+ def __init__(self, mode:int):
95
+ super().__init__(LexerActionType.PUSH_MODE)
96
+ self.mode = mode
97
+
98
+ # <p>This action is implemented by calling {@link Lexer#pushMode} with the
99
+ # value provided by {@link #getMode}.</p>
100
+ def execute(self, lexer:Lexer):
101
+ lexer.pushMode(self.mode)
102
+
103
+ def __hash__(self):
104
+ return hash((self.actionType, self.mode))
105
+
106
+ def __eq__(self, other):
107
+ if self is other:
108
+ return True
109
+ elif not isinstance(other, LexerPushModeAction):
110
+ return False
111
+ else:
112
+ return self.mode == other.mode
113
+
114
+ def __str__(self):
115
+ return "pushMode(" + str(self.mode) + ")"
116
+
117
+
118
+ # Implements the {@code popMode} lexer action by calling {@link Lexer#popMode}.
119
+ #
120
+ # <p>The {@code popMode} command does not have any parameters, so this action is
121
+ # implemented as a singleton instance exposed by {@link #INSTANCE}.</p>
122
+ class LexerPopModeAction(LexerAction):
123
+
124
+ INSTANCE = None
125
+
126
+ def __init__(self):
127
+ super().__init__(LexerActionType.POP_MODE)
128
+
129
+ # <p>This action is implemented by calling {@link Lexer#popMode}.</p>
130
+ def execute(self, lexer:Lexer):
131
+ lexer.popMode()
132
+
133
+ def __str__(self):
134
+ return "popMode"
135
+
136
+ LexerPopModeAction.INSTANCE = LexerPopModeAction()
137
+
138
+ # Implements the {@code more} lexer action by calling {@link Lexer#more}.
139
+ #
140
+ # <p>The {@code more} command does not have any parameters, so this action is
141
+ # implemented as a singleton instance exposed by {@link #INSTANCE}.</p>
142
+ class LexerMoreAction(LexerAction):
143
+
144
+ INSTANCE = None
145
+
146
+ def __init__(self):
147
+ super().__init__(LexerActionType.MORE)
148
+
149
+ # <p>This action is implemented by calling {@link Lexer#popMode}.</p>
150
+ def execute(self, lexer:Lexer):
151
+ lexer.more()
152
+
153
+ def __str__(self):
154
+ return "more"
155
+
156
+ LexerMoreAction.INSTANCE = LexerMoreAction()
157
+
158
+ # Implements the {@code mode} lexer action by calling {@link Lexer#mode} with
159
+ # the assigned mode.
160
+ class LexerModeAction(LexerAction):
161
+ __slots__ = 'mode'
162
+
163
+ def __init__(self, mode:int):
164
+ super().__init__(LexerActionType.MODE)
165
+ self.mode = mode
166
+
167
+ # <p>This action is implemented by calling {@link Lexer#mode} with the
168
+ # value provided by {@link #getMode}.</p>
169
+ def execute(self, lexer:Lexer):
170
+ lexer.mode(self.mode)
171
+
172
+ def __hash__(self):
173
+ return hash((self.actionType, self.mode))
174
+
175
+ def __eq__(self, other):
176
+ if self is other:
177
+ return True
178
+ elif not isinstance(other, LexerModeAction):
179
+ return False
180
+ else:
181
+ return self.mode == other.mode
182
+
183
+ def __str__(self):
184
+ return "mode(" + str(self.mode) + ")"
185
+
186
+ # Executes a custom lexer action by calling {@link Recognizer#action} with the
187
+ # rule and action indexes assigned to the custom action. The implementation of
188
+ # a custom action is added to the generated code for the lexer in an override
189
+ # of {@link Recognizer#action} when the grammar is compiled.
190
+ #
191
+ # <p>This class may represent embedded actions created with the <code>{...}</code>
192
+ # syntax in ANTLR 4, as well as actions created for lexer commands where the
193
+ # command argument could not be evaluated when the grammar was compiled.</p>
194
+
195
+ class LexerCustomAction(LexerAction):
196
+ __slots__ = ('ruleIndex', 'actionIndex')
197
+
198
+ # Constructs a custom lexer action with the specified rule and action
199
+ # indexes.
200
+ #
201
+ # @param ruleIndex The rule index to use for calls to
202
+ # {@link Recognizer#action}.
203
+ # @param actionIndex The action index to use for calls to
204
+ # {@link Recognizer#action}.
205
+ #/
206
+ def __init__(self, ruleIndex:int, actionIndex:int):
207
+ super().__init__(LexerActionType.CUSTOM)
208
+ self.ruleIndex = ruleIndex
209
+ self.actionIndex = actionIndex
210
+ self.isPositionDependent = True
211
+
212
+ # <p>Custom actions are implemented by calling {@link Lexer#action} with the
213
+ # appropriate rule and action indexes.</p>
214
+ def execute(self, lexer:Lexer):
215
+ lexer.action(None, self.ruleIndex, self.actionIndex)
216
+
217
+ def __hash__(self):
218
+ return hash((self.actionType, self.ruleIndex, self.actionIndex))
219
+
220
+ def __eq__(self, other):
221
+ if self is other:
222
+ return True
223
+ elif not isinstance(other, LexerCustomAction):
224
+ return False
225
+ else:
226
+ return self.ruleIndex == other.ruleIndex and self.actionIndex == other.actionIndex
227
+
228
+ # Implements the {@code channel} lexer action by calling
229
+ # {@link Lexer#setChannel} with the assigned channel.
230
+ class LexerChannelAction(LexerAction):
231
+ __slots__ = 'channel'
232
+
233
+ # Constructs a new {@code channel} action with the specified channel value.
234
+ # @param channel The channel value to pass to {@link Lexer#setChannel}.
235
+ def __init__(self, channel:int):
236
+ super().__init__(LexerActionType.CHANNEL)
237
+ self.channel = channel
238
+
239
+ # <p>This action is implemented by calling {@link Lexer#setChannel} with the
240
+ # value provided by {@link #getChannel}.</p>
241
+ def execute(self, lexer:Lexer):
242
+ lexer._channel = self.channel
243
+
244
+ def __hash__(self):
245
+ return hash((self.actionType, self.channel))
246
+
247
+ def __eq__(self, other):
248
+ if self is other:
249
+ return True
250
+ elif not isinstance(other, LexerChannelAction):
251
+ return False
252
+ else:
253
+ return self.channel == other.channel
254
+
255
+ def __str__(self):
256
+ return "channel(" + str(self.channel) + ")"
257
+
258
+ # This implementation of {@link LexerAction} is used for tracking input offsets
259
+ # for position-dependent actions within a {@link LexerActionExecutor}.
260
+ #
261
+ # <p>This action is not serialized as part of the ATN, and is only required for
262
+ # position-dependent lexer actions which appear at a location other than the
263
+ # end of a rule. For more information about DFA optimizations employed for
264
+ # lexer actions, see {@link LexerActionExecutor#append} and
265
+ # {@link LexerActionExecutor#fixOffsetBeforeMatch}.</p>
266
+ class LexerIndexedCustomAction(LexerAction):
267
+ __slots__ = ('offset', 'action')
268
+
269
+ # Constructs a new indexed custom action by associating a character offset
270
+ # with a {@link LexerAction}.
271
+ #
272
+ # <p>Note: This class is only required for lexer actions for which
273
+ # {@link LexerAction#isPositionDependent} returns {@code true}.</p>
274
+ #
275
+ # @param offset The offset into the input {@link CharStream}, relative to
276
+ # the token start index, at which the specified lexer action should be
277
+ # executed.
278
+ # @param action The lexer action to execute at a particular offset in the
279
+ # input {@link CharStream}.
280
+ def __init__(self, offset:int, action:LexerAction):
281
+ super().__init__(action.actionType)
282
+ self.offset = offset
283
+ self.action = action
284
+ self.isPositionDependent = True
285
+
286
+ # <p>This method calls {@link #execute} on the result of {@link #getAction}
287
+ # using the provided {@code lexer}.</p>
288
+ def execute(self, lexer:Lexer):
289
+ # assume the input stream position was properly set by the calling code
290
+ self.action.execute(lexer)
291
+
292
+ def __hash__(self):
293
+ return hash((self.actionType, self.offset, self.action))
294
+
295
+ def __eq__(self, other):
296
+ if self is other:
297
+ return True
298
+ elif not isinstance(other, LexerIndexedCustomAction):
299
+ return False
300
+ else:
301
+ return self.offset == other.offset and self.action == other.action
@@ -0,0 +1,146 @@
1
+ # type: ignore
2
+ # ruff: noqa
3
+ # flake8: noqa
4
+ #
5
+ # Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
6
+ # Use of this file is governed by the BSD 3-clause license that
7
+ # can be found in the LICENSE.txt file in the project root.
8
+ #/
9
+
10
+ # Represents an executor for a sequence of lexer actions which traversed during
11
+ # the matching operation of a lexer rule (token).
12
+ #
13
+ # <p>The executor tracks position information for position-dependent lexer actions
14
+ # efficiently, ensuring that actions appearing only at the end of the rule do
15
+ # not cause bloating of the {@link DFA} created for the lexer.</p>
16
+
17
+
18
+ from ..InputStream import InputStream
19
+ from .LexerAction import LexerAction, LexerIndexedCustomAction
20
+
21
+ # need a forward declaration
22
+ Lexer = None
23
+ LexerActionExecutor = None
24
+
25
+ class LexerActionExecutor(object):
26
+ __slots__ = ('lexerActions', 'hashCode')
27
+
28
+ def __init__(self, lexerActions:list=list()):
29
+ self.lexerActions = lexerActions
30
+ # Caches the result of {@link #hashCode} since the hash code is an element
31
+ # of the performance-critical {@link LexerATNConfig#hashCode} operation.
32
+ self.hashCode = hash("".join([str(la) for la in lexerActions]))
33
+
34
+
35
+ # Creates a {@link LexerActionExecutor} which executes the actions for
36
+ # the input {@code lexerActionExecutor} followed by a specified
37
+ # {@code lexerAction}.
38
+ #
39
+ # @param lexerActionExecutor The executor for actions already traversed by
40
+ # the lexer while matching a token within a particular
41
+ # {@link LexerATNConfig}. If this is {@code null}, the method behaves as
42
+ # though it were an empty executor.
43
+ # @param lexerAction The lexer action to execute after the actions
44
+ # specified in {@code lexerActionExecutor}.
45
+ #
46
+ # @return A {@link LexerActionExecutor} for executing the combine actions
47
+ # of {@code lexerActionExecutor} and {@code lexerAction}.
48
+ @staticmethod
49
+ def append(lexerActionExecutor:LexerActionExecutor , lexerAction:LexerAction ):
50
+ if lexerActionExecutor is None:
51
+ return LexerActionExecutor([ lexerAction ])
52
+
53
+ lexerActions = lexerActionExecutor.lexerActions + [ lexerAction ]
54
+ return LexerActionExecutor(lexerActions)
55
+
56
+ # Creates a {@link LexerActionExecutor} which encodes the current offset
57
+ # for position-dependent lexer actions.
58
+ #
59
+ # <p>Normally, when the executor encounters lexer actions where
60
+ # {@link LexerAction#isPositionDependent} returns {@code true}, it calls
61
+ # {@link IntStream#seek} on the input {@link CharStream} to set the input
62
+ # position to the <em>end</em> of the current token. This behavior provides
63
+ # for efficient DFA representation of lexer actions which appear at the end
64
+ # of a lexer rule, even when the lexer rule matches a variable number of
65
+ # characters.</p>
66
+ #
67
+ # <p>Prior to traversing a match transition in the ATN, the current offset
68
+ # from the token start index is assigned to all position-dependent lexer
69
+ # actions which have not already been assigned a fixed offset. By storing
70
+ # the offsets relative to the token start index, the DFA representation of
71
+ # lexer actions which appear in the middle of tokens remains efficient due
72
+ # to sharing among tokens of the same length, regardless of their absolute
73
+ # position in the input stream.</p>
74
+ #
75
+ # <p>If the current executor already has offsets assigned to all
76
+ # position-dependent lexer actions, the method returns {@code this}.</p>
77
+ #
78
+ # @param offset The current offset to assign to all position-dependent
79
+ # lexer actions which do not already have offsets assigned.
80
+ #
81
+ # @return A {@link LexerActionExecutor} which stores input stream offsets
82
+ # for all position-dependent lexer actions.
83
+ #/
84
+ def fixOffsetBeforeMatch(self, offset:int):
85
+ updatedLexerActions = None
86
+ for i in range(0, len(self.lexerActions)):
87
+ if self.lexerActions[i].isPositionDependent and not isinstance(self.lexerActions[i], LexerIndexedCustomAction):
88
+ if updatedLexerActions is None:
89
+ updatedLexerActions = [ la for la in self.lexerActions ]
90
+ updatedLexerActions[i] = LexerIndexedCustomAction(offset, self.lexerActions[i])
91
+
92
+ if updatedLexerActions is None:
93
+ return self
94
+ else:
95
+ return LexerActionExecutor(updatedLexerActions)
96
+
97
+
98
+ # Execute the actions encapsulated by this executor within the context of a
99
+ # particular {@link Lexer}.
100
+ #
101
+ # <p>This method calls {@link IntStream#seek} to set the position of the
102
+ # {@code input} {@link CharStream} prior to calling
103
+ # {@link LexerAction#execute} on a position-dependent action. Before the
104
+ # method returns, the input position will be restored to the same position
105
+ # it was in when the method was invoked.</p>
106
+ #
107
+ # @param lexer The lexer instance.
108
+ # @param input The input stream which is the source for the current token.
109
+ # When this method is called, the current {@link IntStream#index} for
110
+ # {@code input} should be the start of the following token, i.e. 1
111
+ # character past the end of the current token.
112
+ # @param startIndex The token start index. This value may be passed to
113
+ # {@link IntStream#seek} to set the {@code input} position to the beginning
114
+ # of the token.
115
+ #/
116
+ def execute(self, lexer:Lexer, input:InputStream, startIndex:int):
117
+ requiresSeek = False
118
+ stopIndex = input.index
119
+ try:
120
+ for lexerAction in self.lexerActions:
121
+ if isinstance(lexerAction, LexerIndexedCustomAction):
122
+ offset = lexerAction.offset
123
+ input.seek(startIndex + offset)
124
+ lexerAction = lexerAction.action
125
+ requiresSeek = (startIndex + offset) != stopIndex
126
+ elif lexerAction.isPositionDependent:
127
+ input.seek(stopIndex)
128
+ requiresSeek = False
129
+ lexerAction.execute(lexer)
130
+ finally:
131
+ if requiresSeek:
132
+ input.seek(stopIndex)
133
+
134
+ def __hash__(self):
135
+ return self.hashCode
136
+
137
+ def __eq__(self, other):
138
+ if self is other:
139
+ return True
140
+ elif not isinstance(other, LexerActionExecutor):
141
+ return False
142
+ else:
143
+ return self.hashCode == other.hashCode \
144
+ and self.lexerActions == other.lexerActions
145
+
146
+ del Lexer