fix function regexp
This commit is contained in:
parent
706652048f
commit
ffa0331542
2 changed files with 15 additions and 2 deletions
|
|
@ -87,6 +87,8 @@ define(function(require, exports, module) {
|
||||||
"variable.language": variableLanguage
|
"variable.language": variableLanguage
|
||||||
}, "identifier");
|
}, "identifier");
|
||||||
|
|
||||||
|
var functionRe = "(\\()([^)#]*)(\\))(\\s*)([\\-=]>)"
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
start : [
|
start : [
|
||||||
{
|
{
|
||||||
|
|
@ -160,7 +162,7 @@ define(function(require, exports, module) {
|
||||||
"entity.name.function", "text", "keyword.operator", "text",
|
"entity.name.function", "text", "keyword.operator", "text",
|
||||||
"paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"
|
"paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"
|
||||||
],
|
],
|
||||||
regex : "(" + identifier + ")(\\s*)(=|:)(\\s*)(\\()([^)]*)(\\))(\\s*)([\\-=]>)"
|
regex : "(" + identifier + ")(\\s*)(=|:)(\\s*)" + functionRe
|
||||||
}, {
|
}, {
|
||||||
//play = ->
|
//play = ->
|
||||||
//play : ->
|
//play : ->
|
||||||
|
|
@ -173,7 +175,7 @@ define(function(require, exports, module) {
|
||||||
token : [
|
token : [
|
||||||
"paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"
|
"paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"
|
||||||
],
|
],
|
||||||
regex : "(\\()([^)]*)(\\))(\\s*)([\\-=]>)"
|
regex : functionRe
|
||||||
}, {
|
}, {
|
||||||
token : "identifier",
|
token : "identifier",
|
||||||
regex : "(?:(?:\\.|::)\\s*)" + identifier
|
regex : "(?:(?:\\.|::)\\s*)" + identifier
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,17 @@ module.exports = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"test: tokenize function(invalid code): 'foo:(args#) ->'": function() {
|
||||||
|
var tokens = this.tokenizer.getLineTokens("foo:(args#) ->", "start").tokens;
|
||||||
|
assert.equal(tokens.length, 5);
|
||||||
|
[
|
||||||
|
"identifier", "punctuation.operator", "paren.lparen", "identifier", "comment"
|
||||||
|
].forEach(function(type, i) {
|
||||||
|
assert.equal(tokens[i].type, type);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
"test: tokenize function: '(args) ->'": function() {
|
"test: tokenize function: '(args) ->'": function() {
|
||||||
var tokens = this.tokenizer.getLineTokens("(args) ->", "start").tokens;
|
var tokens = this.tokenizer.getLineTokens("(args) ->", "start").tokens;
|
||||||
assert.equal(tokens.length, 5);
|
assert.equal(tokens.length, 5);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue