From 5a9490c529fd711555f6dda702593602fc08d404 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 4 Sep 2010 11:12:29 +0200 Subject: commented blocks --- rst_parser.lua | 67 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 27 deletions(-) (limited to 'rst_parser.lua') diff --git a/rst_parser.lua b/rst_parser.lua index 5b6a1e9..6466b81 100644 --- a/rst_parser.lua +++ b/rst_parser.lua @@ -193,11 +193,12 @@ local parser = P{ -------------------------------------------------------------------------------- block = V"target_block" + + V"comment" + Cs(V"section") / rst.escape + Cs(V"transition") --/ rst.escape + Cs(V"list") / rst.escape + Cs(V"paragraph") / rst.escape - + V"comment", + , -------------------------------------------------------------------------------- -- Lists @@ -232,29 +233,6 @@ local parser = P{ field_body = C(V"rest_of_line" * V"eol" * V"indented_lines"^-1), - indented_lines = V"indented_first" - * (V"indented_other" - - V"field_marker")^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 - tracklists.currentindent = indent - return true - end) - * V"rest_of_line" - * V"eol", - - indented_other = Cmt(V"space"^1, function (s, i, indent) - warn("idt-m", indent, tracklists.currentindent, indent == tracklists.currentindent, i) - return indent == tracklists.currentindent - end) - * V"rest_of_line" - * V"eol", - -------------------------------------------------------------------------------- -- Definition lists -------------------------------------------------------------------------------- @@ -600,9 +578,44 @@ local parser = P{ -- Comments -------------------------------------------------------------------------------- - comment = Cs(V"doubledot" - * (1 - V"eol")^0 - * V"eol") / ">>comment<<", + comment = V"block_comment" + V"line_comment", + + block_comment = V"doubledot" * V"whitespace"^0 * V"eol" + * Cs(V"indented_lines") + * V"eol"^0 + --* V"blank_line"^0 + / rst.block_comment, + + line_comment = V"doubledot" * V"whitespace"^0 + * 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, + + indented_first = Cmt(V"space"^1, function (s, i, indent) + warn("idt-f", indent, i) + if not indent or + indent == "" then + return false + end + tracklists.currentindent = indent + return true + end) + * V"rest_of_line" + * V"eol", + + indented_other = Cmt(V"space"^1, function (s, i, indent) + warn("idt-m", indent, tracklists.currentindent, indent == tracklists.currentindent, i) + return indent == tracklists.currentindent + end) + * V"rest_of_line" + * V"eol", -------------------------------------------------------------------------------- -- Urls -- cgit v1.2.3