public static void parseFile(Token token, EnegyData data, VariabelDatabase db) { if (parsers == null) setParser(); token.next(); while(data.State == RunningState.Normal && token.getCache().type() != TokenType.EOF) { ParserInterface p; switch (token.getCache().type()) { case TokenType.Use: case TokenType.Class: case TokenType.Function: p = parsers[token.getCache().type()]; break; case TokenType.Public: p = pp; break; default: data.setError(new ScriptError("In file you are only allow to use 'use', 'public', 'class' or 'function'", token.getCache().posision()), db); return; } p.parse(data, db, token); } }
public static CVar convert(object c, EnegyData data, VariabelDatabase db) { if (c is string) { return Types.toString((string)c, data, db, new Posision(0,0)); } else if (c is bool) { return new BooleanVariabel((bool)c); } else if (c is FunctionVariabel) { return (FunctionVariabel)c; } else if (c is double) { return Types.toInt((double)c, data, db, new Posision(0,0)); } else if (c is int) { return Types.toInt(Convert.ToDouble((int)c), data, db, new Posision(0,0)); } else if (c is ObjectVariabel) return (ObjectVariabel)c; else if(c is ClassVariabel) { return (ClassVariabel)c; } data.setError(new ScriptError("Unkown type: " + c.GetType().Name, new Posision(0, 0)), db); return new NullVariabel(); }
public void controleOveride(string name, EnegyData data) { if (!global.ContainsKey(name)) return; CVar var = global[name]; data.setError(new ScriptError("You canĀ“t convert " + name + " becuse it is " + var.type(), new Posision(0, 0)), this); }
public static int getAgumentSize(EnegyData data) { int size; if(int.TryParse(data.Config.get("agument.buffer.size", "20"), out size)) { return size; } return 20; }
public Energy() { Data = new EnegyData() { Config = new ScriptConfig() }; //set the impontans config so the script not can change it! Data.Config.append("tcp.enable", "false", false); Data.Config.append("file.system.enable", "false", false); VariabelDatabase = new VariabelDatabase(); StartItems.CreateStartItems(Data, VariabelDatabase); }
public static void parse(Token token, EnegyData data, VariabelDatabase db) { if(parsers == null) { setParser(); } token.next(); TokenType type; while (data.State == RunningState.Normal && (type = token.getCache().type()) != TokenType.EOF) { if (parsers.ContainsKey(type)) { parsers[type].parse(data, db, token); } else { new VariabelParser().parse(data, db, token); } } }
private static CVar Print_call(CVar[] stack, VariabelDatabase db, EnegyData data, Posision pos) { Console.WriteLine(stack[0].toString(pos, data, db)); return null; }
private static CVar Useage_call(CVar[] stack, VariabelDatabase db, EnegyData data, Posision pos) { Console.WriteLine("----container----"); foreach(string co in db.ContainerKeys()) { Console.WriteLine("-" + co); } Console.WriteLine("------Global-----"); foreach(string go in db.GlobalsKey()) { Console.WriteLine("-" + go); } return new NullVariabel(); }
public void pushFunction(Function function, EnegyData data) { controleOveride(function.Name, data); global.Add(function.Name, new FunctionVariabel(function)); garbageContainer.Add(function.Name); }
public void pushClass(Class c, EnegyData data) { controleOveride(c.GetContainer().Name, data); types.Add(c.GetContainer().Name);//now is this class a types :) garbageType.Add(c.GetContainer().Name); global.Add(c.GetContainer().Name, new ClassVariabel(c)); garbageContainer.Add(c.GetContainer().Name); }
public CVar push(string name, CVar variabel, EnegyData data) { controleOveride(name, data); if (container.ContainsKey(name)) container.Remove(name); container.Add(name, variabel); return variabel; }
public CVar get(string name, EnegyData data) { if (global.ContainsKey(name)) return global[name]; if (container.ContainsKey(name)) return container[name]; data.setError(new ScriptError("Unknown variabel: " + name, new Posision(0, 0)), this); return new NullVariabel(); }