From 7251f750876fd7839e1d4c4a31e1448ec6ad2acb Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 11 Jan 2018 15:32:54 -0800 Subject: Added "local %" macro as a stopgap for locals. --- lib/operators.nom | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/operators.nom') diff --git a/lib/operators.nom b/lib/operators.nom index 7102a65..9f93a39 100644 --- a/lib/operators.nom +++ b/lib/operators.nom @@ -47,6 +47,14 @@ compile [%str |%start|] to: "\(%str as lua):sub(\(%start as lua), \(%start as lu compile [%str |%start - %stop|] to: "\(%str as lua):sub(\(%start as lua), \(%stop as lua))" # Variable assignment operator, and += type versions +compile [local %vars] to code: + lua> ".." + local locals = \%vars.type == "List" and \%vars.value or {\%vars}; + local identifiers = {}; + for i,x in ipairs(locals) do + identifiers[i] = nomsu:tree_to_lua(x).expr; + end + return "local "..table.concat(identifiers, ", "); compile [set %var = %val] to code: lua> ".." if \%var.type == 'List' and \%val.type == 'List' then -- cgit v1.2.3