diff --git a/derive/tests/grammar.pest b/derive/tests/grammar.pest index 630f2c1e..404f33fd 100644 --- a/derive/tests/grammar.pest +++ b/derive/tests/grammar.pest @@ -58,3 +58,23 @@ SYMBOL = { "shadows builtin" } WHITESPACE = _{ " " } COMMENT = _{ "$"+ } + +// Line comment + +/* 1-line multiline comment */ + +/* + N-line multiline comment +*/ + +/* + // Line comment inside multiline + + /* + (Multiline inside) multiline + */ + + Invalid segment of grammar below (repeated rule) + + WHITESPACE = _{ "hi" } +*/ diff --git a/meta/src/grammar.pest b/meta/src/grammar.pest index bf5da55a..64826f61 100644 --- a/meta/src/grammar.pest +++ b/meta/src/grammar.pest @@ -90,4 +90,5 @@ range_operator = { ".." } newline = _{ "\n" | "\r\n" } WHITESPACE = _{ " " | "\t" | newline } -COMMENT = _{ "//" ~ (!newline ~ ANY)* } +block_comment = _{ "/*" ~ (block_comment | !"*/" ~ ANY)* ~ "*/" } +COMMENT = _{ block_comment | ("//" ~ (!newline ~ ANY)*) } diff --git a/vm/tests/grammar.pest b/vm/tests/grammar.pest deleted file mode 100644 index 630f2c1e..00000000 --- a/vm/tests/grammar.pest +++ /dev/null @@ -1,60 +0,0 @@ -// pest. The Elegant Parser -// Copyright (c) 2018 Dragoș Tiselice -// -// Licensed under the Apache License, Version 2.0 -// or the MIT -// license , at your -// option. All files in the project carrying such notice may not be copied, -// modified, or distributed except according to those terms. - -string = { "abc" } -insensitive = { ^"abc" } -range = { '0'..'9' } -ident = { string } -pos_pred = { &string } -neg_pred = { !string } -double_neg_pred = { !!string } -sequence = !{ string ~ string } -sequence_compound = ${ string ~ string } -sequence_atomic = @{ string ~ string } -sequence_non_atomic = @{ sequence } -sequence_atomic_compound = @{ sequence_compound } -sequence_nested = { string ~ string } -sequence_compound_nested = ${ sequence_nested } -choice = { string | range } -optional = { string? } -repeat = { string* } -repeat_atomic = @{ string* } -repeat_once = { string+ } -repeat_once_atomic = @{ string+ } -repeat_min_max = { string{2, 3} } -repeat_min_max_atomic = @{ string{2, 3} } -repeat_exact = { string{2} } -repeat_min = { string{2,} } -repeat_min_atomic = @{ string{2,} } -repeat_max = { string{, 2} } -repeat_max_atomic = @{ string{, 2} } -soi_at_start = { SOI ~ string } -repeat_mutate_stack = { (PUSH('a'..'c') ~ ",")* ~ POP ~ POP ~ POP } -peek_ = { PUSH(range) ~ PUSH(range) ~ PEEK ~ PEEK } -peek_all = { PUSH(range) ~ PUSH(range) ~ PEEK_ALL } -pop_ = { PUSH(range) ~ PUSH(range) ~ POP ~ POP } -pop_all = { PUSH(range) ~ PUSH(range) ~ POP_ALL } -pop_fail = { PUSH(range) ~ !POP ~ range ~ POP } -checkpoint_restore = ${ PUSH("") ~ (PUSH("a") ~ "b" ~ POP | POP ~ "a") ~ EOI } -ascii_digits = { ASCII_DIGIT+ } -ascii_nonzero_digits = { ASCII_NONZERO_DIGIT+ } -ascii_bin_digits = { ASCII_BIN_DIGIT+ } -ascii_oct_digits = { ASCII_OCT_DIGIT+ } -ascii_hex_digits = { ASCII_HEX_DIGIT+ } -ascii_alpha_lowers = { ASCII_ALPHA_LOWER+ } -ascii_alpha_uppers = { ASCII_ALPHA_UPPER+ } -ascii_alphas = { ASCII_ALPHA+ } -ascii_alphanumerics = { ASCII_ALPHANUMERIC+ } -asciis = { ASCII+ } -newline = { NEWLINE+ } -unicode = { XID_START ~ XID_CONTINUE* } -SYMBOL = { "shadows builtin" } - -WHITESPACE = _{ " " } -COMMENT = _{ "$"+ } diff --git a/vm/tests/grammar.pest b/vm/tests/grammar.pest new file mode 120000 index 00000000..0cfe64c2 --- /dev/null +++ b/vm/tests/grammar.pest @@ -0,0 +1 @@ +../../derive/tests/grammar.pest \ No newline at end of file diff --git a/vm/tests/lists.pest b/vm/tests/lists.pest deleted file mode 100644 index 47756b76..00000000 --- a/vm/tests/lists.pest +++ /dev/null @@ -1,18 +0,0 @@ -// pest. The Elegant Parser -// Copyright (c) 2018 Dragoș Tiselice -// -// Licensed under the Apache License, Version 2.0 -// or the MIT -// license , at your -// option. All files in the project carrying such notice may not be copied, -// modified, or distributed except according to those terms. - -item = { (!"\n" ~ ANY)* } - -lists = _{ lines ~ EOI } -lines = _{ top_first ~ ("\n" ~ top_continue)* } -top_first = _{ "- " ~ item ~ ("\n" ~ children)? } -top_continue = _{ PEEK_ALL ~ "- " ~ item ~ ("\n" ~ children)? } - -indentation = _{ (" " | "\t")+ } -children = { PEEK_ALL ~ PUSH(indentation) ~ lines ~ DROP } diff --git a/vm/tests/lists.pest b/vm/tests/lists.pest new file mode 120000 index 00000000..3a975e54 --- /dev/null +++ b/vm/tests/lists.pest @@ -0,0 +1 @@ +../../derive/tests/lists.pest \ No newline at end of file diff --git a/vm/tests/reporting.pest b/vm/tests/reporting.pest deleted file mode 100644 index a59dcc1e..00000000 --- a/vm/tests/reporting.pest +++ /dev/null @@ -1,26 +0,0 @@ -// pest. The Elegant Parser -// Copyright (c) 2018 Dragoș Tiselice -// -// Licensed under the Apache License, Version 2.0 -// or the MIT -// license , at your -// option. All files in the project carrying such notice may not be copied, -// modified, or distributed except according to those terms. - -a = { "a" } -b = { "b" } -c = { "c" } -d = { ANY } - -choices = _{ a | b | c } -choices_no_progress = { a | b | c } -choices_a_progress = { a ~ a | b | c } -choices_b_progress = { a | b ~ b | c } - -level1 = _{ level2 } -level2 = _{ a | b | c } - -negative = _{ !d } -negative_match = _{ !a ~ b } -mixed = _{ !d | a } -mixed_progress = _{ (!d | a | b) ~ a } diff --git a/vm/tests/reporting.pest b/vm/tests/reporting.pest new file mode 120000 index 00000000..15cc1f7e --- /dev/null +++ b/vm/tests/reporting.pest @@ -0,0 +1 @@ +../../derive/tests/reporting.pest \ No newline at end of file