openscad-parser 2.5.0__tar.gz → 2.5.1__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.0
3
+ Version: 2.5.1
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.0"
7
+ version = "2.5.1"
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 = [
@@ -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: (TOK_DQUOTE, _(r'([^"\\]|\\.|\\$)*', str_repr='string'), TOK_DQUOTE)
265
- # After visiting: [string_content] (TOK_DQUOTE nodes return None)
266
- # The string content is a Terminal node, extract its value
267
- value = children[-1] if children else str(node.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)
@@ -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 so ] aligns with [: pass the column of [ as indent.
378
- bracket_col = indent + len(str(node.name)) + 3
379
- rhs = _fmt_expr(node.expr, bracket_col, w)
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
- return (TOK_DQUOTE, string_contents, TOK_DQUOTE)
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():