fix #1490 Parsing Lua comments in the middle of line

This commit is contained in:
nightwing 2013-06-26 20:23:58 +04:00
commit f1e809294c
4 changed files with 21 additions and 11 deletions

View file

@ -34,3 +34,5 @@ print([===[
table.maxn is deprecated, use # instead. table.maxn is deprecated, use # instead.
--]=]-- --]=]--
print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2 print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2
print(5 --[[ blah ]])

View file

@ -1,11 +1,11 @@
[[ [[
["bracketedComment",4,"start"], ["bracketedComment",2,"start"],
["comment","--[[--"] ["comment","--[[--"]
],[ ],[
["bracketedComment",4,"start"], ["bracketedComment",2,"start"],
["comment","num_args takes in 5.1 byte code and extracts the number of arguments"] ["comment","num_args takes in 5.1 byte code and extracts the number of arguments"]
],[ ],[
["bracketedComment",4,"start"], ["bracketedComment",2,"start"],
["comment","from its function header."] ["comment","from its function header."]
],[ ],[
"start", "start",
@ -301,10 +301,10 @@
],[ ],[
"start" "start"
],[ ],[
["bracketedComment",5,"start"], ["bracketedComment",3,"start"],
["comment","--[=[--"] ["comment","--[=[--"]
],[ ],[
["bracketedComment",5,"start"], ["bracketedComment",3,"start"],
["comment","table.maxn is deprecated, use # instead."] ["comment","table.maxn is deprecated, use # instead."]
],[ ],[
"start", "start",
@ -337,4 +337,12 @@
["comment","-- outputs 8 instead of 2"] ["comment","-- outputs 8 instead of 2"]
],[ ],[
"start" "start"
],[
"start",
["support.function","print"],
["paren.lparen","("],
["constant.numeric","5"],
["text"," "],
["comment","--[[ blah ]]"],
["paren.rparen",")"]
]] ]]

View file

@ -21,15 +21,15 @@
["meta.tag.tag-name","html"], ["meta.tag.tag-name","html"],
["meta.tag.r",">"] ["meta.tag.r",">"]
],[ ],[
["lua-bracketedComment",4,"lua-start"], ["lua-bracketedComment",2,"lua-start"],
["keyword","<%"], ["keyword","<%"],
["text"," "], ["text"," "],
["comment","--[[--"] ["comment","--[[--"]
],[ ],[
["lua-bracketedComment",4,"lua-start"], ["lua-bracketedComment",2,"lua-start"],
["comment"," index.lp from the Kepler Project's LuaDoc HTML doclet."] ["comment"," index.lp from the Kepler Project's LuaDoc HTML doclet."]
],[ ],[
["lua-bracketedComment",4,"lua-start"], ["lua-bracketedComment",2,"lua-start"],
["comment"," http://keplerproject.github.com/luadoc/"] ["comment"," http://keplerproject.github.com/luadoc/"]
],[ ],[
"start", "start",

View file

@ -99,7 +99,7 @@ var LuaHighlightRules = function() {
"start" : [{ "start" : [{
stateName: "bracketedComment", stateName: "bracketedComment",
onMatch : function(value, currentState, stack){ onMatch : function(value, currentState, stack){
stack.unshift(this.next, value.length, currentState); stack.unshift(this.next, value.length - 2, currentState);
return "comment"; return "comment";
}, },
regex : /\-\-\[=*\[/, regex : /\-\-\[=*\[/,
@ -115,7 +115,7 @@ var LuaHighlightRules = function() {
} }
return "comment"; return "comment";
}, },
regex : /(?:[^\\]|\\.)*?\]=*\]/, regex : /\]=*\]/,
next : "start" next : "start"
}, { }, {
defaultToken : "comment" defaultToken : "comment"
@ -147,7 +147,7 @@ var LuaHighlightRules = function() {
return "comment"; return "comment";
}, },
regex : /(?:[^\\]|\\.)*?\]=*\]/, regex : /\]=*\]/,
next : "start" next : "start"
}, { }, {
defaultToken : "comment" defaultToken : "comment"