aboutsummaryrefslogtreecommitdiff
path: root/Auxiliary
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2012-01-26 14:03:31 -0600
committerIan Hinder <ian.hinder@aei.mpg.de>2012-01-26 14:03:31 -0600
commitccfab5fc8ea15ba557eafdd7c83afa61f9b5fb31 (patch)
treed4837906980435fa36455afa9c8fda9ddc556155 /Auxiliary
parent4c155b17eb7f62383d9423676e707251f4be0e64 (diff)
kranc2.peg: Add draft Kranc grammar
Diffstat (limited to 'Auxiliary')
-rw-r--r--Auxiliary/Grammars/kranc2.peg19
1 files changed, 19 insertions, 0 deletions
diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg
new file mode 100644
index 0000000..7017b42
--- /dev/null
+++ b/Auxiliary/Grammars/kranc2.peg
@@ -0,0 +1,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