]> git.proxmox.com Git - rustc.git/blob - vendor/pest_derive/tests/grammar.pest
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / pest_derive / tests / grammar.pest
1 // pest. The Elegant Parser
2 // Copyright (c) 2018 DragoČ™ Tiselice
3 //
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.
9
10 string = { "abc" }
11 insensitive = { ^"abc" }
12 range = { '0'..'9' }
13 ident = { string }
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 choice_prefix = { | string | range }
26 optional = { string? }
27 repeat = { string* }
28 repeat_atomic = @{ string* }
29 repeat_once = { string+ }
30 repeat_once_atomic = @{ string+ }
31 repeat_min_max = { string{2, 3} }
32 repeat_min_max_atomic = @{ string{2, 3} }
33 repeat_exact = { string{2} }
34 repeat_min = { string{2,} }
35 repeat_min_atomic = @{ string{2,} }
36 repeat_max = { string{, 2} }
37 repeat_max_atomic = @{ string{, 2} }
38 soi_at_start = { SOI ~ string }
39 repeat_mutate_stack = { (PUSH('a'..'c') ~ ",")* ~ POP ~ POP ~ POP }
40 repeat_mutate_stack_pop_all = { (PUSH('a'..'c') ~ ",")* ~ POP_ALL }
41 will_fail = { repeat_mutate_stack_pop_all ~ "FAIL" }
42 stack_resume_after_fail = { will_fail | repeat_mutate_stack_pop_all }
43 peek_ = { PUSH(range) ~ PUSH(range) ~ PEEK ~ PEEK }
44 peek_all = { PUSH(range) ~ PUSH(range) ~ PEEK_ALL }
45 peek_slice_23 = { PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PEEK[1..-2] }
46 pop_ = { PUSH(range) ~ PUSH(range) ~ POP ~ POP }
47 pop_all = { PUSH(range) ~ PUSH(range) ~ POP_ALL }
48 pop_fail = { PUSH(range) ~ !POP ~ range ~ POP }
49 checkpoint_restore = ${
50 PUSH("") ~ (PUSH("a") ~ "b" ~ POP | DROP ~ "b" | POP ~ "a") ~ EOI
51 }
52 ascii_digits = { ASCII_DIGIT+ }
53 ascii_nonzero_digits = { ASCII_NONZERO_DIGIT+ }
54 ascii_bin_digits = { ASCII_BIN_DIGIT+ }
55 ascii_oct_digits = { ASCII_OCT_DIGIT+ }
56 ascii_hex_digits = { ASCII_HEX_DIGIT+ }
57 ascii_alpha_lowers = { ASCII_ALPHA_LOWER+ }
58 ascii_alpha_uppers = { ASCII_ALPHA_UPPER+ }
59 ascii_alphas = { ASCII_ALPHA+ }
60 ascii_alphanumerics = { ASCII_ALPHANUMERIC+ }
61 asciis = { ASCII+ }
62 newline = { NEWLINE+ }
63 unicode = { XID_START ~ XID_CONTINUE* }
64 SYMBOL = { "shadows builtin" }
65
66 han = { HAN+ }
67 hangul = { HANGUL+ }
68 hiragana = { HIRAGANA+ }
69 arabic = { ARABIC+ }
70
71 WHITESPACE = _{ " " }
72 COMMENT = _{ "$"+ }
73
74 // Line comment
75
76 /* 1-line multiline comment */
77
78 /*
79 N-line multiline comment
80 */
81
82 /*
83 // Line comment inside multiline
84
85 /*
86 (Multiline inside) multiline
87 */
88
89 Invalid segment of grammar below (repeated rule)
90
91 WHITESPACE = _{ "hi" }
92 */