openscad-parser 2.5.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openscad_parser
3
- Version: 2.5.1
3
+ Version: 2.5.2
4
4
  Summary: A PEG parser to read OpenSCAD language source code, with optional AST tree generation.
5
5
  Keywords: openscad,openscad parser,parser
6
6
  Author: Revar Desmera
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "openscad_parser"
7
- version = "2.5.1"
7
+ version = "2.5.2"
8
8
  description = "A PEG parser to read OpenSCAD language source code, with optional AST tree generation."
9
9
  readme = "README.rst"
10
10
  authors = [
@@ -986,10 +986,14 @@ class ASTBuilderVisitor(PTNodeVisitor):
986
986
  return children[0]
987
987
 
988
988
  def visit_range_expr(self, node, children):
989
+ # OpenSCAD syntax: [start:end] or [start:step:end]
989
990
  start = children[0]
990
- end = children[1]
991
- # Step is optional - if present, use it; otherwise default to 1.0
992
- step = children[2] if len(children) > 2 else NumberLiteral(val=1.0, position=self._get_node_position(node))
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))
993
997
  return RangeLiteral(start=start, end=end, step=step, position=self._get_node_position(node))
994
998
 
995
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:2] // Range from 0 to 10 with step 2
384
- [10:0:-1] // Range from 10 to 0 with step -1
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.end} : {self.step}]"
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