diff options
author | Steven R. Brandt <sbrandt@cct.lsu.edu> | 2012-02-02 17:29:34 -0600 |
---|---|---|
committer | Steven R. Brandt <sbrandt@cct.lsu.edu> | 2012-02-02 17:37:06 -0600 |
commit | da49a31cca6d10b54538348fab8f14ecec426e03 (patch) | |
tree | 918e399f6d288836cde09c501a7f63c382c6dede /Auxiliary | |
parent | 8bbaa1855244982b04337b32d765a05ff0001d03 (diff) |
Add support for defining derivative operators
Diffstat (limited to 'Auxiliary')
-rw-r--r-- | Auxiliary/Grammars/kranc2.peg | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index fc6ce10..29ce154 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -1,10 +1,13 @@ -skipper = ([ \t\n\r]+|#.*)* +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_]* -indices = ([_^]([a-zA-Z]'*)+)* +indices = ([_^]({index_symbol}|\({index_expr}(,{index_expr})*\))+)* +index_symbol = [a-zA-Z]'* +index_expr = {index_symbol}([+-]{int}|) tensor = {name}{indices} -dtensor = D{indices} {tensor} +dtensor = D[a-z]*{indices}? {tensor} number = -?[0-9]+(\.[0-9]*|)([eEdD][+-]?[0-9]+|) func = {name} \( ({expr}( , {expr})*|) \) value = {func}|{dtensor}|{tensor}|{number}|\( {expr} \) @@ -14,9 +17,11 @@ mul = {pow}( {mulop} {pow})* addop = [+-] expr = {mul}( {addop} {mul})* eqn = ({dtensor}|{tensor}) \= {expr}{-end} +deqn = {dtensor} \= {expr}{-end} eqns = {eqn}( {eqn})* +deqns = {deqn}( {deqn})* schedule = scheduled[ \t]+at[ \t]{uname} -thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries}| {option})* end[ ]+thorn +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} {tensor}( end[ \t]+variables\b{brk}| {tensor})*{-end} temporaries = begin[ \t]+temporaries{-end} {tensor}( end[ \t]+temporaries\b{brk}| {tensor})*{-end} @@ -26,3 +31,4 @@ 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 |