From 23abab4f809e8d4b825746580082292db700036b Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 29 Oct 2018 13:00:08 -0700 Subject: Some cleanups and fixes, made the parser more permissive of prematurely terminated files. --- core/control_flow.nom | 4 ++-- core/metaprogramming.nom | 2 +- core/operators.nom | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/control_flow.nom b/core/control_flow.nom index 48b9c85..37b2b9c 100644 --- a/core/control_flow.nom +++ b/core/control_flow.nom @@ -53,7 +53,7 @@ compile [..] %when_true_expr if %condition otherwise %when_false_expr %when_false_expr unless %condition else %when_true_expr %when_false_expr unless %condition then %when_true_expr -..to (..) +..to: # If %when_true_expr is guaranteed to be truthy, we can use Lua's idiomatic equivalent of a conditional expression: (cond and if_true or if_false) if {Text:yes, List:yes, Dict:yes, Number:yes}.(%when_true_expr.type): @@ -541,7 +541,7 @@ test: assume (sorted %flat) == [1, 2, 3, 4, 5, 6] # Recurion control flow -compile [for %var in recursive %structure %body] to (..) +compile [for %var in recursive %structure %body] to: with local compile actions: define mangler compile [recurse %v on %x] to (..) diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom index 6a457d9..d85c1ad 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -231,7 +231,7 @@ compile [%tree as nomsu] to (..) Lua value "nomsu:tree_to_nomsu(\(%tree as lua expr))" compile [%tree as inline nomsu] to (..) - Lua value "nomsu:tree_to_nomsu(\(%tree as lua expr), true)" + Lua value "nomsu:tree_to_inline_nomsu(\(%tree as lua expr), true)" action [%var as lua identifier, %var as lua id] (..) lua> "\ diff --git a/core/operators.nom b/core/operators.nom index 960440e..55756bb 100644 --- a/core/operators.nom +++ b/core/operators.nom @@ -157,7 +157,7 @@ compile [with %assignments %body] to: test: assume ((5 wrapped around 2) == 1) or barf "mod not working" compile [%x wrapped around %y, %x mod %y] to (..) - Lua value "(\(%x as lua expr) % \(%y as lua expr))" + Lua value "((\(%x as lua expr)) % (\(%y as lua expr)))" # 3-part chained comparisons # (uses a lambda to avoid re-evaluating middle value, while still being an expression) -- cgit v1.2.3