Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/sdf_toolkit/parser/sdf.lark
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ port_spec: STRING
// Real value (single or triple)
rvalue: FLOAT
| "(" [real_triple] ")"
| "(" FLOAT ")"

real_triple: [FLOAT] ":" [FLOAT] ":" [FLOAT]

Expand Down Expand Up @@ -181,3 +182,5 @@ STRING: /[a-zA-Z0-9_\/.\[\]\\$]+/
%ignore WS
COMMENT: /\/\/[^\n]*/
%ignore COMMENT
BLOCK_COMMENT: /\/\*[\s\S]*?\*\//
%ignore BLOCK_COMMENT
5 changes: 3 additions & 2 deletions src/sdf_toolkit/parser/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ def rvalue(self, *args: float | Values | Token | None) -> Values:
if isinstance(arg, Values):
return arg
if isinstance(arg, float):
return Values(min=None, avg=arg, max=None)
return Values(min=arg, avg=arg, max=arg)
if isinstance(arg, Token) and arg.type == "FLOAT":
return Values(min=None, avg=float(arg), max=None)
value = float(arg)
return Values(min=value, avg=value, max=value)
return Values()

@v_args(inline=True)
Expand Down