From 470a6fe7f987f7c5e5c1fa7b6b31956479ababed Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 23 Jul 2018 14:40:20 -0700 Subject: Fixed blocks starting with extra newline when they start with a comment. --- core/control_flow.nom | 4 ---- core/operators.nom | 10 ++++++---- core/scopes.nom | 4 ++-- core/text.nom | 1 + 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'core') diff --git a/core/control_flow.nom b/core/control_flow.nom index b7cdba3..1c3deaa 100644 --- a/core/control_flow.nom +++ b/core/control_flow.nom @@ -62,7 +62,6 @@ compile [..] %when_false_expr as lua expr ..) ..else: - # Otherwise, need to do an anonymous inline function (yuck, too bad lua doesn't have a proper ternary operator!) To see why this is necessary consider: (random()<.5 and false or 99) @@ -200,7 +199,6 @@ compile [..] for %var in %start to %stop by %step %body for %var in %start to %stop via %step %body ..to: - # This uses Lua's approach of only allowing loop-scoped variables in a loop unless (%var.type is "Var"): compile error at %var.source "Loop expected variable, not: %s" @@ -246,7 +244,6 @@ test: # For-each loop (lua's "ipairs()") compile [for %var in %iterable %body] to: - # This uses Lua's approach of only allowing loop-scoped variables in a loop unless (%var.type is "Var"): compile error at %var.source "Loop expected variable, not: %s" @@ -284,7 +281,6 @@ test: compile [..] for %key = %value in %iterable %body, for %key %value in %iterable %body ..to: - # This uses Lua's approach of only allowing loop-scoped variables in a loop unless (%key.type is "Var"): compile error at %key.source "Loop expected variable, not: %s" diff --git a/core/operators.nom b/core/operators.nom index 191aba9..6d489ff 100644 --- a/core/operators.nom +++ b/core/operators.nom @@ -114,7 +114,7 @@ test: action [set global x local y]: external %foozle = "inner" %y = "inner" - + set global x local y assume ((%foozle == "inner") and (%y == "outer")) or barf "external failed." @@ -131,7 +131,7 @@ test: with external [%foozle]: %foozle = "inner" %y = "inner" - + set global x local y assume ((%foozle == "inner") and (%y == "outer")) or barf ".." 'with external' failed. @@ -148,7 +148,7 @@ test: %z = 999 assume (%z == 999) or barf "'with' failed." assume (%x == 999) or barf "'with' assignment failed." - + assume (%x == 1) or barf "'with' scoping failed" assume (%z == (nil)) or barf "'with' scoping failed" @@ -200,8 +200,10 @@ test: local action [one]: external %calls = (%calls + 1) return 1 + assume (0 <= (one) <= 2) or barf "Three-way chained comparison failed." - assume (%calls == 1) or barf "Three-way comparison evaluated middle value multiple times" + assume (%calls == 1) or barf ".." + Three-way comparison evaluated middle value multiple times parse [%x < %y < %z] as (..) =lua "(function(x,y,z) return x < y and y < z; end)(\%x,\%y,\%z)" diff --git a/core/scopes.nom b/core/scopes.nom index b725660..2b222f9 100644 --- a/core/scopes.nom +++ b/core/scopes.nom @@ -12,13 +12,13 @@ test: with local %x: %x = "inner" assume (%x == "inner") - + assume (%x == "outer") action [foo] "outer foo" with local [action (foo)]: action [foo] "inner foo" assume ((foo) == "inner foo") - + assume ((foo) == "outer foo") compile [with local %locals %body, with local %locals do %body] to: diff --git a/core/text.nom b/core/text.nom index 9b6fe06..a4899be 100644 --- a/core/text.nom +++ b/core/text.nom @@ -49,6 +49,7 @@ compile [capitalized %text, %text capitalized] to (..) test: assume (("asdf" with "X" instead of "s") == "aXdf") or barf ".." substitution failed + compile [..] %text with %sub instead of %patt, %text with %patt replaced by %sub %text s/ %patt / %sub -- cgit v1.2.3