aboutsummaryrefslogtreecommitdiff
path: root/Auxiliary
diff options
context:
space:
mode:
authorBarry Wardell <barry.wardell@gmail.com>2012-02-09 09:49:35 +0000
committerBarry Wardell <barry.wardell@gmail.com>2012-02-09 10:14:42 +0000
commit3f0dc8ca3ddee5c78c6922abc9707d464a2d0506 (patch)
tree008d2b88e137c272ff34c7a1363a8e3c9196dbe8 /Auxiliary
parent4b9da3393b67b7b8f75396c6d8e7abef86ee7b27 (diff)
parent90ef11c6391568bf00fc7258f7f7060a81c0dfe8 (diff)
Merge remote-tracking branch 'origin/piraha'
Conflicts: Tools/CodeGen/Kranc.m
Diffstat (limited to 'Auxiliary')
-rw-r--r--Auxiliary/Grammars/kranc2.peg39
1 files changed, 39 insertions, 0 deletions
diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg
new file mode 100644
index 0000000..9111540
--- /dev/null
+++ b/Auxiliary/Grammars/kranc2.peg
@@ -0,0 +1,39 @@
+skipper = \b([ \t\n\r]+|#.*)*
+int = [0-9]+
+end = ([ \t]+|#.*)*\r*\n
+name = [A-Za-z][A-Za-z0-9]*
+uname = [A-Za-z][A-Za-z0-9_]*
+lower_index = ({index_symbol}|\({index_expr}(,{index_expr})*\))
+upper_index = ({index_symbol}|\({index_expr}(,{index_expr})*\))
+indices = (\_{lower_index}+|\^{upper_index}+)*
+index_symbol = [a-zA-Z]'*|[0-9]
+index_op = [+-]
+index_expr = {index_symbol}({index_op}{int}|)
+tensor = {name}{indices}
+dname = D[a-z0-9]*
+dtensor = {dname}{indices}? {tensor} # Can this "?" be removed?
+number = -?[0-9]+(\.[0-9]*|)([eEdD][+-]?[0-9]+|)
+func = {name} \( ({expr}( , {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}
+deqn = {dtensor} \= {expr}{-end}
+eqns = {eqn}( {eqn})*
+deqns = {deqn}( {deqn})*
+at_or_in = (at|in)
+schedule = scheduled[ \t]+{at_or_in}[ \t]{uname}
+thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries}| {derivatives}| {option})* end[ ]+thorn
+calculation = begin[ \t]+calculation[ \t]+{uname}[ \t]+{schedule}{-end} {eqns} end[ \t]+calculation
+variables = begin[ \t]+variables{-end} ( end[ \t]+variables\b{brk}| {tensor})*{-end}
+temporaries = begin[ \t]+temporaries{-end} ( end[ \t]+temporaries\b{brk}| {tensor})*{-end}
+option = {inherit}|{use}|{disable}|{implement}
+inherit = inherit[ \t]+({uname}[ \t]*)+{-end}
+feature = loopcontrol|vectors|opencl|jacobian|cse
+use = use[ \t]+({feature}[ \t]*)+
+disable = disable[ \t]+({feature}[ \t]*)+
+implement = implement[ \t]+{uname}{-end}
+derivatives = begin[ \t]+derivatives{-end} {deqns} end[ \t]+derivatives