Deduplicated goto label syntax (now just use (--- (label) ---))
This commit is contained in:
parent
a89d69e843
commit
f304138530
@ -60,7 +60,7 @@ upgrade %tree to "4.10.12.7" as:
|
|||||||
go to (insert chunk)
|
go to (insert chunk)
|
||||||
%i += 1
|
%i += 1
|
||||||
return
|
return
|
||||||
=== (insert chunk) ===
|
--- (insert chunk) ---
|
||||||
[%chunk1, %chunk2] = [..]
|
[%chunk1, %chunk2] = [..]
|
||||||
SyntaxTree {type: "Block", source: %first_chunk.source}
|
SyntaxTree {type: "Block", source: %first_chunk.source}
|
||||||
SyntaxTree {type: "Block", source: %first_chunk.source}
|
SyntaxTree {type: "Block", source: %first_chunk.source}
|
||||||
|
@ -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 (..)
|
upgrade action (line number of %pos in %text) to "4.11" as (..)
|
||||||
%text::line number at %pos
|
%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:
|
# Deprecating shorthand functions:
|
||||||
upgrade action [if all of %items %body, if all of %items then %body] to "4.11" as (..)
|
upgrade action [if all of %items %body, if all of %items then %body] to "4.11" as (..)
|
||||||
if (all of %items) %body
|
if (all of %items) %body
|
||||||
|
@ -75,18 +75,18 @@ test:
|
|||||||
# GOTOs
|
# GOTOs
|
||||||
test:
|
test:
|
||||||
%i = 0
|
%i = 0
|
||||||
=== %loop ===
|
--- %loop ---
|
||||||
%i += 1
|
%i += 1
|
||||||
unless (%i == 10):
|
unless (%i == 10):
|
||||||
go to %loop
|
go to %loop
|
||||||
assume (%i == 10)
|
assume (%i == 10)
|
||||||
=== (Loop) ===
|
--- (Loop) ---
|
||||||
%i -= 1
|
%i -= 1
|
||||||
unless (%i == 0):
|
unless (%i == 0):
|
||||||
go to (Loop)
|
go to (Loop)
|
||||||
assume (%i == 0)
|
assume (%i == 0)
|
||||||
|
|
||||||
[=== %label ===, --- %label ---, *** %label ***] all compile to "\
|
(--- %label ---) compiles to "\
|
||||||
..::label_\((%label.stub if (%label.type == "Action") else %label) as lua identifier)::"
|
..::label_\((%label.stub if (%label.type == "Action") else %label) as lua identifier)::"
|
||||||
|
|
||||||
(go to %label) compiles to "\
|
(go to %label) compiles to "\
|
||||||
@ -105,10 +105,10 @@ test:
|
|||||||
..else:
|
..else:
|
||||||
return (Lua "goto continue")
|
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)::"
|
..::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)::"
|
..::continue_\((%var.stub if (%var.type == "action") else %var) as lua identifier)::"
|
||||||
|
|
||||||
# While loops
|
# While loops
|
||||||
@ -214,14 +214,14 @@ test:
|
|||||||
%lua::append "\n ::continue::"
|
%lua::append "\n ::continue::"
|
||||||
|
|
||||||
if (%body has subtree \(do next %var)):
|
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"
|
%lua::append "\nend --numeric for-loop"
|
||||||
if (%body has subtree \(stop %var)):
|
if (%body has subtree \(stop %var)):
|
||||||
%inner_lua = %lua
|
%inner_lua = %lua
|
||||||
%lua = (Lua "do -- scope for stopping for-loop\n ")
|
%lua = (Lua "do -- scope for stopping for-loop\n ")
|
||||||
%lua::append %inner_lua "\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"
|
%lua::append "\nend -- end of scope for stopping for-loop"
|
||||||
return %lua
|
return %lua
|
||||||
|
|
||||||
@ -261,14 +261,14 @@ test:
|
|||||||
%lua::append "\n ::continue::"
|
%lua::append "\n ::continue::"
|
||||||
|
|
||||||
if (%body has subtree \(do next %var)):
|
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"
|
%lua::append "\nend --foreach-loop"
|
||||||
if (%body has subtree \(stop %var)):
|
if (%body has subtree \(stop %var)):
|
||||||
%inner_lua = %lua
|
%inner_lua = %lua
|
||||||
%lua = (Lua "do -- scope for stopping for-loop\n ")
|
%lua = (Lua "do -- scope for stopping for-loop\n ")
|
||||||
%lua::append %inner_lua "\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"
|
%lua::append "\nend -- end of scope for stopping for-loop"
|
||||||
return %lua
|
return %lua
|
||||||
|
|
||||||
@ -284,14 +284,14 @@ test:
|
|||||||
%lua::append "\n ::continue::"
|
%lua::append "\n ::continue::"
|
||||||
|
|
||||||
if (%body has subtree \(do next %var)):
|
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"
|
%lua::append "\nend --foreach-loop"
|
||||||
if (%body has subtree \(stop %var)):
|
if (%body has subtree \(stop %var)):
|
||||||
%inner_lua = %lua
|
%inner_lua = %lua
|
||||||
%lua = (Lua "do -- scope for stopping for-loop\n ")
|
%lua = (Lua "do -- scope for stopping for-loop\n ")
|
||||||
%lua::append %inner_lua "\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"
|
%lua::append "\nend -- end of scope for stopping for-loop"
|
||||||
return %lua
|
return %lua
|
||||||
|
|
||||||
@ -324,18 +324,18 @@ test:
|
|||||||
%lua::append "\n ::continue::"
|
%lua::append "\n ::continue::"
|
||||||
|
|
||||||
if (%body has subtree \(do next %key)):
|
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)):
|
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"
|
%lua::append "\nend --foreach-loop"
|
||||||
%stop_labels = (Lua "")
|
%stop_labels = (Lua "")
|
||||||
if (%body has subtree \(stop %key)):
|
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)):
|
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):
|
if ((size of "\%stop_labels") > 0):
|
||||||
%inner_lua = %lua
|
%inner_lua = %lua
|
||||||
@ -537,10 +537,10 @@ test:
|
|||||||
%lua::append "\n ::continue::"
|
%lua::append "\n ::continue::"
|
||||||
|
|
||||||
if (%body has subtree \(do next %var)):
|
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"
|
%lua::append "\n end -- Recursive loop"
|
||||||
if (%body has subtree \(stop %var)):
|
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"
|
%lua::append "\nend -- Recursive scope"
|
||||||
return %lua
|
return %lua
|
||||||
|
@ -172,7 +172,7 @@ repeat:
|
|||||||
# How do I do a 'goto'?
|
# How do I do a 'goto'?
|
||||||
do:
|
do:
|
||||||
%x = 1
|
%x = 1
|
||||||
=== (my loop) ===
|
--- (my loop) ---
|
||||||
say "GOTO loop #\%x"
|
say "GOTO loop #\%x"
|
||||||
%x += 1
|
%x += 1
|
||||||
if (%x <= 3):
|
if (%x <= 3):
|
||||||
|
@ -34,7 +34,7 @@ repeat:
|
|||||||
go to (run buffer)
|
go to (run buffer)
|
||||||
%buff::add (%line::with "\t" -> " ")
|
%buff::add (%line::with "\t" -> " ")
|
||||||
say (dim (yellow ".. ")) inline
|
say (dim (yellow ".. ")) inline
|
||||||
=== (run buffer) ===
|
--- (run buffer) ---
|
||||||
if ((size of %buff) == 0): stop
|
if ((size of %buff) == 0): stop
|
||||||
%buff = (%buff::joined)
|
%buff = (%buff::joined)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user