mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fix failing parser error message test
This commit is contained in:
parent
44e3a76881
commit
fbc8417263
3 changed files with 10 additions and 11 deletions
|
@ -169,10 +169,10 @@
|
||||||
parser.yy = require('./nodes');
|
parser.yy = require('./nodes');
|
||||||
|
|
||||||
parser.yy.parseError = function(message, _arg) {
|
parser.yy.parseError = function(message, _arg) {
|
||||||
var first_column, first_line, last_column, last_line, loc, token;
|
var first_column, first_line, last_column, last_line, token, _ref;
|
||||||
loc = _arg.loc, token = _arg.token;
|
token = _arg.token;
|
||||||
message = "unexpected " + token;
|
message = "unexpected " + token;
|
||||||
first_line = loc.first_line, first_column = loc.first_column, last_line = loc.last_line, last_column = loc.last_column;
|
_ref = parser.lexer.yylloc, first_line = _ref.first_line, first_column = _ref.first_column, last_line = _ref.last_line, last_column = _ref.last_column;
|
||||||
throw new CompilerError(message, first_line, first_column, last_line, last_column);
|
throw new CompilerError(message, first_line, first_column, last_line, last_column);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -137,13 +137,13 @@ parser.lexer =
|
||||||
parser.yy = require './nodes'
|
parser.yy = require './nodes'
|
||||||
|
|
||||||
# Override Jison's default error handling function.
|
# Override Jison's default error handling function.
|
||||||
parser.yy.parseError = (message, {loc, token}) ->
|
parser.yy.parseError = (message, {token}) ->
|
||||||
# Disregard Jison's message, it contains redundant line numer information.
|
# Disregard Jison's message, it contains redundant line numer information.
|
||||||
message = "unexpected #{token}"
|
message = "unexpected #{token}"
|
||||||
|
|
||||||
# FIXME The `loc` received does not correspond to the `token` token, but to
|
# The second argument has a `loc` property, which should have the location
|
||||||
# the one before it instead. That's why the test in error_messages.coffee is
|
# data for this token. Unfortunately, Jison seems to send an outdated `loc`
|
||||||
# failing. There should be a way to get the location data... maybe accessing
|
# (from the previous token), so we take the location information directly
|
||||||
# the lexer's tokens?
|
# from the lexer.
|
||||||
{first_line, first_column, last_line, last_column} = loc
|
{first_line, first_column, last_line, last_column} = parser.lexer.yylloc
|
||||||
throw new CompilerError message, first_line, first_column, last_line, last_column
|
throw new CompilerError message, first_line, first_column, last_line, last_column
|
|
@ -20,13 +20,12 @@ test "lexer errors formating", ->
|
||||||
^
|
^
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# FIXME Test not passing. See "parser.yy.parseError" in coffee-script.coffee
|
|
||||||
test "parser error formating", ->
|
test "parser error formating", ->
|
||||||
assertErrorFormat '''
|
assertErrorFormat '''
|
||||||
foo in bar or in baz
|
foo in bar or in baz
|
||||||
''',
|
''',
|
||||||
'''
|
'''
|
||||||
test.coffee:1:12: error: unexpected RELATION
|
test.coffee:1:15: error: unexpected RELATION
|
||||||
foo in bar or in baz
|
foo in bar or in baz
|
||||||
^^
|
^^
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Add table
Reference in a new issue