public void OnPlayerPlantTree(AbsTree t, p2Player p, int deltaTurn) { tree = t; tree.OnBeingPlant(p, deltaTurn); t.transform.position = transform.position; t.cell = this; }
internal void Dump(AbsTree source) { if (!dump) { return; } indent = 0; source.Accept(this); }
internal static bool ins(string name, AbsTree acceptor) { if (table.ContainsKey(name)) // prevent duplicated definitions { Report.Error("Duplicate name --> " + name); return(false); } table.Add(name, acceptor); return(true); }
/** Productions * NOTE: use python style indent instead of new line * * source -> exprs * exprs -> expr EOF exprs_ * exprs_ -> expr EOF exprs_ * exprs_ -> * expr -> function * expr -> * * function -> id ( args ) * args -> arg args_ * args_ -> , arg args_ * args_ -> * arg -> id * */ public AbsTree Parse() { Dump("source -> exprs"); AbsTree t = ParseExprs(); if (t != null && lexAn.parsed.Count == 0) { return(t); } else { Report.Dump("Syntax error: " + lexAn.parsed[0]); return(null); } }
AbsTree ParseFunction() { Dump("function -> id ( args )"); Symbol id = peekTakeNext(Token.identifier); if (id != null && peekTakeNext(Token.lparent) != null) { AbsTree t = ParseArgs(); if (peekTakeNext(Token.rparent) != null) { return(new AbsFunCall(id, (AbsArgs)t)); } } return(null); }
virtual protected void Awake() { source = GetComponent <AbsTree>(); targets = new List <p2Player>(); }
public p2FallRecord(AbsTree t, int dt, int io) { tree = t; deltaTurn = dt; initOrder = io; }
static void Run(string[] args) { Console.WriteLine("This is AIM compiler."); string phase = ""; string dump = ""; // parse args for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("--phase=")) { phase = (string)args[i].Substring(8); } else // dump args should be separated by or smth else if (args[i].StartsWith("--dump=")) { dump = (string)args[i].Substring(7); } else if (args[i].StartsWith("--path=")) { path = (string)args[i].Substring(7); outpath = path.Replace(".aim", ".log"); } } string text = File.ReadAllText(path);; Dump("** Begin LEXICAL ANALYZER"); LexAn lexAn = new LexAn(); lexAn.Parse(text); if (dump.Contains("lexan")) { lexAn.Dump(lexAn); } if (phase == "lexan") { return; } Dump("** Begin SYNTAX ANALYZER"); // check if order of commands is correct--> productions Synan synan = new Synan(lexAn, dump.Contains("synan")); AbsTree source = synan.Parse(); if (phase == "synan") { return; } Dump("** Begin AST"); Abstr ast = new Abstr(dump.Contains("ast")); ast.Dump(source); if (phase.Equals("ast")) { return; } Dump("** Begin SEMAN"); SemAn.SemAn semAn = new SemAn.SemAn(dump.Contains("seman")); source.Accept(new NameChecker()); semAn.Dump(source); if (phase.Equals("seman")) { return; } Interpreter.Interpreter interpreter = new Interpreter.Interpreter(); if (phase.Equals("interpreter")) { return; } Report.Error("Unknown phase " + phase + "."); }