aboutsummaryrefslogtreecommitdiffstats
path: root/parser/src/rst.pest
diff options
context:
space:
mode:
authornitnelave2020-10-25 16:32:35 +0100
committerGitHub2020-10-25 16:32:35 +0100
commit273a69564f03d65c2040b25b68a7ddb2c8aa2087 (patch)
treeed15a7a73e4fb0a6aa309de04e88f5f72050e3ad /parser/src/rst.pest
parent4c487a44208a96e3a23ab8974d224cae489688be (diff)
downloadrust-rst-273a69564f03d65c2040b25b68a7ddb2c8aa2087.tar.bz2
Add support for parsing comments (#23)
Diffstat (limited to 'parser/src/rst.pest')
-rw-r--r--parser/src/rst.pest12
1 files changed, 12 insertions, 0 deletions
diff --git a/parser/src/rst.pest b/parser/src/rst.pest
index 8885109..4329e84 100644
--- a/parser/src/rst.pest
+++ b/parser/src/rst.pest
@@ -20,6 +20,9 @@ hanging_block = _{
| admonition
| admonition_gen
| target
+ // Comments should be below the directives to try to match them first, but
+ // above the title that will interpret ".." as a title marker.
+ | block_comment
| title
| bullet_list
| paragraph
@@ -110,6 +113,15 @@ admonition_gen = { ".." ~ PUSH(" "+) ~ admonition_type ~ "::" ~ (blank_lin
admonition_type = { ^"attention" | ^"caution" | ^"danger" | ^"error" | ^"hint" | ^"important" | ^"note" | ^"tip" | ^"warning" }
admonition_content = _{ PEEK[..-1] ~ PUSH(" " ~ POP) ~ hanging_block ~ block* } //TODO: merge with other directives?
+// Comments.
+
+block_comment = {
+ ".." ~ PUSH(" "*) ~ comment_title? ~ NEWLINE? ~ comment_block? ~ (" "* ~ NEWLINE)* ~ DROP
+}
+comment_title = { (!NEWLINE ~ ANY)+ }
+comment_block = { (comment_line_blank* ~ PEEK[..] ~ comment_line)+ }
+comment_line_blank = { " "* ~ NEWLINE }
+comment_line = { " "+ ~ (!NEWLINE ~ ANY)+ ~ NEWLINE }
/*