coffee-lex
Advanced tools
Comparing version
@@ -592,2 +592,3 @@ var babelHelpers = {}; | ||
pending.unshift.apply(pending, babelHelpers.toConsumableArray(stringLocationsFromStream(pending))); | ||
pending.unshift.apply(pending, babelHelpers.toConsumableArray(combinedLocationsForMultiwordOperators(pending, source))); | ||
location = pending.shift(); | ||
@@ -658,2 +659,28 @@ if (previousLocation && previousLocation.type !== SPACE) { | ||
function combinedLocationsForMultiwordOperators(stream, source) { | ||
if (!stream.hasNext(OPERATOR, SPACE, OPERATOR) && !stream.hasNext(OPERATOR, SPACE, RELATION)) { | ||
return []; | ||
} | ||
var not = stream.shift(); | ||
var space = stream.shift(); | ||
var operator = stream.shift(); | ||
var next = stream.peek(); | ||
if (source.slice(not.index, space.index) === 'not') { | ||
var op = source.slice(operator.index, next.index); | ||
switch (op) { | ||
case 'in': | ||
case 'of': | ||
return [new SourceLocation(RELATION, not.index)]; | ||
case 'instanceof': | ||
return [new SourceLocation(OPERATOR, not.index)]; | ||
} | ||
} | ||
// Doesn't match, so put them back. | ||
return [not, space, operator]; | ||
} | ||
var BufferedStream = function () { | ||
@@ -743,2 +770,3 @@ function BufferedStream(stream) { | ||
var RBRACKET = new SourceType('RBRACKET'); | ||
var RELATION = new SourceType('RELATION'); | ||
var RETURN = new SourceType('RETURN'); | ||
@@ -853,2 +881,3 @@ var RPAREN = new SourceType('RPAREN'); | ||
case RETURN: | ||
case RELATION: | ||
case CONTINUATION: | ||
@@ -980,2 +1009,7 @@ if (consume(SPACE_PATTERN)) { | ||
case 'in': | ||
case 'of': | ||
setType(RELATION); | ||
break; | ||
default: | ||
@@ -1205,2 +1239,2 @@ setType(IDENTIFIER); | ||
export { AT, BOOL, COLON, COMMA, COMMENT, CONTINUATION, DELETE, DOT, DSTRING, ELSE, EOF, EXISTENCE, FUNCTION, HERECOMMENT, HEREGEXP, IF, INTERPOLATION_START, INTERPOLATION_END, JS, LBRACE, LBRACKET, LPAREN, NEWLINE, NORMAL, NULL, NUMBER, OPERATOR, PROTO, RANGE, REGEXP, RBRACE, RBRACKET, RETURN, RPAREN, SEMICOLON, SPACE, SSTRING, SUPER, SWITCH, TDSTRING, STRING_CONTENT, STRING_END, STRING_START, THEN, THIS, TSSTRING, UNDEFINED, UNKNOWN, WHEN, IDENTIFIER, stream, consumeStream };export default lex; | ||
export { AT, BOOL, COLON, COMMA, COMMENT, CONTINUATION, DELETE, DOT, DSTRING, ELSE, EOF, EXISTENCE, FUNCTION, HERECOMMENT, HEREGEXP, IF, INTERPOLATION_START, INTERPOLATION_END, JS, LBRACE, LBRACKET, LPAREN, NEWLINE, NORMAL, NULL, NUMBER, OPERATOR, PROTO, RANGE, REGEXP, RBRACE, RBRACKET, RELATION, RETURN, RPAREN, SEMICOLON, SPACE, SSTRING, SUPER, SWITCH, TDSTRING, STRING_CONTENT, STRING_END, STRING_START, THEN, THIS, TSSTRING, UNDEFINED, UNKNOWN, WHEN, IDENTIFIER, stream, consumeStream };export default lex; |
@@ -598,2 +598,3 @@ (function (global, factory) { | ||
pending.unshift.apply(pending, babelHelpers.toConsumableArray(stringLocationsFromStream(pending))); | ||
pending.unshift.apply(pending, babelHelpers.toConsumableArray(combinedLocationsForMultiwordOperators(pending, source))); | ||
location = pending.shift(); | ||
@@ -664,2 +665,28 @@ if (previousLocation && previousLocation.type !== SPACE) { | ||
function combinedLocationsForMultiwordOperators(stream, source) { | ||
if (!stream.hasNext(OPERATOR, SPACE, OPERATOR) && !stream.hasNext(OPERATOR, SPACE, RELATION)) { | ||
return []; | ||
} | ||
var not = stream.shift(); | ||
var space = stream.shift(); | ||
var operator = stream.shift(); | ||
var next = stream.peek(); | ||
if (source.slice(not.index, space.index) === 'not') { | ||
var op = source.slice(operator.index, next.index); | ||
switch (op) { | ||
case 'in': | ||
case 'of': | ||
return [new SourceLocation(RELATION, not.index)]; | ||
case 'instanceof': | ||
return [new SourceLocation(OPERATOR, not.index)]; | ||
} | ||
} | ||
// Doesn't match, so put them back. | ||
return [not, space, operator]; | ||
} | ||
var BufferedStream = function () { | ||
@@ -749,2 +776,3 @@ function BufferedStream(stream) { | ||
var RBRACKET = new SourceType('RBRACKET'); | ||
var RELATION = new SourceType('RELATION'); | ||
var RETURN = new SourceType('RETURN'); | ||
@@ -859,2 +887,3 @@ var RPAREN = new SourceType('RPAREN'); | ||
case RETURN: | ||
case RELATION: | ||
case CONTINUATION: | ||
@@ -986,2 +1015,7 @@ if (consume(SPACE_PATTERN)) { | ||
case 'in': | ||
case 'of': | ||
setType(RELATION); | ||
break; | ||
default: | ||
@@ -1245,2 +1279,3 @@ setType(IDENTIFIER); | ||
exports.RBRACKET = RBRACKET; | ||
exports.RELATION = RELATION; | ||
exports.RETURN = RETURN; | ||
@@ -1247,0 +1282,0 @@ exports.RPAREN = RPAREN; |
{ | ||
"name": "coffee-lex", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Stupid lexer for CoffeeScript.", | ||
@@ -5,0 +5,0 @@ "main": "dist/coffee-lex.umd.js", |
77525
2.79%2200
2.66%