mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
removed support for '->*" and '=>*'
This commit is contained in:
@@ -189,15 +189,11 @@ grammar =
|
||||
o 'FuncGlyph Block', -> new Code [], $2, $1
|
||||
]
|
||||
|
||||
# CoffeeScript has two different symbols for functions and two different
|
||||
# symbols for generators. `->` and `->*` are for ordinary functions and
|
||||
# generators, and `=>` and `=>*` ares for functions and generators bound to
|
||||
# the current value of *this*.
|
||||
# CoffeeScript has two different symbols for functions. `->` is for ordinary
|
||||
# functions, and `=>` is for functions bound to the current value of *this*.
|
||||
FuncGlyph: [
|
||||
o '->', -> 'func'
|
||||
o '->*', -> 'generator'
|
||||
o '=>', -> 'boundfunc'
|
||||
o '=>*', -> 'boundgenerator'
|
||||
]
|
||||
|
||||
# An optional, trailing comma.
|
||||
|
||||
@@ -99,9 +99,8 @@ exports.Lexer = class Lexer
|
||||
# referenced as property names here, so you can still do `jQuery.is()` even
|
||||
# though `is` means `===` otherwise.
|
||||
identifierToken: ->
|
||||
return 0 unless match = /^yield\*/.exec(@chunk) or IDENTIFIER.exec @chunk
|
||||
return 0 unless match = IDENTIFIER.exec @chunk
|
||||
[input, id, colon] = match
|
||||
if input is 'yield*' then id = 'yield*'
|
||||
|
||||
# Preserve length of id for location data
|
||||
idLength = id.length
|
||||
@@ -730,7 +729,7 @@ exports.Lexer = class Lexer
|
||||
JS_KEYWORDS = [
|
||||
'true', 'false', 'null', 'this'
|
||||
'new', 'delete', 'typeof', 'in', 'instanceof'
|
||||
'return', 'throw', 'break', 'continue', 'debugger', 'yield', 'yield*'
|
||||
'return', 'throw', 'break', 'continue', 'debugger', 'yield'
|
||||
'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally'
|
||||
'class', 'extends', 'super'
|
||||
]
|
||||
@@ -790,7 +789,7 @@ NUMBER = ///
|
||||
HEREDOC = /// ^ ("""|''') ((?: \\[\s\S] | [^\\] )*?) (?:\n[^\n\S]*)? \1 ///
|
||||
|
||||
OPERATOR = /// ^ (
|
||||
?: [-=]>\*? # function / generator
|
||||
?: [-=]> # function
|
||||
| [-+*/%<>&|^!?=]= # compound assign / compare
|
||||
| >>>=? # zero-fill right shift
|
||||
| ([-+:])\1 # doubles
|
||||
@@ -803,7 +802,7 @@ WHITESPACE = /^[^\n\S]+/
|
||||
|
||||
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/
|
||||
|
||||
CODE = /^[-=]>\*?/
|
||||
CODE = /^[-=]>/
|
||||
|
||||
MULTI_DENT = /^(?:\n[^\n\S]*)+/
|
||||
|
||||
@@ -852,7 +851,7 @@ COMPOUND_ASSIGN = [
|
||||
]
|
||||
|
||||
# Unary tokens.
|
||||
UNARY = ['NEW', 'TYPEOF', 'DELETE', 'DO', 'YIELD', 'YIELD*']
|
||||
UNARY = ['NEW', 'TYPEOF', 'DELETE', 'DO', 'YIELD']
|
||||
|
||||
UNARY_MATH = ['!', '~']
|
||||
|
||||
|
||||
@@ -1314,10 +1314,12 @@ exports.Assign = class Assign extends Base
|
||||
# has no *children* -- they're within the inner scope.
|
||||
exports.Code = class Code extends Base
|
||||
constructor: (params, body, tag) ->
|
||||
@params = params or []
|
||||
@body = body or new Block
|
||||
@bound = tag is 'boundfunc' or tag is 'boundgenerator'
|
||||
@generator = tag is 'generator' or tag is 'boundgenerator'
|
||||
@params = params or []
|
||||
@body = body or new Block
|
||||
@bound = tag is 'boundfunc'
|
||||
@isGenerator = false
|
||||
@body.traverseChildren false, (child) =>
|
||||
@isGenerator = true if child.operator is 'yield'
|
||||
|
||||
children: ['params', 'body']
|
||||
|
||||
@@ -1385,7 +1387,7 @@ exports.Code = class Code extends Base
|
||||
uniqs.push name
|
||||
@body.makeReturn() unless wasEmpty or @noReturn
|
||||
code = 'function'
|
||||
code += '*' if @generator
|
||||
code += '*' if @isGenerator
|
||||
code += ' ' + @name if @ctor
|
||||
code += '('
|
||||
answer = [@makeCode(code)]
|
||||
@@ -1738,8 +1740,8 @@ exports.Op = class Op extends Base
|
||||
if o.level >= LEVEL_ACCESS
|
||||
return (new Parens this).compileToFragments o
|
||||
plusMinus = op in ['+', '-']
|
||||
parts.push [@makeCode(' ')] if op in ['new', 'typeof', 'delete', 'yield'
|
||||
'yield*'] or plusMinus and @first instanceof Op and @first.operator is op
|
||||
parts.push [@makeCode(' ')] if op in ['new', 'typeof', 'delete', 'yield', 'yield*'] or
|
||||
plusMinus and @first instanceof Op and @first.operator is op
|
||||
if (plusMinus and @first instanceof Op) or (op is 'new' and @first.isStatement o)
|
||||
@first = new Parens @first
|
||||
parts.push @first.compileToFragments o, LEVEL_OP
|
||||
|
||||
@@ -185,8 +185,7 @@ class exports.Rewriter
|
||||
# 1. We have seen a `CONTROL` argument on the line.
|
||||
# 2. The last token before the indent is part of the list below
|
||||
#
|
||||
if prevTag not in ['=>', '->', '=>*', '->*', '[', '(', ',', '{',
|
||||
'TRY', 'ELSE', '=']
|
||||
if prevTag not in ['=>', '->', '[', '(', ',', '{', 'TRY', 'ELSE', '=']
|
||||
endImplicitCall() while inImplicitCall()
|
||||
stack.pop() if inImplicitControl()
|
||||
stack.push [tag, i]
|
||||
@@ -366,8 +365,8 @@ class exports.Rewriter
|
||||
token[1] isnt ';' and token[0] in SINGLE_CLOSERS and
|
||||
not (token[0] is 'TERMINATOR' and @tag(i + 1) in EXPRESSION_CLOSE) and
|
||||
not (token[0] is 'ELSE' and starter isnt 'THEN') and
|
||||
not (token[0] in ['CATCH', 'FINALLY'] and starter in ['->', '=>', '->*',
|
||||
'=>*']) or token[0] in CALL_CLOSERS and @tokens[i - 1].newLine
|
||||
not (token[0] in ['CATCH', 'FINALLY'] and starter in ['->', '=>']) or
|
||||
token[0] in CALL_CLOSERS and @tokens[i - 1].newLine
|
||||
|
||||
action = (token, i) ->
|
||||
@tokens.splice (if @tag(i - 1) is ',' then i - 1 else i), 0, outdent
|
||||
@@ -468,7 +467,7 @@ IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@
|
||||
# If preceded by an `IMPLICIT_FUNC`, indicates a function invocation.
|
||||
IMPLICIT_CALL = [
|
||||
'IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS'
|
||||
'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY',
|
||||
'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY'
|
||||
'UNARY_MATH', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++'
|
||||
]
|
||||
|
||||
@@ -480,7 +479,7 @@ IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY',
|
||||
|
||||
# Single-line flavors of block expressions that have unclosed endings.
|
||||
# The grammar can't disambiguate them, so we insert the implicit indentation.
|
||||
SINGLE_LINERS = ['ELSE', '->', '=>', '->*', '=>*', 'TRY', 'FINALLY', 'THEN']
|
||||
SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN']
|
||||
SINGLE_CLOSERS = ['TERMINATOR', 'CATCH', 'FINALLY', 'ELSE', 'OUTDENT', 'LEADING_WHEN']
|
||||
|
||||
# Tokens that end a line.
|
||||
|
||||
Reference in New Issue
Block a user