本文整理汇总了C#中Lexer.AddEndToken方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.AddEndToken方法的具体用法?C# Lexer.AddEndToken怎么用?C# Lexer.AddEndToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer.AddEndToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RantLexer
//.........这里部分代码省略.........
{
while (!reader.EndOfStringe)
{
if (reader.EatAll('\r', '\n')) return true;
if (!reader.SkipWhiteSpace()) return false;
}
return true;
}, R.Ignore, 2
},
// Escape sequence
{
reader =>
{
if (!reader.Eat('\\')) return false;
if (reader.EatWhile(Char.IsDigit))
{
if (reader.Eat('.')) reader.EatWhile(Char.IsDigit);
reader.EatAny('k', 'M', 'B');
if (!reader.Eat(','))
throw new RantCompilerException(reader.Origin, reader.Stringe.Substringe(reader.Position - 1, 1), "Expected ',' after quantifier.");
}
if (reader.Eat('u'))
{
for (int i = 0; i < 4; i++)
{
var c = reader.ReadChare().Character;
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')))
return false;
}
}
else
{
reader.ReadChare();
}
return true;
}, R.EscapeSequence
},
// Regex
{
reader =>
{
if (!reader.Eat('`')) return false;
var token = reader.Stringe.Substringe(reader.Position - 1, 1);
while (!reader.EndOfStringe)
{
reader.EatAll("\\`");
if (reader.ReadChare() == '`') break;
}
if (reader.EndOfStringe)
throw new RantCompilerException(reader.Origin, token, "Unterminated regular expression.");
reader.Eat('i');
return true;
}, R.Regex
},
// Constant literal
{
reader =>
{
if (!reader.Eat('"')) return false;
var token = reader.Stringe.Substringe(reader.Position - 1, 1);
while (!reader.EndOfStringe)
{
reader.EatAll("\"\"");
if (reader.ReadChare() == '"') return true;
}
throw new RantCompilerException(reader.Origin, token, "Unterminated constant literal.");
}, R.ConstantLiteral
},
{"[", R.LeftSquare}, {"]", R.RightSquare},
{"{", R.LeftCurly}, {"}", R.RightCurly},
{"<", R.LeftAngle}, {">", R.RightAngle},
{"(", R.LeftParen},
{")", R.RightParen},
{"|", R.Pipe},
{";", R.Semicolon},
{":", R.Colon},
{"@", R.At},
{"???", R.Undefined },
{"?", R.Question},
{"::", R.DoubleColon},
{"?!", R.Without},
{"-", R.Hyphen},
{"!", R.Exclamation},
{"$", R.Dollar},
{"=", R.Equal},
{"&", R.Ampersand},
{"%", R.Percent},
{"+", R.Plus},
{"^", R.Caret},
{"`", R.Backtick},
{"*", R.Asterisk},
{"/", R.ForwardSlash},
{",", R.Comma},
{"~", R.Tilde},
{".", R.Subtype}
};
Rules.AddUndefinedCaptureRule(R.Text, TruncatePadding);
Rules.AddEndToken(R.EOF);
Rules.Ignore(R.Ignore);
}