private Stmt Assign() { Word t = look as Word; ExceptGrammar(Tag.IDENTITY); Stmt stmt; Id id = top[t.lexeme]; if (id == null) { throw new TokenIdentityNotDeclareException(t); } if (Except(Tag.Equal)) { stmt = new Set(id, Bool()); } else if (Except(Tag.LeftPar)) { //func call stmt = new Call(new FuncCall((id as IdFunc).Func, ReadParams())); } else { ExceptGrammar(Tag.LeftBra); Access x = Offset(id); ExceptGrammar(Tag.Equal); stmt = new SetElem(x, Bool()); } return(stmt); }
private Stmt AssignStmt() { Stmt stmt; var t = _look; Match(Tag.ID); var id = _top.Get(t); if (id == null) { throw new Error("near line " + Lexer.Line + ": " + t + " undeclared"); } if (_look.Tag == '=') { Move(); stmt = new Set(id, BoolExpr()); } else { var x = Offset(id); Match('='); stmt = new SetElem(x, BoolExpr()); } Match(';'); return(stmt); }
internal virtual Stmt assign() { Stmt stmt; Token t = look; match(Tag.ID); Id id = top.get(t); if (id == null) { error(t.ToString() + " undeclared"); } if (look.tag == '=') { // S -> id = E ; move(); stmt = new Set(id, boolean()); } else { // S -> L = E ; Access x = offset(id); match('='); stmt = new SetElem(x, boolean()); } match(';'); return(stmt); }
Stmt assign() { Stmt stmt; Token t = look; match(Tag.ID); Id id = top.get(t); if (id == null) { error(t.ToString() + " undeclared"); } if (look.tag == '=') { move(); stmt = new Set(id, bool_expr(), compileRows); } else { Access x = offset(id); match('='); stmt = new SetElem(x, bool_expr(), compileRows); } match(';'); return(stmt); }
public void TestSetElem() { var acc = new Access(new Id(new Word("arr", Tag.ID), Sara.Type.Int, 0x20), new Constant(20), Sara.Type.Int); var setElem = new SetElem(acc, new Constant(42)); setElem.Gen(10, 20); //Output: // arr [ 20 ] = 42 }
private List <dynamic> ProcessSets(ActorBrain actorBrain, Dialog dialog, XmlNode node) { List <dynamic> listSetElem = new List <dynamic>(); if (node == null) { return(listSetElem); } bool oneUse = ExistsChildNode(node, "oneuse"); foreach (XmlNode childNode in node) { SetElem setElem = ProcessSetElem(actorBrain, dialog, childNode, oneUse); if (setElem != null) { listSetElem.Add(setElem); } } return(listSetElem); }
private SetElem ProcessSetElem(ActorBrain actorBrain, Dialog dialog, XmlNode node, bool oneUse) { dynamic setElem = null; switch (node.Name) { case "set": setElem = new SetElem(actorBrain, dialog); break; case "inc": setElem = new SetElemIncVar(actorBrain, dialog, false); break; case "dec": setElem = new SetElemIncVar(actorBrain, dialog, true); break; } if (setElem != null) { oneUse = oneUse || ExistsChildNode(node, "oneuse"); string name = FindChildText(node, "name"); string value = null; SetFunctionElem functionElem = null; XmlNode funcNode = FindChildNode(node, "value"); if (funcNode != null) { functionElem = ProcessSetFunctionElem(actorBrain, GetChildNode(funcNode)); } if (functionElem == null) { value = FindChildText(node, "value"); if (value != null && value.Length == 0) { value = null; } } if (name != null) { name = name.ToLower(); } else { name = GetTextNode(node); if (name != null && name.Length == 0) { name = null; } } setElem.SetOneUse(oneUse); setElem.SetName(name); setElem.SetValue(value); setElem.SetFunction(functionElem); } return(setElem); }