From 279c04787d18e186c6c1c6bed2eb9002f8f0ec92 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 16 Sep 2010 22:55:25 +0200 Subject: =?UTF-8?q?talked=20to=20the=20comments.=20still=20haunted=20by=20?= =?UTF-8?q?a=20bug=20whenever=20the=20first=20comment=20of=20comment=20blo?= =?UTF-8?q?ck=20is=20line=20comment=20and=20there=E2=80=99s=20no=20blank?= =?UTF-8?q?=20succeding=20it.=20otherwise=20they=E2=80=99re=20behaving=20r?= =?UTF-8?q?ationally.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rst_parser.lua | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) (limited to 'rst_parser.lua') diff --git a/rst_parser.lua b/rst_parser.lua index f09e959..0901de4 100644 --- a/rst_parser.lua +++ b/rst_parser.lua @@ -36,8 +36,6 @@ local warn = function(str, ...) return 0 end -local debugme = function(x) print ("HERE >"..x.."<") return x end - local C, Cb, Cc, Cg, Cmt, Cp, Cs, Ct = lpeg.C, lpeg.Cb, lpeg.Cc, lpeg.Cg, lpeg.Cmt, lpeg.Cp, lpeg.Cs, lpeg.Ct @@ -108,7 +106,7 @@ local parser = P{ + Cs(V"transition") --/ rst.escape + V"literal_block" + Cs(V"block_quote") / rst.escape - + V"comment" + + V"comment_block" + Cs(V"paragraph") / rst.escape , @@ -121,15 +119,8 @@ local parser = P{ explicit_markup = V"footnote_block" --+ V"directive" + V"substitution_definition" - --+ V"comment block" , - --explicit_markup = V"substitution_definition" - ----+ V"directive" - --+ V"footnote_block" - ----+ V"comment block" - --, - explicit_markup_block = V"explicit_markup"^1 * V"end_block" , @@ -146,7 +137,6 @@ local parser = P{ * C((1 - V"colon" - V"space" - V"eol")^1) -- directive * V"double_colon" * Ct(V"data_directive_block") - --* V"blank_line"^-1 / rst.substitution_definition , @@ -1055,33 +1045,34 @@ local parser = P{ -- Comments -------------------------------------------------------------------------------- - --comment_block = V"comment" * (V"blank_line"^-1 * V"comment")^0, - comment = (V"double_dot" * V"whitespace"^0) / "" - * ((V"block_comment" + V"line_comment") - V"footnote_marker" - V"bar") + comment_block = V"comment"^1 + * V"end_block" + , + + comment = V"double_dot" / "" + * (V"block_comment" + V"line_comment") , block_comment = V"eol" * Cs(V"indented_lines") - * V"end_block" / rst.block_comment, - line_comment = Cs((1 - V"eol")^0 * V"eol") * V"end_block"^-1 - / rst.line_comment, + line_comment = V"whitespace"^1 + * Cs((1 - V"eol")^0 * V"eol") + / rst.line_comment + , -------------------------------------------------------------------------------- -- Generic indented block -------------------------------------------------------------------------------- indented_lines = V"indented_first" - * (V"indented_other" - - V"blank_line" - V"field_marker")^0, + * (V"indented_other"^0 + * (V"blank_line" * V"indented_other"^1)^0) + , indented_first = Cmt(V"space"^1, function (s, i, indent) warn("idt-f", indent, i) - --if not indent or - --indent == "" then - --return false - --end state.currentindent = indent return true end) @@ -1310,18 +1301,6 @@ local function main() else return 1 end - - --for i,j in next, rst.context_references do - --print(i,j[1], j[2]) - --end - - --print(">>>Last used char>: " ..state.lastbullet.." <<<<") - --print(">>>Max list nestin>: "..state.bullets.max .." <<<<") - - --for i,j in next, rst.collected_references do - --print (string.format("== %7s => %s <=", i,j)) - --end - --parser:print() return 0 end -- cgit v1.2.3