aboutsummaryrefslogtreecommitdiff
path: root/lib/object.nom
diff options
context:
space:
mode:
Diffstat (limited to 'lib/object.nom')
-rw-r--r--lib/object.nom14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/object.nom b/lib/object.nom
index ca664b5..0bb2538 100644
--- a/lib/object.nom
+++ b/lib/object.nom
@@ -1,6 +1,6 @@
use "core"
-compile [@%var] to:
+compile [@%var] to
lua> ".."
local key_lua = repr(\%var.value);
local key_attr = (key_lua:match("'([a-zA-Z][a-zA-Z0-9]*)'")
@@ -12,7 +12,7 @@ compile [@%var] to:
end
return {expr="_me["..key_lua.."]"};
-compile [@%var <- %val] to:
+compile [@%var <- %val] to
lua> ".."
local val_lua = \(%val as lua expr);
local key_lua = repr(\%var.value);
@@ -25,12 +25,12 @@ compile [@%var <- %val] to:
end
return {statements="_me["..key_lua.."] = "..val_lua..";"};
-compile [define object %classname %class_body] to:
+compile [define object %classname %class_body] to
%class_identifier <- (=lua "nomsu:var_to_lua_identifier(\(%classname as value)):sub(2,-1)")
if: %class_identifier is ""
%class_identifier <- "class"
%methods <- []
- for %line in (%class_body's "value"):
+ for %line in (%class_body's "value")
if: (%line's "type") is "Comment"
do next %line
assume (((%line's "type") == "FunctionCall") and ((%line's stub) == "action % %"))
@@ -86,7 +86,7 @@ compile [define object %classname %class_body] to:
return {..}
statements:".."
do -- \%class_identifier
- -- Create the class object:
+ -- Create the class object
local \%class_identifier = setmetatable({
name=\(%classname as lua expr), instances=setmetatable({}, {__mode="k"}),
}, {
@@ -104,10 +104,10 @@ compile [define object %classname %class_body] to:
});
\%class_identifier.class = \%class_identifier;
- -- Define the methods:
+ -- Define the methods
\(%methods joined with "\n")
- -- Define class methods for instantiating and accessing instances:
+ -- Define class methods for instantiating and accessing instances
\%class_identifier.instance_metatable = {
__index=\%class_identifier,
__tostring=\%class_identifier['% as text'] or function(inst)