diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-30 13:41:14 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-30 13:41:21 -0700 |
| commit | 0afcb416bcdb768c029e724ba08a900e7e95ee52 (patch) | |
| tree | f0a36fc06b2e55d995d67fb6da4faac2ba7a92cf | |
| parent | aeceba800b9cf489291127f5b3501e6478c6ed77 (diff) | |
Microoptimization
| -rw-r--r-- | nomsu.lua | 7 | ||||
| -rwxr-xr-x | nomsu.moon | 7 |
2 files changed, 8 insertions, 6 deletions
@@ -280,7 +280,7 @@ do local arg_orders = { } for _index_0 = 1, #signature do local alias = signature[_index_0] - local stub = assert(stub_pattern:match(alias)) + local stub = concat(assert(stub_pattern:match(alias)), ' ') local stub_args = assert(var_pattern:match(alias)); (is_compile_action and self.environment.COMPILE_ACTIONS or self.environment.ACTIONS)[stub] = fn do @@ -1359,9 +1359,10 @@ do varname = (NOMSU_DEFS.ident_char ^ 1 * ((-P("'") * NOMSU_DEFS.operator_char ^ 1) + NOMSU_DEFS.ident_char ^ 1) ^ 0) ^ -1 } end - stub_pattern = re.compile([=[ {~ ([ ]*->'') (('%' (%varname->'')) / %word)? (([ ]*->' ') (('%' (%varname->'')) / %word))* ([ ]*->'') ~} + stub_pattern = re.compile([=[ stub <- {| tok ([ ]* tok)* |} !. + tok <- ({'%'} %varname) / {%word} ]=], stub_defs) - var_pattern = re.compile("{| [ ]* ((('%' {%varname}) / %word) [ ]*)+ |}", stub_defs) + var_pattern = re.compile("{| ((('%' {%varname}) / %word) [ ]*)+ !. |}", stub_defs) _nomsu_chunk_counter = 0 _running_files = { } MAX_LINE = 80 @@ -288,9 +288,10 @@ class NomsuCompiler varname: (.ident_char^1 * ((-P("'") * .operator_char^1) + .ident_char^1)^0)^-1 } stub_pattern = re.compile [=[ - {~ ([ ]*->'') (('%' (%varname->'')) / %word)? (([ ]*->' ') (('%' (%varname->'')) / %word))* ([ ]*->'') ~} + stub <- {| tok ([ ]* tok)* |} !. + tok <- ({'%'} %varname) / {%word} ]=], stub_defs - var_pattern = re.compile "{| [ ]* ((('%' {%varname}) / %word) [ ]*)+ |}", stub_defs + var_pattern = re.compile "{| ((('%' {%varname}) / %word) [ ]*)+ !. |}", stub_defs define_action: (signature, fn, is_compile_action=false)=> if type(fn) != 'function' error("Not a function: #{repr fn}") @@ -304,7 +305,7 @@ class NomsuCompiler fn_arg_positions = {debug.getlocal(fn, i), i for i=1,fn_info.nparams} arg_orders = {} for alias in *signature - stub = assert(stub_pattern\match(alias)) + stub = concat(assert(stub_pattern\match(alias)), ' ') stub_args = assert(var_pattern\match(alias)) (is_compile_action and @environment.COMPILE_ACTIONS or @environment.ACTIONS)[stub] = fn arg_orders[stub] = [fn_arg_positions[Types.Var.as_lua_id {value:a}] for a in *stub_args] |
