本文整理汇总了C#中ITokenStream类的典型用法代码示例。如果您正苦于以下问题:C# ITokenStream类的具体用法?C# ITokenStream怎么用?C# ITokenStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITokenStream类属于命名空间,在下文中一共展示了ITokenStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: FastSimpleExpressionParser
public FastSimpleExpressionParser(ITokenStream input, RecognizerSharedState state)
: base(input, state)
{
InitializeTreeAdaptor();
if ( TreeAdaptor == null )
TreeAdaptor = new CommonTreeAdaptor();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例15: CompilationState
public CompilationState(ErrorManager errMgr, string name, ITokenStream tokens)
{
this.errMgr = errMgr;
this.tokens = tokens;
impl.Name = name;
impl.Prefix = Utility.GetPrefix(name);
}