diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-11 15:32:54 -0800 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-11 15:32:54 -0800 |
| commit | 7251f750876fd7839e1d4c4a31e1448ec6ad2acb (patch) | |
| tree | 36f6d569b5e8c662d711d9aa39cd30813829b03d /lib/operators.nom | |
| parent | 1e0dc6e4775168c2610774ea29ed512c5451afe6 (diff) | |
Added "local %" macro as a stopgap for locals.
Diffstat (limited to 'lib/operators.nom')
| -rw-r--r-- | lib/operators.nom | 8 |
1 files changed, 8 insertions, 0 deletions
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 |
