aboutsummaryrefslogtreecommitdiff
path: root/Auxiliary/Grammars/kranc2.peg
blob: 7017b426e8f12f3de1b5aad4188b43ccb090dbcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
skipper = ([ \t\n\r]+|#.*)*
end = ([ \t]+|#.*)*\r*\n
name = [A-Za-z][A-Za-z0-9]*
uname = [A-Za-z][A-Za-z0-9_]*
indices = ([_^]([a-zA-Z]'*)+)*
tensor = {name}{indices}
dtensor = D{indices} {tensor}
number = -?[0-9]+(\.[0-9]*|)([eEdD][+-]?[0-9]+|)
func = {name} \( {expr} \)
value = {func}|{dtensor}|{tensor}|{number}|\( {expr} \)
pow = {value}( \*\* {value}|)
mulop = [*/%]
mul = {pow}( {mulop} {pow})*
addop = [+-]
expr = {mul}( {addop} {mul})*
eqn = ({dtensor}|{tensor}) \= {expr}{-end}
eqns = {eqn}( {eqn})*
thorn = begin[ ]+thorn {name}{-end}( {calculation})* end[ ]+thorn
calculation = begin[ ]+calculation {uname}{-end} {eqns} end[ ]+calculation