diff --git a/lib/lexer.js b/lib/lexer.js index 1a4e25e34..2f06915de 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -381,7 +381,7 @@ exports.doID = function(code, index){ this.fset('for', false); this.fset('by', false); } - if (tag === 'RELATION' || tag === 'THEN' || tag === 'ELSE' || tag === 'CASE' || tag === 'DEFAULT' || tag === 'CATCH' || tag === 'FINALLY' || tag === 'IN' || tag === 'OF' || tag === 'FROM' || tag === 'TO' || tag === 'BY' || tag === 'EXTENDS' || tag === 'IMPLEMENTS' || tag === 'WHERE') { + if (tag === 'RELATION' || tag === 'THEN' || tag === 'ELSE' || tag === 'CASE' || tag === 'DEFAULT' || tag === 'CATCH' || tag === 'FINALLY' || tag === 'IN' || tag === 'OF' || tag === 'FROM' || tag === 'TO' || tag === 'BY' || tag === 'EXTENDS' || tag === 'IMPLEMENTS') { this.unline(); } this.token(tag, id); @@ -1528,7 +1528,7 @@ function addImplicitParentheses(tokens){ continue; } } - if (!(((ref1$ = prev[0]) === 'FUNCTION' || ref1$ === 'GENERATOR' || ref1$ === 'LET' || ref1$ === 'WHERE') || prev.spaced && able(tokens, i, true))) { + if (!(((ref1$ = prev[0]) === 'FUNCTION' || ref1$ === 'GENERATOR' || ref1$ === 'LET') || prev.spaced && able(tokens, i, true))) { continue; } if (token.doblock) { @@ -1831,7 +1831,7 @@ function indexOfPair(tokens, i){ KEYWORDS_SHARED = ['true', 'false', 'null', 'this', 'void', 'super', 'return', 'throw', 'break', 'continue', 'if', 'else', 'for', 'while', 'switch', 'case', 'default', 'try', 'catch', 'finally', 'function', 'class', 'extends', 'implements', 'new', 'do', 'delete', 'typeof', 'in', 'instanceof', 'let', 'with', 'var', 'const', 'import', 'export', 'debugger', 'yield']; KEYWORDS_UNUSED = ['enum', 'interface', 'package', 'private', 'protected', 'public', 'static']; JS_KEYWORDS = KEYWORDS_SHARED.concat(KEYWORDS_UNUSED); -LS_KEYWORDS = ['xor', 'match', 'where']; +LS_KEYWORDS = ['xor', 'match']; ID = /((?!\s)[a-z_$\xAA-\uFFDC](?:(?!\s)[\w$\xAA-\uFFDC]|-[a-z])*)([^\n\S]*:(?![:=]))?|/ig; SYMBOL = /[-\/^]=|[%+:*]{1,2}=|\|>=|\.(?:[&\|\^]|<<|>>>?)\.=?|\.{1,3}|\^\^|\*?<(?:--?|~~?)!?|!?(?:--?|~~?)>>?\*?|([-+&|:])\1|%%|&|\([^\n\S]*\)|[!=]==?|!?\~=|@@?|<\[(?:[\s\S]*?\]>)?|<<<]==|<<=|>>=|<<|>>|[<>]\??=?|\|>|\||=>|\*\*|\^|`|[^\s#]?/g; SPACE = /[^\n\S]*(?:#.*)?/g; diff --git a/src/lexer.ls b/src/lexer.ls index 5000cd111..cfe4d5c13 100644 --- a/src/lexer.ls +++ b/src/lexer.ls @@ -285,7 +285,7 @@ exports <<< @fset 'for' false @fset 'by' false @unline! if tag in <[ RELATION THEN ELSE CASE DEFAULT CATCH FINALLY - IN OF FROM TO BY EXTENDS IMPLEMENTS WHERE ]> + IN OF FROM TO BY EXTENDS IMPLEMENTS ]> @token tag, id input.length @@ -1131,7 +1131,7 @@ character = if not JSON? then uxxxx else -> tag is '[' and brackets.push prev.0 is 'DOT' if prev.0 is ']' if brackets.pop! then prev.index = true else continue - continue unless prev.0 in <[ FUNCTION GENERATOR LET WHERE ]> + continue unless prev.0 in <[ FUNCTION GENERATOR LET ]> or prev.spaced and able tokens, i, true if token.doblock token.0 = 'CALL(' @@ -1341,7 +1341,7 @@ KEYWORDS_UNUSED = JS_KEYWORDS = KEYWORDS_SHARED ++ KEYWORDS_UNUSED -LS_KEYWORDS = <[ xor match where ]> +LS_KEYWORDS = <[ xor match ]> ##### Regexes # Some of these are given `g` flag and made sure to match empty string diff --git a/test/declaration.ls b/test/declaration.ls index d6c837342..9c3008cd6 100644 --- a/test/declaration.ls +++ b/test/declaration.ls @@ -105,3 +105,8 @@ eq '''(function(n){ eq '''var ref$; 1 < 2 && 2 === (ref$ = 4 / 2) && ref$ > 0;''' LiveScript.compile '1 < 2 == 4/2 > 0' {+\const, +bare,-header} + + +### former reserved words +where = 1 +eq 1 where