public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); var nodes = treeNode.ChildNodes; if (nodes.Count != 3) { throw new Exception("If node extended 3 children, received {0}".SafeFormat(nodes.Count)); } _expression = AddChild(string.Empty, nodes[0]) as AstNode; if (_expression == null) { throw new Exception("No expression for if!"); } _trueBranch = AddChild(string.Empty, nodes[1]) as AstNode; if (_expression == null) { throw new Exception("No true branch for if!"); } _falseBranch = AddChild(string.Empty, nodes[2]) as AstNode; if (_expression == null) { throw new Exception("No false branch for if!"); } }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); _target = AddChild(string.Empty, treeNode.ChildNodes[0]) as AstNode; _source = AddChild(string.Empty, treeNode.ChildNodes[1]) as AstNode; }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); var nodes = treeNode.ChildNodes; if (nodes.Count != 2) { throw new Exception("MtBind expects 2 children (received {0}).".SafeFormat(nodes.Count)); } // AstNodeInterpreter, from Irony _targetName = AddChild(string.Empty, nodes[0]) as AstNode; if (_targetName == null) { throw new Exception("No identifier for Bind!"); } // An arbitrary Mt node _expression = AddChild(string.Empty, nodes[1]) as MtAstNode; if (_expression == null) { throw new Exception("No expression for Bind!"); } }
public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode) { base.Init(context, parseNode); Value = parseNode.Token.Value; AsString = Value == null ? "null" : Value.ToString(); if (Value is string) { AsString = "\"" + AsString + "\""; } }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); foreach (var node in treeNode.ChildNodes) { var child = AddChild(string.Empty, node); if (child == null) { throw new Exception("Argument without an AST node!"); } _args.Add(child); } }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); foreach (var node in treeNode.ChildNodes) { var id = AddChild(string.Empty, node) as AstNode; if (id == null) { throw new Exception("Argument can't be null!"); } _argList.Add(id); } }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); if (treeNode.ChildNodes.Count != 1) { throw new Exception("Expected 1 child, received {0}".SafeFormat(treeNode.ChildNodes.Count)); } _expressionList = AddChild(string.Empty, treeNode.ChildNodes[0]) as MtExpressionList; if (_expressionList == null) { throw new Exception("Child should be a MtExpressionList!"); } }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); if (treeNode.ChildNodes.Count != 2) { throw new Exception("MtChain expects 1 child (received {0}.)".SafeFormat(treeNode.ChildNodes.Count)); } _head = AddChild(string.Empty, treeNode.ChildNodes[0]); // Called with a new context, include result of head as '_' _tail = AddChild(string.Empty, treeNode.ChildNodes[1]); AsString = "Chain"; }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); var nodes = treeNode.ChildNodes; if (nodes.Count != 2) { throw new Exception("FunctionLiteral expected 2 children, received {0}".SafeFormat(nodes.Count)); } _arguments = AddChild(string.Empty, nodes[0]) as MtArgListForDecl; if (_arguments == null) { throw new Exception("List of arguments can't be null!"); } _body = AddChild(string.Empty, nodes[1]) as AstNode; if (_body == null) { throw new Exception("Body of function can't be null!");/*v*/ } }
public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode) { base.Init(context, parseNode); AsString = "break"; }
public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); _value = treeNode.ChildNodes[0].Token.Value; AsString = "Atom"; }