aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-08-29 15:09:35 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-08-29 15:10:27 -0700
commitdcb5e8add269f39a116a20b1d0a34e28d388b421 (patch)
treec50620e69209e24b82d47291d186e40655fb8de8 /core
parent23b52bc22d9ec24702c1bed0f8ce90271eec6460 (diff)
Fully updated to 3.6, deprecated old LuaCode global functions like "to 1
write 2" and replaced them with method calls like "1::append 2"
Diffstat (limited to 'core')
-rw-r--r--core/collections.nom2
-rw-r--r--core/control_flow.nom72
-rw-r--r--core/coroutines.nom2
-rw-r--r--core/errors.nom2
-rw-r--r--core/io.nom2
-rw-r--r--core/math.nom2
-rw-r--r--core/metaprogramming.nom19
-rw-r--r--core/operators.nom6
-rw-r--r--core/scopes.nom8
-rw-r--r--core/text.nom2
10 files changed, 49 insertions, 68 deletions
diff --git a/core/collections.nom b/core/collections.nom
index 790fc56..cba20f9 100644
--- a/core/collections.nom
+++ b/core/collections.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains code that supports manipulating and using collections like lists
and dictionaries.
diff --git a/core/control_flow.nom b/core/control_flow.nom
index 5bc0811..95b9bcb 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains compile-time actions that define basic control flow structures
like "if" statements and loops.
@@ -117,10 +117,10 @@ compile [repeat while %condition %body] to:
\(%body as lua statements)
if (%body has subtree \(do next)):
- to %lua write "\n ::continue::"
+ %lua::append "\n ::continue::"
if (%body has subtree \(do next repeat)):
- to %lua write "\n ::continue_repeat::"
- to %lua write "\nend --while-loop"
+ %lua::append "\n ::continue_repeat::"
+ %lua::append "\nend --while-loop"
if (%body has subtree \(stop repeating)):
%lua = (..)
Lua ".."
@@ -145,10 +145,10 @@ compile [repeat %n times %body] to:
\(%body as lua statements)
if (%body has subtree \(do next)):
- to %lua write "\n ::continue::"
+ %lua::append "\n ::continue::"
if (%body has subtree \(do next repeat)):
- to %lua write "\n ::continue_repeat::"
- to %lua write "\nend --numeric for-loop"
+ %lua::append "\n ::continue_repeat::"
+ %lua::append "\nend --numeric for-loop"
if (%body has subtree \(stop repeating)):
%lua = (..)
Lua ".."
@@ -205,10 +205,10 @@ compile [..]
\(%body as lua statements)
if (%body has subtree \(do next)):
- to %lua write "\n ::continue::"
+ %lua::append "\n ::continue::"
if (%body has subtree \(do next %var)):
- to %lua write "\n \(compile as (===next %var ===))"
- to %lua write "\nend --numeric for-loop"
+ %lua::append "\n \(compile as (===next %var ===))"
+ %lua::append "\nend --numeric for-loop"
if (%body has subtree \(stop %var)):
%lua = (..)
Lua ".."
@@ -248,10 +248,10 @@ compile [for %var in %iterable %body] to:
\(%body as lua statements)
if (%body has subtree \(do next)):
- to %lua write "\n ::continue::"
+ %lua::append "\n ::continue::"
if (%body has subtree \(do next %var)):
- to %lua write (Lua "\n\(compile as (===next %var ===))")
- to %lua write "\nend --foreach-loop"
+ %lua::append (Lua "\n\(compile as (===next %var ===))")
+ %lua::append "\nend --foreach-loop"
if (%body has subtree \(stop %var)):
%lua = (..)
Lua ".."
@@ -289,17 +289,17 @@ compile [..]
\(%body as lua statements)
if (%body has subtree \(do next)):
- to %lua write "\n ::continue::"
+ %lua::append "\n ::continue::"
if (%body has subtree \(do next %key)):
- to %lua write (Lua "\n\(compile as (===next %key ===))")
+ %lua::append (Lua "\n\(compile as (===next %key ===))")
if (%body has subtree \(do next %value)):
- to %lua write (Lua "\n\(compile as (===next %value ===))")
- to %lua write "\nend --foreach-loop"
+ %lua::append (Lua "\n\(compile as (===next %value ===))")
+ %lua::append "\nend --foreach-loop"
%stop_labels = (Lua "")
if (%body has subtree \(stop %key)):
- to %stop_labels write "\n\(compile as (===stop %key ===))"
+ %stop_labels::append "\n\(compile as (===stop %key ===))"
if (%body has subtree \(stop %value)):
- to %stop_labels write "\n\(compile as (===stop %value ===))"
+ %stop_labels::append "\n\(compile as (===stop %value ===))"
if ((length of "\%stop_labels") > 0):
%lua = (..)
Lua ".."
@@ -347,14 +347,14 @@ compile [if %body, when %body] to:
compile error at %line.source ".."
Can't have an 'else' block without a preceeding condition
- to %code write ".."
+ %code::append ".."
else
\(%action as lua statements)
%else_allowed = (no)
..else:
- to %code write "\%clause "
+ %code::append "\%clause "
for %i in 1 to ((length of %line) - 1):
unless (%line.%i is syntax tree):
compile error at %line.source ".."
@@ -362,10 +362,10 @@ compile [if %body, when %body] to:
%s
if (%i > 1):
- to %code write " or "
- to %code write (%line.%i as lua expr)
+ %code::append " or "
+ %code::append (%line.%i as lua expr)
- to %code write ".."
+ %code::append ".."
then
\(%action as lua statements)
@@ -373,7 +373,7 @@ compile [if %body, when %body] to:
if ((length of "\%code") == 0):
compile error at %body.source "'if' block has an empty body"
- to %code write "\nend --when"
+ %code::append "\nend --when"
return %code
test:
@@ -410,14 +410,14 @@ compile [if %branch_value is %body, when %branch_value is %body] to:
compile error at %line.source ".."
Can't have an 'else' block without a preceeding condition
- to %code write ".."
+ %code::append ".."
else
\(%action as lua statements)
%else_allowed = (no)
..else:
- to %code write "\%clause "
+ %code::append "\%clause "
for %i in 1 to ((length of %line) - 1):
unless (%line.%i is syntax tree):
compile error at %line.source ".."
@@ -425,10 +425,10 @@ compile [if %branch_value is %body, when %branch_value is %body] to:
%s
if (%i > 1):
- to %code write " or "
- to %code write "branch_value == \(%line.%i as lua expr)"
+ %code::append " or "
+ %code::append "branch_value == \(%line.%i as lua expr)"
- to %code write ".."
+ %code::append ".."
then
\(%action as lua statements)
@@ -436,7 +436,7 @@ compile [if %branch_value is %body, when %branch_value is %body] to:
if ((length of "\%code") == 0):
compile error at %body.source "'if % is % %' block has an empty body"
- to %code write "\nend --when"
+ %code::append "\nend --when"
return (..)
Lua ".."
do --if % is
@@ -504,11 +504,11 @@ compile [for %var in recursive %structure %body] to (..)
\(%body as lua statements)
if (%body has subtree \(do next)):
- to %lua write "\n ::continue::"
+ %lua::append "\n ::continue::"
if (%body has subtree \(do next %var)):
- to %lua write "\n \(compile as (===next %var ===))"
- to %lua write "\n end -- Recursive loop"
+ %lua::append "\n \(compile as (===next %var ===))"
+ %lua::append "\n end -- Recursive loop"
if (%body has subtree \(stop %var)):
- to %lua write "\n \(compile as (===stop %var ===))"
- to %lua write "\nend -- Recursive scope"
+ %lua::append "\n \(compile as (===stop %var ===))"
+ %lua::append "\nend -- Recursive scope"
return %lua
diff --git a/core/coroutines.nom b/core/coroutines.nom
index ff1b978..1570ed7 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file defines the code that creates and manipulates coroutines
diff --git a/core/errors.nom b/core/errors.nom
index 4e87fa5..932bb25 100644
--- a/core/errors.nom
+++ b/core/errors.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains basic error reporting code
diff --git a/core/io.nom b/core/io.nom
index d5895da..856a660 100644
--- a/core/io.nom
+++ b/core/io.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains basic input/output code
diff --git a/core/math.nom b/core/math.nom
index 30332dc..778994f 100644
--- a/core/math.nom
+++ b/core/math.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file defines some common math literals and functions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index e141bc0..bd65a7e 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -297,25 +297,6 @@ action [%tree with %patt ~> %replacement]:
end)
end)
-compile [declare locals in %code] to (..)
- Lua value "\(%code as lua expr):declare_locals()"
-
-compile [declare locals %locals in %code] to (..)
- Lua value "\(%code as lua expr):declare_locals(\(%locals as lua expr))"
-
-compile [add free vars %vars to %code] to (..)
- Lua "\(%code as lua expr):add_free_vars(\(%vars as lua expr));"
-
-compile [remove free vars %vars from %code] to (..)
- Lua "\(%code as lua expr):remove_free_vars(\(%vars as lua expr));"
-
-compile [%lua <-write %code, to %lua write %code] to (..)
- Lua "\(%lua as lua expr):append(\(%code as lua expr));"
-
-compile [to %lua write %code joined by %glue] to (..)
- Lua ".."
- \(%lua as lua expr):concat_append(\(%code as lua expr), \(%glue as lua expr));
-
test:
assume (..)
(..)
diff --git a/core/operators.nom b/core/operators.nom
index 699663c..fbf88bb 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains definitions of operators like "+" and "and".
@@ -21,7 +21,7 @@ compile [%a isn't %b, %a is not %b, %a not= %b, %a != %b] to (..)
# For strict identity checking, use (%x's id) is (%y's id)
test:
- assume (([] == []) and (([]'s id) != ([]'s id)))
+ assume (([] == []) and (([] 's id) != ([] 's id)))
lua> ".."
do
local new_uuid = require('uuid')
@@ -238,7 +238,7 @@ compile [%x or %y] to (Lua value "(\(%x as lua expr) or \(%y as lua expr))")
# Bitwise Operators
# TODO: implement OR, XOR, AND for multiple operands?
test:
- assume ((~5) == -6)
+ assume ((~ 5) == -6)
assume ((1 | 4) == 5)
assume ((1 ~ 3) == 2)
assume ((1 & 3) == 1)
diff --git a/core/scopes.nom b/core/scopes.nom
index 101f955..392649b 100644
--- a/core/scopes.nom
+++ b/core/scopes.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains definitions pertaining to variable scoping
@@ -29,12 +29,12 @@ compile [with local %locals %body, with local %locals do %body] to:
\(compile as (<- %locals))
\%body_lua
- declare locals ("\(%.1 as lua)" for % in %locals) in %body_lua
+ %body_lua::declare locals ("\(%.1 as lua)" for % in %locals)
"List":
- declare locals ("\(% as lua)" for % in %locals) in %body_lua
+ %body_lua::declare locals ("\(% as lua)" for % in %locals)
"Var" "Action":
- declare locals ["\(%locals as lua)"] in %body_lua
+ %body_lua::declare locals ["\(%locals as lua)"]
else:
compile error at %locals.source "Unexpected locals: %s"
diff --git a/core/text.nom b/core/text.nom
index 00a3c4b..25d4066 100644
--- a/core/text.nom
+++ b/core/text.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V3.5.5.6
+#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains some definitions of text escape sequences, including ANSI console
color codes.