diff options
Diffstat (limited to 'script/parser/luadoc.lua')
-rw-r--r-- | script/parser/luadoc.lua | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index f6de87fd..195ea815 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -3,7 +3,7 @@ local re = require 'parser.relabel' local guide = require 'parser.guide' local parser = require 'parser.newparser' -local TokenTypes, TokenStarts, TokenFinishs, TokenContents +local TokenTypes, TokenStarts, TokenFinishs, TokenContents, TokenMarks local Ci, Offset, pushError, NextComment, Lines local parseType local Parser = re.compile([[ @@ -18,15 +18,15 @@ Integer <- ({} {[0-9]+} !'.' {}) -> Integer String <- ({} StringDef {}) -> String -StringDef <- '"' +StringDef <- {'"'} {~(Esc / !'"' .)*~} -> 1 ('"'?) - / "'" + / {"'"} {~(Esc / !"'" .)*~} -> 1 ("'"?) - / ('[' {:eq: '='* :} '[' + / {'[' {:eq: '='* :} '['} {(!StringClose .)*} -> 1 - (StringClose?)) + StringClose? StringClose <- ']' =eq ']' Esc <- '\' -> '' EChar @@ -92,12 +92,13 @@ Symbol <- ({} { TokenFinishs[Ci] = finish - 1 TokenContents[Ci] = content end, - String = function (start, content, finish) + String = function (start, mark, content, finish) Ci = Ci + 1 TokenTypes[Ci] = 'string' TokenStarts[Ci] = start TokenFinishs[Ci] = finish - 1 TokenContents[Ci] = content + TokenMarks[Ci] = mark end, Integer = function (start, content, finish) Ci = Ci + 1 @@ -126,6 +127,7 @@ local function parseTokens(text, offset) TokenStarts = {} TokenFinishs = {} TokenContents = {} + TokenMarks = {} Parser:match(text) Ci = 0 end @@ -163,6 +165,10 @@ local function getFinish() return TokenFinishs[Ci] + Offset + 1 end +local function getMark() + return TokenMarks[Ci] +end + local function try(callback) local savePoint = Ci -- rollback @@ -1077,6 +1083,7 @@ local function parseModule() nextToken() result.start = getStart() result.finish = getFinish() + result.smark = getMark() else pushError { type = 'LUADOC_MISS_MODULE_NAME', |