aboutsummaryrefslogtreecommitdiff
path: root/nomsu.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-30 13:41:14 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-30 13:41:21 -0700
commit0afcb416bcdb768c029e724ba08a900e7e95ee52 (patch)
treef0a36fc06b2e55d995d67fb6da4faac2ba7a92cf /nomsu.moon
parentaeceba800b9cf489291127f5b3501e6478c6ed77 (diff)
Microoptimization
Diffstat (limited to 'nomsu.moon')
-rwxr-xr-xnomsu.moon7
1 files changed, 4 insertions, 3 deletions
diff --git a/nomsu.moon b/nomsu.moon
index 34e9c06..8475ced 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -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]