if (list[i].IsInt)
keyseq.Add (new Key (list[i].Intval));
else if (list[i].IsStr)
- keyseq.Add (new Key (list[i].Strval));
+ keyseq.Add (new Key (list[i].Strval.ToString ()));
else if (list[i].IsSymbol)
keyseq.Add (new Key ((string) list[i].Symval));
else
public static Xex.TermValue Parser (Xex.Domain domain, XmlNode node)
{
- Xex.Term term = new Xex.Term (domain, node.FirstChild).Eval (domain);
- return (term.IsStr ? new KeySeq ((MText) term.Strval)
+ Xex.Term term = Xex.Parse (domain, node.FirstChild);
+ term = Xex.Eval (domain, term);
+ return (term.IsStr ? new KeySeq ((MText) term.Strval.ToString ())
: new KeySeq (term.Listval));
}
object[] parameters = new object[2];
public PluginMethod (Plugin plugin, string name)
- : base ((Xex.Symbol) name, 0, -1)
+ : base ((Xex.Symbol) name, false, 0, -1)
{
this.plugin = plugin;
}
args = (Xex.Term[]) args.Clone ();
for (int i = 0; i < args.Length; i++)
{
- args[i] = args[i].Eval (domain);
- if (domain.Thrown)
+ args[i] = Xex.Eval (domain, args[i]);
+ if (domain.Thrown ())
return args[i];
}
if (method_info == null)
{
Index = index;
if (term.IsStr)
- Data = (MText) term.Strval;
+ Data = (MText) term.Strval.ToString ();
else
{
MPlist plist = new MPlist ();
MPlist p = plist;
foreach (Xex.Term t in term.Listval)
- p = p.Add (MSymbol.mtext, (MText) t.Strval);
+ p = p.Add (MSymbol.mtext, (MText) t.Strval.ToString ());
Data = plist;
}
}
public bool Run (Xex.Domain domain)
{
- Xex.Term result = action.Eval (domain);
+ Xex.Term result = Xex.Eval (domain, action);
if (result.IsError)
{
((Context) domain.context).Error = result.ToString ();
for (node = node.FirstChild; node != null; node = node.NextSibling)
{
if (node.Name == Qstate_hook)
- enter_actions = Xex.ParseTerms (im.domain, node.FirstChild);
+ enter_actions = Xex.Parse (im.domain, node.FirstChild, null);
else if (node.Name == Qcatch_all_branch)
- fallback_actions = Xex.ParseTerms (im.domain, node.FirstChild);
+ fallback_actions = Xex.Parse (im.domain, node.FirstChild, null);
else if (node.Name == Qbranch)
{
MSymbol mapname = node.Attributes[Qmname].Value;
Map map;
if (im.maps.TryGetValue (mapname, out map))
- keymap.AddMap (map, Xex.ParseTerms (im.domain,
- node.FirstChild));
+ keymap.AddMap (map, Xex.Parse (im.domain, node.FirstChild,
+ null));
else
throw new Exception ("Unknown map: " + mapname);
}
variables = new Xex.Variable[var_names.Length];
int i = 0;
foreach (Xex.Symbol name in var_names)
- variables[i++] = domain.GetVar (name, false);
+ variables[i++] = domain.GetVar (name);
}
commands = this.commands;
return true;
if (! im_global.Open ())
throw new Exception ("Failed to load global");
}
- return im_global.domain.GetVar (name, false);
+ return im_global.domain.GetVar (name);
}
private void parse_variables (MPlist plist)
Xex.Variable vari = get_global_var (name);
if (vari != null)
domain.Defvar (vari);
- domain.Defvar (node_list[i]);
+ Xex.Parse (domain, node_list[i]);
var_names[i] = name;
}
}
private void parse_macros (XmlNode node)
{
for (XmlNode nn = node.FirstChild; nn != null; nn = nn.NextSibling)
- if (nn.NodeType == XmlNodeType.Element)
- {
- if (nn.Name == Xex.Qdefun)
- domain.Defun (nn, true);
- else if (nn.Name == Qxi_include)
+ if (nn.NodeType == XmlNodeType.Element && nn.Name == Qxi_include)
+ {
parse_include (nn);
- }
- for (XmlNode nn = node.FirstChild; nn != null; nn = nn.NextSibling)
- if (nn.NodeType == XmlNodeType.Element
- && nn.Name == Xex.Qdefun)
- domain.Defun (nn, false);
+ nn = nn.PreviousSibling;
+ node.RemoveChild (nn.NextSibling);
+ }
+ Xex.Parse (domain, node.FirstChild, null);
}
private void parse_maps (XmlNode node)
if (n.Name != Qkeyseq)
continue;
KeySeq keyseq = (KeySeq) KeySeq.Parser (domain, n);
- Xex.Term[] actions = Xex.ParseTerms (domain, n.NextSibling);
+ n = n.NextSibling;
+ Xex.Term[] actions = Xex.Parse (domain, n, null);
map.entries.Add (new Map.Entry (domain, keyseq, actions));
}
}
return terms;
}
- private Xex.Variable[] parse_args (Xex.Domain domain, Xex.Symbol[] args)
- {
- int nfixed = 0;
- int noptional = 0;
- int nrest = 0;
-
- if (args.Length > 0)
- {
- int i = 0;
- for (i = 0; i < args.Length; i++, nfixed++)
- if (args[i] == Qoptional || args[i] == Qrest)
- break;
- if (i < args.Length)
- {
- if (args[i] == Qoptional)
- {
- for (i++; i < args.Length; i++, noptional++)
- if (args[i] == Qrest)
- break;
- if (i < args.Length)
- nrest = 1;
- }
- }
- min_args = nfixed;
- max_args = nfixed + noptional + nrest;
- this.args = new Variable[max_args];
- int j;
- for (i = j = 0; j < this.args.Length; i++)
- if (args[i] != Qoptional || args[i] != Qrest)
- this.args[j++] = domain.Defvar (args[i]);
- }
- else
- {
- min_args = max_args = 0;
- }
- with_var = false;
- }
-
private void parse_macros (MPlist plist)
{
for (MPlist pl = plist; ! pl.IsEmpty; pl = pl.next)
MPlist p = pl.Plist;
if (! p.IsSymbol)
continue;
- domain.Defun ((Xex.Symbol) p.Symbol.Name, null, null, true);
+ domain.Defun ((Xex.Symbol) p.Symbol.Name, 0, 0, null, null);
}
for (MPlist pl = plist; ! pl.IsEmpty; pl = pl.next)
if (pl.IsPlist)
{
MPlist p = pl.Plist;
-
if (! p.IsSymbol)
continue;
- domain.Defun ((Xex.Symbol) p.Symbol.Name, null,
- parse_actions (p.next, false), false);
+ domain.Defun ((Xex.Symbol) p.Symbol.Name, 0, 0, null,
+ parse_actions (p.next, false));
}
}
if (args[0].IsInt)
((Context) domain.context).insert (args[0].Intval, null);
else
- ((Context) domain.context).insert ((MText) args[0].Strval, null);
+ ((Context) domain.context).insert ((MText) args[0].Strval.ToString (),
+ null);
return args[0];
}
Xex.Term[] args)
{
Context ic = (Context) domain.context;
- Xex.Variable v = ic.domain.GetVar (Qcandidates_group_size, false);
- int column = (v == null ? 0 : v.Value.Intval);
+ Xex.Variable v = ic.domain.GetVar (Qcandidates_group_size);
+ int column = v == null ? 0 : v.Value.Intval;
Candidates candidates = new Candidates (args, column);
object candidate = candidates.Current;
if (args[0].IsInt)
ic.pushback (args[0].Intval);
else if (args[0].IsStr)
- ic.pushback (new KeySeq (args[0].Strval));
+ ic.pushback (new KeySeq (args[0].Strval.ToString ()));
else
ic.pushback ((KeySeq) args[0].Objval);
return args[0];
catch_args[0] = Tcatch_tag;
catch_args[1]= new Xex.Term (domain, Qprogn, actions);
Xex.Term term = new Xex.Term (domain, Qcatch, catch_args);
- term = term.Eval (domain);
+ term = Xex.Eval (domain, term);
return (! term.IsSymbol || term.Symval != Tcatch_tag.Symval);
}
{
if (im.load_status != LoadStatus.Full
&& ! im.Open ())
- throw new Exception ("Openging " + im.tag + " failed");
+ throw new Exception ("Opening " + im.tag + " failed");
this.im = im;
domain = new Xex.Domain ("context", im.domain, this);
initial_state = (State) im.states.Val;