public void Parse ()
{
if (tokenizer == null) {
OnError ("AspParser not initialized properly.");
return;
}
int token;
string id;
TagAttributes attributes;
TagType tagtype = TagType.Text;
StringBuilder text = new StringBuilder ();
try {
while ((token = tokenizer.get_token ()) != Token.EOF) {
BeginElement ();
if (tokenizer.Verbatim){
string end_verbatim = "</" + verbatimID + ">";
string verbatim_text = GetVerbatim (token, end_verbatim);
if (verbatim_text == null)
OnError ("Unexpected EOF processing " + verbatimID);
tokenizer.Verbatim = false;
EndElement ();
endPosition -= end_verbatim.Length;
OnTextParsed (verbatim_text);
beginPosition = endPosition;
endPosition += end_verbatim.Length;
OnTagParsed (TagType.Close, verbatimID, null);
continue;
}
if (token == '<') {
GetTag (out tagtype, out id, out attributes);
EndElement ();
if (tagtype == TagType.ServerComment)
continue;
if (tagtype == TagType.Text)
OnTextParsed (id);
else
OnTagParsed (tagtype, id, attributes);
continue;
}
if (tokenizer.Value.Trim ().Length == 0 && tagtype == TagType.Directive) {
continue;
}
text.Length = 0;
do {
text.Append (tokenizer.Value);
token = tokenizer.get_token ();
} while (token != '<' && token != Token.EOF);
tokenizer.put_back ();
EndElement ();
OnTextParsed (text.ToString ());
}
} finally {
if (fileReader != null) {
fileReader.Close ();
fileReader = null;
}
#if NET_2_0
checksum = tokenizer.Checksum;
#endif
tokenizer = null;
}
#if NET_2_0
OnParsingComplete ();
#endif
}