waypoint -- jison has a reverse order of operations from yacc

This commit is contained in:
Jeremy Ashkenas 2010-02-11 23:29:12 -05:00
parent 7c01bba4f4
commit 13c49ad865
5 changed files with 9 additions and 9 deletions

View File

@ -556,7 +556,7 @@
parser = new Parser({ parser = new Parser({
tokens: tokens, tokens: tokens,
bnf: bnf, bnf: bnf,
operators: operators, operators: operators.reverse(),
startSymbol: 'Root' startSymbol: 'Root'
}, { }, {
debug: false debug: false

View File

@ -188,15 +188,15 @@
// toString representation of the node, for inspecting the parse tree. // toString representation of the node, for inspecting the parse tree.
Node.prototype.toString = function toString(idt) { Node.prototype.toString = function toString(idt) {
var __a, __b, __c, child; var __a, __b, __c, child;
idt = idt || ''; idt = (idt || '') + TAB;
return (this.type || 'anon') + "\n" + ((function() { return this.type + "\n" + ((function() {
__a = []; __b = this.children; __a = []; __b = this.children;
for (__c = 0; __c < __b.length; __c++) { for (__c = 0; __c < __b.length; __c++) {
child = __b[__c]; child = __b[__c];
__a.push(idt + TAB + child.toString(idt + TAB)); __a.push(idt + child.toString(idt));
} }
return __a; return __a;
}).call(this)); }).call(this)).join('');
}; };
// Default implementations of the common node methods. // Default implementations of the common node methods.
Node.prototype.unwrap = function unwrap() { Node.prototype.unwrap = function unwrap() {

File diff suppressed because one or more lines are too long

View File

@ -458,7 +458,7 @@ for name, non_terminal of grammar
option[1] = "return " + option[1] option[1] = "return " + option[1]
option option
tokens: tokens.join(" ") tokens: tokens.join(" ")
parser: new Parser({tokens: tokens, bnf: bnf, operators: operators, startSymbol: 'Root'}, {debug: false}) parser: new Parser({tokens: tokens, bnf: bnf, operators: operators.reverse(), startSymbol: 'Root'}, {debug: false})
# Save the parser to a file. # Save the parser to a file.
# puts parser.generate() # puts parser.generate()

View File

@ -105,8 +105,8 @@ Node::contains: (block) ->
# toString representation of the node, for inspecting the parse tree. # toString representation of the node, for inspecting the parse tree.
Node::toString: (idt) -> Node::toString: (idt) ->
idt ||= '' idt: (idt || '') + TAB
(@type || 'anon') + "\n" + (idt + TAB + child.toString(idt + TAB) for child in @children) @type + "\n" + (idt + child.toString(idt) for child in @children).join('')
# Default implementations of the common node methods. # Default implementations of the common node methods.
Node::unwrap: -> this Node::unwrap: -> this