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


C# ParseTreeNode.FindTokenAndGetText方法代码示例

本文整理汇总了C#中ParseTreeNode.FindTokenAndGetText方法的典型用法代码示例。如果您正苦于以下问题:C# ParseTreeNode.FindTokenAndGetText方法的具体用法?C# ParseTreeNode.FindTokenAndGetText怎么用?C# ParseTreeNode.FindTokenAndGetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParseTreeNode的用法示例。


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

示例1: Init

 // this is where data is initially passed to the item
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     string sVal = treeNode.FindTokenAndGetText();
     base.Init(context, treeNode);
     var nodes = treeNode.GetMappedChildNodes();
     var functionOrProperty = AddChild("FunctionOrId", nodes[0]);
     if (functionOrProperty is SelectFunctionNode)
     {
         _TheFunction = (SelectFunctionNode)functionOrProperty;
     }
     else if (functionOrProperty is SelectPropertyNode)
     {
         _PropNode = (SelectPropertyNode)functionOrProperty;
     }
     else
     {
         throw new Exception("Unmanaged type in selectmemberaccessnode");
     }
     if (nodes.Count > 1)
     {
         var child = AddChild("Queue", nodes[1]);
         string sval = nodes[1].FindTokenAndGetText();
         if (child is LeftObjectNode)
         {
             _queue = (LeftObjectNode)child;
         }
     }
 }
开发者ID:bnaand,项目名称:xBim-Toolkit,代码行数:29,代码来源:SelectMemberAccessNode.cs

示例2: CreateDefinedRulesList

        //-----------------------------------------
        public void CreateDefinedRulesList(ParseTreeNode node, List<string> rulenames)
        {
            foreach (var child in node.ChildNodes)
                CreateDefinedRulesList(child, rulenames);

            if (node.Term.Name == "newrulename")
                rulenames.Add(node.FindTokenAndGetText());
        }
开发者ID:vf1,项目名称:bnf2dfa,代码行数:9,代码来源:Builder.cs

示例3: Init

        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            //TODO: units conversion
            _Value=decimal.Parse(treeNode.FindTokenAndGetText(), CultureInfo.InvariantCulture);
            AsString=string.Format(
                CultureInfo.InvariantCulture,
                "{0:G}m",
                _Value
            );
        }
开发者ID:mcartoixa,项目名称:GeoSIK,代码行数:12,代码来源:ToleranceNode.cs

示例4: BuildRuleExpressions

		private void BuildRuleExpressions(ParseTreeNode node)
		{
			var ruleName = node.FindTokenAndGetText();
			var rule = rules.ContainsKey(ruleName) ? rules[ruleName] : rules[ruleName] = new AlternationExpression();

			ParseTreeNode elements = null;
			foreach (var child in node.ChildNodes)
				if (child.Term.Name == "elements")
					elements = child;

			rule.Add(
				BuildAlternationExpression(elements.ChildNodes[0]));
		}
开发者ID:five-x,项目名称:siprevo,代码行数:13,代码来源:Builder.cs

示例5: Init

        // this is where data is initially passed to the item
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            string sVal = treeNode.FindTokenAndGetText();

            base.Init(context, treeNode);
            var nodes = treeNode.GetMappedChildNodes();
            property = treeNode;

            if (nodes.Count > 1)
            {
                var child = AddChild("Queue", nodes[1]);
                string sval = nodes[1].FindTokenAndGetText();
                if (child is LeftObjectNode)
                {
                    _queue = (LeftObjectNode)child;
                }
            }
        }
开发者ID:bnaand,项目名称:xBim-Toolkit,代码行数:19,代码来源:SelectPropertyNode.cs

示例6: CreateCharval

		public string CreateCharval(ParseTreeNode node)
		{
			return "FromString(" + node.FindTokenAndGetText().Replace("\\", "\\\\") + ",rulenames)";
		}
开发者ID:five-x,项目名称:siprevo,代码行数:4,代码来源:XbnfGrammar.cs

示例7: BuildExpandableStringLiteralAst

        ExpressionAst BuildExpandableStringLiteralAst(ParseTreeNode parseTreeNode)
        {
            var matches = Regex.Match(parseTreeNode.FindTokenAndGetText(), this._grammar.expandable_string_literal.Pattern, RegexOptions.IgnoreCase);
            string value = matches.Groups[this._grammar.expandable_string_characters.Name].Value +
                matches.Groups[this._grammar.dollars.Name].Value
                ;

            var ast = new ExpandableStringExpressionAst(new ScriptExtent(parseTreeNode), value, StringConstantType.DoubleQuoted);
            if (ast.NestedExpressions.Any())
            {
                return ast;
            }
            return new StringConstantExpressionAst(new ScriptExtent(parseTreeNode), value, StringConstantType.DoubleQuoted);
        }
开发者ID:Ventero,项目名称:Pash,代码行数:14,代码来源:AstBuilder.cs

示例8: BuildDecimalRealLiteralAst

        private ConstantExpressionAst BuildDecimalRealLiteralAst(ParseTreeNode parseTreeNode, Group multiplier, Group decimalTypeSuffix)
        {
            string digits = parseTreeNode.FindTokenAndGetText();

            if (multiplier.Success)
            {
                digits = RemoveMatchedString(digits, multiplier);
            }

            digits = RemoveMatchedString(digits, decimalTypeSuffix);

            decimal value;
            if (!decimal.TryParse(digits, NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out value))
            {
                throw new OverflowException(string.Format("Bad numeric constant: {0}.", parseTreeNode.FindTokenAndGetText()));
            }

            if (multiplier.Success)
            {
                value *= NumericMultiplier.GetValue(multiplier.Value);
            }

            return new ConstantExpressionAst(new ScriptExtent(parseTreeNode), value);
        }
开发者ID:Ventero,项目名称:Pash,代码行数:24,代码来源:AstBuilder.cs

示例9: SelectTokenKind

        TokenKind SelectTokenKind(ParseTreeNode parseTreeNode)
        {
            if (!(parseTreeNode.Term is Terminal)) throw new InvalidOperationException(parseTreeNode.ToString());

            var text = parseTreeNode.FindTokenAndGetText();

            switch (text)
            {
                case "=":
                    return TokenKind.Equals;

                case "+=":
                    return TokenKind.PlusEquals;

                case "-=":
                    return TokenKind.MinusEquals;

                case "*=":
                    return TokenKind.MultiplyEquals;

                case "/=":
                    return TokenKind.DivideEquals;

                case "%=":
                    return TokenKind.RemainderEquals;

                default:
                    throw new NotImplementedException(parseTreeNode.ToString());
            }
        }
开发者ID:Ventero,项目名称:Pash,代码行数:30,代码来源:AstBuilder.cs

示例10: BuildRealLiteralAst

        ConstantExpressionAst BuildRealLiteralAst(ParseTreeNode parseTreeNode)
        {
            VerifyTerm(parseTreeNode, this._grammar.real_literal);
            var matches = Regex.Match(parseTreeNode.FindTokenAndGetText(), this._grammar.real_literal.Pattern, RegexOptions.IgnoreCase);
            Group multiplier = matches.Groups[this._grammar.numeric_multiplier.Name];
            Group decimalTypeSuffix = matches.Groups[this._grammar.decimal_type_suffix.Name];

            if (decimalTypeSuffix.Success)
            {
                return BuildDecimalRealLiteralAst(parseTreeNode, multiplier, decimalTypeSuffix);
            }

            return BuildDoubleRealLiteralAst(parseTreeNode, multiplier);
        }
开发者ID:Ventero,项目名称:Pash,代码行数:14,代码来源:AstBuilder.cs

示例11: BuildDecimalIntegerLiteralAst

        ConstantExpressionAst BuildDecimalIntegerLiteralAst(ParseTreeNode parseTreeNode)
        {
            VerifyTerm(parseTreeNode, this._grammar.decimal_integer_literal);
            var matches = Regex.Match(parseTreeNode.FindTokenAndGetText(), this._grammar.decimal_integer_literal.Pattern, RegexOptions.IgnoreCase);
            string digits = matches.Groups[this._grammar.decimal_digits.Name].Value;
            string typeSuffix = matches.Groups[this._grammar.numeric_type_suffix.Name].Value;
            string longTypeSuffix = matches.Groups[this._grammar.long_type_suffix.Name].Value;
            string multiplier = matches.Groups[this._grammar.numeric_multiplier.Name].Value;

            // The type of an integer literal is determined by its value, the presence or absence of long-type-suffix, and the
            // presence of a numeric-multiplier (§2.3.5.1.3).

            object value;

            if (typeSuffix == string.Empty)
            {
                // For an integer literal with no long-type-suffix
                // • If its value can be represented by type int (§4.2.3), that is its type;
                // • Otherwise, if its value can be represented by type long (§4.2.3), that is its type.
                if (!ParseIntOrLongLiteral(digits, multiplier, NumberStyles.Integer, out value))
                {
                    decimal decimalValue;
                    double doubleValue;
                    if (decimal.TryParse(digits, out decimalValue))
                        // • Otherwise, if its value can be represented by type decimal (§2.3.5.1.2), that is its type.
                        value = NumericMultiplier.Multiply(decimalValue, multiplier);
                    else if (double.TryParse(digits, out doubleValue))
                        // • Otherwise, it is represented by type double (§2.3.5.1.2).
                        value = NumericMultiplier.Multiply(doubleValue, multiplier);
                    else
                        // For PowerShell compatibility throw an error here instead of saturating the double to infinity.
                        throw new OverflowException(string.Format("The integer literal {0} is too large.", matches.Value));
                }
            }
            else if (longTypeSuffix != string.Empty)
            {
                // For an integer literal with long-type-suffix

                long longValue;

                // • If its value can be represented by type long (§4.2.3), that is its type;
                if (long.TryParse(digits, out longValue))
                    value = NumericMultiplier.Multiply(longValue, multiplier);
                else
                    // • Otherwise, that literal is ill formed.
                    throw new ArithmeticException(string.Format("The integer literal {0} is invalid because it does not fit into a long.", matches.Value));
            }
            else
            {
                // The spec doesn't explicitly mention this case, but it seems to be handled
                // similar to a long suffix.
                decimal decimalValue;

                if (decimal.TryParse(digits, out decimalValue))
                    value = NumericMultiplier.Multiply(decimalValue, multiplier);
                else
                    throw new ArithmeticException(string.Format("The integer literal {0} is invalid because it does not fit into a decimal.", matches.Value));
            }

            return new ConstantExpressionAst(new ScriptExtent(parseTreeNode), value);
        }
开发者ID:Pash-Project,项目名称:Pash,代码行数:61,代码来源:AstBuilder.cs

示例12: GetMessage

		public static string GetMessage(ParseTreeNode node, string message)
		{
			return string.Format(@"ParseTreeNode: {0}, Error: {1}", node.FindTokenAndGetText(), message);
		}
开发者ID:five-x,项目名称:siprevo,代码行数:4,代码来源:BuilderException.cs

示例13: CreateUsedRulesList

        public void CreateUsedRulesList(ParseTreeNode node, List<string> rulenames)
        {
            foreach (var child in node.ChildNodes)
                CreateUsedRulesList(child, rulenames);

            if (node.Term.Name == "rulename")
            {
                var rulename = node.FindTokenAndGetText();

                if (rulenames.Find((fromList) => { return fromList == rulename; }) == null)
                    rulenames.Add(node.FindTokenAndGetText());
            }
        }
开发者ID:vf1,项目名称:bnf2dfa,代码行数:13,代码来源:Builder.cs

示例14: BuildCharvalExpression

 private IExpression BuildCharvalExpression(ParseTreeNode node)
 {
     var charval = node.FindTokenAndGetText();//.Replace("\\", "\\\\");
     charval = charval.Substring(1, charval.Length - 2);
     return new CharvalExpression(this, charval);
 }
开发者ID:vf1,项目名称:bnf2dfa,代码行数:6,代码来源:Builder.cs

示例15: GetParseTreeNodeText

        private static string GetParseTreeNodeText(ParseTreeNode parseTreeNode)
        {
            if (parseTreeNode == null)
            {
                return string.Empty;
            }

            // We cannot use FindTokenAndGetText always because it will give us only the text of the root node in
            // case of complex expressions. So we have to do that:
            if (parseTreeNode.ChildNodes.Count > 0)
            {
                var result = new StringBuilder();
                foreach (var node in parseTreeNode.ChildNodes)
                {
                    int offset = node.Span.Location.Position - parseTreeNode.Span.Location.Position;
                    if (result.Length < offset)
                    {
                        result.Append(' ', offset - result.Length);
                    }

                    result.Append(GetParseTreeNodeText(node));
                }

                return result.ToString();
            }

            return parseTreeNode.FindTokenAndGetText() ?? string.Empty;
        }
开发者ID:mauve,项目名称:Pash,代码行数:28,代码来源:ScriptExtent.cs


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