本文整理汇总了C#中Tokenizer.ConsumeChar方法的典型用法代码示例。如果您正苦于以下问题:C# Tokenizer.ConsumeChar方法的具体用法?C# Tokenizer.ConsumeChar怎么用?C# Tokenizer.ConsumeChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer.ConsumeChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.CHARACTER_TABULATION:
case Chars.LINE_FEED:
case Chars.FORM_FEED:
case Chars.SPACE:
t.ChangeTokenState<BeforeAttributeNameState>();
return;
case Chars.SOLIDUS:
t.ChangeTokenState<SelfClosingStartTagState>();
return;
case Chars.GREATER_THAN_SIGN:
t.ChangeTokenState<DataState>();
t.EmitToken();
return;
case null:
OnMessageRaised(new SuddenlyEndAtAttributeError());
t.UnConsume(1);
t.ChangeTokenState<DataState>();
return;
default:
OnMessageRaised(new MissingSpaceAfterAttributeValueError(c));
t.UnConsume(1);
t.ChangeTokenState<BeforeAttributeNameState>();
return;
}
}
示例2: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.HYPHEN_MINUS:
t.ChangeTokenState<ScriptDataDoubleEscapedDashState>();
t.EmitToken(Chars.HYPHEN_MINUS);
return;
case Chars.LESS_THAN_SIGN:
t.ChangeTokenState<ScriptDataDoubleEscapedLessThanSignState>();
t.EmitToken(Chars.LESS_THAN_SIGN);
return;
case Chars.NULL:
OnMessageRaised(new NullInScriptError());
t.EmitToken(Chars.REPLACEMENT_CHARACTER);
return;
case null:
OnMessageRaised(new SuddenlyEndAtScriptError());
t.UnConsume(1);
t.ChangeTokenState<DataState>();
return;
default:
t.EmitToken(c);
return;
}
}
示例3: ConsumeCharacterReference
// 文字参照
// 参照されている文字を取得します。失敗したときはnullを返します。
protected ReferencedCharacterToken ConsumeCharacterReference(Tokenizer t)
{
char? c = t.ConsumeChar();
if(t.AdditionalAllowedCharacter != null && c == t.AdditionalAllowedCharacter){
// Not a character reference. No characters are consumed, and nothing is returned. (This is not an error, either.)
OnMessageRaised(new RawAmpersandWarning());
t.UnConsume(1);
return null;
}
switch(c){
case Chars.AMPERSAND:
case Chars.LINE_FEED:
case Chars.FORM_FEED:
case Chars.SPACE:
case Chars.LESS_THAN_SIGN:
case null:
// Not a character reference. No characters are consumed, and nothing is returned. (This is not an error, either.)
OnMessageRaised(new RawAmpersandWarning());
t.UnConsume(1);
return null;
case Chars.NUMBER_SIGN:
return ConsumeNumericCharacterReference(t);
default:
return ConsumeNamedCharacterReference(t);
}
}
示例4: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
if(c.IsLatinCapitalLetter()){
t.TemporaryBuffer = "";
t.TemporaryBuffer += c.ToLower();
t.EmitToken(Chars.LESS_THAN_SIGN);
t.EmitToken(c);
t.ChangeTokenState<ScriptDataDoubleEscapeStartState>();
return;
} else if(c.IsLatinSmallLetter()){
t.TemporaryBuffer = "";
t.TemporaryBuffer += c;
t.EmitToken(Chars.LESS_THAN_SIGN);
t.EmitToken(c);
t.ChangeTokenState<ScriptDataDoubleEscapeStartState>();
return;
}
switch(c){
case Chars.SOLIDUS:
t.TemporaryBuffer = "";
t.ChangeTokenState<ScriptDataEscapedEndTagOpenState>();
return;
default:
t.EmitToken(Chars.LESS_THAN_SIGN);
t.UnConsume(1);
t.ChangeTokenState<ScriptDataEscapedState>();
return;
}
}
示例5: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.GREATER_THAN_SIGN:
OnMessageRaised(new EmptyEndTagError());
t.ChangeTokenState<DataState>();
return;
case null:
OnMessageRaised(new SuddenlyEndAtTagError());
t.EmitToken(Chars.LESS_THAN_SIGN);
t.EmitToken(Chars.SOLIDUS);
t.UnConsume(1);
t.ChangeTokenState<DataState>();
return;
}
if(c.IsLatinCapitalLetter()){
t.CurrentToken = new EndTagToken(){Name = c.ToLower().ToString()};
t.ChangeTokenState<TagNameState>();
return;
} else if(c.IsLatinSmallLetter()){
t.CurrentToken = new EndTagToken(){Name = c.ToString()};
t.ChangeTokenState<TagNameState>();
return;
}
OnMessageRaised(new UnknownEndTagError());
t.ChangeTokenState<BogusCommentState>();
return;
}
示例6: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
if(c.IsLatinCapitalLetter()){
t.TemporaryBuffer += c.ToLower();
t.EmitToken(c);
return;
} else if(c.IsLatinSmallLetter()){
t.TemporaryBuffer += c;
t.EmitToken(c);
return;
}
switch(c){
case Chars.CHARACTER_TABULATION:
case Chars.LINE_FEED:
case Chars.FORM_FEED:
case Chars.SPACE:
case Chars.SOLIDUS:
case Chars.GREATER_THAN_SIGN:
if(t.TemporaryBuffer.Equals("script", StringComparison.InvariantCulture)){
t.ChangeTokenState<ScriptDataDoubleEscapedState>();
} else {
t.ChangeTokenState<ScriptDataEscapedState>();
}
t.EmitToken(c);
return;
default:
t.UnConsume(1);
t.ChangeTokenState<ScriptDataEscapedState>();
return;
}
}
示例7: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.EXCLAMATION_MARK:
t.ChangeTokenState<MarkupDeclarationOpenState>();
return;
case Chars.SOLIDUS:
t.ChangeTokenState<EndTagOpenState>();
return;
case Chars.QUESTION_MARK:
OnMessageRaised(new ProcessingInstructionError());
t.ChangeTokenState<BogusCommentState>();
return;
}
if(c.IsLatinCapitalLetter()){
t.CurrentToken = new StartTagToken(){Name = c.ToLower().ToString()};
t.ChangeTokenState<TagNameState>();
return;
} else if(c.IsLatinSmallLetter()){
t.CurrentToken = new StartTagToken(){Name = c.ToString()};
t.ChangeTokenState<TagNameState>();
return;
}
OnMessageRaised(new UnknownMarkupError());
t.UnConsume(1);
t.ChangeTokenState<DataState>();
t.EmitToken(Chars.LESS_THAN_SIGN);
return;
}
示例8: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.CHARACTER_TABULATION:
case Chars.LINE_FEED:
case Chars.FORM_FEED:
case Chars.SPACE:
return;
case Chars.GREATER_THAN_SIGN:{
t.ChangeTokenState<DataState>();
t.EmitToken();
return;
}
case null:
OnMessageRaised(new SuddenlyEndAtDoctypeError());
((DoctypeToken)t.CurrentToken).ForceQuirks = true;
t.UnConsume(1);
t.ChangeTokenState<DataState>();
t.EmitToken();
return;
default:
OnMessageRaised(new UnknownIdentifierAfterDoctypeError());
t.ChangeTokenState<BogusDoctypeState>();
return;
}
}
示例9: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.HYPHEN_MINUS:
t.ChangeTokenState<CommentEndState>();
return;
case Chars.NULL:
OnMessageRaised(new NullInCommentError());
t.CurrentCommentToken.Append(Chars.HYPHEN_MINUS);
t.CurrentCommentToken.Append(Chars.REPLACEMENT_CHARACTER);
t.ChangeTokenState<CommentState>();
return;
case null:
OnMessageRaised(new SuddenlyEndAtCommentError());
t.EmitToken();
t.UnConsume(1);
t.ChangeTokenState<DataState>();
return;
default:
t.CurrentCommentToken.Append(Chars.HYPHEN_MINUS);
t.CurrentCommentToken.Append(c);
t.ChangeTokenState<CommentState>();
return;
}
}
示例10: character
/*
If the character reference is being consumed as part of an attribute, and the last character matched is not a U+003B SEMICOLON character (;), and the next character is either a U+003D EQUALS SIGN character (=) or in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for historical reasons, all the characters that were matched after the U+0026 AMPERSAND character (&) must be unconsumed, and nothing is returned.
*/
// 名前による文字参照を展開します。
protected ReferencedCharacterToken ConsumeNamedCharacterReference(Tokenizer t)
{
StringBuilder referenceName = new StringBuilder();
bool semicolonFound = false;
char? lastChar = t.CurrentInputChar;
while(lastChar.IsNameToken()){
referenceName.Append(lastChar);
lastChar = t.ConsumeChar();
}
if(lastChar == Chars.SEMICOLON){
referenceName.Append(lastChar);
semicolonFound = true;
} else {
// CurrentInputCharをreferenceNameの末尾にそろえる
t.UnConsume(1);
}
string originalString = referenceName.ToString();
string matchResult = null;
while(referenceName.Length > 0){
if(Chars.ExistsNamedChar(referenceName.ToString())){
matchResult = Chars.GetNamedChar(referenceName.ToString());
break;
}
referenceName.Remove(referenceName.Length-1, 1);
// CurrentInputCharをreferenceNameの末尾にそろえる
t.UnConsume(1);
}
if(matchResult == null){
if(semicolonFound){
// 名前がなく、セミコロンがある場合はパースエラー
// if the characters after the U+0026 AMPERSAND character (&) consist of a sequence of one or more characters in the range ASCII digits, lowercase ASCII letters, and uppercase ASCII letters, followed by a ";" (U+003B) character, then this is a parse error.
OnMessageRaised(new UnknownNamedCharacterReferenceWithSemicolonError(originalString));
} else {
// 名前がなくセミコロンがない場合はパースエラーにならない
OnMessageRaised(new UnknownNamedCharacterReferenceWithoutSemicolonWarning(originalString));
}
t.UnConsume(referenceName.Length);
return null;
}
if(!semicolonFound){
// 属性値の中のセミコロンなし文字参照は無視する
if(t.CurrentTokenState is CharacterReferenceInAttributeState && t.NextInputChar.IsSuffixOfIgnoreCharacterReferenceInAttribute()){
OnMessageRaised(new IgnoredCharacterReferenceInAttributeWarning(referenceName));
t.UnConsume(referenceName.Length);
return null;
}
// それ以外のセミコロンなし文字参照はエラー
OnMessageRaised(new NamedCharacterReferenceWithoutSemicolonError(referenceName));
}
ReferencedCharacterToken resultToken = new ReferencedCharacterToken(matchResult);
resultToken.OriginalString = referenceName.ToString();
return resultToken;
}
示例11: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.CHARACTER_TABULATION:
case Chars.LINE_FEED:
case Chars.FORM_FEED:
case Chars.SPACE:
return;
case Chars.SOLIDUS:
t.ChangeTokenState<SelfClosingStartTagState>();
return;
case Chars.EQUALS_SIGN:
t.ChangeTokenState<BeforeAttributeValueState>();
return;
case Chars.GREATER_THAN_SIGN:
t.ChangeTokenState<DataState>();
t.EmitToken();
return;
case Chars.NULL:
if(t.CurrentTagToken.FixAttribute() == false){
OnMessageRaised(new DuplicateAttributeError(t.CurrentTagToken.CurrentAttribute.Name));
t.CurrentTagToken.CurrentAttribute = null;
}
OnMessageRaised(new NullInAttributeNameError());
t.CurrentTagToken.CreateAttribute(Chars.REPLACEMENT_CHARACTER, "");
return;
case Chars.QUOTATION_MARK:
case Chars.APOSTROPHE:
case Chars.LESS_THAN_SIGN:
OnMessageRaised(new InvaridCharAtAfterAttributeNameError(c, t.CurrentTagToken.CurrentAttribute.Name));
goto default;
case null:
OnMessageRaised(new SuddenlyEndAtAttributeError());
t.UnConsume(1);
t.ChangeTokenState<DataState>();
return;
default:
if(t.CurrentTagToken.FixAttribute() == false){
OnMessageRaised(new DuplicateAttributeError(t.CurrentTagToken.CurrentAttribute.Name));
t.CurrentTagToken.CurrentAttribute = null;
}
if(c.IsLatinCapitalLetter()){
t.CurrentTagToken.CreateAttribute(c.ToLower(), "");
} else {
t.CurrentTagToken.CreateAttribute(c, "");
}
t.ChangeTokenState<AttributeNameState>();
return;
}
}
示例12: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
if(c == Chars.SOLIDUS){
t.TemporaryBuffer = "";
t.ChangeTokenState<RAWTEXTEndTagOpenState>();
return;
}
t.EmitToken(Chars.LESS_THAN_SIGN);
t.UnConsume(1);
t.ChangeTokenState<RAWTEXTState>();
return;
}
示例13: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.HYPHEN_MINUS:
t.EmitToken(Chars.HYPHEN_MINUS);
t.ChangeTokenState<ScriptDataEscapedDashDashState>();
return;
default:
t.UnConsume(1);
t.ChangeTokenState<ScriptDataState>();
return;
}
}
示例14: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
switch(c){
case Chars.SOLIDUS:
t.TemporaryBuffer = "";
t.ChangeTokenState<ScriptDataDoubleEscapeEndState>();
return;
default:
t.UnConsume(1);
t.ChangeTokenState<ScriptDataDoubleEscapedState>();
return;
}
}
示例15: Read
public override void Read(Tokenizer t)
{
char? c = t.ConsumeChar();
if(c.IsLatinCapitalLetter()){
t.CurrentTagToken.Name += c.ToLower();
t.TemporaryBuffer += c;
return;
} else if(c.IsLatinSmallLetter()){
t.CurrentTagToken.Name += c;
t.TemporaryBuffer += c;
return;
}
switch(c){
case Chars.CHARACTER_TABULATION:
case Chars.LINE_FEED:
case Chars.FORM_FEED:
case Chars.SPACE:
if(t.IsAppropriateEndTagToken){
t.ChangeTokenState<BeforeAttributeNameState>();
return;
}
goto default;
case Chars.SOLIDUS:
if(t.IsAppropriateEndTagToken){
t.ChangeTokenState<SelfClosingStartTagState>();
return;
}
goto default;
case Chars.GREATER_THAN_SIGN:
if(t.IsAppropriateEndTagToken){
t.EmitToken();
t.ChangeTokenState<DataState>();
return;
}
goto default;
default:{
t.EmitToken(Chars.LESS_THAN_SIGN);
t.EmitToken(Chars.SOLIDUS);
t.EmitToken(t.TemporaryBuffer);
t.UnConsume(1);
t.ChangeTokenState<ScriptDataEscapedState>();
return;
}
}
}