aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-19 17:44:46 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-19 17:44:46 -0800
commitf30413853063483147d941ffccc4b663b71bc943 (patch)
tree31747b3d020a5d252e70910fdd741ecf27a58ef5
parenta89d69e843ba83df928051005d02a932a9981f46 (diff)
Deduplicated goto label syntax (now just use (--- (label) ---))
-rw-r--r--compatibility/4.10.12.7.nom2
-rw-r--r--compatibility/4.11.nom5
-rw-r--r--core/control_flow.nom34
-rw-r--r--examples/how_do_i.nom4
-rw-r--r--tools/repl.nom2
5 files changed, 26 insertions, 21 deletions
diff --git a/compatibility/4.10.12.7.nom b/compatibility/4.10.12.7.nom
index fe1511c..28c07af 100644
--- a/compatibility/4.10.12.7.nom
+++ b/compatibility/4.10.12.7.nom
@@ -60,7 +60,7 @@ upgrade %tree to "4.10.12.7" as:
go to (insert chunk)
%i += 1
return
- === (insert chunk) ===
+ --- (insert chunk) ---
[%chunk1, %chunk2] = [..]
SyntaxTree {type: "Block", source: %first_chunk.source}
SyntaxTree {type: "Block", source: %first_chunk.source}
diff --git a/compatibility/4.11.nom b/compatibility/4.11.nom
index 71bf3ee..042da1e 100644
--- a/compatibility/4.11.nom
+++ b/compatibility/4.11.nom
@@ -38,6 +38,11 @@ upgrade action (line %n in %text) to "4.11" as (%text::line %n)
upgrade action (line number of %pos in %text) to "4.11" as (..)
%text::line number at %pos
+# Deduplicating goto labels:
+upgrade action [=== %label ===, *** %label ***] to "4.11" as (--- %label ---)
+upgrade action [===stop %label ===, ***stop %label ***] to "4.11" as (---stop %label ---)
+upgrade action [===next %label ===, ***next %label ***] to "4.11" as (---next %label ---)
+
# Deprecating shorthand functions:
upgrade action [if all of %items %body, if all of %items then %body] to "4.11" as (..)
if (all of %items) %body
diff --git a/core/control_flow.nom b/core/control_flow.nom
index 27ff96d..636f586 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -75,18 +75,18 @@ test:
# GOTOs
test:
%i = 0
- === %loop ===
+ --- %loop ---
%i += 1
unless (%i == 10):
go to %loop
assume (%i == 10)
- === (Loop) ===
+ --- (Loop) ---
%i -= 1
unless (%i == 0):
go to (Loop)
assume (%i == 0)
-[=== %label ===, --- %label ---, *** %label ***] all compile to "\
+(--- %label ---) compiles to "\
..::label_\((%label.stub if (%label.type == "Action") else %label) as lua identifier)::"
(go to %label) compiles to "\
@@ -105,10 +105,10 @@ test:
..else:
return (Lua "goto continue")
-[===stop %var ===, ---stop %var ---, ***stop %var ***] all compile to "\
+(---stop %var ---) compiles to "\
..::stop_\((%var.stub if (%var.type == "action") else %var) as lua identifier)::"
-[===next %var ===, ---next %var ---, ***next %var ***] all compile to "\
+(---next %var ---) compiles to "\
..::continue_\((%var.stub if (%var.type == "action") else %var) as lua identifier)::"
# While loops
@@ -214,14 +214,14 @@ test:
%lua::append "\n ::continue::"
if (%body has subtree \(do next %var)):
- %lua::append "\n " (what (===next %var ===) compiles to)
+ %lua::append "\n " (what (---next %var ---) compiles to)
%lua::append "\nend --numeric for-loop"
if (%body has subtree \(stop %var)):
%inner_lua = %lua
%lua = (Lua "do -- scope for stopping for-loop\n ")
%lua::append %inner_lua "\n "
- %lua::append (what (===stop %var ===) compiles to)
+ %lua::append (what (---stop %var ---) compiles to)
%lua::append "\nend -- end of scope for stopping for-loop"
return %lua
@@ -261,14 +261,14 @@ test:
%lua::append "\n ::continue::"
if (%body has subtree \(do next %var)):
- %lua::append "\n " (what (===next %var ===) compiles to)
+ %lua::append "\n " (what (---next %var ---) compiles to)
%lua::append "\nend --foreach-loop"
if (%body has subtree \(stop %var)):
%inner_lua = %lua
%lua = (Lua "do -- scope for stopping for-loop\n ")
%lua::append %inner_lua "\n "
- %lua::append (what (===stop %var ===) compiles to)
+ %lua::append (what (---stop %var ---) compiles to)
%lua::append "\nend -- end of scope for stopping for-loop"
return %lua
@@ -284,14 +284,14 @@ test:
%lua::append "\n ::continue::"
if (%body has subtree \(do next %var)):
- %lua::append "\n " (what (===next %var ===) compiles to)
+ %lua::append "\n " (what (---next %var ---) compiles to)
%lua::append "\nend --foreach-loop"
if (%body has subtree \(stop %var)):
%inner_lua = %lua
%lua = (Lua "do -- scope for stopping for-loop\n ")
%lua::append %inner_lua "\n "
- %lua::append (what (===stop %var ===) compiles to)
+ %lua::append (what (---stop %var ---) compiles to)
%lua::append "\nend -- end of scope for stopping for-loop"
return %lua
@@ -324,18 +324,18 @@ test:
%lua::append "\n ::continue::"
if (%body has subtree \(do next %key)):
- %lua::append "\n " (what (===next %key ===) compiles to)
+ %lua::append "\n " (what (---next %key ---) compiles to)
if (%body has subtree \(do next %value)):
- %lua::append "\n " (what (===next %value ===) compiles to)
+ %lua::append "\n " (what (---next %value ---) compiles to)
%lua::append "\nend --foreach-loop"
%stop_labels = (Lua "")
if (%body has subtree \(stop %key)):
- %stop_labels::append "\n" (what (===stop %key ===) compiles to)
+ %stop_labels::append "\n" (what (---stop %key ---) compiles to)
if (%body has subtree \(stop %value)):
- %stop_labels::append "\n" (what (===stop %value ===) compiles to)
+ %stop_labels::append "\n" (what (---stop %value ---) compiles to)
if ((size of "\%stop_labels") > 0):
%inner_lua = %lua
@@ -537,10 +537,10 @@ test:
%lua::append "\n ::continue::"
if (%body has subtree \(do next %var)):
- %lua::append "\n \(what (===next %var ===) compiles to)"
+ %lua::append "\n \(what (---next %var ---) compiles to)"
%lua::append "\n end -- Recursive loop"
if (%body has subtree \(stop %var)):
- %lua::append "\n \(what (===stop %var ===) compiles to)"
+ %lua::append "\n \(what (---stop %var ---) compiles to)"
%lua::append "\nend -- Recursive scope"
return %lua
diff --git a/examples/how_do_i.nom b/examples/how_do_i.nom
index 39e9bdb..bd868be 100644
--- a/examples/how_do_i.nom
+++ b/examples/how_do_i.nom
@@ -65,7 +65,7 @@ say "\
Similarly, you can put a long interpolated indented value like: \(..)
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
.. between a backslash and two periods."
-
+
say "Single-line text can contain escape sequences like \", \\, \000, and \n"
# How do I define a list?
@@ -172,7 +172,7 @@ repeat:
# How do I do a 'goto'?
do:
%x = 1
- === (my loop) ===
+ --- (my loop) ---
say "GOTO loop #\%x"
%x += 1
if (%x <= 3):
diff --git a/tools/repl.nom b/tools/repl.nom
index 39d6360..ac61242 100644
--- a/tools/repl.nom
+++ b/tools/repl.nom
@@ -34,7 +34,7 @@ repeat:
go to (run buffer)
%buff::add (%line::with "\t" -> " ")
say (dim (yellow ".. ")) inline
- === (run buffer) ===
+ --- (run buffer) ---
if ((size of %buff) == 0): stop
%buff = (%buff::joined)