Allow block comments with /* */ (#421)
This commit is contained in:
parent
03db60d94c
commit
f95a27b412
2 changed files with 11 additions and 4 deletions
|
|
@ -1,13 +1,15 @@
|
|||
// Grammar for the "Podlang" language. Used for describing POD2 Custom
|
||||
// Predicates and Proof Requests.
|
||||
|
||||
// Silent rules (`_`) are automatically handled by Pest between other rules.
|
||||
// Note: Silent rules (`_`) generate no tokens. WHITESPACE and COMMENT are
|
||||
// special names known to Pest. If defined they are implicitly allowed between
|
||||
// any others rules.
|
||||
|
||||
// WHITESPACE matches one or more spaces, tabs, or newlines.
|
||||
WHITESPACE = _{ (" " | "\t" | NEWLINE)+ }
|
||||
|
||||
// COMMENT matches '//' followed by any characters until the end of the line.
|
||||
// Also silent.
|
||||
COMMENT = _{ "//" ~ (!NEWLINE ~ ANY)* }
|
||||
// COMMENT matches a line comment (//...\n) or block comment (/*...*/).
|
||||
COMMENT = _{ ("//" ~ (!NEWLINE ~ ANY)* | "/*" ~ (!"*/" ~ ANY)* ~ "*/" ) }
|
||||
|
||||
// Define rules for identifiers (predicate names, variable names without '?')
|
||||
// Must start with alpha or _, followed by alpha, numeric, or _
|
||||
|
|
|
|||
|
|
@ -54,12 +54,17 @@ mod tests {
|
|||
assert_parses(Rule::document, " ");
|
||||
assert_parses(Rule::document, "\n\n");
|
||||
assert_parses(Rule::document, "// comment only");
|
||||
assert_parses(Rule::document, "/* comment only */");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_comment() {
|
||||
assert_parses(Rule::document, "// This is a comment\n");
|
||||
assert_parses(Rule::document, " // Indented comment");
|
||||
assert_parses(Rule::document, "/* This is a comment*/\n");
|
||||
assert_fails(Rule::document, "/* Wrong closing characters/*\n");
|
||||
assert_parses(Rule::literal_array, "[1// No nested comments /*\n, 2]");
|
||||
assert_parses(Rule::literal_array, "[1/* No nested comments //*/, 2]\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue