syncraft 0.1.11__tar.gz → 0.1.12__tar.gz
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.
Potentially problematic release.
This version of syncraft might be problematic. Click here for more details.
- {syncraft-0.1.11 → syncraft-0.1.12}/PKG-INFO +1 -1
- {syncraft-0.1.11 → syncraft-0.1.12}/pyproject.toml +1 -1
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/generator.py +15 -2
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft.egg-info/PKG-INFO +1 -1
- {syncraft-0.1.11 → syncraft-0.1.12}/LICENSE +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/README.md +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/setup.cfg +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/__init__.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/algebra.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/ast.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/cmd.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/diagnostic.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/dsl.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/parser.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/py.typed +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft/sqlite3.py +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft.egg-info/SOURCES.txt +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft.egg-info/dependency_links.txt +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft.egg-info/requires.txt +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/syncraft.egg-info/top_level.txt +0 -0
- {syncraft-0.1.11 → syncraft-0.1.12}/tests/test_parse.py +0 -0
|
@@ -142,7 +142,8 @@ class TokenGen(TokenSpec):
|
|
|
142
142
|
class Generator(Algebra[GenResult[T], GenState[T]]):
|
|
143
143
|
def flat_map(self, f: Callable[[GenResult[T]], Algebra[B, GenState[T]]]) -> Algebra[B, GenState[T]]:
|
|
144
144
|
def flat_map_run(input: GenState[T], use_cache:bool) -> Either[Any, Tuple[B, GenState[T]]]:
|
|
145
|
-
|
|
145
|
+
lft = input.left()
|
|
146
|
+
match self.run(lft, use_cache=use_cache):
|
|
146
147
|
case Left(error):
|
|
147
148
|
return Left(error)
|
|
148
149
|
case Right((value, next_input)):
|
|
@@ -175,8 +176,20 @@ class Generator(Algebra[GenResult[T], GenState[T]]):
|
|
|
175
176
|
match self.run(input.down(index), use_cache):
|
|
176
177
|
case Right((value, next_input)):
|
|
177
178
|
ret.append(value)
|
|
179
|
+
if at_most is not None and len(ret) > at_most:
|
|
180
|
+
return Left(Error(
|
|
181
|
+
message=f"Expected at most {at_most} matches, got {len(ret)}",
|
|
182
|
+
this=self,
|
|
183
|
+
state=input.down(index)
|
|
184
|
+
))
|
|
178
185
|
case Left(_):
|
|
179
186
|
pass
|
|
187
|
+
if len(ret) < at_least:
|
|
188
|
+
return Left(Error(
|
|
189
|
+
message=f"Expected at least {at_least} matches, got {len(ret)}",
|
|
190
|
+
this=self,
|
|
191
|
+
state=input.down(index)
|
|
192
|
+
))
|
|
180
193
|
return Right((ManyResult(tuple(ret)), input))
|
|
181
194
|
return self.__class__(many_run, name=f"many({self.name})") # type: ignore
|
|
182
195
|
|
|
@@ -203,7 +216,7 @@ class Generator(Algebra[GenResult[T], GenState[T]]):
|
|
|
203
216
|
case Left(error):
|
|
204
217
|
return Left(error)
|
|
205
218
|
raise ValueError("or_else should always return a value or an error.")
|
|
206
|
-
return self.__class__(or_else_run, name=f"
|
|
219
|
+
return self.__class__(or_else_run, name=f"or_else({self.name} | {other.name})") # type: ignore
|
|
207
220
|
|
|
208
221
|
@classmethod
|
|
209
222
|
def token(cls,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|