本文整理汇总了C#中Lexer.Whitespace方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.Whitespace方法的具体用法?C# Lexer.Whitespace怎么用?C# Lexer.Whitespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer.Whitespace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
lexer.Whitespace(state.RuntimeState);
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), range.ToString());
char character = lexer.Peek();
if (!range.Contains(character))
{
lexer.ErrorStrings[start].Add(range.ToString());
state.RuntimeState.Runtime.ParseTrace.No(this,
lexer.SourceFrom(start), TextEscape.Quote(character));
return ParseTree.No;
}
lexer.Read();
state.RuntimeState.Runtime.ParseTrace.Yes(this,
lexer.SourceFrom(start), TextEscape.Quote(character));
if (state.BuildTextNodes)
return new ParseTree(Convert.ToString(character));
else
return ParseTree.Yes;
}
示例2: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
lexer.Whitespace(state.RuntimeState);
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), "[]");
char character = lexer.Peek();
if (character == '\0')
{
state.RuntimeState.Runtime.ParseTrace.No(this, lexer.SourceFrom(start), "End of source");
return ParseTree.No;
}
lexer.Read();
state.RuntimeState.Runtime.ParseTrace.Yes(this, lexer.SourceFrom(start), TextEscape.Quote(character));
if (state.BuildTextNodes)
return new ParseTree(Convert.ToString(character));
else
return ParseTree.Yes;
}
示例3: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
lexer.Whitespace(state.RuntimeState);
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(
this,
lexer.CurrentSource(),
TextEscape.Quote(text));
for (int n = 0; n < text.Length; n++)
{
char character = lexer.Peek(n);
if (character != text[n])
{
string stoppedString;
if (character == '\0')
stoppedString = "end";
else
stoppedString = TextEscape.Quote(character);
lexer.ErrorStrings[start + n].Add(TextEscape.Quote(text));
if (n > 0)
state.RuntimeState.Runtime.ParseTrace.No(
this,
lexer.SourceFrom(start),
TextEscape.Quote(lexer.Text.Substring(start, n))
+ "..." + stoppedString);
else
state.RuntimeState.Runtime.ParseTrace.No(
this,
lexer.SourceFrom(start),
stoppedString);
return ParseTree.No;
}
}
lexer.Skip(text.Length);
state.RuntimeState.Runtime.ParseTrace.Yes(this,
lexer.SourceFrom(start));
if (state.BuildTextNodes)
return new ParseTree(text);
else
return ParseTree.Yes;
}
示例4: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), "options");
bool oldBuildTextNodes = state.BuildTextNodes;
Pattern oldWhitespace = lexer.WhitespacePattern;
Precedence oldCurrentPrecedence = state.CurrentPrecedence;
bool oldPrecedenceCanEqualCurrent = state.PrecedenceCanEqualCurrent;
if (buildTextNodes.HasValue)
state.BuildTextNodes = buildTextNodes.Value;
if (whitespace.HasValue)
{
lexer.Whitespace(state.RuntimeState);
lexer.WhitespacePattern = whitespace.Value;
}
if (exclude.HasValue)
state.Excluded.Add(exclude.Value);
if (dropPrecedence.HasValue && dropPrecedence.Value)
{
state.CurrentPrecedence = null;
state.PrecedenceCanEqualCurrent = false;
}
ParseTree tree = body.Parse(lexer, state);
state.BuildTextNodes = oldBuildTextNodes;
lexer.WhitespacePattern = oldWhitespace;
if (exclude.HasValue)
state.Excluded.Remove(exclude.Value);
state.CurrentPrecedence = oldCurrentPrecedence;
state.PrecedenceCanEqualCurrent = oldPrecedenceCanEqualCurrent;
if (tree == ParseTree.No)
{
state.RuntimeState.Runtime.ParseTrace.No(this, lexer.SourceFrom(start));
return ParseTree.No;
}
state.RuntimeState.Runtime.ParseTrace.Yes(this, lexer.SourceFrom(start));
return tree;
}
示例5: Parse
public override ParseTree Parse(Lexer lexer, ParserState state)
{
int start = lexer.Position;
state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), "Pattern " + Type.Name);
/*state.RuntimeState.Runtime.ParseTrace.Enter(this, lexer.CurrentSource(), "Excluded:");
foreach (Pattern excluded in state.Excluded)
state.RuntimeState.Runtime.ParseTrace.Single(excluded.Type.Name);
state.RuntimeState.Runtime.ParseTrace.Leave(this);*/
if (state.Excluded.Contains(this))
{
state.RuntimeState.Runtime.ParseTrace.No(this, lexer.CurrentSource(), "Excluded");
return ParseTree.No;
}
ParserMemoryKey key = new ParserMemoryKey(this, start);
bool oldSkipMemoryForLeftRecursion = state.SkipMemoryForLeftRecursion;
if (state.SkipMemoryForLeftRecursion)
{
state.SkipMemoryForLeftRecursion = false;
}
else
{
ParserMemoryEntry entry;
if (state.Memory.TryGetValue(key, out entry))
{
state.RuntimeState.Runtime.ParseTrace.LinkNext(entry.Tag);
if (entry.Tree == ParseTree.No)
{
state.RuntimeState.Runtime.ParseTrace.No(this, lexer.SourceFrom(start), "From memory");
}
else
{
state.RuntimeState.Runtime.ParseTrace.Yes(this, lexer.SourceFrom(start), "From memory");
lexer.Position = entry.End;
}
return entry.Tree;
}
}
ConcretePattern oldRecursionExclude = state.RecursionExclude;
if (RecursionBehaviour != RecursionBehaviour.Recursive)
{
if (state.RecursionExclude != null)
state.Excluded.Remove(state.RecursionExclude);
state.RecursionExclude = this;
state.Excluded.Add(this);
}
RecursionBehaviour oldRecursionBehaviour = state.RecursionBehaviour;
state.RecursionBehaviour = RecursionBehaviour;
Precedence oldCurrentPrecedence = state.CurrentPrecedence;
if (Precedence.Overwrites(state.CurrentPrecedence))
state.CurrentPrecedence = Precedence;
bool oldPrecedenceCanEqualCurrent = state.PrecedenceCanEqualCurrent;
state.PrecedenceCanEqualCurrent = RecursionBehaviour == RecursionBehaviour.Recursive;
ParseTree tree = ParseGraph.Parse(lexer, state);
state.CurrentPrecedence = oldCurrentPrecedence;
state.PrecedenceCanEqualCurrent = oldPrecedenceCanEqualCurrent;
state.RecursionBehaviour = oldRecursionBehaviour;
state.RecursionExclude = oldRecursionExclude;
state.SkipMemoryForLeftRecursion = oldSkipMemoryForLeftRecursion;
if (RecursionBehaviour != RecursionBehaviour.Recursive)
{
if (oldRecursionExclude != null)
state.Excluded.Add(oldRecursionExclude);
state.Excluded.Remove(this);
}
if (tree != ParseTree.No)
{
lexer.Whitespace(state.RuntimeState);
tree = Instantiate(lexer, state, start, tree);
}
object nextTag = new object();
state.RuntimeState.Runtime.ParseTrace.TagNext(nextTag);
if (tree == ParseTree.No)
{
//.........这里部分代码省略.........