当前位置: 首页>>代码示例>>C#>>正文


C# ProgrammingLanguageNr1.AST类代码示例

本文整理汇总了C#中ProgrammingLanguageNr1.AST的典型用法代码示例。如果您正苦于以下问题:C# AST类的具体用法?C# AST怎么用?C# AST使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AST类属于ProgrammingLanguageNr1命名空间,在下文中一共展示了AST类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: addChildAtPosition

        public void addChildAtPosition(AST childTree, int pos)
        {
            Debug.Assert(childTree != null);

            allocateListIfNecessary();
            m_children.Insert(pos, childTree);
        }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:7,代码来源:AST.cs

示例2: addChildFirst

        public void addChildFirst(AST childTree)
        {
            Debug.Assert(childTree != null);

            allocateListIfNecessary();
            m_children.Insert(0, childTree);
        }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:7,代码来源:AST.cs

示例3: MemorySpace

        public MemorySpace(string name, AST root, Scope scope, MemorySpaceNodeListCache cache)
        {
            Debug.Assert(name != null);
            Debug.Assert(root != null);
            Debug.Assert(scope != null);
            Debug.Assert(cache != null);

            m_name = name;
            m_scope = scope;
            m_cache = cache;

            //Console.WriteLine("Creating list of nodes from tree: " + root.getTreeAsString());

            if(m_cache.hasCachedFunction(root)) {
                //Console.WriteLine("Found cached list for " + m_name);
                m_nodes = m_cache.getList(root).ToArray();
            }
            else {
                List<AST> list = new List<AST>();
                addToList(list, root);
                m_cache.addMemorySpaceList(list, root);
                m_nodes = list.ToArray();
                //Console.WriteLine("Created new list for " + m_name);
            }

            m_currentNode = -1;

            //Console.WriteLine("New memory space " + name + " has got " + list.Count + " AST nodes in its list.");
        }
开发者ID:substans,项目名称:Sprak,代码行数:29,代码来源:MemorySpace.cs

示例4: assignment

 private void assignment(AST tree)
 {
     string variableName = tree.getChild(0).getTokenString();
     AST expression = tree.getChild(1);
     ReturnValue expressionValue = execute(expression);
     assignValue(variableName, expressionValue);
 }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:7,代码来源:Interpreter.cs

示例5: evaluateIfScope

        private void evaluateIfScope(AST tree)
        {
            Scope subscope = new Scope(Scope.ScopeType.IF_SCOPE,"<IF-SUBSCOPE>", m_currentScope);

            #if WRITE_DEBUG_INFO
            Console.WriteLine("\nDefined IF-subscope");
            #endif

            m_currentScope = subscope;

            AST_IfNode ifNode = (tree as AST_IfNode);
            Debug.Assert(ifNode != null);

            ifNode.setScope(subscope); // save the new scope in the IF-token tree node

            // Evaluate expression
            evaluateScopeDeclarationsInAllChildren(tree.getChild(0));

            AST trueNode = ifNode.getChild(1);
            AST falseNode = null;
            if (ifNode.getChildren().Count == 3)
            {
                falseNode = ifNode.getChild(2);
            }

            evaluateScopeDeclarationsInAllChildren(trueNode);
            if (falseNode != null)
            {
                evaluateScopeDeclarationsInAllChildren(falseNode);
            }

            m_currentScope = m_currentScope.getEnclosingScope(); // pop scope
        }
开发者ID:substans,项目名称:Sprak,代码行数:33,代码来源:ScopeBuilder.cs

示例6: addChild

        public void addChild(AST childTree)
        {
            Debug.Assert(childTree != null);
            if(childTree == null) throw new Exception("Child tree was null!");

            allocateListIfNecessary();
            m_children.Add(childTree);
        }
开发者ID:substans,项目名称:Sprak,代码行数:8,代码来源:AST.cs

示例7: Interpreter

 public Interpreter(AST ast, Scope globalScope, ErrorHandler errorHandler, ExternalFunctionCreator externalFunctionCreator)
 {
     m_ast = ast;
     m_errorHandler = errorHandler;
     m_globalScope = globalScope;
     m_currentScope = m_globalScope;
     m_externalFunctionCreator = externalFunctionCreator;
 }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:8,代码来源:Interpreter.cs

示例8: ScopeBuilder

        public ScopeBuilder(AST ast, ErrorHandler errorHandler)
        {
            Debug.Assert(ast != null);
            Debug.Assert(errorHandler != null);

            m_errorHandler = errorHandler;
            m_ast = ast;
        }
开发者ID:substans,项目名称:Sprak,代码行数:8,代码来源:ScopeBuilder.cs

示例9: GetNodeString

        private string GetNodeString( AST pNode )
        {
			string result;
			result = /*pNode.getTokenType().ToString() + " : " + */ pNode.ToString();
			if(_printExecutions) {
				result += " : " + pNode.Executions;
			}
            return result;
        }
开发者ID:substans,项目名称:Sprak,代码行数:9,代码来源:ASTPainter.cs

示例10: BooleanGREATEROREQUALS2

 public void BooleanGREATEROREQUALS2()
 {
     AST root = new AST(new Token(Token.TokenType.OPERATOR, ">="));
     AST lhs = new AST(new Token(Token.TokenType.NUMBER, "4"));
     AST rhs = new AST(new Token(Token.TokenType.NUMBER, "3"));
     root.addChild(lhs);
     root.addChild(rhs);
     ExpressionEvaluator e = new ExpressionEvaluator(root);
     Assert.AreEqual(1, e.getValue());
 }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:10,代码来源:ExpressionEvaluator_TEST.cs

示例11: BooleanAND

 public void BooleanAND()
 {
     AST root = new AST(new Token(Token.TokenType.OPERATOR, "&&"));
     AST lhs = new AST(new Token(Token.TokenType.NUMBER, "1"));
     AST rhs = new AST(new Token(Token.TokenType.NUMBER, "0"));
     root.addChild(lhs);
     root.addChild(rhs);
     ExpressionEvaluator e = new ExpressionEvaluator(root);
     Assert.AreEqual(0, e.getValue());
 }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:10,代码来源:ExpressionEvaluator_TEST.cs

示例12: FunctionSymbol

        public FunctionSymbol(Scope enclosingScope, string name, ReturnValueType type, AST functionDefinitionNode)
            : base(Scope.ScopeType.FUNCTION_SCOPE, name, enclosingScope)
        {
            Debug.Assert(enclosingScope != null);
            Debug.Assert(functionDefinitionNode != null);

            m_enclosingScope = enclosingScope;
            m_functionDefinitionNode = functionDefinitionNode;
            m_returnValueType = type;
        }
开发者ID:substans,项目名称:Sprak,代码行数:10,代码来源:FunctionSymbol.cs

示例13: addChild

        public void addChild(AST childTree)
        {
            if (childTree == null) {
                //throw new Exception ("Child tree is null");
                if(childTree == null) throw new Error("Failed to understand source code", Error.ErrorType.SYNTAX, -1, -1);
            }

            allocateListIfNecessary();
            m_children.Add(childTree);
        }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:10,代码来源:AST.cs

示例14: createFunctionDefinitionNode

        private AST_FunctionDefinitionNode createFunctionDefinitionNode(string returnTypeName, string functionName, AST parameterList)
        {
            AST_FunctionDefinitionNode functionNode =
                new AST_FunctionDefinitionNode(new Token(Token.TokenType.FUNC_DECLARATION, "<EXTERNAL_FUNC_DECLARATION>"));

            functionNode.addChild(new Token(Token.TokenType.BUILT_IN_TYPE_NAME, returnTypeName));
            functionNode.addChild(new Token(Token.TokenType.NAME, functionName));
            functionNode.addChild(parameterList);
            functionNode.addChild(new Token(Token.TokenType.STATEMENT_LIST, "<EMPTY_STATEMENT_LIST>"));

            return functionNode;
        }
开发者ID:substans,项目名称:Sprak,代码行数:12,代码来源:ExternalFunctionCreator.cs

示例15: createParameterDefinition

        private AST createParameterDefinition(string typeName, string variableName)
        {
            AST parameter = new AST(new Token(Token.TokenType.PARAMETER, "<PARAMETER>"));

            AST declaration = new AST_VariableDeclaration(new Token(Token.TokenType.VAR_DECLARATION, "<PARAMETER_DECLARATION>"), ReturnValue.getReturnValueTypeFromString(typeName), variableName);
            AST assigment = new AST_Assignment(new Token(Token.TokenType.ASSIGNMENT, "="), variableName);

            parameter.addChild(declaration);
            parameter.addChild(assigment);

            return parameter;
        }
开发者ID:substans,项目名称:Sprak,代码行数:12,代码来源:ExternalFunctionCreator.cs


注:本文中的ProgrammingLanguageNr1.AST类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。