summaryrefslogtreecommitdiffstats
path: root/vendor/pest_derive/tests/grammar.pest
blob: 43a7b8cfd1fc650fb308d612fcbd7e3fee774d13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// pest. The Elegant Parser
// Copyright (c) 2018 Dragoș Tiselice
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 }
peek_slice_23 = { PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PEEK[1..-2] }
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 | DROP ~ "b" | 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 = _{ "$"+ }

// 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" }
*/