{
if (DelSurroundingText != null)
{
+ Console.WriteLine ("deleting the prev {0} chars", - pos);
callback_arg.Set (MSymbol.integer, pos);
if (DelSurroundingText (this, callback_arg))
{
{
if (DelSurroundingText != null)
{
+ Console.WriteLine ("deleting the next {0} chars",
+ pos - preedit.Length);
callback_arg.Set (MSymbol.integer, pos - preedit.Length);
if (DelSurroundingText (this, callback_arg))
{
private bool del_surrounding_text (Context ic, MPlist args)
{
int pos = this.pos + args.Integer;
+ Console.WriteLine ("del-surround: {0}-{1}", this.pos, pos);
if (pos < this.pos)
{
mt.Del (pos, this.pos);
using System.Collections;
using System.Collections.Generic;
using System.IO;
+using System.Reflection;
using System.Xml;
namespace System.Xml
termtypes[name] = new TermType (name, parser);
}
+ public void DefType (Type type)
+ {
+ if (! type.IsSubclassOf (typeof (TermValue)))
+ throw new Exception ("Not a subclass of TermValue: " + type);
+ BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic;
+ FieldInfo finfo = type.GetField ("name", flags);
+ if (finfo == null)
+ throw new Exception ("No \"name\" field: " + type);
+ Type[] types = new Type[] { typeof (Domain), typeof (XmlNode),
+ typeof (TermValue) };
+ MethodInfo minfo = type.GetMethod ("Parser");
+ if (minfo == null)
+ throw new Exception ("No \"Parser\" method: " + type);
+ }
+
public void DefSubr (Builtin builtin, string str, bool setvar,
int min_arg, int max_arg, params string[] aliases)
{
{
basic.DefTerm ("funcall", Funcall.parser);
basic.DefTerm ("varref", Varref.parser);
+ basic.DefType (typeof (Funcall));
basic.DefSubr (Fset, "set", true, 1, 1, "=");
basic.DefSubr (Fnot, "not", false, 1, 1, "!");
public class TermType
{
- public readonly Symbol type;
- internal readonly TermParser parser;
+ private readonly Symbol name;
+ private readonly TermParser parser;
- public TermType (Symbol type, TermParser parser)
+ public TermType (Symbol name, TermParser parser)
{
- this.type = type;
+ this.name = name;
this.parser = parser;
}
+
+ public Symbol Name { get { return name; } }
+ internal TermParser Parser { get { return parser; } }
}
public abstract class TermValue
private class Varref : TermValue
{
- private Symbol name;
+ private Symbol vname;
private Variable vari;
- public Varref (Symbol name) { this.name = name; }
+ public Varref (Symbol vname) { this.vname = vname; }
public override Term Eval (Domain domain)
{
if (vari == null || vari.domain != domain)
- vari = domain.GetVar (name, true);
+ vari = domain.GetVar (vname, true);
return vari.Value;
}
public override string ToString ()
{
- return "<varref vname=\"" + name + "\"/>";
+ return "<varref vname=\"" + vname + "\"/>";
}
}
private class Funcall : TermValue
{
+ private static Symbol name = "funcall";
+
+ public static Symbol Name { get { return name; } }
+
internal Function func;
internal Variable vari;
internal Term[] args;
this.args = args;
}
+ public static TermValue Parser (Domain domain, XmlNode node)
+ {
+ return null;
+ }
+
internal static TermValue parser (Domain domain, XmlNode node)
{
Symbol fname = node.Name;
TermType term_type;
if (domain.termtypes.TryGetValue (name, out term_type))
- objval = term_type.parser (domain, node);
+ objval = term_type.Parser (domain, node);
else
{
Funcall funcall = (Funcall) Funcall.parser (domain, node);