Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

250 lines (222 sloc) 8.962 kB
{
"lex": {
"rules": [
["$", "return 'EOF'"],
["--.*", "/* ignore comments */"],
["<[0-9A-Fa-f][0-9A-Fa-f](\\s+[0-9A-Fa-f][0-9A-Fa-f])*>", "return 'BUFFER'"],
["(null|true|false)\\b", "return 'CONSTANT'"],
["(Integer|Boolean|Null|String|Buffer|Tuple|List|Object|Function|Coroutine|Form)\\b", "return 'TYPE'"],
["return\\b", "return 'RETURN'"],
["abort\\b", "return 'ABORT'"],
["vars\\b", "return 'VARS'"],
["for\\b", "return 'FOR'"],
["delete\\b", "return 'DELETE'"],
["in\\b", "return 'IN'"],
["is\\b", "return 'IS'"],
["escape\\b", "return 'ESCAPE'"],
["exec\\b", "return 'EXEC'"],
["split\\b", "return 'SPLIT'"],
["\\s*and\\b", "return 'AND'"],
["if\\b", "return 'IF'"],
["\\s*elif\\b", "return 'ELIF'"],
["\\s*else\\b", "return 'ELSE'"],
["while\\b", "return 'WHILE'"],
["\"(?:[^\"\\\\]|\\\\.)*\"", "return 'STRING'"],
["'(?:[^'\\\\]|\\\\.)*'", "return 'STRING'"],
["@[a-z]+", "return 'FORM'"],
["[a-zA-Z_]([-]?[a-zA-Z0-9_])*[?!]?","return 'IDENT'"],
[":+[a-zA-Z_]([-]?[a-zA-Z0-9_])*[?!]?","return 'SYMBOL'"],
["-?0[xX][0-9a-fA-F]+", "return 'HEX'"],
["[+-]?[1-9][0-9]*", "return 'INTEGER'"],
["0", "return 'ZERO'"],
[":", "return ':'"],
["\\|\\|", "return '||'"],
["\\^\\^", "return '^^'"],
["&&", "return '&&'"],
["!=", "return '!='"],
["==", "return '=='"],
["<=", "return '<='"],
["<", "return '<'"],
[">=", "return '>='"],
[">", "return '>'"],
["\\+", "return '+'"],
["-", "return '-'"],
["\\*", "return '*'"],
["\\/", "return '/'"],
["\\^", "return '^'"],
["\\%", "return '%'"],
["\\#", "return '#'"],
[",\\s*", "return ','"],
["\\s*\\.", "return '.'"],
["!", "return '!'"],
["=\\s*", "return '='"],
["\\[\\s*", "return '['"],
["\\s*\\]", "return ']'"],
["\\{\\s*", "return '{'"],
["\\|\\s*", "return '|'"],
["\\s*\\}", "return '}'"],
["\\(\\s*", "return '('"],
["\\s*\\)", "return ')'"],
["\\s*(?:\\r\\n|\\r|\\n|;)\\s*", "return 'TERM'"],
["\\s+", "/* skip whitespace */"]
]
},
"operators": [
["left", "EXEC", "ESCAPE"],
["left", ",", ";"],
["right", "="],
["left", "IS", "IN"],
["left", "||", "^^"],
["left", "&&"],
["left", "!=", "=="],
["left", "<", "<=", ">", ">="],
["left", "+", "-"],
["left", "*", "/", "^", "%"],
["right", "!", "-", "#"],
["left", ".", "[", "("]
],
"bnf": {
"root": [
["code EOF", "return $1"]
],
"term0": ["", "term1"],
"term1": ["TERM", "term1 TERM"],
"code1": [
["expr", "$$ = [$1]"],
["statement", "$$ = [$1]"],
["code1 term1 expr", "$$ = $1.concat([$3])"],
["code1 term1 statement", "$$ = $1.concat([$3])"]
],
"code": [
["term0", "$$ = []"],
["term0 code1 term0", "$$ = $2"]
],
"list1": [
["expr", "$$ = [$1]"],
["list1 term1 expr", "$$ = $1.concat([$3])"],
["list1 , expr", "$$ = $1.concat([$3])"]
],
"list": [
["", "$$ = []"],
["list1", "$$ = $1"],
["list1 ,", "$$ = $1"]
],
"params": [
["IDENT", "$$ = [$1]"],
["params , IDENT", "$$ = $1.concat([$3])"]
],
"key": [
["form :", "$$ = $1"],
["IDENT :", "$$ = $1"],
["STRING :", "$$ = eval($1)"],
["[ expr ] :", "$$ = $2"]
],
"pairs1": [
["key expr", "$$ = [$1, $2]"],
["pairs1 term1 key expr", "$$ = $1.concat([$3, $4])"],
["pairs1 , key expr", "$$ = $1.concat([$3, $4])"]
],
"pairs": [
["", "$$ = []"],
["pairs1", "$$ = $1"],
["pairs1 ,", "$$ = $1"]
],
"elifs": [
["expr block", "$$ = [$1, $2]"],
["elifs ELIF expr block", "$$ = $1.concat([$3, $4])"]
],
"func": [
["{ params | code }", "$$ = [[yy.F('params')].concat($2)].concat($4)"],
["{ | code }", "$$ = $3"]
],
"block": [
["{ code }", "$$ = $2"]
],
"expr2": [
["expr , expr", "$$ = [$1, $3]"],
["expr2 , expr", "$$ = $1.concat([$3])"]
],
"integer": [
["ZERO", "$$ = 0"],
["INTEGER", "$$ = parseInt($1, 10)"],
["HEX", "$$ = parseInt($1.substr(2), 16)"]
],
"form": [
["FORM", "$$ = yy.F($1.substr(1))"]
],
"lookup": [
[". integer", "$$ = $2"],
[". IDENT", "$$ = $2"],
[". form", "$$ = $2"],
["[ expr ]", "$$ = $2"]
],
"expr": [
["STRING", "$$ = eval($1)"],
["IDENT", "$$ = yy.S($1)"],
["SYMBOL", "$$ = yy.S($1)"],
["form", "$$ = $1"],
["integer", "$$ = $1"],
["CONSTANT", "$$ = $1 === 'true' ? true : $1 === 'false' ? false : undefined"],
["BUFFER", "$$ = new Buffer($1.substr(1, $1.length - 2).split(/\\s+/).map(function (b) { return parseInt(b, 16);}))"],
["expr IS TYPE", "$$ = [yy.F('is'), $1, $3]"],
["expr IN expr", "$$ = [yy.F('in'), $3, $1]"],
["expr * expr", "$$ = [yy.F('mul'), $1, $3]"],
["expr / expr", "$$ = [yy.F('div'), $1, $3]"],
["expr ^ expr", "$$ = [yy.F('pow'), $1, $3]"],
["expr % expr", "$$ = [yy.F('mod'), $1, $3]"],
["expr + expr", "$$ = [yy.F('add'), $1, $3]"],
["expr - expr", "$$ = [yy.F('sub'), $1, $3]"],
["expr < expr", "$$ = [yy.F('lt'), $1, $3]"],
["expr <= expr", "$$ = [yy.F('le'), $1, $3]"],
["expr > expr", "$$ = [yy.F('lt'), $3, $1]"],
["expr >= expr", "$$ = [yy.F('le'), $3, $1]"],
["expr != expr", "$$ = [yy.F('neq'), $1, $3]"],
["expr == expr", "$$ = [yy.F('eq'), $1, $3]"],
["expr && expr", "$$ = [yy.F('and'), $1, $3]"],
["expr || expr", "$$ = [yy.F('or'), $1, $3]"],
["expr ^^ expr", "$$ = [yy.F('xor'), $1, $3]"],
["! expr", "$$ = [yy.F('not'), $2]"],
["- expr", "$$ = [yy.F('unm'), $2]"],
["# expr", "$$ = [yy.F('len'), $2]"],
["func", "$$ = [yy.F('fn')].concat($1)"],
["IDENT = expr", "$$ = [yy.F('assign'), $1, $3]"],
["ESCAPE expr", "$$ = [yy.F('escape'), $2]"],
["EXEC expr", "$$ = [yy.F('exec'), $2]"],
["( expr )", "$$ = $2"],
["( expr2 )", "$$ = [yy.F('tuple')].concat($2)"],
["[ list ]", "$$ = [yy.F('list')].concat($2)"],
["{ pairs }", "$$ = [yy.F('object')].concat($2)"],
["[ expr FOR iterator ]", "$$ = [yy.F('map')].concat($4).concat([$2])"],
["expr lookup", "$$ = [yy.F('get'), $1, $2]"],
["expr lookup = expr", "$$ = [yy.F('set'), $1, $2, $4]"],
["expr ( list )", "$$ = [yy.F('call'), $1].concat($3)"],
["FOR iterator block", "$$ = [yy.F('for')].concat($2).concat($3)"],
["WHILE expr block", "$$ = [yy.F('while'), $2].concat($3)"],
["if", "$$ = $1"],
["split", "$$ = $1"],
["if ELSE { code }", "$$ = $1.concat([$4])"]
],
"iterator": [
["loopvars IN expr", "$$ = [$3, $1, undefined]"],
["loopvars IN expr IF expr", "$$ = [$3, $1, $5]"]
],
"loopvars": [
["IDENT", "$$ = [$1]"],
["IDENT , IDENT", "$$ = [$1, $3]"]
],
"split": [
["SPLIT { code }", "$$ = [yy.F('split'), $3]"],
["split AND { code }", "$$ = $1.concat([$4])"]
],
"if": [
["IF expr { code }", "$$ = [yy.F('if'), $2, $4]"],
["if ELIF expr { code }", "$$ = $1.concat([$3, $5])"]
],
"statement": [
["DELETE expr lookup", "$$ = [yy.F('delete'), $2, $3]"],
["VARS params", "$$ = [yy.F('vars')].concat($2)"],
["RETURN expr", "$$ = [yy.F('return'), $2]"],
["ABORT expr", "$$ = [yy.F('abort'), $2]"]
]
}
}
Jump to Line
Something went wrong with that request. Please try again.