From ccfab5fc8ea15ba557eafdd7c83afa61f9b5fb31 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Thu, 26 Jan 2012 14:03:31 -0600 Subject: kranc2.peg: Add draft Kranc grammar --- Auxiliary/Grammars/kranc2.peg | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Auxiliary/Grammars/kranc2.peg (limited to 'Auxiliary') 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 -- cgit v1.2.3 From 966c1927241051d844d30bbd6306a08b8121310d Mon Sep 17 00:00:00 2001 From: "Steven R. Brandt" Date: Fri, 27 Jan 2012 16:25:04 -0600 Subject: Added support for variables and temporaries --- Auxiliary/Grammars/kranc2.peg | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index 7017b42..15c183c 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -6,7 +6,7 @@ indices = ([_^]([a-zA-Z]'*)+)* tensor = {name}{indices} dtensor = D{indices} {tensor} number = -?[0-9]+(\.[0-9]*|)([eEdD][+-]?[0-9]+|) -func = {name} \( {expr} \) +func = {name} \( ({expr}( , {expr})*|) \) value = {func}|{dtensor}|{tensor}|{number}|\( {expr} \) pow = {value}( \*\* {value}|) mulop = [*/%] @@ -15,5 +15,7 @@ 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 +thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries})* end[ ]+thorn +calculation = begin[ \t]+calculation[ \t]+{uname}{-end} {eqns} end[ \t]+calculation +variables = begin[ \t]+variables{-end} {name}( end[ \t]+variables\b{brk}| {name})*{-end} +temporaries = begin[ \t]+temporaries{-end} {name}( end[ \t]+temporaries\b{brk}| {name})*{-end} -- cgit v1.2.3 From 82ea63caccde8afba2ee1a8f3b9be897c4ec9d9a Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Fri, 27 Jan 2012 19:36:52 -0600 Subject: kranc2.peg: Accept tensors instead of names in variables and temporaries --- Auxiliary/Grammars/kranc2.peg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index 15c183c..efbc283 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -17,5 +17,5 @@ eqn = ({dtensor}|{tensor}) \= {expr}{-end} eqns = {eqn}( {eqn})* thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries})* end[ ]+thorn calculation = begin[ \t]+calculation[ \t]+{uname}{-end} {eqns} end[ \t]+calculation -variables = begin[ \t]+variables{-end} {name}( end[ \t]+variables\b{brk}| {name})*{-end} -temporaries = begin[ \t]+temporaries{-end} {name}( end[ \t]+temporaries\b{brk}| {name})*{-end} +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} -- cgit v1.2.3 From 53e9c9afd8733ad9cd79793c1845de341e583dd3 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Fri, 27 Jan 2012 23:13:47 -0600 Subject: kranc2.peg: Add "scheduled at" to the calculation definition --- Auxiliary/Grammars/kranc2.peg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index efbc283..35c9ece 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -15,7 +15,8 @@ addop = [+-] expr = {mul}( {addop} {mul})* eqn = ({dtensor}|{tensor}) \= {expr}{-end} eqns = {eqn}( {eqn})* +schedule = scheduled[ \t]+at[ \t]{uname} thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries})* end[ ]+thorn -calculation = begin[ \t]+calculation[ \t]+{uname}{-end} {eqns} end[ \t]+calculation +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} -- cgit v1.2.3 From 236a0028ce197db03d71f17bc9e4a01306686c9e Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Sun, 29 Jan 2012 23:46:44 -0600 Subject: Add options and features to the script language --- Auxiliary/Grammars/kranc2.peg | 7 ++++++- Tools/CodeGen/KrancScript.m | 26 ++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index 35c9ece..3cbe0c1 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -16,7 +16,12 @@ expr = {mul}( {addop} {mul})* eqn = ({dtensor}|{tensor}) \= {expr}{-end} eqns = {eqn}( {eqn})* schedule = scheduled[ \t]+at[ \t]{uname} -thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries})* end[ ]+thorn +thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries}| {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} +option = {inherit}|{use}|{disable} +inherit = inherit[ \t]+({uname}[ \t]*)+{-end} +feature = loopcontrol|vectors|opencl|jacobian|cse +use = use[ \t]+({feature}[ \t]*)+ +disable = disable[ \t]+({feature}[ \t]*)+ diff --git a/Tools/CodeGen/KrancScript.m b/Tools/CodeGen/KrancScript.m index d73a72c..6847c84 100644 --- a/Tools/CodeGen/KrancScript.m +++ b/Tools/CodeGen/KrancScript.m @@ -19,7 +19,7 @@ *) BeginPackage["KrancScript`", {"Errors`", "Helpers`", "Kranc`", "JLink`", "TensorTools`", - "KrancTensor`", "Piraha`"}]; + "KrancTensor`", "Piraha`", "MapLookup`"}]; CreateThornFromKrancScript; @@ -52,14 +52,15 @@ process[h_[args___]] := process[thorn:"thorn"[content___]] := Module[ - {calcs = {}, name, options, variables = {}, temporaries = {}, tensors, kernels, - nonScalars, tensorRule, withInds}, + {calcs = {}, name, variables = {}, temporaries = {}, tensors, kernels, + nonScalars, tensorRule, withInds, options = {}}, Do[Switch[el, "calculation"[___], AppendTo[calcs,process[el]], "name"[_], name = el[[1]], "variables"[__], variables = Join[variables,List@@Map[process,el]], "temporaries"[__], temporaries = Join[temporaries,List@@Map[process,el]], + "option"[__], options = Join[options, process[el]], _, ThrowError["Unrecognised element '"<>Head[el]<>"' in thorn"]], {el, {content}}]; @@ -74,7 +75,9 @@ process[thorn:"thorn"[content___]] := SetEnhancedTimes[False]; - options = {Calculations -> calcs, Variables -> variables, Shorthands -> temporaries} /. tensorRule; + options = Join[{Calculations -> calcs, Variables -> variables, Shorthands -> temporaries} /. tensorRule, + options]; + CreateKrancThornTT2[name,Sequence@@options]]; process[calc:"calculation"[content___]] := @@ -160,6 +163,21 @@ process["value"[a_]] := process[a]; process["number"[a_]] := ToExpression[a]; +process["uname"[n_]] := n; + +process["option"["inherit"[imps__]]] := + {InheritedImplementations -> Map[process, {imps}]}; + +flags = {"loopcontrol"->UseLoopControl,"vectors"->UseVectors,"opencl"->UseOpenCL, + "jacobian"->UseJacobian, "cse" -> CSE}; + +process["option"["use"[features__]]] := + Map[(lookup[flags,#] -> True) &,{features}/.(("feature"[n_]):>n)]; + +process["option"["disable"[features__]]] := + Map[(lookup[flags,#] -> False) &,{features}/.(("feature"[n_]):>n)]; + + End[]; EndPackage[]; -- cgit v1.2.3 From ad9f846549d84fa82af5dabd6e288f3641c54a54 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Sun, 29 Jan 2012 23:57:15 -0600 Subject: Add Implementation to script language --- Auxiliary/Grammars/kranc2.peg | 3 ++- Tools/CodeGen/KrancScript.m | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index 3cbe0c1..fc6ce10 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -20,8 +20,9 @@ thorn = begin[ ]+thorn {name}{-end}( {calculation}| {variables}| {temporaries}| 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} -option = {inherit}|{use}|{disable} +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} diff --git a/Tools/CodeGen/KrancScript.m b/Tools/CodeGen/KrancScript.m index 6ba2536..810088f 100644 --- a/Tools/CodeGen/KrancScript.m +++ b/Tools/CodeGen/KrancScript.m @@ -168,6 +168,9 @@ process["uname"[n_]] := n; process["option"["inherit"[imps__]]] := {InheritedImplementations -> Map[process, {imps}]}; +process["option"["implement"[imp_]]] := + {Implementation -> process[imp]}; + flags = {"loopcontrol"->UseLoopControl,"vectors"->UseVectors,"opencl"->UseOpenCL, "jacobian"->UseJacobian, "cse" -> CSE}; -- cgit v1.2.3 From da49a31cca6d10b54538348fab8f14ecec426e03 Mon Sep 17 00:00:00 2001 From: "Steven R. Brandt" Date: Thu, 2 Feb 2012 17:29:34 -0600 Subject: Add support for defining derivative operators --- Auxiliary/Grammars/kranc2.peg | 14 ++++++++++---- Examples/SimpleWaveScript.kranc | 9 +++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'Auxiliary') 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 diff --git a/Examples/SimpleWaveScript.kranc b/Examples/SimpleWaveScript.kranc index 35b938f..0aeb6ae 100644 --- a/Examples/SimpleWaveScript.kranc +++ b/Examples/SimpleWaveScript.kranc @@ -4,6 +4,15 @@ begin variables phi pi end variables +begin temporaries + foo bar +end temporaries + +begin derivatives + Du u_i = (u_(i+1) - u_(i-1))/h + Dv v_i = (v_(i+1,j) - u_(i-1,j))/h +end derivatives + begin calculation initial_sine_calc scheduled at initial phi = sin(2*PI*(x-t)) pi = -2*pi*cos(2*PI*(x-t)) -- cgit v1.2.3 From 412670ec56e30fed32b43fb6fc05a3f0314dd44c Mon Sep 17 00:00:00 2001 From: "Steven R. Brandt" Date: Mon, 6 Feb 2012 15:39:05 -0600 Subject: latest to parse Funwave.kranc --- Auxiliary/Grammars/kranc2.peg | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index 29ce154..e078f7e 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -7,10 +7,10 @@ indices = ([_^]({index_symbol}|\({index_expr}(,{index_expr})*\))+)* index_symbol = [a-zA-Z]'* index_expr = {index_symbol}([+-]{int}|) tensor = {name}{indices} -dtensor = D[a-z]*{indices}? {tensor} +dtensor = D[a-z0-9]*{indices}? {tensor} number = -?[0-9]+(\.[0-9]*|)([eEdD][+-]?[0-9]+|) func = {name} \( ({expr}( , {expr})*|) \) -value = {func}|{dtensor}|{tensor}|{number}|\( {expr} \) +value = {func}|{dtensor}|-?{tensor}|{number}|-?\( {expr} \) pow = {value}( \*\* {value}|) mulop = [*/%] mul = {pow}( {mulop} {pow})* @@ -20,11 +20,12 @@ eqn = ({dtensor}|{tensor}) \= {expr}{-end} deqn = {dtensor} \= {expr}{-end} eqns = {eqn}( {eqn})* deqns = {deqn}( {deqn})* -schedule = scheduled[ \t]+at[ \t]{uname} +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} {tensor}( end[ \t]+variables\b{brk}| {tensor})*{-end} -temporaries = begin[ \t]+temporaries{-end} {tensor}( end[ \t]+temporaries\b{brk}| {tensor})*{-end} +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 -- cgit v1.2.3 From 1e4cc8ea75f3fd79ad3b4bfa4fcb9089aa15e15c Mon Sep 17 00:00:00 2001 From: "Steven R. Brandt" Date: Mon, 6 Feb 2012 15:48:55 -0600 Subject: allow integer values as indices --- Auxiliary/Grammars/kranc2.peg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index e078f7e..a98aaf7 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -4,7 +4,7 @@ end = ([ \t]+|#.*)*\r*\n name = [A-Za-z][A-Za-z0-9]* uname = [A-Za-z][A-Za-z0-9_]* indices = ([_^]({index_symbol}|\({index_expr}(,{index_expr})*\))+)* -index_symbol = [a-zA-Z]'* +index_symbol = [a-zA-Z]'*|[0-9] index_expr = {index_symbol}([+-]{int}|) tensor = {name}{indices} dtensor = D[a-z0-9]*{indices}? {tensor} -- cgit v1.2.3 From 01a4164aed15f8444d01caf9fc588576a8d0e37f Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Mon, 6 Feb 2012 17:58:15 -0600 Subject: kranc2.peg: Identify lower and upper indices in the parser Previously this logic was in Kranc, where it has to be more complicated. --- Auxiliary/Grammars/kranc2.peg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index a98aaf7..91ea573 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -3,7 +3,9 @@ int = [0-9]+ end = ([ \t]+|#.*)*\r*\n name = [A-Za-z][A-Za-z0-9]* uname = [A-Za-z][A-Za-z0-9_]* -indices = ([_^]({index_symbol}|\({index_expr}(,{index_expr})*\))+)* +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_expr = {index_symbol}([+-]{int}|) tensor = {name}{indices} -- cgit v1.2.3 From 3cc6aee48df9407f27df03237911bb4279cddcd5 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Mon, 6 Feb 2012 19:23:35 -0600 Subject: kranc2.peg: Add derivative name to parse tree --- Auxiliary/Grammars/kranc2.peg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index 91ea573..054eaa4 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -9,7 +9,8 @@ indices = (\_{lower_index}+|\^{upper_index}+)* index_symbol = [a-zA-Z]'*|[0-9] index_expr = {index_symbol}([+-]{int}|) tensor = {name}{indices} -dtensor = D[a-z0-9]*{indices}? {tensor} +dname = D[a-z0-9]* +dtensor = {dname}{indices}? {tensor} number = -?[0-9]+(\.[0-9]*|)([eEdD][+-]?[0-9]+|) func = {name} \( ({expr}( , {expr})*|) \) value = {func}|{dtensor}|-?{tensor}|{number}|-?\( {expr} \) -- cgit v1.2.3 From e43ef1fbbfaecfdd3837fb5c5eef23b60be6335e Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Tue, 7 Feb 2012 01:17:16 -0500 Subject: kranc2.peg: Add question about removing an "optional" --- Auxiliary/Grammars/kranc2.peg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index 054eaa4..fe6aab3 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -10,7 +10,7 @@ index_symbol = [a-zA-Z]'*|[0-9] index_expr = {index_symbol}([+-]{int}|) tensor = {name}{indices} dname = D[a-z0-9]* -dtensor = {dname}{indices}? {tensor} +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} \) -- cgit v1.2.3 From 2898d3ef389ea8df8f762cc5f14e7567e4d175d5 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Tue, 7 Feb 2012 01:17:42 -0500 Subject: kranc2.peg: Capture index expression operator in a group --- Auxiliary/Grammars/kranc2.peg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Auxiliary') diff --git a/Auxiliary/Grammars/kranc2.peg b/Auxiliary/Grammars/kranc2.peg index fe6aab3..9111540 100644 --- a/Auxiliary/Grammars/kranc2.peg +++ b/Auxiliary/Grammars/kranc2.peg @@ -7,7 +7,8 @@ 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_expr = {index_symbol}([+-]{int}|) +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? -- cgit v1.2.3