Building with latest version of Jison.

This commit is contained in:
Jeremy Ashkenas 2010-11-13 15:10:12 -05:00
parent 354708dbc2
commit f0b73dc9f5
2 changed files with 12 additions and 16 deletions

View File

@ -1,5 +1,6 @@
fs = require 'fs'
path = require 'path'
{extend} = require './lib/helpers'
CoffeeScript = require './lib/coffee-script'
{spawn, exec} = require 'child_process'
@ -65,6 +66,7 @@ task 'build:full', 'rebuild the source twice, and run the tests', ->
task 'build:parser', 'rebuild the Jison parser (run build first)', ->
extend global, require('utils')
require 'jison'
parser = require('./lib/grammar').parser
fs.writeFile 'lib/parser.js', parser.generate()

View File

@ -511,13 +511,6 @@ parse: function parse(input) {
vstack.length = vstack.length - n;
}
function checkRecover (st) {
for (var p in table[st]) if (p == TERROR) {
return true;
}
return false;
}
function lex() {
var token;
token = self.lexer.lex() || 1; // $end = 1
@ -552,21 +545,22 @@ parse: function parse(input) {
for (p in table[state]) if (this.terminals_[p] && p > 2) {
expected.push("'"+this.terminals_[p]+"'");
}
var errStr = '';
if (this.lexer.showPosition) {
parseError.call(this, 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+'\nExpecting '+expected.join(', '),
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, expected: expected});
errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+'\nExpecting '+expected.join(', ');
} else {
var errStr = symbol == 1 /*EOF*/ ? "end of input" :
("'"+(this.terminals_[symbol] || symbol)+"'");
parseError.call(this, 'Parse error on line '+(yylineno+1)+": Unexpected "+errStr,
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, expected: expected});
errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
(symbol == 1 /*EOF*/ ? "end of input" :
("'"+(this.terminals_[symbol] || symbol)+"'"));
}
parseError.call(this, errStr,
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, expected: expected});
}
// just recovered from another error
if (recovering == 3) {
if (symbol == EOF) {
throw 'Parsing halted.'
throw new Error(errStr || 'Parsing halted.');
}
// discard current lookahead and grab another
@ -579,11 +573,11 @@ parse: function parse(input) {
// try to recover from error
while (1) {
// check for error recovery rule in this state
if (checkRecover(state)) {
if ((TERROR.toString()) in table[state]) {
break;
}
if (state == 0) {
throw 'Parsing halted.'
throw new Error(errStr || 'Parsing halted.');
}
popStack(1);
state = stack[stack.length-1];