當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。