openscad-parser 2.5.0__tar.gz → 2.5.2__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.
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/PKG-INFO +1 -1
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/pyproject.toml +1 -1
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/ast/builder.py +11 -10
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/ast/nodes.py +3 -3
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/ast/pretty_print.py +3 -3
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/grammar.py +2 -5
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/README.rst +0 -0
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/__init__.py +0 -0
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/ast/__init__.py +0 -0
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/ast/scope.py +0 -0
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/ast/serialization.py +0 -0
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/ast/source_map.py +0 -0
- {openscad_parser-2.5.0 → openscad_parser-2.5.2}/src/openscad_parser/cli.py +0 -0
|
@@ -257,14 +257,11 @@ class ASTBuilderVisitor(PTNodeVisitor):
|
|
|
257
257
|
position=self._get_node_position(node)
|
|
258
258
|
)
|
|
259
259
|
|
|
260
|
-
def visit_string_contents(self, node, children):
|
|
261
|
-
return str(children[-1]) if children else str(node.value)
|
|
262
|
-
|
|
263
260
|
def visit_string_literal(self, node, children):
|
|
264
|
-
# Grammar:
|
|
265
|
-
#
|
|
266
|
-
|
|
267
|
-
value =
|
|
261
|
+
# Grammar: single regex matching the full quoted string including quotes.
|
|
262
|
+
# Strip the surrounding double-quotes to get the raw content.
|
|
263
|
+
raw = str(node.value)
|
|
264
|
+
value = raw[1:-1] if raw.startswith('"') and raw.endswith('"') else raw
|
|
268
265
|
return StringLiteral(
|
|
269
266
|
val=value,
|
|
270
267
|
position=self._get_node_position(node)
|
|
@@ -989,10 +986,14 @@ class ASTBuilderVisitor(PTNodeVisitor):
|
|
|
989
986
|
return children[0]
|
|
990
987
|
|
|
991
988
|
def visit_range_expr(self, node, children):
|
|
989
|
+
# OpenSCAD syntax: [start:end] or [start:step:end]
|
|
992
990
|
start = children[0]
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
991
|
+
if len(children) > 2:
|
|
992
|
+
step = children[1]
|
|
993
|
+
end = children[2]
|
|
994
|
+
else:
|
|
995
|
+
end = children[1]
|
|
996
|
+
step = NumberLiteral(val=1.0, position=self._get_node_position(node))
|
|
996
997
|
return RangeLiteral(start=start, end=end, step=step, position=self._get_node_position(node))
|
|
997
998
|
|
|
998
999
|
def visit_vector_expr(self, node, children):
|
|
@@ -380,8 +380,8 @@ class RangeLiteral(Primary):
|
|
|
380
380
|
|
|
381
381
|
Examples:
|
|
382
382
|
[0:10] // Range from 0 to 10 with step 1
|
|
383
|
-
[0:10
|
|
384
|
-
[10:0
|
|
383
|
+
[0:2:10] // Range from 0 to 10 with step 2
|
|
384
|
+
[10:-1:0] // Range from 10 to 0 with step -1
|
|
385
385
|
|
|
386
386
|
Attributes:
|
|
387
387
|
start: The starting value of the range.
|
|
@@ -393,7 +393,7 @@ class RangeLiteral(Primary):
|
|
|
393
393
|
step: Expression
|
|
394
394
|
|
|
395
395
|
def __str__(self):
|
|
396
|
-
return f"[{self.start} : {self.
|
|
396
|
+
return f"[{self.start} : {self.step} : {self.end}]"
|
|
397
397
|
|
|
398
398
|
def build_scope(self, parent_scope: "Scope") -> None:
|
|
399
399
|
self.scope = parent_scope
|
|
@@ -374,9 +374,9 @@ def _fmt_node(node: ASTNode, indent: int, w: int) -> str:
|
|
|
374
374
|
rhs = _fmt_expr(node.expr, indent, w)
|
|
375
375
|
inline = f"{pad}{node.name} = {rhs};"
|
|
376
376
|
if rhs.startswith("[\n"):
|
|
377
|
-
# Re-format
|
|
378
|
-
|
|
379
|
-
rhs = _fmt_expr(node.expr,
|
|
377
|
+
# Re-format with ] one level from the assignment and content one
|
|
378
|
+
# level deeper — independent of variable name length.
|
|
379
|
+
rhs = _fmt_expr(node.expr, indent + w, w)
|
|
380
380
|
return f"{pad}{node.name} = {rhs};"
|
|
381
381
|
if len(inline.split("\n")[0]) > _MULTILINE_CHAR_LIMIT:
|
|
382
382
|
rhs2 = _fmt_expr(node.expr, indent + w, w)
|
|
@@ -622,12 +622,9 @@ def member_expr():
|
|
|
622
622
|
return (TOK_PERIOD, member_name)
|
|
623
623
|
|
|
624
624
|
|
|
625
|
-
def string_contents():
|
|
626
|
-
return _(r'([^"\\]|\\.|\\$)*', str_repr='string')
|
|
627
|
-
|
|
628
|
-
|
|
629
625
|
def string_literal():
|
|
630
|
-
|
|
626
|
+
# Single regex to avoid arpeggio's skipws stripping leading whitespace inside quotes.
|
|
627
|
+
return _(r'"(?:[^"\\]|\\.|\\$)*"', str_repr='string')
|
|
631
628
|
|
|
632
629
|
|
|
633
630
|
def primary():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|