private static Modifier ConvertNode(ITree node) { switch ((JavaNodeType) node.Type) { case JavaNodeType.PUBLIC: return Modifier.Public; case JavaNodeType.PROTECTED: return Modifier.Protected; case JavaNodeType.PRIVATE: return Modifier.Private; case JavaNodeType.STATIC: return Modifier.Static; case JavaNodeType.ABSTRACT: return Modifier.Abstract; case JavaNodeType.NATIVE: return Modifier.Native; case JavaNodeType.SYNCHRONIZED: return Modifier.Syncronized; case JavaNodeType.TRANSIENT: return Modifier.Transient; case JavaNodeType.VOLATILE: return Modifier.Volatile; case JavaNodeType.STRICTFP: return Modifier.Strict; default: throw new NotImplementedException(); } }
public override void SetChild(int i, ITree t) { var oldChild = this.Children; base.SetChild(i, t); if (oldChild == null && this.Children != null) OnChanged("Children"); }
public static TreeItemType AddNewItem(ITree tree, Func<ITreeItem> createProject, Func<ITreeItem> createDiagram, IdCounter counter) { var selected = tree.GetSelectedItem() as ITreeItem; var type = GetTreeItemType(selected.GetUid()); if (type == TreeItemType.Diagram) { var project = selected.GetParent() as ITreeItem; AddDiagram(project, true, createDiagram, counter); return TreeItemType.Diagram; } else if (type == TreeItemType.Project) { AddDiagram(selected, true, createDiagram, counter); return TreeItemType.Diagram; } else if (type == TreeItemType.Solution) { AddProject(selected, createProject, counter); return TreeItemType.Project; } return TreeItemType.None; }
internal static QueryParseException Create(ITree parserNode, string message, string parsedString, Exception innerException, QueryParseErrorReason? errorReason = null, string memberName = null) { if (parserNode != null && parsedString != null) { var sb = new StringBuilder(); sb.AppendLine(message); var commonErrorNode = parserNode as CommonErrorNode; var line = parserNode.Line; var charPositionInLine = parserNode.CharPositionInLine; if (commonErrorNode != null) { line = commonErrorNode.trappedException.Line; charPositionInLine = commonErrorNode.trappedException.CharPositionInLine; sb.AppendFormat("({0})\r\n", commonErrorNode.trappedException.Message); } sb.AppendFormat("Error on line {0} character {1} of query:\r\n", line, charPositionInLine); sb.Append(' ', charPositionInLine); sb.AppendLine("|/"); sb.AppendLine(GetLineOfString(parsedString, line)); message = sb.ToString(); } return new QueryParseException(message, innerException, errorReason ?? QueryParseErrorReason.GenericError, memberName); }
public List<string> getBranchListDisplay(ITree t) { List<string> strList = new List<string>(); int count = 1; foreach (var tb in branchList) { var branchInclude = true; //check conditions on branch if (tb.conditionList != null) { foreach (var cond in tb.conditionList) { if (!t.globalFlags.checkFlag(cond.flagName, cond.value, cond.flagCompareType)) { branchInclude = false; } } } if (branchInclude) { strList.Add(string.Format("-->{0}. {1}", count, tb.ToString())); count++; } } return strList; }
public static Type ProcessClass(ITree node) { switch ((JavaNodeType)node.Type) { case JavaNodeType.QUALIFIED_TYPE_IDENT: return ProcessQualified(node); case JavaNodeType.BOOLEAN: return PrimativeTypes.Boolean; case JavaNodeType.CHAR: return PrimativeTypes.Char; case JavaNodeType.BYTE: return PrimativeTypes.Byte; case JavaNodeType.SHORT: return PrimativeTypes.Short; case JavaNodeType.INT: return PrimativeTypes.Int; case JavaNodeType.LONG: return PrimativeTypes.Long; case JavaNodeType.FLOAT: return PrimativeTypes.Float; case JavaNodeType.DOUBLE: return PrimativeTypes.Double; default: throw new NotImplementedException(); } }
//------------------------------------------------------------------------------------- /// <summary> /// Инициализирующий конструктор. /// </summary> /// <param name="hasChildren">Определяет, имеются ли дочерние элементы.</param> /// <param name="item">Элемент дерева, для которого определяется наличие дочерних элементов.</param> /// <param name="tree">Дерево</param> public SimTreeGridItemEventArgs(ITree tree, ITreeItem item, bool hasChildren) : this() { Item = item; HasChildren = hasChildren; Tree = tree; }
public List<string> Validate(ITree tree) { _errors = new List<string>(); CreateFilterInner(); InnerValidate(tree.Root); return _errors; }
public static Statement Parse(ITree tree) { if (tree.Text == "FUNCCALL") { Expression exp = tree.ParseExpr(); return new ExprStatement(exp); } else if (tree.Text == "IF") { Expression cond = tree.GetChild("IF_CONDITION").GetOnlyChild().ParseExpr(); ITree actionTree = tree.GetChild("IF_ACTION"); Statement action = actionTree.ParseStmtList(); return new IfStatement(cond, action); } else if (tree.Text == "ASSIGNMENT") { Expression variable = tree.GetChild(0).ParseExpr(); Expression value = tree.GetChild(1).ParseExpr(); Statement assignment = new AssignmentStatement(variable, value); return assignment; } else if (tree.Text == "Return") { Expression exp = tree.GetOnlyChild().ParseExpr(); return new ReturnStatement(exp); } else { throw new InvalidGameException(tree.FileCoords() + " - Ivalid statement: " + tree.Text); } }
public void Block(ITree node) { for (int i = 0; i < node.ChildCount; i++) { Execute(node.GetChild(i)); } }
public MSILGenerator(ITree programNode) { if (programNode.Type != AstNodeType.PROGRAM) throw new MSILGeneratorException("AST-дерево не является программой"); this.programNode = programNode; }
/// <summary> /// Gets the command for the function called in the specified source tree. /// </summary> /// <param name="source">The source Antlr tree representing a function call..</param> /// <returns>The parsed AstFunctionNode.</returns> /// <exception cref="NoViableAltException"><c>NoViableAltException</c>.</exception> private static PostfixMathCommand GetCommandForOperator( ITree source ) { PostfixMathCommand command; switch ( source.Type ) { case TokenTypes.OP_ADD: command = new Add(); break; case TokenTypes.OP_SUBTRACT: command = new Subtract(); break; case TokenTypes.OP_MULTIPLY: command = new Multiply(); break; case TokenTypes.OP_DIVIDE: command = new Divide(); break; default: throw new NoViableAltException(); } return command; }
private ITree FindStmt(ITree t) { ITree treeStmt = null; ITree child = null; for (int idx = 0; idx < t.ChildCount; idx++) { if (t.GetChild(idx).Text == "<EOF>") continue; child = t.GetChild(idx); if ( (child.Text.Equals("create", StringComparison.OrdinalIgnoreCase)) && (child.GetChild( child.ChildCount - 1 ).Text.Equals( "begin_stmt", StringComparison.OrdinalIgnoreCase ) )) { treeStmt = FindStmt( child ); if( treeStmt != null ) { break; } } else { if (child.TokenStartIndex == -1 || child.TokenStopIndex == -1) return null; if ((position >= tokens.Get(child.TokenStartIndex).StartIndex) && (position <= tokens.Get(child.TokenStopIndex).StopIndex)) { treeStmt = child; break; } } } if (t.IsNil) { treeStmt = child; } return treeStmt; }
public MathExprIntepreter(ITree programNode) { if (programNode.Type != AstNodeType.PROGRAM) throw new IntepreterException("AST-дерево не является программой"); this.programNode = programNode; }
public fsTypeInferer(ITree tree, string outFileName) { this.tree = tree; functionsInfos = new Dictionary<string, fsDerFuncInfo>(); varDerFuncTable = new Dictionary<string, fsDerFuncInfo>(); enteredFunctionsNames = new List<string>(); enteredFunctionsNames.Add(outFileName); inferenceFunctions = new Dictionary<int, InferNodeTypeDelegate>(); inferenceFunctions.Add(fsharp_ssParser.PROGRAM, InferProgramType); inferenceFunctions.Add(fsharp_ssParser.PLUS, InferPlusType); inferenceFunctions.Add(fsharp_ssParser.MINUS, InferMinusType); inferenceFunctions.Add(fsharp_ssParser.MULT, InferMultType); inferenceFunctions.Add(fsharp_ssParser.DIV, InferDivideType); inferenceFunctions.Add(fsharp_ssParser.EQ, InferEqNeqOperType); inferenceFunctions.Add(fsharp_ssParser.NEQ, InferEqNeqOperType); inferenceFunctions.Add(fsharp_ssParser.GT, InferCompareOperType); inferenceFunctions.Add(fsharp_ssParser.GE, InferCompareOperType); inferenceFunctions.Add(fsharp_ssParser.LT, InferCompareOperType); inferenceFunctions.Add(fsharp_ssParser.LE, InferCompareOperType); inferenceFunctions.Add(fsharp_ssParser.ID, InferIDType); inferenceFunctions.Add(fsharp_ssParser.INT, InferIntType); inferenceFunctions.Add(fsharp_ssParser.DOUBLE, InferDoubleType); inferenceFunctions.Add(fsharp_ssParser.CHAR, InferCharType); inferenceFunctions.Add(fsharp_ssParser.TRUE, InferBoolType); inferenceFunctions.Add(fsharp_ssParser.FALSE, InferBoolType); inferenceFunctions.Add(fsharp_ssParser.STRING, InferStringType); inferenceFunctions.Add(fsharp_ssParser.BODY, InferBodyType); inferenceFunctions.Add(fsharp_ssParser.IF, InferIfClauseType); inferenceFunctions.Add(fsharp_ssParser.ELIF, InferElifClauseType); inferenceFunctions.Add(fsharp_ssParser.FUNCTION_DEFN, InferFunctionDefnType); inferenceFunctions.Add(fsharp_ssParser.FUNCTION_CALL, InferFuncCallType); inferenceFunctions.Add(fsharp_ssParser.VALUE_DEFN, InferValueDefnType); }
public void SetUp() { forest = new Forest(); // forest.CurrentSeason = forest.GetSeason(DateTime.Now); forest.Add(TypeOfTree.Fir); first = forest.TreesInForest[0]; }
public LiteralExpression(ITree tree) { for(int i = 0; i<tree.ChildCount;i++) { value += tree.GetChild(i).Text; } }
public static new SetType CreateFromAntlrAst(ITree tree) { SetType ret = DefaultBackend.Instance.Factory.CreateSetType(); if (tree.ChildCount>0) SequenceOrSetType.CreateFromAntlrAst(ret, tree.GetChild(0)); return ret; }
private static MethodTree WalkInit(ITree initNode) { Debug.Assert(initNode.Type == (int)JavaNodeType.FOR_INIT); if (initNode.ChildCount == 0) { return null; } var child = initNode.GetChild(0); var exprs = new MethodTree(); if (child.Type == (int)JavaNodeType.VAR_DECLARATION) { new VarDeclarationTranslator(child).Walk().ForEach(exprs.Add); } else { for (var i = 0; i < initNode.ChildCount; i++) { exprs.Add(new ExpressionTranslator(initNode.GetChild(i)).Walk()); } } return exprs; }
/// <summary> /// Initializes a new instance of the <see cref="TreeObject"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="type"> /// The type. /// </param> /// <param name="numericTree"> /// The numeric tree. /// </param> public TreeObject(string name, string type, ITree<double> numericTree) { this.Name = name; this.Type = type; this.TextTree = null; this.NumericTree = numericTree; }
//^(SEQUENCE_OF_TYPE (SIMPLIFIED_SIZE_CONSTRAINT $sz)? $gen? identifier? type) public static new SequenceOfType CreateFromAntlrAst(ITree tree) { SequenceOfType ret = DefaultBackend.Instance.Factory.CreateSequenceOfType(); for (int i = 0; i < tree.ChildCount; i++) { ITree child = tree.GetChild(i); switch (child.Type) { case asn1Parser.SIMPLIFIED_SIZE_CONSTRAINT: case asn1Parser.CONSTRAINT: ret.m_AntlrConstraints.Add(child); break; case asn1Parser.LID: ret.m_xmlVarName = child.Text; break; case asn1Parser.TYPE_DEF: ret.m_type = Asn1Type.CreateFromAntlrAst(child); break; default: throw new Exception("Unkown child: " + child.Text + " for node: " + tree.Text); } } return ret; }
public void Execute(ITree node) { switch (node.Type) { case cLexer.ASSIGN: Assign(node); break; case cLexer.VAR_DEC: VarsDeclaration(node); break; // todo funccall // todo read // todo write // todo func_declaration // todo return case cLexer.BLOCK: Block(node); break; case cLexer.IF: If(node); break; // todo for_construction default: throw new Exception("Non executable node."); } }
public void GenerateClassFiles(ITree sourceAST) { List<string> mainFile = new List<string>(); GenerateManifest(); Generate(sourceAST, mainFile); SaveToFile(mainFile, outputFileName); }
public void Assign(ITree node) { string var_name = node.GetChild(0).ToString(); ITree node_to_solve = node.GetChild(1); _varStorage[var_name].Assign(Solve(node_to_solve)); }
private static Stylesheet BuildStylesheet(ITree tree) { var stylesheet = new Stylesheet(); stylesheet.Build(tree); return stylesheet; }
protected override IRequest InternalToTransferCodeBase(IPuzzlePiece root, ITree<IPuzzlePiece> matchtree, Dictionary<string, object> bindings) { ILocation loca = TilingUtils.MatchLocation (matchtree.ChildAt(0x00).ChildAt(0x00).Data); ILocation locb = TilingUtils.MatchLocation (matchtree.ChildAt(0x00).ChildAt(0x01).Data); DateTime dt = bindings.ValueOrDefault<string,object,DateTime>("time"); string als = bindings.ValueOrDefault<string,object,string>("airlinecode"); string scs = bindings.ValueOrDefault<string,object,string>("classname"); Airline al = null; SeatClass sc = null; if(als != null) { al = new Airline (als); } if(scs != null) { sc = new SeatClass (scs); } if (loca is Country && locb is Country) { return new RequestGetFlights ((Country)loca, (Country)locb, dt, al, sc); } else if (loca is City && locb is City) { return new RequestGetFlights ((City)loca, (City)locb, dt, al, sc); } else if (loca is Airport && locb is Airport) { return new RequestGetFlights ((Airport)loca, (Airport)locb, dt, al, sc); } else { return null; } }
private static string getStringSubTree(ITree node, string indent, bool root) { if (node == null) return ""; string result = indent; if (!root) { if (node.ChildIndex < node.Parent.ChildCount - 1) { result += MiddleNodeChar + " "; indent += ConnectChar + " "; } else { result += LastNodeChar + " "; indent += " "; } } result += node + "\n"; for (int i = 0; i < node.ChildCount; i++) result += getStringSubTree(node.GetChild(i), indent, false); return result; }
public override void AddChild(ITree t) { var oldChild = this.Children; base.AddChild(t); if (oldChild == null && this.Children != null) OnChanged("Children"); }
public List<TreeBranch> getBranchList(ITree t) { List<TreeBranch> branchList = new List<TreeBranch>(); foreach (var tb in this.branchList) { var branchInclude = true; //check conditions on branch if (tb.conditionList != null) { foreach (var cond in tb.conditionList) { if (!t.globalFlags.checkFlag(cond.flagName, cond.value, cond.flagCompareType)) { branchInclude = false; } } } if (branchInclude) { branchList.Add(tb); } } return branchList; }
public MethodTranslator(ITree node) { Debug.Assert( node.Type == (int) JavaNodeType.VOID_METHOD_DECL || node.Type == (int) JavaNodeType.FUNCTION_METHOD_DECL); this.node = node; }
/// <summary> /// Transforms an EXTENDS tree node into a list of Qualifier objects. /// </summary> /// <param name="extending">The AST node</param> /// <returns>The list of qualifiers</returns> public List <Qualifier> Extendation(ITree extending) { return(GetExtendation(extending)); }
protected ObjectDef EmitInteger(ITree expressionNode) { var result = new ValueObjectDef(typeof(int), int.Parse(expressionNode.ToString())); return(result); }
/// <summary> /// Transforms an IMPLEMENTS tree node into a list of Qualifier objects. /// </summary> /// <param name="implementing">The AST node</param> /// <returns>The list of qualifiers</returns> public List <Qualifier> Implements(ITree implementing) { return(GetImplements(implementing)); }
protected ObjectDef EmitBoolean(ITree expressionNode) { var result = new ValueObjectDef(typeof(bool), bool.Parse(expressionNode.ToString())); return(result); }
protected ObjectDef EmitDouble(ITree expressionNode) { var result = new ValueObjectDef(typeof(double), double.Parse(expressionNode.ToString())); return(result); }
public ManageController(IMongoRepository <ServiceList> rep, IMongoRepository <GroupName> group, ITree tree, IMongoRepository <FileEntity> file, IMongoRepository <ServiceAlertContacts> alertContacts) : base(rep) { _tree = tree; _file = file; _alertContacts = alertContacts; _group = group; Rep = rep; Updated += ManageController_Updated; }
public PrototypeFactory(ITree tree, IFlower flower, IFruit fruit) { this.tree = tree; this.flower = flower; this.fruit = fruit; }
private void Enter(ITree <T> tree) { _nodeVisitor.OnEnter(tree, null); }
private void Leave(ITree <T> tree) { _nodeVisitor.OnLeave(tree, null); }
/// <summary> /// Checks if the current context is invalid for further visiting /// </summary> /// <param name="context"></param> private bool IsInvalidContext(ITree context) => context == null || context.ChildCount == 0;
/// <summary> /// Creates the chain. /// </summary> /// <param name="parameter1">The parameter1.</param> /// <param name="parameter2">The parameter2.</param> /// <param name="nodes">The nodes.</param> /// <exception cref="NotSupportedException"></exception> private void CreateChain(TParameter1 parameter1, TParameter2 parameter2, ITree nodes) { foreach (var treeRoot in nodes.Roots) { switch (treeRoot) { case ParameterNode parameterElement: { if (!(parameterElement.Next is PropertyNode propertyElement)) { continue; } var parameterGetter = ExpressionGetter.CreateParameterGetter( parameterElement, propertyExpression); var root = new RootPropertyObserverNode( propertyElement.PropertyInfo, this.OnAction, (INotifyPropertyChanged)parameterGetter(parameter1, parameter2)); Looptree(propertyElement, root); RootNodes.Add(root); break; } case ConstantNode constantElement when treeRoot.Next is FieldNode fieldElement: { if (!(fieldElement.Next is PropertyNode propertyElement)) { continue; } var root = new RootPropertyObserverNode( propertyElement.PropertyInfo, this.OnAction, (INotifyPropertyChanged)fieldElement.FieldInfo.GetValue(constantElement.Value)); Looptree(propertyElement, root); RootNodes.Add(root); break; } case ConstantNode constantElement: { if (!(treeRoot.Next is PropertyNode propertyElement)) { continue; } var root = new RootPropertyObserverNode( propertyElement.PropertyInfo, this.OnAction, (INotifyPropertyChanged)constantElement.Value); Looptree(propertyElement, root); RootNodes.Add(root); break; } default: throw new NotSupportedException(); } } }
public TreeRenderer(ITree itree) { Initialize(itree); }
void Initialize(ITree itree) { this.tree = itree; this.flipped = tree.flipped; }
public override void calculate() { DayCounter rfdc = process_.riskFreeRate().link.dayCounter(); DayCounter divdc = process_.dividendYield().link.dayCounter(); DayCounter voldc = process_.blackVolatility().link.dayCounter(); Calendar volcal = process_.blackVolatility().link.calendar(); double s0 = process_.stateVariable().link.value(); Utils.QL_REQUIRE(s0 > 0.0, () => "negative or null underlying given"); double v = process_.blackVolatility().link.blackVol(arguments_.exercise.lastDate(), s0); Date maturityDate = arguments_.exercise.lastDate(); double r = process_.riskFreeRate().link.zeroRate(maturityDate, rfdc, Compounding.Continuous, Frequency.NoFrequency).value(); double q = process_.dividendYield().link.zeroRate(maturityDate, divdc, Compounding.Continuous, Frequency.NoFrequency).value(); Date referenceDate = process_.riskFreeRate().link.referenceDate(); // binomial trees with constant coefficient Handle <YieldTermStructure> flatRiskFree = new Handle <YieldTermStructure>(new FlatForward(referenceDate, r, rfdc)); Handle <YieldTermStructure> flatDividends = new Handle <YieldTermStructure>(new FlatForward(referenceDate, q, divdc)); Handle <BlackVolTermStructure> flatVol = new Handle <BlackVolTermStructure>(new BlackConstantVol(referenceDate, volcal, v, voldc)); StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; Utils.QL_REQUIRE(payoff != null, () => "non-striked payoff given"); double maturity = rfdc.yearFraction(referenceDate, maturityDate); StochasticProcess1D bs = new GeneralizedBlackScholesProcess(process_.stateVariable(), flatDividends, flatRiskFree, flatVol); TimeGrid grid = new TimeGrid(maturity, timeSteps_); ITree tree = getTree_(bs, maturity, timeSteps_, payoff.strike()); BlackScholesLattice <ITree> lattice = new BlackScholesLattice <ITree>(tree, r, maturity, timeSteps_); DiscretizedAsset option = getAsset_(arguments_, process_, grid); option.initialize(lattice, maturity); // Partial derivatives calculated from various points in the // binomial tree // (see J.C.Hull, "Options, Futures and other derivatives", 6th edition, pp 397/398) // Rollback to third-last step, and get underlying prices (s2) & // option values (p2) at this point option.rollback(grid[2]); Vector va2 = new Vector(option.values()); Utils.QL_REQUIRE(va2.size() == 3, () => "Expect 3 nodes in grid at second step"); double p2u = va2[2]; // up double p2m = va2[1]; // mid double p2d = va2[0]; // down (low) double s2u = lattice.underlying(2, 2); // up price double s2m = lattice.underlying(2, 1); // middle price double s2d = lattice.underlying(2, 0); // down (low) price // calculate gamma by taking the first derivate of the two deltas double delta2u = (p2u - p2m) / (s2u - s2m); double delta2d = (p2m - p2d) / (s2m - s2d); double gamma = (delta2u - delta2d) / ((s2u - s2d) / 2); // Rollback to second-last step, and get option values (p1) at // this point option.rollback(grid[1]); Vector va = new Vector(option.values()); Utils.QL_REQUIRE(va.size() == 2, () => "Expect 2 nodes in grid at first step"); double p1u = va[1]; double p1d = va[0]; double s1u = lattice.underlying(1, 1); // up (high) price double s1d = lattice.underlying(1, 0); // down (low) price double delta = (p1u - p1d) / (s1u - s1d); // Finally, rollback to t=0 option.rollback(0.0); double p0 = option.presentValue(); // Store results results_.value = p0; results_.delta = delta; results_.gamma = gamma; // theta can be approximated by calculating the numerical derivative // between mid value at third-last step and at t0. The underlying price // is the same, only time varies. results_.theta = (p2m - p0) / grid[2]; }
/// <summary> /// Transforms a MODIFIERS tree node into a list of modifiers. /// </summary> /// <param name="modifiers">The AST node</param> /// <returns>The list of modifiers</returns> public List <string> Modifiers(ITree modifiers) { return(GetModifiers(modifiers)); }
/// <summary> /// Removes the specified child. /// </summary> /// <param name="child">The child.</param> /// <returns>A value indicating whether the child was found in this tree.</returns> bool ITree <T> .Remove(ITree <T> child) { return(this.Remove((GeneralTree <T>)child)); }
// Non-abstract functions /// <summary> /// Transforms a FQUALIFIER tree node into a full qualifier object. /// </summary> /// <param name="fullQualifier">The AST node</param> /// <returns>The full qualifier</returns> public Qualifier FullQualifier(ITree fullQualifier) { return(GetFullQualifier(fullQualifier)); }
/// <summary> /// Adds the specified child to the tree. /// </summary> /// <param name="child">The child to add..</param> void ITree <T> .Add(ITree <T> child) { this.Add((GeneralTree <T>)child); }
public ActionEvaluator(StringTemplate self, ASTExpr chunk, IStringTemplateWriter writer, ITree input) : base(new CommonTreeNodeStream(new StringTemplateTreeAdaptor(), input)) { this.self = self; this.chunk = chunk; this.writer = writer; }
protected ITree <TreeNodeModel> PrettifyName(ITree <TreeNodeModel> node) => node.Select(v => v.WithName(v.Name.SplitOnUpperCaseLetters()));
protected ObjectDef EmitVoid(ITree expressionNode) { var result = new ValueObjectDef(typeof(Nullable), null); return(result); }
/// <summary> /// Transforms an IMPLEMENTS tree node into a list of Qualifier objects. /// </summary> /// <param name="implementing">The AST node</param> /// <returns>The list of qualifiers</returns> public static List <Qualifier> GetImplements(ITree implementing) { return(GetExtendation(implementing)); }
protected ObjectDef EmitString(ITree expressionNode) { var result = new ValueObjectDef(typeof(string), expressionNode.ToString()); return(result); }
/// <summary> /// Retrieves the parameter types of a METHOD node /// </summary> /// <param name="parameters">The tree containing the method definition</param> /// <returns>The method parameter types</returns> public string[] ParameterTypes(ITree parameters) { return(GetParameterTypes(parameters)); }
public virtual string ToDot(ITree tree) { return(this.ToDot((object)tree, (ITreeAdaptor) new CommonTreeAdaptor())); }
public ITree SetChild(int i, ITree t) { return(null); //TODO }
/// <summary>Print out a whole tree in LISP form.</summary> /// <remarks> /// Print out a whole tree in LISP form. /// <see cref="GetNodeText(ITree, Antlr4.Runtime.Parser)">GetNodeText(ITree, Antlr4.Runtime.Parser) /// </see> /// is used on the /// node payloads to get the text for the nodes. Detect /// parse trees and extract data appropriately. /// </remarks> public static string ToStringTree(ITree t) { return(ToStringTree(t, (IList <string>)null)); }
public bool Equal(ITree tree) { return(CompareNodes(root, (tree as BsTreeR).root)); }
private static void ShowGreenery() { string Place = ""; int[] Input = null; ITree Tree = null; Console.Clear(); Console.WriteLine("Places to grow avaiable: "); int FileNumber = 1; Dictionary <int, string> filenames = new Dictionary <int, string>(); foreach (var filename in Directory.GetFiles(@"Data\", "*.txt").OrderBy(p => p.Length)) { Console.WriteLine("\t{0}) {1}", FileNumber, filename); filenames.Add(FileNumber++, filename); } Console.WriteLine("\n\t0) Back\n"); // *Choosing filePath while (Input == null) { ColorWrite(("* Choose a place to grow: "), ConsoleColor.DarkMagenta); Place = Console.ReadLine(); if (Place == "0") { State = States.MainMenu; return; } else // There's might be an exception, i'll fix it latelly { Input = GetNumbers(filenames[Int32.Parse(Place)]); } break; } // **Choosing Tree sort while (Tree == null) { Console.Clear(); Console.WriteLine("Tree seeds avaiable:\n\t1) RedBlack Tree\n\t2) Cartesian Tree\n\t3) BTree\n\t4) AVL Tree\n\t5) Splay Tree\n\t0) Back"); ColorWrite(("Choose a seed: "), ConsoleColor.DarkMagenta); string Seed = Console.ReadLine(); ColorWrite("\nGrowing up tree. Please wait...", ConsoleColor.DarkRed); int PlaneSeconds = Environment.TickCount; switch (Seed.ToLower()) { case "1": Tree = new RedBlackTree(Input); break; case "2": Tree = Treap.Treapify(Input); break; case "3": Tree = BTree.Initialize(Input); break; case "4": Tree = AVLTree.Initialize(Input); break; case "5": Tree = new SplayTree(Input); break; case "0": State = States.MainMenu; return; } Console.WriteLine("\n** Grown for {0} miliseconds.\n", Environment.TickCount - PlaneSeconds); } // ***Calculating Existing and Unexisting values while (State != States.MainMenu) { // All existing is even int Existing_dt = Environment.TickCount; for (int i = 0; i < Input.Count(); i++) { if (Tree.Search(Input[i]) == false) { throw new Exception("BUG. Tree Couldn't find existing value. Cut it down."); } } Existing_dt = Environment.TickCount - Existing_dt; // All Unexisting is odd int Unexisting_dt = Environment.TickCount; for (int i = 0; i < Input.Count(); i++) { if (Tree.Search(Input[i] - 1) == true) { throw new Exception("BUG. Tree Found Unexisting value. Cut it down."); } } Unexisting_dt = Environment.TickCount - Unexisting_dt; Console.Clear(); Console.WriteLine("*** The whole search took {0} miliseconds", Existing_dt + Unexisting_dt); ColorWriteLine("ExistingValues: " + Existing_dt + " ms", ConsoleColor.Green); ColorWriteLine("UnexistingValues: " + Unexisting_dt + " ms", ConsoleColor.Red); Console.WriteLine("Press 0 to exit or any other key to continue the tests..."); if (Console.ReadLine() == "0") { State = States.MainMenu; } } }
public static void AssertRootEqual <TKey, TValue, TNode>(this ITree <TKey, TValue, TNode> tree, TKey expectedKey, params TValue[] expectedValues) where TNode : class, INode <TKey, TValue, TNode> { Assert.NotNull(tree.Root); tree.Root.AssertEqual(expectedKey, expectedValues); }