summaryrefslogtreecommitdiff
path: root/rst_parser.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-16 22:55:25 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-16 22:55:25 +0200
commit279c04787d18e186c6c1c6bed2eb9002f8f0ec92 (patch)
tree3f0bb121930683217b6c2adc98a4df42aa2ba518 /rst_parser.lua
parenteb4c6f0b9ab96b75b944ea6b13c344c58840efb0 (diff)
downloadcontext-rst-279c04787d18e186c6c1c6bed2eb9002f8f0ec92.tar.gz
talked to the comments. still haunted by a bug whenever the first comment of comment block is line comment and there’s no blank succeding it. otherwise they’re behaving rationally.
Diffstat (limited to 'rst_parser.lua')
-rw-r--r--rst_parser.lua49
1 files changed, 14 insertions, 35 deletions
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