Skip to content

Commit

Permalink
little changes in the grammar file to make it consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
jairodemorais committed Aug 13, 2012
1 parent 9ace431 commit 87d1ad3
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 211 deletions.
1 change: 0 additions & 1 deletion dist/dust-core-1.0.0.js
Expand Up @@ -160,7 +160,6 @@ Context.prototype.getPath = function(cur, down) {
len = down.length;

if (cur && len === 0) return ctx.head;
if (!ctx.isObject) return undefined;
ctx = ctx.head;
var i = 0;
while(ctx && i < len) {
Expand Down
232 changes: 130 additions & 102 deletions dist/dust-full-1.0.0.js
Expand Up @@ -160,7 +160,6 @@ Context.prototype.getPath = function(cur, down) {
len = down.length;

if (cur && len === 0) return ctx.head;
if (!ctx.isObject) return undefined;
ctx = ctx.head;
var i = 0;
while(ctx && i < len) {
Expand Down Expand Up @@ -1136,8 +1135,8 @@ var parser = (function(){
"integer": parse_integer,
"path": parse_path,
"key": parse_key,
"nestedKey": parse_nestedKey,
"array": parse_array,
"array_part": parse_array_part,
"inline": parse_inline,
"inline_part": parse_inline_part,
"buffer": parse_buffer,
Expand Down Expand Up @@ -2282,15 +2281,15 @@ var parser = (function(){
result0 = parse_key();
result0 = result0 !== null ? result0 : "";
if (result0 !== null) {
result2 = parse_nestedKey();
result2 = parse_array_part();
if (result2 === null) {
result2 = parse_array();
}
if (result2 !== null) {
result1 = [];
while (result2 !== null) {
result1.push(result2);
result2 = parse_nestedKey();
result2 = parse_array_part();
if (result2 === null) {
result2 = parse_array();
}
Expand All @@ -2313,7 +2312,7 @@ var parser = (function(){
d = d[0];
if (k && d) {
d.unshift(k);
return [false, d];;
return [false, d];
}
return [true, d];
})(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
Expand All @@ -2323,6 +2322,7 @@ var parser = (function(){
}
if (result0 === null) {
pos0 = clone(pos);
pos1 = clone(pos);
if (input.charCodeAt(pos.offset) === 46) {
result0 = ".";
advance(pos, 1);
Expand All @@ -2333,7 +2333,35 @@ var parser = (function(){
}
}
if (result0 !== null) {
result0 = (function(offset, line, column) { return [true, []] })(pos0.offset, pos0.line, pos0.column);
result1 = [];
result2 = parse_array_part();
if (result2 === null) {
result2 = parse_array();
}
while (result2 !== null) {
result1.push(result2);
result2 = parse_array_part();
if (result2 === null) {
result2 = parse_array();
}
}
if (result1 !== null) {
result0 = [result0, result1];
} else {
result0 = null;
pos = clone(pos1);
}
} else {
result0 = null;
pos = clone(pos1);
}
if (result0 !== null) {
result0 = (function(offset, line, column, d) {
if (d.length > 0) {
return [true, d[0]];
}
return [true, []]
})(pos0.offset, pos0.line, pos0.column, result0[1]);
}
if (result0 === null) {
pos = clone(pos0);
Expand Down Expand Up @@ -2408,7 +2436,7 @@ var parser = (function(){
return result0;
}

function parse_nestedKey() {
function parse_array() {
var result0, result1, result2;
var pos0, pos1, pos2, pos3;

Expand All @@ -2417,72 +2445,74 @@ var parser = (function(){
pos1 = clone(pos);
pos2 = clone(pos);
pos3 = clone(pos);
if (input.charCodeAt(pos.offset) === 46) {
result1 = ".";
if (input.charCodeAt(pos.offset) === 91) {
result0 = "[";
advance(pos, 1);
} else {
result1 = null;
result0 = null;
if (reportFailures === 0) {
matchFailed("\".\"");
matchFailed("\"[\"");
}
}
if (result1 !== null) {
result2 = parse_key();
if (result0 !== null) {
if (/^[0-9]/.test(input.charAt(pos.offset))) {
result2 = input.charAt(pos.offset);
advance(pos, 1);
} else {
result2 = null;
if (reportFailures === 0) {
matchFailed("[0-9]");
}
}
if (result2 !== null) {
result1 = [result1, result2];
result1 = [];
while (result2 !== null) {
result1.push(result2);
if (/^[0-9]/.test(input.charAt(pos.offset))) {
result2 = input.charAt(pos.offset);
advance(pos, 1);
} else {
result2 = null;
if (reportFailures === 0) {
matchFailed("[0-9]");
}
}
}
} else {
result1 = null;
pos = clone(pos3);
}
} else {
result1 = null;
pos = clone(pos3);
}
if (result1 !== null) {
result1 = (function(offset, line, column, k) {return k})(pos2.offset, pos2.line, pos2.column, result1[1]);
}
if (result1 === null) {
pos = clone(pos2);
}
if (result1 !== null) {
result0 = [];
while (result1 !== null) {
result0.push(result1);
pos2 = clone(pos);
pos3 = clone(pos);
if (input.charCodeAt(pos.offset) === 46) {
result1 = ".";
if (result1 !== null) {
if (input.charCodeAt(pos.offset) === 93) {
result2 = "]";
advance(pos, 1);
} else {
result1 = null;
result2 = null;
if (reportFailures === 0) {
matchFailed("\".\"");
matchFailed("\"]\"");
}
}
if (result1 !== null) {
result2 = parse_key();
if (result2 !== null) {
result1 = [result1, result2];
} else {
result1 = null;
pos = clone(pos3);
}
if (result2 !== null) {
result0 = [result0, result1, result2];
} else {
result1 = null;
result0 = null;
pos = clone(pos3);
}
if (result1 !== null) {
result1 = (function(offset, line, column, k) {return k})(pos2.offset, pos2.line, pos2.column, result1[1]);
}
if (result1 === null) {
pos = clone(pos2);
}
} else {
result0 = null;
pos = clone(pos3);
}
} else {
result0 = null;
pos = clone(pos3);
}
if (result0 !== null) {
result1 = parse_array();
result0 = (function(offset, line, column, a) {return a.join('')})(pos2.offset, pos2.line, pos2.column, result0[1]);
}
if (result0 === null) {
pos = clone(pos2);
}
if (result0 !== null) {
result1 = parse_array_part();
result1 = result1 !== null ? result1 : "";
if (result1 !== null) {
result0 = [result0, result1];
Expand All @@ -2495,19 +2525,19 @@ var parser = (function(){
pos = clone(pos1);
}
if (result0 !== null) {
result0 = (function(offset, line, column, d, a) { if (a) { return d.concat(a); } else { return d; } })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
result0 = (function(offset, line, column, i, nk) { if(nk) { nk.unshift(i); } else {nk = [i] } return nk; })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
}
if (result0 === null) {
pos = clone(pos0);
}
reportFailures--;
if (reportFailures === 0 && result0 === null) {
matchFailed("nestedKey");
matchFailed("array");
}
return result0;
}

function parse_array() {
function parse_array_part() {
var result0, result1, result2;
var pos0, pos1, pos2, pos3;

Expand All @@ -2516,74 +2546,72 @@ var parser = (function(){
pos1 = clone(pos);
pos2 = clone(pos);
pos3 = clone(pos);
if (input.charCodeAt(pos.offset) === 91) {
result0 = "[";
if (input.charCodeAt(pos.offset) === 46) {
result1 = ".";
advance(pos, 1);
} else {
result0 = null;
result1 = null;
if (reportFailures === 0) {
matchFailed("\"[\"");
matchFailed("\".\"");
}
}
if (result0 !== null) {
if (/^[0-9]/.test(input.charAt(pos.offset))) {
result2 = input.charAt(pos.offset);
advance(pos, 1);
} else {
result2 = null;
if (reportFailures === 0) {
matchFailed("[0-9]");
}
}
if (result1 !== null) {
result2 = parse_key();
if (result2 !== null) {
result1 = [];
while (result2 !== null) {
result1.push(result2);
if (/^[0-9]/.test(input.charAt(pos.offset))) {
result2 = input.charAt(pos.offset);
advance(pos, 1);
} else {
result2 = null;
if (reportFailures === 0) {
matchFailed("[0-9]");
}
}
}
result1 = [result1, result2];
} else {
result1 = null;
pos = clone(pos3);
}
if (result1 !== null) {
if (input.charCodeAt(pos.offset) === 93) {
result2 = "]";
} else {
result1 = null;
pos = clone(pos3);
}
if (result1 !== null) {
result1 = (function(offset, line, column, k) {return k})(pos2.offset, pos2.line, pos2.column, result1[1]);
}
if (result1 === null) {
pos = clone(pos2);
}
if (result1 !== null) {
result0 = [];
while (result1 !== null) {
result0.push(result1);
pos2 = clone(pos);
pos3 = clone(pos);
if (input.charCodeAt(pos.offset) === 46) {
result1 = ".";
advance(pos, 1);
} else {
result2 = null;
result1 = null;
if (reportFailures === 0) {
matchFailed("\"]\"");
matchFailed("\".\"");
}
}
if (result2 !== null) {
result0 = [result0, result1, result2];
if (result1 !== null) {
result2 = parse_key();
if (result2 !== null) {
result1 = [result1, result2];
} else {
result1 = null;
pos = clone(pos3);
}
} else {
result0 = null;
result1 = null;
pos = clone(pos3);
}
} else {
result0 = null;
pos = clone(pos3);
if (result1 !== null) {
result1 = (function(offset, line, column, k) {return k})(pos2.offset, pos2.line, pos2.column, result1[1]);
}
if (result1 === null) {
pos = clone(pos2);
}
}
} else {
result0 = null;
pos = clone(pos3);
}
if (result0 !== null) {
result0 = (function(offset, line, column, a) {return a.join('')})(pos2.offset, pos2.line, pos2.column, result0[1]);
}
if (result0 === null) {
pos = clone(pos2);
}
if (result0 !== null) {
result1 = parse_nestedKey();
result1 = parse_array();
result1 = result1 !== null ? result1 : "";
if (result1 !== null) {
result0 = [result0, result1];
Expand All @@ -2596,14 +2624,14 @@ var parser = (function(){
pos = clone(pos1);
}
if (result0 !== null) {
result0 = (function(offset, line, column, i, nk) { if(nk) { nk.unshift(i); } else {nk = [i] } return nk; })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
result0 = (function(offset, line, column, d, a) { if (a) { return d.concat(a); } else { return d; } })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]);
}
if (result0 === null) {
pos = clone(pos0);
}
reportFailures--;
if (reportFailures === 0 && result0 === null) {
matchFailed("array");
matchFailed("array_part");
}
return result0;
}
Expand Down

0 comments on commit 87d1ad3

Please sign in to comment.