aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-23 14:40:20 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-23 14:41:30 -0700
commit470a6fe7f987f7c5e5c1fa7b6b31956479ababed (patch)
tree8c25a3ae22740bfd14ecf460bfdc7d732023610f
parent0d7bb7eb038d7fb986bb879112d599b2c517889c (diff)
Fixed blocks starting with extra newline when they start with a comment.
-rw-r--r--core/control_flow.nom4
-rw-r--r--core/operators.nom10
-rw-r--r--core/scopes.nom4
-rw-r--r--core/text.nom1
-rw-r--r--lib/object.nom6
-rw-r--r--nomsu_compiler.lua2
-rw-r--r--nomsu_compiler.moon2
-rwxr-xr-xtools/find_action.nom3
8 files changed, 15 insertions, 17 deletions
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
diff --git a/lib/object.nom b/lib/object.nom
index e78eb14..10b0afa 100644
--- a/lib/object.nom
+++ b/lib/object.nom
@@ -13,7 +13,7 @@ test:
return (%barks joined with " ")
method [get pissed off] ((me).barks += 1)
-
+
%d = (new Dog {barks:2})
as %d:
assume ((me) == %d)
@@ -24,7 +24,7 @@ test:
assume ((me).barks == 3)
assume ((bark) == "Bark! Bark! Bark!")
assume ((me).genus == "Canus")
-
+
assume ("\(%d.class)" == "Dog")
assume (%d.genus == "Canus")
assume (%d.barks == 3)
@@ -36,7 +36,7 @@ test:
try (as (new Dog {barks:8}) (barf)) and if it succeeds (barf)
assume ((me).barks == 101) or barf ".."
Error in nested 'as % %' failed to properly reset 'self'
-
+
object "Corgi" extends (class Dog) (method [sploot] "splooted")
%corg = (new Corgi)
assume (%corg.barks == 0)
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index daf7c5f..0299156 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -1104,7 +1104,7 @@ do
elseif "Block" == _exp_0 then
local nomsu = NomsuCode(tree.source, pop_comments(tree.source.start))
for i, line in ipairs(tree) do
- nomsu:append(pop_comments(line.source.start, '\n'))
+ nomsu:append(pop_comments(line.source.start, i > 1 and '\n' or ''))
local line_nomsu = recurse(line)
nomsu:append(line_nomsu)
if i < #tree then
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 5790188..2856ff2 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -698,7 +698,7 @@ with NomsuCompiler
when "Block"
nomsu = NomsuCode(tree.source, pop_comments(tree.source.start))
for i, line in ipairs tree
- nomsu\append pop_comments(line.source.start, '\n')
+ nomsu\append pop_comments(line.source.start, i > 1 and '\n' or '')
line_nomsu = recurse(line)
nomsu\append line_nomsu
if i < #tree
diff --git a/tools/find_action.nom b/tools/find_action.nom
index ae3bf72..b51a0f8 100755
--- a/tools/find_action.nom
+++ b/tools/find_action.nom
@@ -19,5 +19,4 @@ for %path in %files:
say (yellow (source lines of %t))
if (%t is syntax tree):
- for %sub in %t:
- recurse %t on %sub
+ for %sub in %t: recurse %t on %sub