public static CharValue New(char value, SrcInfo si) { var ret = new CharValue(); ret.value = value; ret.SrcInfo = si; return ret; }
public static SrcInfo New(string source, int number, int position) { var ret = new SrcInfo(); ret.Source = source; ret.Number = number; ret.Position = position; return ret; }
public Exception AbortInfo(SrcInfo si, string format, params object[] args) { var s1 = ""; var s2 = ""; if (si != null) { s1 = si.Source + ": "; s2 = string.Format("[{0}:{1}] ", si.Number, si.Position); } return new Exception(s1 + s2 + string.Format(format, args)); }
private NodeBase ReservedInternal(SrcInfo si, string t) { string t2; NodeBase arg; switch (t) { case "null": return Null.New(parent); case "true": return Cast.New(parent, "bool", IntValue.One); case "false": return Cast.New(parent, "bool", IntValue.Zero); case "base": return Base.New(parent); case "new": return ReadNew(); case "function": return AutoDelegate(ReadFunction(t, false)); case "delegate": return ReadDelegate(); case "\\": return AutoDelegate(Lambda()); case "sizeof": t2 = Read(); if (t2 != "(" && t2 != null) Rewind(); arg = ReadExpression(); if (arg == null) throw parent.AbortInfo(si, "sizeof: 引数が必要です。"); if (t2 == "(") Check("sizeof", ")"); return SizeOf.New(parent, arg); case "addrof": return AddrOf.New(parent, ReadExpression()); case "typeof": t2 = Read(); if (t2 != "(" && t2 != null) Rewind(); arg = ReadExpression(); if (arg == null) throw parent.AbortInfo(si, "typeof: 引数が必要です。"); if (t2 == "(") Check("typeof", ")"); if (arg is TypeOf) return arg; return TypeOf.New(parent, arg); case "__FUNCTION__": return StringValue.New(parent.FullName); case "__FILE__": return StringValue.New(si.Source); case "__LINE__": return IntValue.New(si.Number); case "__VERSION__": return StringValue.New("LLPML ver." + Root.VERSION); default: return null; } }
public static TokenData New(int pos, SrcInfo si) { var ret = new TokenData(); ret.Pos = pos; ret.SrcInfo = si; return ret; }