1 // pest. The Elegant Parser
2 // Copyright (c) 2018 DragoČ™ Tiselice
4 // Licensed under the Apache License, Version 2.0
5 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
6 // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. All files in the project carrying such notice may not be copied,
8 // modified, or distributed except according to those terms.
11 insensitive = { ^"abc" }
14 pos_pred = { &string }
15 neg_pred = { !string }
16 double_neg_pred = { !!string }
17 sequence = !{ string ~ string }
18 sequence_compound = ${ string ~ string }
19 sequence_atomic = @{ string ~ string }
20 sequence_non_atomic = @{ sequence }
21 sequence_atomic_compound = @{ sequence_compound }
22 sequence_nested = { string ~ string }
23 sequence_compound_nested = ${ sequence_nested }
24 choice = { string | range }
25 optional = { string? }
27 repeat_atomic = @{ string* }
28 repeat_once = { string+ }
29 repeat_once_atomic = @{ string+ }
30 repeat_min_max = { string{2, 3} }
31 repeat_min_max_atomic = @{ string{2, 3} }
32 repeat_exact = { string{2} }
33 repeat_min = { string{2,} }
34 repeat_min_atomic = @{ string{2,} }
35 repeat_max = { string{, 2} }
36 repeat_max_atomic = @{ string{, 2} }
37 soi_at_start = { SOI ~ string }
38 repeat_mutate_stack = { (PUSH('a'..'c') ~ ",")* ~ POP ~ POP ~ POP }
39 peek_ = { PUSH(range) ~ PUSH(range) ~ PEEK ~ PEEK }
40 peek_all = { PUSH(range) ~ PUSH(range) ~ PEEK_ALL }
41 peek_slice_23 = { PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PEEK[1..-2] }
42 pop_ = { PUSH(range) ~ PUSH(range) ~ POP ~ POP }
43 pop_all = { PUSH(range) ~ PUSH(range) ~ POP_ALL }
44 pop_fail = { PUSH(range) ~ !POP ~ range ~ POP }
45 checkpoint_restore = ${
46 PUSH("") ~ (PUSH("a") ~ "b" ~ POP | DROP ~ "b" | POP ~ "a") ~ EOI
48 ascii_digits = { ASCII_DIGIT+ }
49 ascii_nonzero_digits = { ASCII_NONZERO_DIGIT+ }
50 ascii_bin_digits = { ASCII_BIN_DIGIT+ }
51 ascii_oct_digits = { ASCII_OCT_DIGIT+ }
52 ascii_hex_digits = { ASCII_HEX_DIGIT+ }
53 ascii_alpha_lowers = { ASCII_ALPHA_LOWER+ }
54 ascii_alpha_uppers = { ASCII_ALPHA_UPPER+ }
55 ascii_alphas = { ASCII_ALPHA+ }
56 ascii_alphanumerics = { ASCII_ALPHANUMERIC+ }
58 newline = { NEWLINE+ }
59 unicode = { XID_START ~ XID_CONTINUE* }
60 SYMBOL = { "shadows builtin" }
67 /* 1-line multiline comment */
70 N-line multiline comment
74 // Line comment inside multiline
77 (Multiline inside) multiline
80 Invalid segment of grammar below (repeated rule)
82 WHITESPACE = _{ "hi" }