Skip to content

Commit

Permalink
KrancScript.m: Add support for variables and temporaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Jan 28, 2012
1 parent 82ea63c commit 22e16e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Tools/CodeGen/KrancScript.m
Expand Up @@ -95,15 +95,17 @@

process[thorn:"thorn"[content___]] :=
Module[
{calcs = {}, name, options},
{calcs = {}, name, options, variables = {}, temporaries = {}},

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]],
_, ThrowError["Unrecognised element '"<>Head[el]<>"' in thorn"]],
{el, {content}}];

options = {Calculations -> calcs};
options = {Calculations -> calcs, Variables -> variables, Shorthands -> temporaries};
CreateThornTTExpression[groups,parentDirectory,name,Sequence@@options]];

process[calc:"calculation"[content___]] :=
Expand Down

0 comments on commit 22e16e3

Please sign in to comment.