diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/control_flow.nom | 24 | ||||
| -rw-r--r-- | core/math.nom | 8 | ||||
| -rw-r--r-- | core/metaprogramming.nom | 24 | ||||
| -rw-r--r-- | core/operators.nom | 10 |
4 files changed, 33 insertions, 33 deletions
diff --git a/core/control_flow.nom b/core/control_flow.nom index 77e55c6..f5c61e3 100644 --- a/core/control_flow.nom +++ b/core/control_flow.nom @@ -188,14 +188,14 @@ immediately %body has subtree % where (%.type = "Action") and (%.stub is "do next %") and - %.value.3.value = %var.value + %.3.value = %var.value ..: to %lua write (Lua "\n ::continue_\(%var as lua identifier)::") to %lua write "\nend --foreach-loop" if %body has subtree % where (%.type = "Action") and (%.stub is "stop %") and - %.value.2.value = %var.value + %.2.value = %var.value .. %lua <- Lua ".." @@ -222,14 +222,14 @@ immediately %body has subtree % where (%.type = "Action") and (%.stub is "do next %") and - %.value.3.value = %key.value + %.3.value = %key.value ..: to %lua write (Lua "\n ::continue_\(%key as lua identifier)::") if %body has subtree % where (%.type = "Action") and (%.stub is "do next %") and - %.value.3.value = %value.value + %.3.value = %value.value ..: to %lua write (Lua "\n ::continue_\(%value as lua identifier)::") to %lua write "\nend --foreach-loop" @@ -238,14 +238,14 @@ immediately %body has subtree % where (%.type = "Action") and (%.stub is "stop %") and - %.value.2.value = %key.value + %.2.value = %key.value ..: to %stop_labels write "\n::stop_\(%key as lua identifier)::" if %body has subtree % where (%.type = "Action") and (%.stub is "stop %") and - %.value.2.value = %value.value + %.2.value = %value.value ..: to %stop_labels write "\n::stop_\(%value as lua identifier)::" if: (length of %stop_labels) > 0 @@ -265,14 +265,14 @@ immediately %is_first <- (yes) %seen_else <- (no) %branches <- - %body.value if (%body.type = "Block") else [%body] + %body if (%body.type = "Block") else [%body] for %func_call in %branches assume (%func_call.type is "Action") or barf ".." Invalid format for 'when' statement. Only '*' blocks are allowed. with {..} - %star: %func_call.value.1 - %condition: %func_call.value.2 - %action: %func_call.value.3 + %star: %func_call.1 + %condition: %func_call.2 + %action: %func_call.3 .. assume (%star = "*") or barf ".." Invalid format for 'when' statement. Lines must begin with '*' @@ -313,11 +313,11 @@ immediately %is_first <- (yes) %seen_else <- (no) %branches <- - %body.value if (%body.type = "Block") else [%body] + %body if (%body.type = "Block") else [%body] for %func_call in %branches assume (%func_call.type is "Action") or barf ".." Invalid format for 'when' statement. Only '*' blocks are allowed. - with {%star:%func_call.value.1, %condition:%func_call.value.2, %action:%func_call.value.3} + with {%star:%func_call.1, %condition:%func_call.2, %action:%func_call.3} assume (%star = "*") or barf ".." Invalid format for 'when' statement. Lines must begin with '*' assume %condition or barf ".." diff --git a/core/math.nom b/core/math.nom index 677230b..2f16b11 100644 --- a/core/math.nom +++ b/core/math.nom @@ -42,7 +42,7 @@ compile [all of %items, all %items] to unless: (%items' "type") is "List" return: Lua value "utils.all(\(%items as lua expr))" %clauses <- [] - for % in %items.value + for % in %items lua> "table.insert(\%clauses, \(% as lua expr));" return: Lua value "(\(%clauses joined with " and "))" parse [not all of %items, not all %items] as: not (all of %items) @@ -50,7 +50,7 @@ compile [any of %items, any %items] to unless: (%items' "type") is "List" return: Lua value "utils.any(\(%items as lua expr))" %clauses <- [] - for % in %items.value + for % in %items lua> "table.insert(\%clauses, \(% as lua expr));" return: Lua value "(\(%clauses joined with " or "))" parse [none of %items, none %items] as: not (any of %items) @@ -58,14 +58,14 @@ compile [sum of %items, sum %items] to unless: (%items' "type") is "List" return: Lua value "utils.sum(\(%items as lua expr))" %clauses <- [] - for % in %items.value + for % in %items lua> "table.insert(\%clauses, \(% as lua expr));" return: Lua value "(\(%clauses joined with " + "))" compile [product of %items, product %items] to unless: (%items' "type") is "List" return: Lua value "utils.product(\(%items as lua expr))" %clauses <- [] - for % in %items.value + for % in %items lua> "table.insert(\%clauses, \(% as lua expr));" return: Lua value "(\(%clauses joined with " * "))" action [avg of %items, average of %items] diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom index c343ae9..66af1e6 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -8,7 +8,7 @@ immediately nomsu:define_compile_action("compile %actions to %lua", function(tree, \%actions, \%lua) local lua = Lua(tree.source, "nomsu:define_compile_action(") local specs = {} - for i, action in ipairs(\%actions.value) do + for i, action in ipairs(\%actions) do specs[i] = action:get_spec() end specs = repr(specs) @@ -19,7 +19,7 @@ immediately end lua:append("function(tree") local args = {} - for i,tok in ipairs(\%actions.value[1].value) do + for i,tok in ipairs(\%actions[1]) do if tok.type == "Var" then args[#args+1] = tok end end for i, arg in ipairs(args) do @@ -38,7 +38,7 @@ immediately lua> ".." local lua = Lua(tree.source, "nomsu:define_action(") local specs = {} - for i, action in ipairs(\%actions.value) do + for i, action in ipairs(\%actions) do specs[i] = action:get_spec() end specs = repr(specs) @@ -49,7 +49,7 @@ immediately end lua:append("function(") local args = {} - for i,tok in ipairs(\%actions.value[1].value) do + for i,tok in ipairs(\%actions[1]) do if tok.type == "Var" then args[#args+1] = tok end end for i, arg in ipairs(args) do @@ -68,7 +68,7 @@ immediately lua> ".." local lua = Lua(tree.source, "nomsu:define_compile_action(") local specs = {} - for i, action in ipairs(\%shorthand.value) do + for i, action in ipairs(\%shorthand) do specs[i] = action:get_spec() end specs = repr(specs) @@ -79,7 +79,7 @@ immediately end lua:append("function(tree") local replacements = {} - for i,tok in ipairs(\%shorthand.value[1].value) do + for i,tok in ipairs(\%shorthand[1]) do if tok.type == "Var" then local lua_var = tostring(nomsu:tree_to_lua(tok)) replacements[tok.value] = lua_var @@ -93,15 +93,15 @@ immediately elseif t.type == 'Var' and replacements[t.value] then return replacements[t.value] elseif t.type == 'Var' then - return t.type.."("..repr(t.value.."#"..tostring(MANGLE_INDEX))..", "..repr(tostring(t.source))..")" + return t.type.."("..repr(tostring(t.source))..", "..repr(t.value.."#"..tostring(MANGLE_INDEX))..")" elseif t.is_multi then - local bits = {} - for i, entry in ipairs(t.value) do - bits[i] = make_tree(entry) + local bits = {repr(tostring(t.source))} + for i, entry in ipairs(t) do + bits[#bits+1] = make_tree(entry) end - return t.type.."(Tuple("..table.concat(bits, ", ").."), "..repr(tostring(t.source))..")" + return t.type.."("..table.concat(bits, ", ")..")" else - return t.type.."("..repr(t.value)..", "..repr(tostring(t.source))..")" + return t.type.."("..repr(tostring(t.source))..", "..repr(t.value)..")" end end lua:append(")\n local tree = ", make_tree(\%longhand), "\n return nomsu:tree_to_lua(tree)\nend);") diff --git a/core/operators.nom b/core/operators.nom index 9b6b68a..5222a69 100644 --- a/core/operators.nom +++ b/core/operators.nom @@ -72,8 +72,8 @@ immediately Expected a Dict for the assignments part of '<- %' statement, not \%assignments lua> ".." local lhs, rhs = Lua(tree.source), Lua(tree.source) - for i, item in ipairs(\%assignments.value) do - local \%target, \%value = item.value[1], item.value[2] + for i, item in ipairs(\%assignments) do + local \%target, \%value = item[1], item[2] \%value = \%value:map(function(t) if Action:is_instance(t) and t.stub == "?" then return \%target @@ -105,7 +105,7 @@ immediately compile [with external %externs %body] to %body_lua <- (%body as lua statements) - lua> "\%body_lua:remove_free_vars(\%externs.value);" + lua> "\%body_lua:remove_free_vars(\%externs);" return %body_lua compile [with %assignments %body] to @@ -113,8 +113,8 @@ immediately lua> ".." local lhs, rhs = Lua(tree.source), Lua(tree.source) local vars = {} - for i, item in ipairs(\%assignments.value) do - local \%target, \%value = item.value[1], item.value[2] + for i, item in ipairs(\%assignments) do + local \%target, \%value = item[1], item[2] if not \%target.type == "Var" then error("Invalid target for 'with' assignment: "..tostring(\%target)) end |
