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

C# ITokenStream类代码示例

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

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



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

示例1: CreateSimpleSelector

        static ParseItem CreateSimpleSelector(ComplexItem parent, IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            switch (stream.Current.Type)
            {
                case TokenType.Ampersand: return new ParentReferenceSelector();
                case TokenType.Asterisk: return new UniversalSelector();
                case TokenType.Period: return new ClassSelector();
                case TokenType.Hash: return new IdSelector();
                case TokenType.Identifier: return new TypeSelector();
                case TokenType.OpenBrace: return new AttributeSelector();
                case TokenType.DoubleColon: return new PseudoElementSelector();
                case TokenType.PercentSign: return new ExtendOnlySelector();
            }

            if (stream.Current.Type == TokenType.Colon)
            {
                var next = stream.Peek(1);
                switch (next.Type)
                {
                    case TokenType.Identifier: return new PseudoClassSelector();
                    case TokenType.Function: return new PseudoFunctionSelector();
                }
            }

            return null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:26,代码来源:DefaultSassItemFactory.cs


示例2: ParseSelectorToken

        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.OpenBrace)
            {
                OpenBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.SquareBrace);
                if (stream.Current.Type == TokenType.Identifier)
                    Attribute = Children.AddCurrentAndAdvance(stream);

                if (IsAttributeOperator(stream.Current.Type))
                    Operator = Children.AddCurrentAndAdvance(stream);

                if (stream.Current.Type == TokenType.String || stream.Current.Type == TokenType.BadString)
                {
                    Value = itemFactory.CreateSpecificParsed<StringValue>(this, text, stream);
                    if (Value != null)
                        Children.Add(Value);
                } else if (stream.Current.Type == TokenType.Identifier)
                {
                    Value = Children.AddCurrentAndAdvance(stream, SassClassifierType.String);
                }

                if (stream.Current.Type == TokenType.CloseBrace)
                    CloseBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.SquareBrace);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:27,代码来源:AttributeSelector.cs


示例3: FastSimpleExpressionParser

	public FastSimpleExpressionParser(ITokenStream input, RecognizerSharedState state)
		: base(input, state)
	{
		InitializeTreeAdaptor();
		if ( TreeAdaptor == null )
			TreeAdaptor = new CommonTreeAdaptor();
	}
开发者ID:sebasjm,项目名称:antlr,代码行数:7,代码来源:FastSimpleExpressionParser.cs


示例4: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "media"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                    Children.Add(Rule);

                while (!IsTerminator(stream.Current.Type))
                {
                    var query = itemFactory.CreateSpecific<MediaQuery>(this, text, stream);
                    if (query.Parse(itemFactory, text, stream))
                    {
                        _Queries.Add(query);
                        Children.Add(query);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                var block = itemFactory.CreateSpecific<MediaQueryBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Body = block;
                    Children.Add(block);
                }
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:32,代码来源:MediaQueryDirective.cs


示例5: ParseSelectorToken

        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Asterisk)
                Asterisk = Children.AddCurrentAndAdvance(stream);

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:7,代码来源:UniversalSelector.cs


示例6: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "each"))
            {
                ParseRule(itemFactory, text, stream);
                while (!IsListTerminator(stream.Current.Type))
                {
                    var item = itemFactory.CreateSpecific<ListItem>(this, text, stream);
                    if (item != null && item.Parse(itemFactory, text, stream))
                    {
                        _Items.Add(item);
                        Children.Add(item);
                    }
                    else
                    {
                        // bad news bears
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                ParseBody(itemFactory, text, stream);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:25,代码来源:EachLoopDirective.cs


示例7: DebugTokenStream

 public DebugTokenStream(ITokenStream input, IDebugEventListener dbg) {
     this.input = input;
     DebugListener = dbg;
     // force TokenStream to get at least first valid token
     // so we know if there are any hidden tokens first in the stream
     input.LT(1);
 }
开发者ID:EightPillars,项目名称:PathwayEditor,代码行数:7,代码来源:DebugTokenStream.cs


示例8: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsModifier(text.GetText(stream.Current.Start, stream.Current.Length)))
                Modifier = Children.AddCurrentAndAdvance(stream);

            ParseItem mediaType;
            if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out mediaType))
            {
                MediaType = mediaType;
                Children.Add(mediaType);
            }

            while (!IsTerminator(text, stream))
            {
                var expression = itemFactory.CreateSpecific<MediaQueryExpression>(this, text, stream);
                if (expression.Parse(itemFactory, text, stream))
                {
                    _Expressions.Add(expression);
                    Children.Add(expression);
                }
                else
                {
                    Children.AddCurrentAndAdvance(stream);
                }
            }

            if (stream.Current.Type == TokenType.Comma)
                Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:31,代码来源:MediaQuery.cs


示例9: PredicateEvalInfo

 /// <summary>
 /// Constructs a new instance of the
 /// <see cref="PredicateEvalInfo"/>
 /// class with the
 /// specified detailed predicate evaluation information.
 /// </summary>
 /// <param name="state">The simulator state</param>
 /// <param name="decision">The decision number</param>
 /// <param name="input">The input token stream</param>
 /// <param name="startIndex">The start index for the current prediction</param>
 /// <param name="stopIndex">
 /// The index at which the predicate evaluation was
 /// triggered. Note that the input stream may be reset to other positions for
 /// the actual evaluation of individual predicates.
 /// </param>
 /// <param name="semctx">The semantic context which was evaluated</param>
 /// <param name="evalResult">The results of evaluating the semantic context</param>
 /// <param name="predictedAlt">
 /// The alternative number for the decision which is
 /// guarded by the semantic context
 /// <paramref name="semctx"/>
 /// . See
 /// <see cref="predictedAlt"/>
 /// for more information.
 /// </param>
 /// <seealso cref="ParserATNSimulator.EvalSemanticContext(SemanticContext, ParserRuleContext, int)"/>
 /// <seealso cref="SemanticContext.Eval"/>
 public PredicateEvalInfo(SimulatorState state, int decision, ITokenStream input, int startIndex, int stopIndex, SemanticContext semctx, bool evalResult, int predictedAlt)
     : base(decision, state, input, startIndex, stopIndex, state.useContext)
 {
     this.semctx = semctx;
     this.evalResult = evalResult;
     this.predictedAlt = predictedAlt;
 }
开发者ID:antlr,项目名称:antlr4,代码行数:34,代码来源:PredicateEvalInfo.cs


示例10: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsSelectorTerminator(stream.Current.Type))
            {
                var selector = itemFactory.CreateSpecific<SelectorGroup>(this, text, stream);
                if (!selector.Parse(itemFactory, text, stream))
                    break;

                _Selectors.Add(selector);
                Children.Add(selector);

                if (stream.Current.Type == TokenType.Comma)
                    Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);
            }

            if (stream.Current.Type == TokenType.OpenCurlyBrace)
            {
                var block = itemFactory.CreateSpecific<RuleBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Block = block;
                    Children.Add(block);
                }
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:27,代码来源:RuleSet.cs


示例11: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.XmlDocumentationComment)
            {
                Opening = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                // look for <reference
                if (stream.Current.Type == TokenType.LessThan)
                {
                    var tag = itemFactory.CreateSpecific<XmlDocumentationTag>(this, text, stream);
                    if (tag.Parse(itemFactory, text, stream))
                    {
                        Tag = tag;
                        Children.Add(tag);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationComment);
                    }
                }
                else
                {
                    while (!IsCommentTerminator(stream.Current.Type))
                    {
                        Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationComment);
                    }
                }

                //if (stream.Current.Type == TokenType.NewLine)
                //    NewLine = Children.AddCurrentAndAdvance(stream);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:34,代码来源:XmlDocumentationComment.cs


示例12: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "extend"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                    Children.Add(Rule);

                var selector = itemFactory.CreateSpecific<SelectorGroup>(this, text, stream);
                if (selector.Parse(itemFactory, text, stream))
                {
                    Selector = selector;
                    Children.Add(selector);
                }

                if (stream.Current.Type == TokenType.Bang)
                {
                    var modifier = new OptionalModifier();
                    if (modifier.Parse(itemFactory, text, stream))
                    {
                        Modifier = modifier;
                        Children.Add(modifier);
                    }
                }

                if (stream.Current.Type == TokenType.Semicolon)
                    Semicolon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:31,代码来源:ExtendDirective.cs


示例13: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.LessThan)
            {
                OpenTag = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);
                if (stream.Current.Type == TokenType.Identifier)
                {
                    Name = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                    while (!IsTagTerminator(stream.Current.Type))
                    {
                        var attribute = itemFactory.CreateSpecific<XmlAttribute>(this, text, stream);
                        if (!attribute.Parse(itemFactory, text, stream))
                            break;

                        Children.Add(attribute);
                        _Attributes.Add(attribute);
                        OnAttributeParsed(attribute, text);
                    }
                }

                if (stream.Current.Type == TokenType.Slash)
                    CloseSlash = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                if (stream.Current.Type == TokenType.GreaterThan)
                    CloseTag = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:30,代码来源:XmlDocumentationTag.cs


示例14: Parse

        private ParseItemList Parse(ITextProvider text, IItemFactory itemFactory, ITokenStream stream, IParsingExecutionContext context)
        {
            var results = new ParseItemList();
            while (!context.IsCancellationRequested && stream.Current.Type != TokenType.EndOfFile)
            {
                int position = stream.Position;

                ParseItem item;
                if (!itemFactory.TryCreate(null, text, stream, out item))
                    break;

                if (item.Parse(itemFactory, text, stream))
                    results.Add(item);

                // guard against infinite loop (in case token couldn't be handled)
                if (stream.Position == position)
                    stream.Advance();
            }

            // freeze everything
            if (!context.IsCancellationRequested)
                foreach (var item in results)
                    item.Freeze();

            return results;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:26,代码来源:Parser.cs


示例15: CompilationState

 public CompilationState(ErrorManager errMgr, string name, ITokenStream tokens)
 {
     this.errMgr = errMgr;
     this.tokens = tokens;
     impl.Name = name;
     impl.Prefix = Utility.GetPrefix(name);
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:7,代码来源:CompilationState.cs


示例16: ErrorNode

 /** <summary>
  *  Create tree node that holds the start and stop tokens associated
  *  with an error.
  *  </summary>
  *
  *  <remarks>
  *  If you specify your own kind of tree nodes, you will likely have to
  *  override this method. CommonTree returns Token.INVALID_TOKEN_TYPE
  *  if no token payload but you might have to set token type for diff
  *  node type.
  *
  *  You don't have to subclass CommonErrorNode; you will likely need to
  *  subclass your own tree node class to avoid class cast exception.
  *  </remarks>
  */
 public virtual object ErrorNode( ITokenStream input, IToken start, IToken stop,
                         RecognitionException e )
 {
     CommonErrorNode t = new CommonErrorNode( input, start, stop, e );
     //System.out.println("returning error node '"+t+"' @index="+input.index());
     return t;
 }
开发者ID:sebasjm,项目名称:antlr,代码行数:22,代码来源:BaseTreeAdaptor.cs


示例17: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if ((IsConditionalDirective(text, stream) || IsConditionalContinuationDirective(text, stream)))
            {
                ParseRule(itemFactory, text, stream);

                while (!IsConditionTerminator(stream.Current.Type))
                {
                    ParseItem item;
                    if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item))
                    {
                        Children.Add(item);
                        ConditionStatements.Add(item);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                ParseBody(itemFactory, text, stream);

                while (IsConditionalContinuationDirective(text, stream))
                {
                    var subsequentConditional = itemFactory.CreateSpecific<ConditionalControlDirective>(this, text, stream);
                    if (!subsequentConditional.Parse(itemFactory, text, stream))
                        break;

                    ElseStatements.Add(subsequentConditional);
                    Children.Add(subsequentConditional);
                }
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:35,代码来源:ConditionalControlDirective.cs


示例18: MatlabParser

        public MatlabParser(ITokenStream input, Configuration configuration)
            : this(input)
        {
            Checker.CheckNotNull(configuration);

            this.Configuration = configuration;
        }
开发者ID:samuel-suffos,项目名称:matlab-parser,代码行数:7,代码来源:MatlabParser.cs


示例19: ParseCombinator

        protected virtual bool ParseCombinator(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            SelectorCombinator combinator = null;
            switch (stream.Current.Type)
            {
                case TokenType.GreaterThan:
                    combinator = new ChildCombinator();
                    break;
                case TokenType.Plus:
                    combinator = new AdjacentSiblingCombinator();
                    break;
                case TokenType.Tilde:
                    combinator = new GeneralSiblingCombinator();
                    break;
            }

            if (combinator != null)
            {
                if (combinator.Parse(itemFactory, text, stream))
                {
                    Children.Add(combinator);
                    Combinator = combinator;
                }
            }
            else if (stream.Current.Type != TokenType.OpenCurlyBrace)
            {
                // whitespace only combinator means no adding to children or parsing
                // we just want to know that there was a combinator
                if (stream.Current.Start >= (stream.Peek(-1).End + 1))
                    Combinator = new DescendantCombinator();
            }

            return Combinator != null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:34,代码来源:SimpleSelector.cs


示例20: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (ParseSelectorToken(itemFactory, text, stream))
                ParseCombinator(itemFactory, text, stream);

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:7,代码来源:SimpleSelector.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ITokener类代码示例发布时间:2022-05-24
下一篇:
C# ITokenSource类代码示例发布时间: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