Comparing version 0.0.2 to 1.1.1
/** | ||
* @preserve Crox v1.1 | ||
* @preserve Crox v1.1.0 | ||
* https://github.com/thx/crox | ||
* | ||
* Released under the MIT license | ||
* Date: Fri, 6 Dec 2013 07:44:26 UTC | ||
* Date: Tue, 21 Jan 2014 09:13:34 UTC | ||
*/ | ||
var Crox = (function() { | ||
(function(root) {var Crox = (function() { | ||
function Class(base, constructor, methods) { | ||
@@ -113,2 +113,18 @@ /// <param name="base" type="Function"></param> | ||
} | ||
function singleQuote(s) { | ||
/// <param name="s" type="String"></param> | ||
/// <returns type="String" /> | ||
return "'" + (s).replace(/[\x00-\x1f'\\\u2028\u2029]/g, function(a) { | ||
switch (a) { | ||
case "'": return "\\'"; | ||
case '\\': return '\\\\'; | ||
case '\b': return '\\b'; | ||
case '\f': return '\\f'; | ||
case '\n': return '\\n'; | ||
case '\r': return '\\r'; | ||
case '\t': return '\\t'; | ||
} | ||
return '\\u' + ('000' + a.charCodeAt(0).toString(16)).slice(-4); | ||
}) + "'"; | ||
} | ||
function phpQuote(s) { | ||
@@ -120,2 +136,33 @@ /// <param name="s" type="String"></param> | ||
function formatPath(s) { | ||
/// <param name="s" type="String"></param> | ||
/// <returns type="String" /> | ||
s = s.replace(/\\/g, '/'); | ||
s = s.replace(/\/\/+/g, '/'); | ||
if (s.indexOf('/') == -1) | ||
return s; | ||
else { | ||
var a = s.split('/'); | ||
var b = []; | ||
for (var i = 0; i < a.length; ++i) { | ||
if (a[i].indexOf('..') != -1) { | ||
b.pop(); | ||
} | ||
else if (a[i] != '.') { | ||
b.push(a[i]); | ||
} | ||
} | ||
return b.join('/'); | ||
} | ||
} | ||
function buildPath(currentPath, path) { | ||
/// <param name="currentPath" type="String"></param> | ||
/// <param name="path" type="String"></param> | ||
/// <returns type="String" /> | ||
if (path.charAt(0) != '/' && path.charAt(0) != '\\') { | ||
path = currentPath.replace(/[^/\\]+$/, '') + path; | ||
} | ||
return formatPath(path); | ||
} | ||
/// <reference path="common.js"/> | ||
@@ -229,3 +276,3 @@ function createLexer(g) { | ||
var code = [ | ||
[/\s+/, function() { return 'ws'; }], | ||
[/\s+/, function() { return null; }], | ||
[re_id, function(a) { | ||
@@ -237,3 +284,3 @@ switch (a) { | ||
case 'set': | ||
//case 'include': | ||
case 'include': | ||
//case 'this': | ||
@@ -306,119 +353,69 @@ return a; | ||
/* state num: 88 */ | ||
var parse = function() { | ||
function $f0($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['each', $2, $6, $4 && eval($4.text), eval($3.text)]; | ||
return $$; | ||
} | ||
function $f1($1) { | ||
var $$; $$ = ['lit', eval($1.text)]; return $$; | ||
} | ||
function $f2($1, $2, $3) { | ||
var $$; $$ = [$2.text, $1, $3]; return $$; | ||
} | ||
var nBegin = 36; | ||
var tSymbols = ["$", "!", "%", "&&", "(", ")", "*", "+", "-", ".", "/", "<", "<=", "=", ">", ">=", "[", "]", "boolean", "eq", "ne", "number", "realId", "set", "string", "text", "{{", "{{#each", "{{#if", "{{/each}}", "{{/if}}", "{{else}}", "{{{", "||", "}}", "}}}", "AdditiveExpression", "EqualityExpression", "LogicalAndExpression", "LogicalOrExpression", "MemberExpression", "MultiplicativeExpression", "PrimaryExpression", "RelationalExpression", "UnaryExpression", "epsilon", "expr", "id", "program", "statement", "statements"]; | ||
var tSymbolIndex = {}; | ||
for (var i = 0; i < tSymbols.length; ++i) | ||
tSymbolIndex[tSymbols[i]] = i; | ||
var tAction = [{ _: -2 }, { _: -32768 }, { 25: 3, 26: 4, 27: 5, 28: 6, 32: 7, _: -1 }, { _: -11 }, { 1: 9, 4: 10, 8: 11, 18: 12, 21: 13, 22: 14, 23: 15, 24: 16, _: 0 }, { 1: 9, 4: 10, 8: 11, 18: 12, 21: 13, 22: 14, 23: 28, 24: 16, _: 0 }, { _: -3 }, { _: -16 }, { _: -15 }, { _: -12 }, { 22: 14, 23: 28, _: -13 }, { _: -14 }, { 7: 36, 8: 37, _: -32 }, { 19: 38, 20: 39, _: -40 }, { 3: 40, _: -42 }, { 33: 41, _: -44 }, { 9: 42, 16: 43, _: -22 }, { 2: 44, 6: 45, 10: 46, _: -29 }, { _: -19 }, { 11: 47, 12: 48, 14: 49, 15: 50, _: -37 }, { _: -25 }, { 34: 51, _: 0 }, { _: -17 }, { _: -13 }, { 24: 52, _: 0 }, { 34: 53, _: 0 }, { 35: 54, _: 0 }, { _: -23 }, { 5: 55, _: 0 }, { _: -24 }, { 13: 56, _: 0 }, { 22: 14, 23: 28, _: 0 }, { _: -9 }, { 24: 72, _: -45 }, { _: -10 }, { _: -18 }, { 2: 44, 6: 45, 10: 46, _: -30 }, { 2: 44, 6: 45, 10: 46, _: -31 }, { 11: 47, 12: 48, 14: 49, 15: 50, _: -38 }, { 11: 47, 12: 48, 14: 49, 15: 50, _: -39 }, { 19: 38, 20: 39, _: -41 }, { 3: 40, _: -43 }, { _: -20 }, { 17: 76, _: 0 }, { _: -28 }, { _: -26 }, { _: -27 }, { 7: 36, 8: 37, _: -33 }, { 7: 36, 8: 37, _: -35 }, { 7: 36, 8: 37, _: -34 }, { 7: 36, 8: 37, _: -36 }, { 34: 77, _: 0 }, { 34: 78, _: 0 }, { 25: 3, 26: 4, 27: 5, 28: 6, 30: 79, 31: 80, 32: 7, _: 0 }, { 34: 81, _: 0 }, { _: -21 }, { _: -4 }, { _: -8 }, { 25: 3, 26: 4, 27: 5, 28: 6, 29: 85, 32: 7, _: 0 }, { 25: 3, 26: 4, 27: 5, 28: 6, 29: 86, 32: 7, _: 0 }, { 25: 3, 26: 4, 27: 5, 28: 6, 30: 87, 32: 7, _: 0 }, { _: -7 }, { _: -6 }, { _: -5 }]; | ||
var actionIndex = [0, 1, 2, 3, 4, 5, 5, 5, 6, 5, 5, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 5, 5, 5, 5, 5, 5, 31, 5, 5, 5, 5, 5, 5, 5, 5, 32, 33, 0, 34, 35, 5, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 0, 56, 0, 57, 58, 59, 60, 61, 62, 63]; | ||
var tGoto = [{ 12: 1, 14: 2 }, , { 13: 8 }, , { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 26, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 29, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 30, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 31, 11: 27 }, , { 4: 21, 6: 23, 8: 32, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 33, 11: 27 }, { 4: 21, 6: 23, 8: 34, 11: 27 }, , , , { 11: 35 }, , , , , , , , , , , , , , , , , , , , , { 4: 21, 5: 57, 6: 23, 8: 25, 11: 27 }, { 4: 21, 5: 58, 6: 23, 8: 25, 11: 27 }, { 0: 17, 4: 21, 5: 22, 6: 23, 7: 59, 8: 25, 11: 27 }, { 0: 17, 4: 21, 5: 22, 6: 23, 7: 60, 8: 25, 11: 27 }, { 0: 17, 1: 61, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 11: 27 }, { 0: 17, 1: 18, 2: 62, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 11: 27 }, { 11: 63 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 64, 11: 27 }, { 4: 21, 6: 23, 8: 65, 11: 27 }, { 4: 21, 6: 23, 8: 66, 11: 27 }, { 4: 21, 6: 23, 8: 67, 11: 27 }, { 0: 68, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, { 0: 69, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, { 0: 70, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, { 0: 71, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, , { 9: 73 }, { 14: 74 }, , , { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 75, 11: 27 }, , , , , , , , , , , , , , , , , , { 13: 8 }, , , { 14: 82 }, { 14: 83 }, , { 14: 84 }, , { 13: 8 }, { 13: 8 }, { 13: 8 }]; | ||
var tRules = [[51, 48], [48, 50], [50], [50, 50, 49], [49, 28, 46, 34, 50, 30], [49, 28, 46, 34, 50, 31, 50, 30], [49, 27, 46, 24, 45, 34, 50, 29], [49, 27, 46, 24, 24, 34, 50, 29], [49, 26, 23, 47, 13, 46, 34], [49, 26, 46, 34], [49, 32, 46, 35], [49, 25], [47, 22], [47, 23], [42, 24], [42, 21], [42, 18], [42, 47], [42, 4, 46, 5], [40, 42], [40, 40, 9, 47], [40, 40, 16, 46, 17], [44, 40], [44, 1, 44], [44, 8, 44], [41, 44], [41, 41, 6, 44], [41, 41, 10, 44], [41, 41, 2, 44], [36, 41], [36, 36, 7, 41], [36, 36, 8, 41], [43, 36], [43, 43, 11, 36], [43, 43, 14, 36], [43, 43, 12, 36], [43, 43, 15, 36], [37, 43], [37, 37, 19, 43], [37, 37, 20, 43], [38, 37], [38, 38, 3, 37], [39, 38], [39, 39, 33, 38], [46, 39], [45]]; | ||
var tFuncs = [, function($1) { | ||
var $$; $$ = ['prog', $1]; return $$; | ||
}, function() { | ||
var $$; $$ = []; return $$; | ||
}, function($1, $2) { | ||
var $$; $1.push($2); $$ = $1; return $$; | ||
}, function($1, $2, $3, $4, $5) { | ||
var $$; $$ = ['if', $2, $4]; return $$; | ||
}, function($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['if', $2, $4, $6]; return $$; | ||
}, $f0, $f0, function($1, $2, $3, $4, $5, $6) { | ||
var $$; $$ = ['set', $3.text, $5]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, true]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, false]; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['text', $1.text]; return $$; | ||
}, , , $f1, $f1, function($1) { | ||
var $$; $$ = ['lit', $1.text == 'true']; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['id', $1.text]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = $2; return $$; | ||
}, , function($1, $2, $3) { | ||
var $$; $$ = ['.', $1, $3.text]; return $$; | ||
}, function($1, $2, $3, $4) { | ||
var $$; $$ = ['[]', $1, $3]; return $$; | ||
}, , function($1, $2) { | ||
var $$; $$ = ['!', $2]; return $$; | ||
}, function($1, $2) { | ||
var $$; $$ = ['u-', $2]; return $$; | ||
}, , $f2, $f2, $f2, , $f2, $f2, , $f2, $f2, $f2, $f2, , function($1, $2, $3) { | ||
var $$; $$ = ['eq', $1, $3]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['ne', $1, $3]; return $$; | ||
}, , $f2, , $f2]; | ||
function getAction(x, y) { | ||
var list = tAction[actionIndex[x]]; | ||
return list[y] || list._; | ||
} | ||
return function(lexer, others) { | ||
function getToken() { | ||
var t = lexer.scan(); | ||
if (t.tag == 'ws') t = lexer.scan(); | ||
return t; | ||
} | ||
var s = 0; | ||
var stateStack = [0]; | ||
var a = getToken(); | ||
var valueStack = []; | ||
var obj = { | ||
get: function(i) { | ||
return valueStack[valueStack.length + i]; | ||
}, | ||
set: function(i, v) { | ||
valueStack[valueStack.length + i] = v; | ||
var table = {/* state num: 92 */ | ||
nStart: 37, | ||
tSymbols: ["$", "!", "%", "&&", "(", ")", "*", "+", "-", ".", "/", "<", "<=", "=", ">", ">=", "[", "]", "boolean", "eq", "include", "ne", "number", "realId", "set", "string", "text", "{{", "{{#each", "{{#if", "{{/each}}", "{{/if}}", "{{else}}", "{{{", "||", "}}", "}}}", "AdditiveExpression", "EqualityExpression", "LogicalAndExpression", "LogicalOrExpression", "MemberExpression", "MultiplicativeExpression", "PrimaryExpression", "RelationalExpression", "UnaryExpression", "epsilon", "expr", "id", "program", "statement", "statements"], | ||
tSymbolIndex: { "$": 0, "!": 1, "%": 2, "&&": 3, "(": 4, ")": 5, "*": 6, "+": 7, "-": 8, ".": 9, "/": 10, "<": 11, "<=": 12, "=": 13, ">": 14, ">=": 15, "[": 16, "]": 17, "boolean": 18, "eq": 19, "include": 20, "ne": 21, "number": 22, "realId": 23, "set": 24, "string": 25, "text": 26, "{{": 27, "{{#each": 28, "{{#if": 29, "{{/each}}": 30, "{{/if}}": 31, "{{else}}": 32, "{{{": 33, "||": 34, "}}": 35, "}}}": 36, "AdditiveExpression": 37, "EqualityExpression": 38, "LogicalAndExpression": 39, "LogicalOrExpression": 40, "MemberExpression": 41, "MultiplicativeExpression": 42, "PrimaryExpression": 43, "RelationalExpression": 44, "UnaryExpression": 45, "epsilon": 46, "expr": 47, "id": 48, "program": 49, "statement": 50, "statements": 51 }, | ||
tAction: [{ _: -2 }, { _: -32768 }, { 26: 3, 27: 4, 28: 5, 29: 6, 33: 7, _: -1 }, { _: -11 }, { 1: 9, 4: 10, 8: 11, 18: 12, 20: 13, 22: 14, 23: 15, 24: 16, 25: 17, _: 0 }, { 1: 9, 4: 10, 8: 11, 18: 12, 20: 29, 22: 14, 23: 15, 24: 30, 25: 17, _: 0 }, { _: -3 }, { _: -18 }, { 25: 37, _: -15 }, { _: -17 }, { _: -13 }, { 20: 29, 23: 15, 24: 30, _: -14 }, { _: -16 }, { 7: 39, 8: 40, _: -34 }, { 19: 41, 21: 42, _: -42 }, { 3: 43, _: -44 }, { 34: 44, _: -46 }, { 9: 45, 16: 46, _: -24 }, { 2: 47, 6: 48, 10: 49, _: -31 }, { _: -21 }, { 11: 50, 12: 51, 14: 52, 15: 53, _: -39 }, { _: -27 }, { 35: 54, _: 0 }, { _: -19 }, { _: -15 }, { _: -14 }, { 25: 55, _: 0 }, { 35: 56, _: 0 }, { 36: 57, _: 0 }, { _: -25 }, { 5: 58, _: 0 }, { _: -26 }, { 35: 59, _: 0 }, { 13: 60, _: 0 }, { 20: 29, 23: 15, 24: 30, _: 0 }, { _: -9 }, { 25: 76, _: -47 }, { _: -10 }, { _: -20 }, { _: -12 }, { 2: 47, 6: 48, 10: 49, _: -32 }, { 2: 47, 6: 48, 10: 49, _: -33 }, { 11: 50, 12: 51, 14: 52, 15: 53, _: -40 }, { 11: 50, 12: 51, 14: 52, 15: 53, _: -41 }, { 19: 41, 21: 42, _: -43 }, { 3: 43, _: -45 }, { _: -22 }, { 17: 80, _: 0 }, { _: -30 }, { _: -28 }, { _: -29 }, { 7: 39, 8: 40, _: -35 }, { 7: 39, 8: 40, _: -37 }, { 7: 39, 8: 40, _: -36 }, { 7: 39, 8: 40, _: -38 }, { 35: 81, _: 0 }, { 35: 82, _: 0 }, { 26: 3, 27: 4, 28: 5, 29: 6, 31: 83, 32: 84, 33: 7, _: 0 }, { 35: 85, _: 0 }, { _: -23 }, { _: -4 }, { _: -8 }, { 26: 3, 27: 4, 28: 5, 29: 6, 30: 89, 33: 7, _: 0 }, { 26: 3, 27: 4, 28: 5, 29: 6, 30: 90, 33: 7, _: 0 }, { 26: 3, 27: 4, 28: 5, 29: 6, 31: 91, 33: 7, _: 0 }, { _: -7 }, { _: -6 }, { _: -5 }], | ||
actionIndex: [0, 1, 2, 3, 4, 5, 5, 5, 6, 5, 5, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 5, 5, 5, 5, 5, 5, 34, 5, 5, 5, 5, 5, 5, 5, 5, 35, 36, 0, 37, 38, 39, 5, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 60, 0, 61, 62, 63, 64, 65, 66, 67], | ||
tGoto: [{ 12: 1, 14: 2 }, , { 13: 8 }, , { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 27, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 31, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 32, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 33, 11: 28 }, , { 4: 22, 6: 24, 8: 34, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 35, 11: 28 }, { 4: 22, 6: 24, 8: 36, 11: 28 }, , , , , { 11: 38 }, , , , , , , , , , , , , , , , , , , , , , , { 4: 22, 5: 61, 6: 24, 8: 26, 11: 28 }, { 4: 22, 5: 62, 6: 24, 8: 26, 11: 28 }, { 0: 18, 4: 22, 5: 23, 6: 24, 7: 63, 8: 26, 11: 28 }, { 0: 18, 4: 22, 5: 23, 6: 24, 7: 64, 8: 26, 11: 28 }, { 0: 18, 1: 65, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 11: 28 }, { 0: 18, 1: 19, 2: 66, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 11: 28 }, { 11: 67 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 68, 11: 28 }, { 4: 22, 6: 24, 8: 69, 11: 28 }, { 4: 22, 6: 24, 8: 70, 11: 28 }, { 4: 22, 6: 24, 8: 71, 11: 28 }, { 0: 72, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, { 0: 73, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, { 0: 74, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, { 0: 75, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, , { 9: 77 }, { 14: 78 }, , , , { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 79, 11: 28 }, , , , , , , , , , , , , , , , , , { 13: 8 }, , , { 14: 86 }, { 14: 87 }, , { 14: 88 }, , { 13: 8 }, { 13: 8 }, { 13: 8 }], | ||
tRules: [[52, 49], [49, 51], [51], [51, 51, 50], [50, 29, 47, 35, 51, 31], [50, 29, 47, 35, 51, 32, 51, 31], [50, 28, 47, 25, 46, 35, 51, 30], [50, 28, 47, 25, 25, 35, 51, 30], [50, 27, 24, 48, 13, 47, 35], [50, 27, 47, 35], [50, 33, 47, 36], [50, 26], [50, 27, 20, 25, 35], [48, 23], [48, 24], [48, 20], [43, 25], [43, 22], [43, 18], [43, 48], [43, 4, 47, 5], [41, 43], [41, 41, 9, 48], [41, 41, 16, 47, 17], [45, 41], [45, 1, 45], [45, 8, 45], [42, 45], [42, 42, 6, 45], [42, 42, 10, 45], [42, 42, 2, 45], [37, 42], [37, 37, 7, 42], [37, 37, 8, 42], [44, 37], [44, 44, 11, 37], [44, 44, 14, 37], [44, 44, 12, 37], [44, 44, 15, 37], [38, 44], [38, 38, 19, 44], [38, 38, 21, 44], [39, 38], [39, 39, 3, 38], [40, 39], [40, 40, 34, 39], [47, 40], [46]], | ||
tFuncs: function() { | ||
function $f0($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['each', $2, $6, $4 && eval($4.text), eval($3.text)]; | ||
return $$; | ||
} | ||
}; | ||
if (others) for (var i in others) | ||
obj[i] = others[i]; | ||
while (1) { | ||
var t = getAction(s, tSymbolIndex[a.tag]); | ||
if (!t) err(); | ||
else if (t > 0) { | ||
stateStack.push(s = t); | ||
valueStack.push(a); | ||
a = getToken(); | ||
function $f1($1) { | ||
var $$; $$ = ['lit', eval($1.text)]; return $$; | ||
} | ||
else if (t < 0 && t > -32768) { | ||
var idx = -t; | ||
var p = tRules[idx]; | ||
var num = p.length - 1; | ||
stateStack.length -= num; | ||
s = tGoto[stateStack[stateStack.length - 1]][p[0] - nBegin]; | ||
stateStack.push(s); | ||
if (tFuncs[idx]) { | ||
var val = tFuncs[idx].apply(obj, valueStack.splice(valueStack.length - num, num)); | ||
valueStack.push(val); | ||
} | ||
else if (num != 1) { | ||
valueStack.splice(valueStack.length - num, num, null); | ||
} | ||
function $f2($1, $2, $3) { | ||
var $$; $$ = [$2.text, $1, $3]; return $$; | ||
} | ||
else { | ||
if (a.tag != tSymbols[0]) err(); | ||
return valueStack[0]; | ||
} | ||
return [, function($1) { | ||
var $$; $$ = ['prog', $1]; return $$; | ||
}, function() { | ||
var $$; $$ = []; return $$; | ||
}, function($1, $2) { | ||
var $$; $1.push($2); $$ = $1; return $$; | ||
}, function($1, $2, $3, $4, $5) { | ||
var $$; $$ = ['if', $2, $4]; return $$; | ||
}, function($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['if', $2, $4, $6]; return $$; | ||
}, $f0, $f0, function($1, $2, $3, $4, $5, $6) { | ||
var $$; $$ = ['set', $3.text, $5]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, true]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, false]; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['text', $1.text]; return $$; | ||
}, function($1, $2, $3, $4) { | ||
var $$; $$ = ['inc', eval($3.text)]; return $$; | ||
}, , , , $f1, $f1, function($1) { | ||
var $$; $$ = ['lit', $1.text == 'true']; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['id', $1.text]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = $2; return $$; | ||
}, , function($1, $2, $3) { | ||
var $$; $$ = ['.', $1, $3.text]; return $$; | ||
}, function($1, $2, $3, $4) { | ||
var $$; $$ = ['[]', $1, $3]; return $$; | ||
}, , function($1, $2) { | ||
var $$; $$ = ['!', $2]; return $$; | ||
}, function($1, $2) { | ||
var $$; $$ = ['u-', $2]; return $$; | ||
}, , $f2, $f2, $f2, , $f2, $f2, , $f2, $f2, $f2, $f2, , function($1, $2, $3) { | ||
var $$; $$ = ['eq', $1, $3]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['ne', $1, $3]; return $$; | ||
}, , $f2, , $f2]; | ||
}() | ||
}; | ||
return function(a) { | ||
function e(a, d) { return c[a][d] } var b = a.nStart, f = a.tSymbols, d = a.tSymbolIndex, c = a.tAction, g = a.tGoto, l = a.tRules, k = a.tFuncs, p = a.actionIndex; p && (e = function(a, d) { var b = c[p[a]]; return b[d] || b._ }); return function(a, c) { | ||
function p(d) { throw Error("Syntax error: " + a.getPos(t.index) + (d ? "\n" + d : "")); } var v = 0, B = [0], t = a.scan(), C = [], A = { get: function(a) { return C[C.length + a] }, set: function(a, d) { C[C.length + a] = d } }; if (c) for (var x in c) A[x] = | ||
c[x]; for (; ;) if (x = e(v, d[t.tag])) if (0 < x) B.push(v = x), C.push(t), t = a.scan(); else if (0 > x && -32768 < x) { x = -x; var v = l[x], E = v.length - 1; B.length -= E; v = g[B[B.length - 1]][v[0] - b]; B.push(v); k[x] ? (x = k[x].apply(A, C.splice(C.length - E, E)), C.push(x)) : 1 != E && C.splice(C.length - E, E, null) } else return t.tag != f[0] && p(), C[0]; else { x = []; for (E = 0; E < b; ++E) e(v, E) && x.push(f[E]); p("find " + t.tag + "\nexpect " + x.join(" ")) } | ||
} | ||
function err() { | ||
throw Error("Syntax error: " + lexer.getPos(a.index)); | ||
} | ||
}; | ||
}(table); | ||
}(); | ||
@@ -535,2 +532,5 @@ | ||
break; | ||
case 'inc': | ||
//stmtsGen(a[2][1]); | ||
break; | ||
default: | ||
@@ -615,17 +615,33 @@ throw Error('unknown stmt: ' + a[0]); | ||
/// <reference path="codegen_js.js"/> | ||
function parsetmpl(s) { | ||
/// <summary>解析模板,得到语法树</summary> | ||
/// <param name="s" type="String">模板</param> | ||
var ast = parse(Lexer(s)); | ||
return ast; | ||
} | ||
function compile2jsfn(s) { | ||
return codegen_js_tofn(parse(Lexer(s))); | ||
/// <summary>编译模板,得到一个 js 函数</summary> | ||
/// <param name="s" type="String">模板</param> | ||
/// <returns type="Function" /> | ||
var ast = parsetmpl(s); | ||
return codegen_js_tofn(ast); | ||
} | ||
var Crox = { | ||
compile: function(s) { | ||
return compile2jsfn(s); | ||
parse: parsetmpl, | ||
compile: compile2jsfn, | ||
compileToJs: function(s) { | ||
/// <summary>返回编译后的 js 代码</summary> | ||
/// <param name="s" type="String"></param> | ||
/// <returns type="String" /> | ||
return codegen_js_tran(parsetmpl(s)); | ||
}, | ||
compileToStr: function(s) { | ||
return codegen_js_tran(parse(Lexer(s))); | ||
}, | ||
render: function(s, data) { | ||
return compile2jsfn(s)(data); | ||
/// <summary>将数据 data 填充到模板 s</summary> | ||
/// <param name="s" type="String">模板</param> | ||
/// <returns type="String" /> | ||
var fn = compile2jsfn(s); | ||
return fn(data); | ||
} | ||
}; | ||
Crox.version = "1.1";return Crox;})(); | ||
Crox.version = "1.1.0";return Crox;})();if ( typeof module == "object" && module && typeof module.exports == "object" ) module.exports = Crox;else if (typeof define == "function" && (define.amd || define.cmd) ) define(function () { return Crox; } );else if (typeof KISSY != "undefined") KISSY.add("crox",function(){ return Crox; });if (root) root.Crox = Crox; })(this); |
var gccPath = "D:\\gcc\\compiler.jar"; | ||
var phpPath = "E:\\php\\php.exe"; | ||
var buildVersion = '1.1'; |
{ | ||
"name": "crox", | ||
"version": "0.0.2", | ||
"description": "Looks like a mustache, but more powerful template, support of JS, PHP.", | ||
"homepage": "http://thx.github.io/corx", | ||
"keywords": [ | ||
"front end", | ||
"template" | ||
], | ||
"author": "shtml <shtml@live.com>", | ||
"contributors": [ | ||
"lenel <lenel@outlook.com>" | ||
], | ||
"engines": { | ||
"node": ">= 0.8.17" | ||
}, | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"grunt": "0.4.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/thx/crox" | ||
}, | ||
"main": "./build/nodejs/crox.js", | ||
"scripts": { | ||
}, | ||
"preferGlobal": false | ||
"name": "crox", | ||
"version": "1.1.1", | ||
"description": "Crox is a high performance cross-language template engine, written by the JavaScript.", | ||
"homepage": "http://github.com/thx/crox", | ||
"keywords": [ | ||
"front end", | ||
"template" | ||
], | ||
"author": "shtml <shtml@live.com>", | ||
"contributors": [ | ||
"shtml <shtml@live.com>", | ||
"lenel <lenel@outlook.com>", | ||
"wangjeaf <wangjeaf@gmail.com>" | ||
], | ||
"engines": { | ||
"node": ">= 0.8.17" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"grunt": "0.4.1", | ||
"semver": "~2.2.1", | ||
"async": "~0.2.9" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/thx/crox" | ||
}, | ||
"main": "./build/crox-all.js", | ||
"scripts": {}, | ||
"preferGlobal": false | ||
} |
@@ -54,2 +54,5 @@ /// <reference path="common.js"/> | ||
break; | ||
case 'inc': | ||
//stmtsGen(a[2][1]); | ||
break; | ||
default: | ||
@@ -56,0 +59,0 @@ throw Error('unknown stmt: ' + a[0]); |
@@ -61,2 +61,5 @@ /// <reference path="common.js"/> | ||
case 'text': compileContent(a); break; | ||
case 'inc': | ||
//emit("include '" + a[1] + "';"); | ||
break; | ||
default: throw Error('unknown stmt: ' + a[0]); | ||
@@ -63,0 +66,0 @@ } |
@@ -105,2 +105,18 @@ function Class(base, constructor, methods) { | ||
} | ||
function singleQuote(s) { | ||
/// <param name="s" type="String"></param> | ||
/// <returns type="String" /> | ||
return "'" + (s).replace(/[\x00-\x1f'\\\u2028\u2029]/g, function(a) { | ||
switch (a) { | ||
case "'": return "\\'"; | ||
case '\\': return '\\\\'; | ||
case '\b': return '\\b'; | ||
case '\f': return '\\f'; | ||
case '\n': return '\\n'; | ||
case '\r': return '\\r'; | ||
case '\t': return '\\t'; | ||
} | ||
return '\\u' + ('000' + a.charCodeAt(0).toString(16)).slice(-4); | ||
}) + "'"; | ||
} | ||
function phpQuote(s) { | ||
@@ -111,1 +127,32 @@ /// <param name="s" type="String"></param> | ||
} | ||
function formatPath(s) { | ||
/// <param name="s" type="String"></param> | ||
/// <returns type="String" /> | ||
s = s.replace(/\\/g, '/'); | ||
s = s.replace(/\/\/+/g, '/'); | ||
if (s.indexOf('/') == -1) | ||
return s; | ||
else { | ||
var a = s.split('/'); | ||
var b = []; | ||
for (var i = 0; i < a.length; ++i) { | ||
if (a[i].indexOf('..') != -1) { | ||
b.pop(); | ||
} | ||
else if (a[i] != '.') { | ||
b.push(a[i]); | ||
} | ||
} | ||
return b.join('/'); | ||
} | ||
} | ||
function buildPath(currentPath, path) { | ||
/// <param name="currentPath" type="String"></param> | ||
/// <param name="path" type="String"></param> | ||
/// <returns type="String" /> | ||
if (path.charAt(0) != '/' && path.charAt(0) != '\\') { | ||
path = currentPath.replace(/[^/\\]+$/, '') + path; | ||
} | ||
return formatPath(path); | ||
} |
/// <reference path="codegen_js.js"/> | ||
function parsetmpl(s) { | ||
/// <summary>解析模板,得到语法树</summary> | ||
/// <param name="s" type="String">模板</param> | ||
var ast = parse(Lexer(s)); | ||
return ast; | ||
} | ||
function compile2jsfn(s) { | ||
return codegen_js_tofn(parse(Lexer(s))); | ||
/// <summary>编译模板,得到一个 js 函数</summary> | ||
/// <param name="s" type="String">模板</param> | ||
/// <returns type="Function" /> | ||
var ast = parsetmpl(s); | ||
return codegen_js_tofn(ast); | ||
} | ||
var Crox = { | ||
compile: function(s) { | ||
return compile2jsfn(s); | ||
parse: parsetmpl, | ||
compile: compile2jsfn, | ||
compileToJs: function(s) { | ||
/// <summary>返回编译后的 js 代码</summary> | ||
/// <param name="s" type="String"></param> | ||
/// <returns type="String" /> | ||
return codegen_js_tran(parsetmpl(s)); | ||
}, | ||
compileToStr: function(s) { | ||
return codegen_js_tran(parse(Lexer(s))); | ||
}, | ||
render: function(s, data) { | ||
return compile2jsfn(s)(data); | ||
/// <summary>将数据 data 填充到模板 s</summary> | ||
/// <param name="s" type="String">模板</param> | ||
/// <returns type="String" /> | ||
var fn = compile2jsfn(s); | ||
return fn(data); | ||
} | ||
}; |
@@ -18,4 +18,5 @@ #start program; | ||
| text { $$ = ['text', $1.text]; } | ||
| "{{" include string "}}" { $$ = ['inc', eval($3.text)]; } | ||
; | ||
id: realId | set; | ||
id: realId | set | include; | ||
@@ -22,0 +23,0 @@ PrimaryExpression: |
@@ -9,5 +9,5 @@ | ||
stm.open(); | ||
try { | ||
stm.loadFromFile(fname); | ||
} catch (e) { WScript.Echo(fname); throw e; } | ||
//try { | ||
stm.loadFromFile(fname); | ||
//} catch (e) { alert(fname); throw e; } | ||
s = stm.readtext(); | ||
@@ -14,0 +14,0 @@ stm.close(); |
@@ -11,3 +11,3 @@ /// <reference path="createLexer.js"/> | ||
var code = [ | ||
[/\s+/, function() { return 'ws'; }], | ||
[/\s+/, function() { return null; }], | ||
[re_id, function(a) { | ||
@@ -19,3 +19,3 @@ switch (a) { | ||
case 'set': | ||
//case 'include': | ||
case 'include': | ||
//case 'this': | ||
@@ -22,0 +22,0 @@ return a; |
@@ -1,118 +0,68 @@ | ||
/* state num: 88 */ | ||
var parse = function() { | ||
function $f0($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['each', $2, $6, $4 && eval($4.text), eval($3.text)]; | ||
return $$; | ||
} | ||
function $f1($1) { | ||
var $$; $$ = ['lit', eval($1.text)]; return $$; | ||
} | ||
function $f2($1, $2, $3) { | ||
var $$; $$ = [$2.text, $1, $3]; return $$; | ||
} | ||
var nBegin = 36; | ||
var tSymbols = ["$", "!", "%", "&&", "(", ")", "*", "+", "-", ".", "/", "<", "<=", "=", ">", ">=", "[", "]", "boolean", "eq", "ne", "number", "realId", "set", "string", "text", "{{", "{{#each", "{{#if", "{{/each}}", "{{/if}}", "{{else}}", "{{{", "||", "}}", "}}}", "AdditiveExpression", "EqualityExpression", "LogicalAndExpression", "LogicalOrExpression", "MemberExpression", "MultiplicativeExpression", "PrimaryExpression", "RelationalExpression", "UnaryExpression", "epsilon", "expr", "id", "program", "statement", "statements"]; | ||
var tSymbolIndex = {}; | ||
for (var i = 0; i < tSymbols.length; ++i) | ||
tSymbolIndex[tSymbols[i]] = i; | ||
var tAction = [{ _: -2 }, { _: -32768 }, { 25: 3, 26: 4, 27: 5, 28: 6, 32: 7, _: -1 }, { _: -11 }, { 1: 9, 4: 10, 8: 11, 18: 12, 21: 13, 22: 14, 23: 15, 24: 16, _: 0 }, { 1: 9, 4: 10, 8: 11, 18: 12, 21: 13, 22: 14, 23: 28, 24: 16, _: 0 }, { _: -3 }, { _: -16 }, { _: -15 }, { _: -12 }, { 22: 14, 23: 28, _: -13 }, { _: -14 }, { 7: 36, 8: 37, _: -32 }, { 19: 38, 20: 39, _: -40 }, { 3: 40, _: -42 }, { 33: 41, _: -44 }, { 9: 42, 16: 43, _: -22 }, { 2: 44, 6: 45, 10: 46, _: -29 }, { _: -19 }, { 11: 47, 12: 48, 14: 49, 15: 50, _: -37 }, { _: -25 }, { 34: 51, _: 0 }, { _: -17 }, { _: -13 }, { 24: 52, _: 0 }, { 34: 53, _: 0 }, { 35: 54, _: 0 }, { _: -23 }, { 5: 55, _: 0 }, { _: -24 }, { 13: 56, _: 0 }, { 22: 14, 23: 28, _: 0 }, { _: -9 }, { 24: 72, _: -45 }, { _: -10 }, { _: -18 }, { 2: 44, 6: 45, 10: 46, _: -30 }, { 2: 44, 6: 45, 10: 46, _: -31 }, { 11: 47, 12: 48, 14: 49, 15: 50, _: -38 }, { 11: 47, 12: 48, 14: 49, 15: 50, _: -39 }, { 19: 38, 20: 39, _: -41 }, { 3: 40, _: -43 }, { _: -20 }, { 17: 76, _: 0 }, { _: -28 }, { _: -26 }, { _: -27 }, { 7: 36, 8: 37, _: -33 }, { 7: 36, 8: 37, _: -35 }, { 7: 36, 8: 37, _: -34 }, { 7: 36, 8: 37, _: -36 }, { 34: 77, _: 0 }, { 34: 78, _: 0 }, { 25: 3, 26: 4, 27: 5, 28: 6, 30: 79, 31: 80, 32: 7, _: 0 }, { 34: 81, _: 0 }, { _: -21 }, { _: -4 }, { _: -8 }, { 25: 3, 26: 4, 27: 5, 28: 6, 29: 85, 32: 7, _: 0 }, { 25: 3, 26: 4, 27: 5, 28: 6, 29: 86, 32: 7, _: 0 }, { 25: 3, 26: 4, 27: 5, 28: 6, 30: 87, 32: 7, _: 0 }, { _: -7 }, { _: -6 }, { _: -5 }]; | ||
var actionIndex = [0, 1, 2, 3, 4, 5, 5, 5, 6, 5, 5, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 5, 5, 5, 5, 5, 5, 31, 5, 5, 5, 5, 5, 5, 5, 5, 32, 33, 0, 34, 35, 5, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 0, 56, 0, 57, 58, 59, 60, 61, 62, 63]; | ||
var tGoto = [{ 12: 1, 14: 2 }, , { 13: 8 }, , { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 26, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 29, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 30, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 31, 11: 27 }, , { 4: 21, 6: 23, 8: 32, 11: 27 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 33, 11: 27 }, { 4: 21, 6: 23, 8: 34, 11: 27 }, , , , { 11: 35 }, , , , , , , , , , , , , , , , , , , , , { 4: 21, 5: 57, 6: 23, 8: 25, 11: 27 }, { 4: 21, 5: 58, 6: 23, 8: 25, 11: 27 }, { 0: 17, 4: 21, 5: 22, 6: 23, 7: 59, 8: 25, 11: 27 }, { 0: 17, 4: 21, 5: 22, 6: 23, 7: 60, 8: 25, 11: 27 }, { 0: 17, 1: 61, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 11: 27 }, { 0: 17, 1: 18, 2: 62, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 11: 27 }, { 11: 63 }, { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 64, 11: 27 }, { 4: 21, 6: 23, 8: 65, 11: 27 }, { 4: 21, 6: 23, 8: 66, 11: 27 }, { 4: 21, 6: 23, 8: 67, 11: 27 }, { 0: 68, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, { 0: 69, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, { 0: 70, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, { 0: 71, 4: 21, 5: 22, 6: 23, 8: 25, 11: 27 }, , { 9: 73 }, { 14: 74 }, , , { 0: 17, 1: 18, 2: 19, 3: 20, 4: 21, 5: 22, 6: 23, 7: 24, 8: 25, 10: 75, 11: 27 }, , , , , , , , , , , , , , , , , , { 13: 8 }, , , { 14: 82 }, { 14: 83 }, , { 14: 84 }, , { 13: 8 }, { 13: 8 }, { 13: 8 }]; | ||
var tRules = [[51, 48], [48, 50], [50], [50, 50, 49], [49, 28, 46, 34, 50, 30], [49, 28, 46, 34, 50, 31, 50, 30], [49, 27, 46, 24, 45, 34, 50, 29], [49, 27, 46, 24, 24, 34, 50, 29], [49, 26, 23, 47, 13, 46, 34], [49, 26, 46, 34], [49, 32, 46, 35], [49, 25], [47, 22], [47, 23], [42, 24], [42, 21], [42, 18], [42, 47], [42, 4, 46, 5], [40, 42], [40, 40, 9, 47], [40, 40, 16, 46, 17], [44, 40], [44, 1, 44], [44, 8, 44], [41, 44], [41, 41, 6, 44], [41, 41, 10, 44], [41, 41, 2, 44], [36, 41], [36, 36, 7, 41], [36, 36, 8, 41], [43, 36], [43, 43, 11, 36], [43, 43, 14, 36], [43, 43, 12, 36], [43, 43, 15, 36], [37, 43], [37, 37, 19, 43], [37, 37, 20, 43], [38, 37], [38, 38, 3, 37], [39, 38], [39, 39, 33, 38], [46, 39], [45]]; | ||
var tFuncs = [, function($1) { | ||
var $$; $$ = ['prog', $1]; return $$; | ||
}, function() { | ||
var $$; $$ = []; return $$; | ||
}, function($1, $2) { | ||
var $$; $1.push($2); $$ = $1; return $$; | ||
}, function($1, $2, $3, $4, $5) { | ||
var $$; $$ = ['if', $2, $4]; return $$; | ||
}, function($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['if', $2, $4, $6]; return $$; | ||
}, $f0, $f0, function($1, $2, $3, $4, $5, $6) { | ||
var $$; $$ = ['set', $3.text, $5]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, true]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, false]; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['text', $1.text]; return $$; | ||
}, , , $f1, $f1, function($1) { | ||
var $$; $$ = ['lit', $1.text == 'true']; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['id', $1.text]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = $2; return $$; | ||
}, , function($1, $2, $3) { | ||
var $$; $$ = ['.', $1, $3.text]; return $$; | ||
}, function($1, $2, $3, $4) { | ||
var $$; $$ = ['[]', $1, $3]; return $$; | ||
}, , function($1, $2) { | ||
var $$; $$ = ['!', $2]; return $$; | ||
}, function($1, $2) { | ||
var $$; $$ = ['u-', $2]; return $$; | ||
}, , $f2, $f2, $f2, , $f2, $f2, , $f2, $f2, $f2, $f2, , function($1, $2, $3) { | ||
var $$; $$ = ['eq', $1, $3]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['ne', $1, $3]; return $$; | ||
}, , $f2, , $f2]; | ||
function getAction(x, y) { | ||
var list = tAction[actionIndex[x]]; | ||
return list[y] || list._; | ||
} | ||
return function(lexer, others) { | ||
function getToken() { | ||
var t = lexer.scan(); | ||
if (t.tag == 'ws') t = lexer.scan(); | ||
return t; | ||
} | ||
var s = 0; | ||
var stateStack = [0]; | ||
var a = getToken(); | ||
var valueStack = []; | ||
var obj = { | ||
get: function(i) { | ||
return valueStack[valueStack.length + i]; | ||
}, | ||
set: function(i, v) { | ||
valueStack[valueStack.length + i] = v; | ||
var table = {/* state num: 92 */ | ||
nStart: 37, | ||
tSymbols: ["$", "!", "%", "&&", "(", ")", "*", "+", "-", ".", "/", "<", "<=", "=", ">", ">=", "[", "]", "boolean", "eq", "include", "ne", "number", "realId", "set", "string", "text", "{{", "{{#each", "{{#if", "{{/each}}", "{{/if}}", "{{else}}", "{{{", "||", "}}", "}}}", "AdditiveExpression", "EqualityExpression", "LogicalAndExpression", "LogicalOrExpression", "MemberExpression", "MultiplicativeExpression", "PrimaryExpression", "RelationalExpression", "UnaryExpression", "epsilon", "expr", "id", "program", "statement", "statements"], | ||
tSymbolIndex: { "$": 0, "!": 1, "%": 2, "&&": 3, "(": 4, ")": 5, "*": 6, "+": 7, "-": 8, ".": 9, "/": 10, "<": 11, "<=": 12, "=": 13, ">": 14, ">=": 15, "[": 16, "]": 17, "boolean": 18, "eq": 19, "include": 20, "ne": 21, "number": 22, "realId": 23, "set": 24, "string": 25, "text": 26, "{{": 27, "{{#each": 28, "{{#if": 29, "{{/each}}": 30, "{{/if}}": 31, "{{else}}": 32, "{{{": 33, "||": 34, "}}": 35, "}}}": 36, "AdditiveExpression": 37, "EqualityExpression": 38, "LogicalAndExpression": 39, "LogicalOrExpression": 40, "MemberExpression": 41, "MultiplicativeExpression": 42, "PrimaryExpression": 43, "RelationalExpression": 44, "UnaryExpression": 45, "epsilon": 46, "expr": 47, "id": 48, "program": 49, "statement": 50, "statements": 51 }, | ||
tAction: [{ _: -2 }, { _: -32768 }, { 26: 3, 27: 4, 28: 5, 29: 6, 33: 7, _: -1 }, { _: -11 }, { 1: 9, 4: 10, 8: 11, 18: 12, 20: 13, 22: 14, 23: 15, 24: 16, 25: 17, _: 0 }, { 1: 9, 4: 10, 8: 11, 18: 12, 20: 29, 22: 14, 23: 15, 24: 30, 25: 17, _: 0 }, { _: -3 }, { _: -18 }, { 25: 37, _: -15 }, { _: -17 }, { _: -13 }, { 20: 29, 23: 15, 24: 30, _: -14 }, { _: -16 }, { 7: 39, 8: 40, _: -34 }, { 19: 41, 21: 42, _: -42 }, { 3: 43, _: -44 }, { 34: 44, _: -46 }, { 9: 45, 16: 46, _: -24 }, { 2: 47, 6: 48, 10: 49, _: -31 }, { _: -21 }, { 11: 50, 12: 51, 14: 52, 15: 53, _: -39 }, { _: -27 }, { 35: 54, _: 0 }, { _: -19 }, { _: -15 }, { _: -14 }, { 25: 55, _: 0 }, { 35: 56, _: 0 }, { 36: 57, _: 0 }, { _: -25 }, { 5: 58, _: 0 }, { _: -26 }, { 35: 59, _: 0 }, { 13: 60, _: 0 }, { 20: 29, 23: 15, 24: 30, _: 0 }, { _: -9 }, { 25: 76, _: -47 }, { _: -10 }, { _: -20 }, { _: -12 }, { 2: 47, 6: 48, 10: 49, _: -32 }, { 2: 47, 6: 48, 10: 49, _: -33 }, { 11: 50, 12: 51, 14: 52, 15: 53, _: -40 }, { 11: 50, 12: 51, 14: 52, 15: 53, _: -41 }, { 19: 41, 21: 42, _: -43 }, { 3: 43, _: -45 }, { _: -22 }, { 17: 80, _: 0 }, { _: -30 }, { _: -28 }, { _: -29 }, { 7: 39, 8: 40, _: -35 }, { 7: 39, 8: 40, _: -37 }, { 7: 39, 8: 40, _: -36 }, { 7: 39, 8: 40, _: -38 }, { 35: 81, _: 0 }, { 35: 82, _: 0 }, { 26: 3, 27: 4, 28: 5, 29: 6, 31: 83, 32: 84, 33: 7, _: 0 }, { 35: 85, _: 0 }, { _: -23 }, { _: -4 }, { _: -8 }, { 26: 3, 27: 4, 28: 5, 29: 6, 30: 89, 33: 7, _: 0 }, { 26: 3, 27: 4, 28: 5, 29: 6, 30: 90, 33: 7, _: 0 }, { 26: 3, 27: 4, 28: 5, 29: 6, 31: 91, 33: 7, _: 0 }, { _: -7 }, { _: -6 }, { _: -5 }], | ||
actionIndex: [0, 1, 2, 3, 4, 5, 5, 5, 6, 5, 5, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 5, 5, 5, 5, 5, 5, 34, 5, 5, 5, 5, 5, 5, 5, 5, 35, 36, 0, 37, 38, 39, 5, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 60, 0, 61, 62, 63, 64, 65, 66, 67], | ||
tGoto: [{ 12: 1, 14: 2 }, , { 13: 8 }, , { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 27, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 31, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 32, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 33, 11: 28 }, , { 4: 22, 6: 24, 8: 34, 11: 28 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 35, 11: 28 }, { 4: 22, 6: 24, 8: 36, 11: 28 }, , , , , { 11: 38 }, , , , , , , , , , , , , , , , , , , , , , , { 4: 22, 5: 61, 6: 24, 8: 26, 11: 28 }, { 4: 22, 5: 62, 6: 24, 8: 26, 11: 28 }, { 0: 18, 4: 22, 5: 23, 6: 24, 7: 63, 8: 26, 11: 28 }, { 0: 18, 4: 22, 5: 23, 6: 24, 7: 64, 8: 26, 11: 28 }, { 0: 18, 1: 65, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 11: 28 }, { 0: 18, 1: 19, 2: 66, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 11: 28 }, { 11: 67 }, { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 68, 11: 28 }, { 4: 22, 6: 24, 8: 69, 11: 28 }, { 4: 22, 6: 24, 8: 70, 11: 28 }, { 4: 22, 6: 24, 8: 71, 11: 28 }, { 0: 72, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, { 0: 73, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, { 0: 74, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, { 0: 75, 4: 22, 5: 23, 6: 24, 8: 26, 11: 28 }, , { 9: 77 }, { 14: 78 }, , , , { 0: 18, 1: 19, 2: 20, 3: 21, 4: 22, 5: 23, 6: 24, 7: 25, 8: 26, 10: 79, 11: 28 }, , , , , , , , , , , , , , , , , , { 13: 8 }, , , { 14: 86 }, { 14: 87 }, , { 14: 88 }, , { 13: 8 }, { 13: 8 }, { 13: 8 }], | ||
tRules: [[52, 49], [49, 51], [51], [51, 51, 50], [50, 29, 47, 35, 51, 31], [50, 29, 47, 35, 51, 32, 51, 31], [50, 28, 47, 25, 46, 35, 51, 30], [50, 28, 47, 25, 25, 35, 51, 30], [50, 27, 24, 48, 13, 47, 35], [50, 27, 47, 35], [50, 33, 47, 36], [50, 26], [50, 27, 20, 25, 35], [48, 23], [48, 24], [48, 20], [43, 25], [43, 22], [43, 18], [43, 48], [43, 4, 47, 5], [41, 43], [41, 41, 9, 48], [41, 41, 16, 47, 17], [45, 41], [45, 1, 45], [45, 8, 45], [42, 45], [42, 42, 6, 45], [42, 42, 10, 45], [42, 42, 2, 45], [37, 42], [37, 37, 7, 42], [37, 37, 8, 42], [44, 37], [44, 44, 11, 37], [44, 44, 14, 37], [44, 44, 12, 37], [44, 44, 15, 37], [38, 44], [38, 38, 19, 44], [38, 38, 21, 44], [39, 38], [39, 39, 3, 38], [40, 39], [40, 40, 34, 39], [47, 40], [46]], | ||
tFuncs: function() { | ||
function $f0($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['each', $2, $6, $4 && eval($4.text), eval($3.text)]; | ||
return $$; | ||
} | ||
}; | ||
if (others) for (var i in others) | ||
obj[i] = others[i]; | ||
while (1) { | ||
var t = getAction(s, tSymbolIndex[a.tag]); | ||
if (!t) err(); | ||
else if (t > 0) { | ||
stateStack.push(s = t); | ||
valueStack.push(a); | ||
a = getToken(); | ||
function $f1($1) { | ||
var $$; $$ = ['lit', eval($1.text)]; return $$; | ||
} | ||
else if (t < 0 && t > -32768) { | ||
var idx = -t; | ||
var p = tRules[idx]; | ||
var num = p.length - 1; | ||
stateStack.length -= num; | ||
s = tGoto[stateStack[stateStack.length - 1]][p[0] - nBegin]; | ||
stateStack.push(s); | ||
if (tFuncs[idx]) { | ||
var val = tFuncs[idx].apply(obj, valueStack.splice(valueStack.length - num, num)); | ||
valueStack.push(val); | ||
} | ||
else if (num != 1) { | ||
valueStack.splice(valueStack.length - num, num, null); | ||
} | ||
function $f2($1, $2, $3) { | ||
var $$; $$ = [$2.text, $1, $3]; return $$; | ||
} | ||
else { | ||
if (a.tag != tSymbols[0]) err(); | ||
return valueStack[0]; | ||
} | ||
return [, function($1) { | ||
var $$; $$ = ['prog', $1]; return $$; | ||
}, function() { | ||
var $$; $$ = []; return $$; | ||
}, function($1, $2) { | ||
var $$; $1.push($2); $$ = $1; return $$; | ||
}, function($1, $2, $3, $4, $5) { | ||
var $$; $$ = ['if', $2, $4]; return $$; | ||
}, function($1, $2, $3, $4, $5, $6, $7) { | ||
var $$; $$ = ['if', $2, $4, $6]; return $$; | ||
}, $f0, $f0, function($1, $2, $3, $4, $5, $6) { | ||
var $$; $$ = ['set', $3.text, $5]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, true]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['eval', $2, false]; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['text', $1.text]; return $$; | ||
}, function($1, $2, $3, $4) { | ||
var $$; $$ = ['inc', eval($3.text)]; return $$; | ||
}, , , , $f1, $f1, function($1) { | ||
var $$; $$ = ['lit', $1.text == 'true']; return $$; | ||
}, function($1) { | ||
var $$; $$ = ['id', $1.text]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = $2; return $$; | ||
}, , function($1, $2, $3) { | ||
var $$; $$ = ['.', $1, $3.text]; return $$; | ||
}, function($1, $2, $3, $4) { | ||
var $$; $$ = ['[]', $1, $3]; return $$; | ||
}, , function($1, $2) { | ||
var $$; $$ = ['!', $2]; return $$; | ||
}, function($1, $2) { | ||
var $$; $$ = ['u-', $2]; return $$; | ||
}, , $f2, $f2, $f2, , $f2, $f2, , $f2, $f2, $f2, $f2, , function($1, $2, $3) { | ||
var $$; $$ = ['eq', $1, $3]; return $$; | ||
}, function($1, $2, $3) { | ||
var $$; $$ = ['ne', $1, $3]; return $$; | ||
}, , $f2, , $f2]; | ||
}() | ||
}; | ||
return function(a) { | ||
function e(a, d) { return c[a][d] } var b = a.nStart, f = a.tSymbols, d = a.tSymbolIndex, c = a.tAction, g = a.tGoto, l = a.tRules, k = a.tFuncs, p = a.actionIndex; p && (e = function(a, d) { var b = c[p[a]]; return b[d] || b._ }); return function(a, c) { | ||
function p(d) { throw Error("Syntax error: " + a.getPos(t.index) + (d ? "\n" + d : "")); } var v = 0, B = [0], t = a.scan(), C = [], A = { get: function(a) { return C[C.length + a] }, set: function(a, d) { C[C.length + a] = d } }; if (c) for (var x in c) A[x] = | ||
c[x]; for (; ;) if (x = e(v, d[t.tag])) if (0 < x) B.push(v = x), C.push(t), t = a.scan(); else if (0 > x && -32768 < x) { x = -x; var v = l[x], E = v.length - 1; B.length -= E; v = g[B[B.length - 1]][v[0] - b]; B.push(v); k[x] ? (x = k[x].apply(A, C.splice(C.length - E, E)), C.push(x)) : 1 != E && C.splice(C.length - E, E, null) } else return t.tag != f[0] && p(), C[0]; else { x = []; for (E = 0; E < b; ++E) e(v, E) && x.push(f[E]); p("find " + t.tag + "\nexpect " + x.join(" ")) } | ||
} | ||
function err() { | ||
throw Error("Syntax error: " + lexer.getPos(a.index)); | ||
} | ||
}; | ||
}(table); | ||
}(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1
487
505958
3
44
3265