• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ImperativeAST.BinaryExpressionNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestProtoASTExecute_Imperative_IfStatement02

            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            astList.Add(assign);

            // Verify the results
            ExecutionMirror mirror = thisTest.RunASTSource(astList);
            Obj o = mirror.GetValue("a");
            Assert.IsTrue((Int64)o.Payload == 11);
        }

        [Test]
        public void TestProtoASTExecute_Imperative_IfStatement02()
        {
            //
            //  a = [Imperative]
            //  {
            //      b = 10;
            //      if (b > 10)
            //      {
            //          b = 11;
            //      }
            //      else
            //      {
            //          b = 12
            //      }
            //      return = b;
            //  }
            //

            List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();

            // b = 10
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                new ProtoCore.AST.ImperativeAST.IntNode(10),
                ProtoCore.DSASM.Operator.assign);
            imperativeList.Add(imperativeAssign);

            // if (b > 10)
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode equality = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                new ProtoCore.AST.ImperativeAST.IntNode(10),
                ProtoCore.DSASM.Operator.gt);

            ProtoCore.AST.ImperativeAST.IfStmtNode ifNode = new ProtoCore.AST.ImperativeAST.IfStmtNode();
            ifNode.IfExprNode = equality;

            // if body
            // b = 11
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode ifCodeBlockStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                new ProtoCore.AST.ImperativeAST.IntNode(11),
                ProtoCore.DSASM.Operator.assign);
            List<ProtoCore.AST.ImperativeAST.ImperativeNode> ifCodeBlock = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
            ifCodeBlock.Add(ifCodeBlockStmt);
            ifNode.IfBody = ifCodeBlock;

            // else body
            // b = 12
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode elseCodeBlockStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                new ProtoCore.AST.ImperativeAST.IntNode(12),
                ProtoCore.DSASM.Operator.assign);
            List<ProtoCore.AST.ImperativeAST.ImperativeNode> elseCodeBlock = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
            elseCodeBlock.Add(elseCodeBlockStmt);
            ifNode.ElseBody = elseCodeBlock;

            imperativeList.Add(ifNode);

            // return = b
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode returnStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                ProtoCore.DSASM.Operator.assign);
            imperativeList.Add(returnStmt);


            // Build the language block
            ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
            imperativeCodeBlock.Body = imperativeList;

            ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
            langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
            langblock.CodeBlockNode = imperativeCodeBlock;


            // Build an assignment where the rhs is the imperative block
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                langblock,
                ProtoCore.DSASM.Operator.assign);
开发者ID:limrzx,项目名称:Dynamo,代码行数:90,代码来源:ProtoASTExecutionTests.cs


示例2: TestCodegenDS_Imperative_IfStatement01

            // Generate the script
            ProtoCore.CodeGenDS codegen = new ProtoCore.CodeGenDS(astList);
            string code = codegen.GenerateCode();


            ExecutionMirror mirror = thisTest.RunScriptSource(code);
            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 10);
        }

        [Test]
        public void TestCodegenDS_Imperative_IfStatement01()
        {
            //
            //  a = [Imperative]
            //  {
            //      b = 10;
            //      if (b == 10)
            //      {
            //          b = 11;
            //      }
            //      return = b;
            //  }
            //

            List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();

            // b = 10
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                new ProtoCore.AST.ImperativeAST.IntNode(10),
                ProtoCore.DSASM.Operator.assign);
            imperativeList.Add(imperativeAssign);

            // if (b == 10)
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode equality = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                new ProtoCore.AST.ImperativeAST.IntNode(10),
                ProtoCore.DSASM.Operator.eq);

            ProtoCore.AST.ImperativeAST.IfStmtNode ifNode = new ProtoCore.AST.ImperativeAST.IfStmtNode();
            ifNode.IfExprNode = equality;

            // b = 11
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode ifCodeBlockStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                new ProtoCore.AST.ImperativeAST.IntNode(11),
                ProtoCore.DSASM.Operator.assign);
            List<ProtoCore.AST.ImperativeAST.ImperativeNode> ifCodeBlock = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
            ifCodeBlock.Add(ifCodeBlockStmt);
            ifNode.IfBody = ifCodeBlock;

            imperativeList.Add(ifNode);

            // return = b
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode returnStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
                new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
                ProtoCore.DSASM.Operator.assign);
            imperativeList.Add(returnStmt);


            // Build the language block
            ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
            imperativeCodeBlock.Body = imperativeList;

            ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
            langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
            langblock.CodeBlockNode = imperativeCodeBlock;


            // Build an assignment where the rhs is the imperative block
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                langblock,
                ProtoCore.DSASM.Operator.assign);


            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
开发者ID:limrzx,项目名称:Dynamo,代码行数:78,代码来源:ProtoASTExecutionTests.cs


示例3: TestProtoASTExecute_Imperative_Assign01

            // Generate the script
            ProtoCore.CodeGenDS codegen = new ProtoCore.CodeGenDS(astList);
            string code = codegen.GenerateCode();


            ExecutionMirror mirror = thisTest.RunScriptSource(code);
            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 12);
        }

        [Test]
        public void TestProtoASTExecute_Imperative_Assign01()
        {
            //
            //  a = [Imperative]
            //  {
            //      return = 10;
            //  }
            //

            List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();

            // return = 10
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
                new ProtoCore.AST.ImperativeAST.IntNode(10),
                ProtoCore.DSASM.Operator.assign);
            imperativeList.Add(imperativeAssign);


            // Build the language block
            ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
            imperativeCodeBlock.Body = imperativeList;

            ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
            langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
            langblock.CodeBlockNode = imperativeCodeBlock;


            // Build an assignment where the rhs is the imperative block
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                langblock,
                ProtoCore.DSASM.Operator.assign);
开发者ID:limrzx,项目名称:Dynamo,代码行数:43,代码来源:ProtoASTExecutionTests.cs


示例4: Imperative_DefaultArgDecl

	void Imperative_DefaultArgDecl(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		Imperative_ArgDecl(out node);
		ProtoCore.AST.ImperativeAST.VarDeclNode varDeclNode = node as ProtoCore.AST.ImperativeAST.VarDeclNode; 
		Expect(51);
		ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode; 
		Imperative_expr(out rhsNode);
		ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
		bNode.LeftNode = varDeclNode.NameNode;
		bNode.RightNode = rhsNode;
		bNode.Optr = Operator.assign;
		NodeUtils.CopyNodeLocation(bNode, varDeclNode);
		varDeclNode.NameNode = bNode;        
		
		node = varDeclNode;
		if(!isGlobalScope) {
		   localVarCount++;
		}
		
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:19,代码来源:Parser.cs


示例5: Imperative_functionalMethodBodySingleStatement

	void Imperative_functionalMethodBodySingleStatement(out List<ProtoCore.AST.ImperativeAST.ImperativeNode> funcBody) {
		funcBody = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
		ProtoCore.AST.ImperativeAST.BinaryExpressionNode binaryExpr = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
		binaryExpr.LeftNode = BuildImperativeIdentifier("return", ProtoCore.PrimitiveType.Return);
		ProtoCore.AST.ImperativeAST.ImperativeNode expr;
		
		Imperative_expr(out expr);
		binaryExpr.RightNode = expr;
		binaryExpr.Optr = Operator.assign;
		
		funcBody.Add(binaryExpr);
		
		
		if (la.kind != _endline)
		  SynErr(Resources.SemiColonExpected);
		
		Expect(23);
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:18,代码来源:Parser.cs


示例6: Imperative_term

	void Imperative_term(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null;
		#if ENABLE_BIT_OP 
		Imperative_interimfactor(out node);
		#else             
		Imperative_factor(out node);
		#endif            
		while (la.kind == 56 || la.kind == 57 || la.kind == 58) {
			Operator op; 
			Imperative_mulop(out op);
			ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode; 
			#if ENABLE_BIT_OP 
			Imperative_interimfactor(out rhsNode);
			#else             
			Imperative_factor(out rhsNode);
			#endif            
			ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
			bNode.LeftNode = node;
			bNode.RightNode = rhsNode;
			bNode.Optr = op;
			NodeUtils.CopyNodeLocation(bNode, node);
			node = bNode;
			
		}
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:25,代码来源:Parser.cs


示例7: Imperative_interimfactor

	void Imperative_interimfactor(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null;
		Imperative_factor(out node);
		while (la.kind == 16 || la.kind == 59 || la.kind == 60) {
			Operator op; 
			Imperative_bitop(out op);
			ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode; 
			Imperative_factor(out rhsNode);
			ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
			bNode.LeftNode = node;
			bNode.RightNode = rhsNode;
			bNode.Optr = op;
			NodeUtils.CopyNodeLocation(bNode, node);
			node = bNode;
			
		}
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:17,代码来源:Parser.cs


示例8: Imperative_rel

	void Imperative_rel(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null;
		Imperative_term(out node);
		while (la.kind == 15 || la.kind == 55) {
			Operator op; 
			Imperative_addop(out op);
			ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode; 
			Imperative_term(out rhsNode);
			ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
			bNode.LeftNode = node;
			bNode.RightNode = rhsNode;
			bNode.Optr = op;
			NodeUtils.SetNodeLocation(bNode, bNode.LeftNode, bNode.RightNode);
			node = bNode;
			
		}
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:17,代码来源:Parser.cs


示例9: Imperative_logicalexpr

	void Imperative_logicalexpr(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null;
		Imperative_RangeExpr(out node);
		while (StartOf(18)) {
			Operator op; 
			Imperative_relop(out op);
			ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode = null; 
			Imperative_RangeExpr(out rhsNode);
			ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
			bNode.LeftNode = node;
			bNode.RightNode = rhsNode;
			bNode.Optr = op;
			NodeUtils.SetNodeLocation(bNode, bNode.LeftNode, bNode.RightNode);
			node = bNode;
			
		}
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:17,代码来源:Parser.cs


示例10: Imperative_binexpr

	void Imperative_binexpr(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null;
		Imperative_logicalexpr(out node);
		while (la.kind == 61 || la.kind == 62) {
			Operator op; 
			Imperative_logicalop(out op);
			ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode = null; 
			Imperative_logicalexpr(out rhsNode);
			ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
			bNode.LeftNode = node;
			bNode.RightNode = rhsNode;
			bNode.Optr = op;
			NodeUtils.CopyNodeLocation(bNode, node);
			node = bNode;
			
		}
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:17,代码来源:Parser.cs


示例11: Imperative_assignstmt

	void Imperative_assignstmt(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null; 
		ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
		ProtoCore.AST.ImperativeAST.ImperativeNode lhsNode = null; 
		NodeUtils.SetNodeLocation(bNode, la);
		
		Imperative_decoratedIdentifier(out lhsNode);
		node = lhsNode; 
		if (la.kind == 23) {
			Get();
			bNode.LeftNode = lhsNode;
			bNode.RightNode = null;
			bNode.Optr = Operator.assign;
			NodeUtils.SetNodeEndLocation(bNode, t);
			node = bNode; 
			
		} else if (la.kind == 51) {
			Get();
			ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode = null; 
			if (HasMoreAssignmentStatements()) {
				Imperative_assignstmt(out rhsNode);
			} else if (StartOf(4)) {
				Imperative_expr(out rhsNode);
				if (la.kind != _endline)
				  SynErr(Resources.SemiColonExpected);
				
				Expect(23);
			} else if (la.kind == 10) {
				Imperative_languageblock(out rhsNode);
			} else SynErr(111);
			bNode.LeftNode = lhsNode;
			bNode.RightNode = rhsNode;
			bNode.Optr = Operator.assign;
			NodeUtils.SetNodeEndLocation(bNode, t);
			node = bNode;       
			
		} else if (StartOf(13)) {
			SynErr("';' is expected"); 
		} else SynErr(112);
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:40,代码来源:Parser.cs


示例12: TestcodegenDS_Imperative_Assign01

        public void TestcodegenDS_Imperative_Assign01()
        {
            //
            //  a = [Imperative]
            //  {
            //      return = 10;
            //  }
            //

            List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();

            // return = 10
            ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
                new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
                new ProtoCore.AST.ImperativeAST.IntNode(10),
                ProtoCore.DSASM.Operator.assign);
            imperativeList.Add(imperativeAssign);


            // Build the language block
            ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
            imperativeCodeBlock.Body = imperativeList;

            ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
            langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
            langblock.CodeBlockNode = imperativeCodeBlock;


            // Build an assignment where the rhs is the imperative block
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                langblock,
                ProtoCore.DSASM.Operator.assign);


            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            astList.Add(assign);

            // Generate the script
            ProtoCore.CodeGenDS codegen = new ProtoCore.CodeGenDS(astList);
            string code = codegen.GenerateCode();


            ExecutionMirror mirror = thisTest.RunScriptSource(code);
            thisTest.Verify("a", 10);
        }
开发者ID:sm6srw,项目名称:Dynamo,代码行数:46,代码来源:ProtoASTExecutionTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ProtoCore.CodeGenDS类代码示例发布时间:2022-05-24
下一篇:
C# AssociativeAST.FunctionDefinitionNode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap