svg-path-parser
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "svg-path-parser", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A parser for SVG's path syntax", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublish": "node build.js > parser.js" | ||
"prepublish": "pegjs grammar.peg parser.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
452
parser.js
@@ -191,3 +191,3 @@ module.exports = (function(){ | ||
function parse_moveTo_drawTo_commandGroups() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1; | ||
@@ -198,22 +198,44 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos1 = pos; | ||
result1 = []; | ||
result2 = parse_wsp(); | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
result2 = parse_wsp(); | ||
result2 = []; | ||
result3 = parse_wsp(); | ||
while (result3 !== null) { | ||
result2.push(result3); | ||
result3 = parse_wsp(); | ||
} | ||
if (result1 !== null) { | ||
result2 = parse_moveTo_drawTo_commandGroups(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
if (result2 !== null) { | ||
result3 = parse_moveTo_drawTo_commandGroup(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos1 = pos; | ||
result2 = []; | ||
result3 = parse_wsp(); | ||
while (result3 !== null) { | ||
result2.push(result3); | ||
result3 = parse_wsp(); | ||
} | ||
if (result2 !== null) { | ||
result3 = parse_moveTo_drawTo_commandGroup(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -266,3 +288,3 @@ result0 = [result0, result1]; | ||
function parse_drawto_commands() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1; | ||
@@ -273,22 +295,44 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos1 = pos; | ||
result1 = []; | ||
result2 = parse_wsp(); | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
result2 = parse_wsp(); | ||
result2 = []; | ||
result3 = parse_wsp(); | ||
while (result3 !== null) { | ||
result2.push(result3); | ||
result3 = parse_wsp(); | ||
} | ||
if (result1 !== null) { | ||
result2 = parse_drawto_commands(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
if (result2 !== null) { | ||
result3 = parse_drawto_command(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos1 = pos; | ||
result2 = []; | ||
result3 = parse_wsp(); | ||
while (result3 !== null) { | ||
result2.push(result3); | ||
result3 = parse_wsp(); | ||
} | ||
if (result2 !== null) { | ||
result3 = parse_drawto_command(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos1; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -377,3 +421,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, seq) { return {command:"moveto", relative:c=='m', args:seq} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, seq) { return {command:'moveto', relative:c=='m', args:seq} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -421,3 +465,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { return more ? [first].concat(more[1]) : [first] })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -445,3 +489,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return {command:"closepath"} })(pos0); | ||
result0 = (function(offset) { return {command:'closepath'} })(pos0); | ||
} | ||
@@ -493,3 +537,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"lineto", relative:c=='l', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'lineto', relative:c=='l', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -503,3 +547,3 @@ if (result0 === null) { | ||
function parse_lineto_argument_sequence() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1, pos2; | ||
@@ -511,18 +555,36 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
result1 = parse_comma_wsp(); | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result2 = parse_lineto_argument_sequence(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_coordinate_pair(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_coordinate_pair(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -539,3 +601,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { return more ? [first].concat(more[1]) : [first] })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -587,3 +649,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"horizontal lineto", relative:c=='h', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'horizontal lineto', relative:c=='h', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -597,3 +659,3 @@ if (result0 === null) { | ||
function parse_coordinate_sequence() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1, pos2; | ||
@@ -605,18 +667,36 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
result1 = parse_comma_wsp(); | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result2 = parse_coordinate_sequence(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_number(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_number(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -633,3 +713,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { for (var a=[first],i=1,len=more.length;i<len;++i){ a[i]=more[i][0] }; return a; })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -681,3 +761,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"vertical lineto", relative:c=='v', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'vertical lineto', relative:c=='v', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -729,3 +809,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"curveto", relative:c=='c', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'curveto', relative:c=='c', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -739,3 +819,3 @@ if (result0 === null) { | ||
function parse_curveto_argument_sequence() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1, pos2; | ||
@@ -747,18 +827,36 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
result1 = parse_comma_wsp(); | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result2 = parse_curveto_argument_sequence(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_curveto_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_curveto_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -775,3 +873,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { for (var a=[first],i=1,len=more.length;i<len;++i){ a[i]=more[i][0] }; return a; })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -871,3 +969,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"smooth curveto", relative:c=='s', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'smooth curveto', relative:c=='s', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -881,3 +979,3 @@ if (result0 === null) { | ||
function parse_smooth_curveto_argument_sequence() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1, pos2; | ||
@@ -889,18 +987,36 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
result1 = parse_comma_wsp(); | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result2 = parse_smooth_curveto_argument_sequence(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_smooth_curveto_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_smooth_curveto_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -917,3 +1033,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { for (var a=[first],i=1,len=more.length;i<len;++i){ a[i]=more[i][0] }; return a; })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -1000,3 +1116,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"quadratic curveto", relative:c=='q', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'quadratic curveto', relative:c=='q', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -1010,3 +1126,3 @@ if (result0 === null) { | ||
function parse_quadratic_bezier_curveto_argument_sequence() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1, pos2; | ||
@@ -1018,18 +1134,36 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
result1 = parse_comma_wsp(); | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result2 = parse_quadratic_bezier_curveto_argument_sequence(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_quadratic_bezier_curveto_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_quadratic_bezier_curveto_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -1046,3 +1180,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { for (var a=[first],i=1,len=more.length;i<len;++i){ a[i]=more[i][0] }; return a; })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -1129,3 +1263,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"smooth quadratic curveto", relative:c=='t', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'smooth quadratic curveto', relative:c=='t', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -1139,3 +1273,3 @@ if (result0 === null) { | ||
function parse_smooth_quadratic_bezier_curveto_argument_sequence() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1, pos2; | ||
@@ -1147,18 +1281,36 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
result1 = parse_comma_wsp(); | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result2 = parse_smooth_quadratic_bezier_curveto_argument_sequence(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_coordinate_pair(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_coordinate_pair(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -1175,3 +1327,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { for (var a=[first],i=1,len=more.length;i<len;++i){ a[i]=more[i][0] }; return a; })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -1223,3 +1375,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, c, args) { return {command:"elliptical arc", relative:c=='a', args:args} })(pos0, result0[0], result0[2]); | ||
result0 = (function(offset, c, args) { return {command:'elliptical arc', relative:c=='a', args:args} })(pos0, result0[0], result0[2]); | ||
} | ||
@@ -1233,3 +1385,3 @@ if (result0 === null) { | ||
function parse_elliptical_arc_argument_sequence() { | ||
var result0, result1, result2; | ||
var result0, result1, result2, result3; | ||
var pos0, pos1, pos2; | ||
@@ -1241,18 +1393,36 @@ | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
result1 = parse_comma_wsp(); | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result2 = parse_elliptical_arc_argument_sequence(); | ||
if (result2 !== null) { | ||
result1 = [result1, result2]; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_elliptical_arc_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result1 = null; | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
result2 = parse_comma_wsp(); | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse_elliptical_arc_argument(); | ||
if (result3 !== null) { | ||
result2 = [result2, result3]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
} | ||
if (result1 !== null) { | ||
@@ -1269,3 +1439,3 @@ result0 = [result0, result1]; | ||
if (result0 !== null) { | ||
result0 = (function(offset, first, more) { for (var a=[first],i=1,len=more.length;i<len;++i){ a[i]=more[i][0] }; return a; })(pos0, result0[0], result0[1]); | ||
result0 = (function(offset, first, more) { return merge(first,more) })(pos0, result0[0], result0[1]); | ||
} | ||
@@ -1468,4 +1638,4 @@ if (result0 === null) { | ||
pos0 = pos; | ||
if (input.charCodeAt(pos) === 48) { | ||
result0 = "0"; | ||
if (/^[01]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
@@ -1475,18 +1645,7 @@ } else { | ||
if (reportFailures === 0) { | ||
matchFailed("\"0\""); | ||
matchFailed("[01]"); | ||
} | ||
} | ||
if (result0 === null) { | ||
if (input.charCodeAt(pos) === 49) { | ||
result0 = "1"; | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"1\""); | ||
} | ||
} | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, bit) { return bit=="1" })(pos0, result0); | ||
result0 = (function(offset, bit) { return bit=='1' })(pos0, result0); | ||
} | ||
@@ -1688,3 +1847,3 @@ if (result0 === null) { | ||
if (result0 !== null) { | ||
result0 = (function(offset, n) { return flatten(n).join('')*1 })(pos0, result0); | ||
result0 = (function(offset, n) { return flatten(n).join('') })(pos0, result0); | ||
} | ||
@@ -1736,4 +1895,4 @@ if (result0 === null) { | ||
if (input.charCodeAt(pos) === 43) { | ||
result0 = "+"; | ||
if (/^[+\-]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
@@ -1743,16 +1902,5 @@ } else { | ||
if (reportFailures === 0) { | ||
matchFailed("\"+\""); | ||
matchFailed("[+\\-]"); | ||
} | ||
} | ||
if (result0 === null) { | ||
if (input.charCodeAt(pos) === 45) { | ||
result0 = "-"; | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"-\""); | ||
} | ||
} | ||
} | ||
return result0; | ||
@@ -1793,3 +1941,3 @@ } | ||
if (result0 !== null) { | ||
result0 = (function(offset, digits) { return digits.join("") })(pos0, result0); | ||
result0 = (function(offset, digits) { return digits.join('') })(pos0, result0); | ||
} | ||
@@ -1875,5 +2023,6 @@ if (result0 === null) { | ||
for (var i=0,l=a.length;i<l;++i){ | ||
var o=a[i]; | ||
if (o.constructor==Array) flatten(o,result); | ||
else if (o && o!=" ") result.push(o); | ||
if (a[i]!=null){ | ||
if (a[i].constructor==Array) flatten(a[i],result); | ||
else if (a[i]!='') result.push(a[i]); | ||
} | ||
} | ||
@@ -1883,3 +2032,8 @@ return result; | ||
function merge(first,more){ | ||
for (var a=[first],i=0,l=more.length;i<l;i++) a[i+1]=more[i][1]; | ||
return a; | ||
} | ||
var result = parseFunctions[startRule](); | ||
@@ -1968,2 +2122,2 @@ | ||
return result; | ||
})() | ||
})(); |
# svg-path-parser [![stable](http://hughsk.github.io/stability-badges/dist/stable.svg)](http://github.com/hughsk/stability-badges) # | ||
An SVG path parser, built from the [PEG.js](http://pegjs.majda.cz/) grammar | ||
An SVG path parser, originally built from the [PEG.js](http://pegjs.majda.cz/) grammar | ||
specified [here](http://pastie.org/1036541), published as an NPM module. | ||
@@ -155,2 +155,5 @@ | ||
### v0.0.4 - 2014-Oct-10 | ||
+ Unroll recursive grammar descriptions that could cause parsing a large path to overflow the stack. | ||
### v0.0.3 - 2014-Oct-1 | ||
@@ -157,0 +160,0 @@ + Fix bug that prevented parsing some valid documents. |
1964
164
64751
6