Skip to content

Instantly share code, notes, and snippets.

@tripplyons
Last active May 20, 2016 03:32
Show Gist options
  • Save tripplyons/5be6049973ad2f1493e346907aa917a7 to your computer and use it in GitHub Desktop.
Save tripplyons/5be6049973ad2f1493e346907aa917a7 to your computer and use it in GitHub Desktop.
thing
start = exps:(expr+) {
return exps.join('')
}
call = first:((func:function) / (identifier:id)) "(" exp:expr? ")" {
return first + "(" + exp + ")"
}
id = chars:([a-zA-Z]+) {
return chars.join('')
}
def = "#" identifier:id {
return 'var ' + identifier + ';'
}
digit =
[0-9]
int = val:([1-9] digit*/"0") {
return parseInt([val[0]].concat(val[1]).join(""));
}
function = "<" exps:(expr+) ">" {
return "(function(){"+exps+";})"
} / "<>" {
return "(function(){})"
}
arg = "$" exp:expr {
return "this.v["+exp+"]"
}
expr = int / arg / function / call / id / def
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment