diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-29 11:13:58 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-29 11:14:07 -0700 |
| commit | e17822d1e548f96952efb95c64c69704fdfeaf76 (patch) | |
| tree | 209d604ac323c36453730bc354e2c7d8e467e121 /nomsu.moon | |
| parent | b6be516e3fbc082b1dbd9740b95185976f4b0040 (diff) | |
Cleaned up some asserts for performance.
Diffstat (limited to 'nomsu.moon')
| -rwxr-xr-x | nomsu.moon | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -15,7 +15,8 @@ _pairs, _ipairs = pairs, ipairs if jit package.cpath = "./luajit_lpeg/?.so;"..package.cpath --package.path = "./LPegLJ/src/?.lua;"..package.path - lpeg = require "lpeglj" + --lpeg = require "lpeglj" + lpeg = require 'lpeg' export bit32 bit32 = require('bit') @@ -302,7 +303,8 @@ class NomsuCompiler ]=], stub_defs var_pattern = re.compile "{| %space ((('%' {%varname}) / %word) %space)+ |}", stub_defs define_action: (signature, fn, is_compile_action=false)=> - assert(type(fn) == 'function', "Bad fn: #{repr fn}") + if type(fn) != 'function' + error("Not a function: #{repr fn}") if type(signature) == 'string' signature = {signature} elseif type(signature) != 'table' @@ -350,7 +352,8 @@ class NomsuCompiler run: (nomsu_code, compile_fn=nil)=> if #tostring(nomsu_code) == 0 then return nil tree = @parse(nomsu_code) - assert tree, "Failed to parse: #{nomsu_code}" + unless tree + error "Failed to parse: #{nomsu_code}" lua = @tree_to_lua(tree)\as_statements! lua\declare_locals! lua\prepend "-- File: #{nomsu_code.source or ""}\n" |
