summaryrefslogtreecommitdiff
path: root/src/piraha/pegs/par.peg
blob: b6fe0af48f7c70317a1a28c22ae6ae2ca18fa75d (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
skipper = ([ \t\r\n]|\#.*)*
# comment
skipeol = ([ \t\r]|\#.*)*($|\n)
any = [^]
stringcomment = #.*
stringparser = ^({stringcomment}|{var}|{name}|{any})*$
# Note that / occurs in some par files. It is my
# feeling that this should require quote marks.
name = [a-zA-Z][a-zA-Z0-9_]*
dname = [0-9][a-zA-Z_]{2,}
inquot = ({var}|\\.|[^\\"])*
fname = \.?/[-\./0-9a-zA-Z_]+
quot = "{inquot}"|{fname}
num = ([0-9]+(\.[0-9]*|)|\.[0-9]+)([ed][+-]?[0-9]+|)
env = ENV\{{name}\}
var = \$({env}|{name}|\{{name}\})
powexpr = {value}( \*\* {value})?
mulop = [*/%]
mexpr = {powexpr}( {mulop} {powexpr})*
addop = [+-]
aexpr = {mexpr}( {addop} {mexpr})*
compop = [<>]=?
compexpr = {aexpr}( {compop} {aexpr})?
eqop = [!=]=
eqexpr = {compexpr}( {eqop} {eqexpr})?
andexpr = {eqexpr}( && {eqexpr})?
expr = {andexpr}( \|\| {andexpr})?
eval = {expr}
paren = \( {expr} \)
par = {name} :: {name}( {parindex})?
func = {name} \( {expr} \)
array = \[ {expr}( , {expr})* \]
value = {unop}?({par}|{func}|{paren}|{dname}|{num}|{quot}|{name}|{var})
unop = [-!]
int = [0-9]+
index = \[ {int} \]
parindex = \[ {expr} \]
active = (?i:ActiveThorns)
set = ({active} = ({quot}|{name})|{par}( {index}|) = ({array}|\+?{expr})){-skipeol}
desc = !DESC {quot}
file = ^( ({desc}|{set}|{active}) )*$