本文整理汇总了C#中Lexer.Scan方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.Scan方法的具体用法?C# Lexer.Scan怎么用?C# Lexer.Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer.Scan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dump
public static string Dump(Lexer aLexer)
{
using (var xOut = new StringWriter())
{
while (true)
{
var xToken = aLexer.Scan();
xOut.Write(xToken.TagValue);
var xWord = xToken as Word;
if (xWord != null)
{
xOut.Write("\t");
xOut.Write(xWord.Value);
}
var xUnknown = xToken as CharToken;
if (xUnknown != null)
{
xOut.Write("\t");
xOut.Write(xUnknown.Value);
}
xOut.WriteLine();
if (xToken.TagValue == Tag.EndOfStream)
{
break;
}
}
return xOut.ToString();
}
}
示例2: Parse
public static Tree Parse(Stream stream)
{
var lexer = new Lexer();
var parser = new Parser();
using (stream)
{
var tokens = lexer.Scan(stream);
var tree = parser.Parse(tokens);
return tree;
}
}
示例3: TryParse
public static bool TryParse (string input, out ProductHeaderValue parsedValue)
{
parsedValue = null;
var lexer = new Lexer (input);
var t = lexer.Scan ();
if (t != Token.Type.Token)
return false;
var value = new ProductHeaderValue ();
value.Name = lexer.GetStringValue (t);
t = lexer.Scan ();
if (t == Token.Type.SeparatorSlash) {
t = lexer.Scan ();
if (t != Token.Type.Token)
return false;
value.Version = lexer.GetStringValue (t);
t = lexer.Scan ();
}
if (t != Token.Type.End)
return false;
parsedValue = value;
return true;
}
示例4: TryParse
public static bool TryParse (string input, out ViaHeaderValue parsedValue)
{
parsedValue = null;
var lexer = new Lexer (input);
var t = lexer.Scan ();
if (t != Token.Type.Token)
return false;
var next = lexer.Scan ();
ViaHeaderValue value = new ViaHeaderValue ();
if (next == Token.Type.SeparatorSlash) {
next = lexer.Scan ();
if (next != Token.Type.Token)
return false;
value.ProtocolName = lexer.GetStringValue (t);
value.ProtocolVersion = lexer.GetStringValue (next);
next = lexer.Scan ();
} else {
value.ProtocolVersion = lexer.GetStringValue (t);
}
if (next != Token.Type.Token)
return false;
if (lexer.PeekChar () == ':') {
lexer.EatChar ();
t = lexer.Scan ();
if (t != Token.Type.Token)
return false;
} else {
t = next;
}
value.ReceivedBy = lexer.GetStringValue (next, t);
string comment;
if (!lexer.ScanCommentOptional (out comment))
return false;
value.Comment = comment;
parsedValue = value;
return true;
}
示例5: TryParse
public static bool TryParse (string input, out AuthenticationHeaderValue parsedValue)
{
var lexer = new Lexer (input);
var t = lexer.Scan ();
if (t != Token.Type.Token || !(lexer.PeekChar () == ' ' || lexer.PeekChar () == -1)) {
parsedValue = null;
return false;
}
parsedValue = new AuthenticationHeaderValue ();
parsedValue.Scheme = lexer.GetStringValue (t);
t = lexer.Scan ();
if (t != Token.Type.End)
parsedValue.Parameter = lexer.GetRemainingStringValue (t.StartPosition);
return true;
}
示例6: TryParse
public static bool TryParse (string input, out EntityTagHeaderValue parsedValue)
{
parsedValue = null;
var lexer = new Lexer (input);
var t = lexer.Scan ();
bool is_weak = false;
if (t == Token.Type.Token) {
if (lexer.GetStringValue (t) != "W" || lexer.PeekChar () != '/')
return false;
is_weak = true;
lexer.EatChar ();
t = lexer.Scan ();
}
if (t != Token.Type.QuotedString)
return false;
if (lexer.Scan () != Token.Type.End)
return false;
parsedValue = new EntityTagHeaderValue ();
parsedValue.Tag = lexer.GetStringValue (t);
parsedValue.IsWeak = is_weak;
return true;
}