// Block rules
+ Rule.Action reduce_paragraph = () => {
+ var head = (Paragraph) pop ();
+ ((BlockContent) peek ()).content.add (head);
+
+ Text last_element = head.content.last () as Text;
+ if (last_element != null) {
+ last_element.content._chomp ();
+ }
+ };
+
Rule paragraph =
Rule.seq ({
Rule.option ({
})
.set_name ("Paragraph")
.set_start (() => { push (_factory.create_paragraph ()); })
- .set_reduce (() => {
- var head = (Paragraph) pop ();
- ((BlockContent) peek ()).content.add (head);
-
- Text last_element = head.content.last () as Text;
- if (last_element != null) {
- last_element.content._chomp ();
- }
- });
+ .set_reduce (reduce_paragraph);
Rule warning =
Rule.seq ({
((Comment) peek ()).taglets.add (head);
});
- Rule comment =
+ Rule ml_comment =
Rule.seq ({
TokenType.EOL,
Rule.option ({
Rule.many ({ taglet })
})
})
+ .set_name ("MultiLineComment");
+
+ Rule sl_comment =
+ Rule.seq ({
+ run
+ })
+ .set_start (() => { push (_factory.create_paragraph ()); })
+ .set_reduce (reduce_paragraph)
+ .set_name ("SingleLineComment");
+
+ Rule comment =
+ Rule.one_of ({
+ ml_comment,
+ sl_comment
+ })
.set_name ("Comment")
.set_start (() => { push (_factory.create_comment ()); });