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.
--]=]--
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","--[[--"]
],[
["bracketedComment",4,"start"],
["bracketedComment",2,"start"],
["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."]
],[
"start",
@ -301,10 +301,10 @@
],[
"start"
],[
["bracketedComment",5,"start"],
["bracketedComment",3,"start"],
["comment","--[=[--"]
],[
["bracketedComment",5,"start"],
["bracketedComment",3,"start"],
["comment","table.maxn is deprecated, use # instead."]
],[
"start",
@ -337,4 +337,12 @@
["comment","-- outputs 8 instead of 2"]
],[
"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.r",">"]
],[
["lua-bracketedComment",4,"lua-start"],
["lua-bracketedComment",2,"lua-start"],
["keyword","<%"],
["text"," "],
["comment","--[[--"]
],[
["lua-bracketedComment",4,"lua-start"],
["lua-bracketedComment",2,"lua-start"],
["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/"]
],[
"start",

View file

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