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 /nomsu.moon | |
| parent | aeceba800b9cf489291127f5b3501e6478c6ed77 (diff) | |
Microoptimization
Diffstat (limited to 'nomsu.moon')
| -rwxr-xr-x | nomsu.moon | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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] |
