From 46956a6a4079917bca0d5a22497116caa82386db Mon Sep 17 00:00:00 2001 From: booo Date: Sun, 30 Jan 2011 01:35:57 +0100 Subject: almost working; do some testing... --- src/nodejs/alternative/parser.js | 54 +++++++++++++++++++++----------------- src/nodejs/alternative/testgrammar | 2 +- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/nodejs/alternative/parser.js b/src/nodejs/alternative/parser.js index ac10479..d388471 100644 --- a/src/nodejs/alternative/parser.js +++ b/src/nodejs/alternative/parser.js @@ -96,49 +96,55 @@ exports.parser = parser = (function(){ var savedPos1 = pos; - var result7 = parse_object(context); - if (result7 !== null) { - var result8 = parse_predicate(context); - if (result8 !== null) { - var result9 = parse_predicate(context); - if (result9 !== null) { - var result6 = [result7, result8, result9]; + var result9 = parse_object(context); + if (result9 !== null) { + var result10 = parse_predicate(context); + if (result10 !== null) { + var result11 = parse_predicate(context); + if (result11 !== null) { + var result8 = [result9, result10, result11]; } else { - var result6 = null; + var result8 = null; pos = savedPos1; } } else { - var result6 = null; + var result8 = null; pos = savedPos1; } } else { - var result6 = null; + var result8 = null; pos = savedPos1; } - var result5 = result6 !== null - ? (function(object, p1, p2) { var result = {object:object}; if(p1.tags != undefined) {result.tags= p1.tags} else if(p1.bbox != undefined) {result.bbox=p1.bbox;} if(p2.tags != undefined) {result.tags= p2.tags} else if(p2.bbox != undefined) {result.bbox=p2.bbox;} return result;})(result6[0], result6[1], result6[2]) + var result7 = result8 !== null + ? (function(object, p1, p2) { var result = {object:object}; if(p1.tags != undefined) {result.tags= p1.tags} else if(p1.bbox != undefined) {result.bbox=p1.bbox;} if(p2.tags != undefined) {result.tags= p2.tags} else if(p2.bbox != undefined) {result.bbox=p2.bbox;} return result;})(result8[0], result8[1], result8[2]) : null; - if (result5 !== null) { - var result0 = result5; + if (result7 !== null) { + var result0 = result7; } else { var savedPos0 = pos; - var result3 = parse_object(context); - if (result3 !== null) { - var result4 = parse_predicate(context); - if (result4 !== null) { - var result2 = [result3, result4]; + var result5 = parse_object(context); + if (result5 !== null) { + var result6 = parse_predicate(context); + if (result6 !== null) { + var result4 = [result5, result6]; } else { - var result2 = null; + var result4 = null; pos = savedPos0; } } else { - var result2 = null; + var result4 = null; pos = savedPos0; } - if (result2 !== null) { - var result0 = result2; + var result3 = result4 !== null + ? (function(object, p) {var result={}; result.object=object; if(p.tags != undefined) {result.tags=p.tags} else {result.bbox=p.bbox} return result})(result4[0], result4[1]) + : null; + if (result3 !== null) { + var result0 = result3; } else { - var result1 = parse_object(context); + var result2 = parse_object(context); + var result1 = result2 !== null + ? (function(object) { return {object:object}})(result2) + : null; if (result1 !== null) { var result0 = result1; } else { diff --git a/src/nodejs/alternative/testgrammar b/src/nodejs/alternative/testgrammar index e212493..0e43013 100644 --- a/src/nodejs/alternative/testgrammar +++ b/src/nodejs/alternative/testgrammar @@ -3,7 +3,7 @@ * "2*(3+4)". The parser generated from this grammar then computes their value. */ -url = object:object p1:predicate p2:predicate { var result = {object:object}; if(p1.tags != undefined) {result.tags= p1.tags} else if(p1.bbox != undefined) {result.bbox=p1.bbox;} if(p2.tags != undefined) {result.tags= p2.tags} else if(p2.bbox != undefined) {result.bbox=p2.bbox;} return result;}/ object predicate / object +url = object:object p1:predicate p2:predicate { var result = {object:object}; if(p1.tags != undefined) {result.tags= p1.tags} else if(p1.bbox != undefined) {result.bbox=p1.bbox;} if(p2.tags != undefined) {result.tags= p2.tags} else if(p2.bbox != undefined) {result.bbox=p2.bbox;} return result;}/ object:object p:predicate {var result={}; result.object=object; if(p.tags != undefined) {result.tags=p.tags} else {result.bbox=p.bbox} return result} / object:object { return {object:object}} object = v:"node" {return v} / v:"way" {return v} / v:"relation" {return v} / v:"*" {return v} -- cgit v1.2.3