📄 lexer.java
字号:
continue;
case LEX_ENDTAG: /* </letter */
this.txtstart = this.lexsize - 1;
this.in.curcol += 2;
c = parseTagName();
this.token = newNode(Node.EndTag, /* create endtag token */
this.lexbuf,
this.txtstart,
this.txtend,
getString(this.lexbuf,
this.txtstart,
this.txtend - this.txtstart));
this.lexsize = this.txtstart;
this.txtend = this.txtstart;
/* skip to '>' */
while (c != '>')
{
c = this.in.readChar();
if (c == StreamIn.EndOfStream)
break;
}
if (c == StreamIn.EndOfStream)
{
this.in.ungetChar(c);
continue;
}
this.state = LEX_CONTENT;
this.waswhite = false;
return this.token; /* the endtag token */
case LEX_STARTTAG: /* first letter of tagname */
this.txtstart = this.lexsize - 1; /* set txtstart to first letter */
c = parseTagName();
isempty.value = false;
attributes = null;
this.token = newNode((isempty.value ? Node.StartEndTag : Node.StartTag),
this.lexbuf,
this.txtstart,
this.txtend,
getString(this.lexbuf,
this.txtstart,
this.txtend - this.txtstart));
/* parse attributes, consuming closing ">" */
if (c != '>')
{
if (c == '/')
this.in.ungetChar(c);
attributes = parseAttrs(isempty);
}
if (isempty.value)
this.token.type = Node.StartEndTag;
this.token.attributes = attributes;
this.lexsize = this.txtstart;
this.txtend = this.txtstart;
/* swallow newline following start tag */
/* special check needed for CRLF sequence */
/* this doesn't apply to empty elements */
if (expectsContent(this.token) ||
this.token.tag == TagTable.tagBr)
{
c = this.in.readChar();
if (c == '\r')
{
c = this.in.readChar();
if (c != '\n')
this.in.ungetChar(c);
}
else if (c != '\n' && c != '\f')
this.in.ungetChar(c);
this.waswhite = true; /* to swallow leading whitespace */
}
else
this.waswhite = false;
this.state = LEX_CONTENT;
if (this.token.tag == null)
Report.error(this, null, this.token, Report.UNKNOWN_ELEMENT);
else if (!this.configuration.XmlTags)
{
this.versions &= this.token.tag.versions;
if ((this.token.tag.versions & Dict.VERS_PROPRIETARY) != 0)
{
if (!this.configuration.MakeClean && (this.token.tag == TagTable.tagNobr ||
this.token.tag == TagTable.tagWbr))
Report.warning(this, null, this.token, Report.PROPRIETARY_ELEMENT);
}
if (this.token.tag.chkattrs != null)
{
this.token.checkUniqueAttributes(this);
this.token.tag.chkattrs.check(this, this.token);
}
else
this.token.checkAttributes(this);
}
return this.token; /* return start tag */
case LEX_COMMENT: /* seen <!-- so look for --> */
if (c != '-')
continue;
c = this.in.readChar();
addCharToLexer(c);
if (c != '-')
continue;
end_comment: while (true) {
c = this.in.readChar();
if (c == '>')
{
if (badcomment != 0)
Report.warning(this, null, null, Report.MALFORMED_COMMENT);
this.txtend = this.lexsize - 2; // AQ 8Jul2000
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.CommentTag,
this.lexbuf,
this.txtstart,
this.txtend);
/* now look for a line break */
c = this.in.readChar();
if (c == '\r')
{
c = this.in.readChar();
if (c != '\n')
this.token.linebreak = true;
}
if (c == '\n')
this.token.linebreak = true;
else
this.in.ungetChar(c);
return this.token;
}
/* note position of first such error in the comment */
if (badcomment == 0)
{
this.lines = this.in.curline;
this.columns = this.in.curcol - 3;
}
badcomment++;
if (this.configuration.FixComments)
this.lexbuf[this.lexsize - 2] = (byte)'=';
addCharToLexer(c);
/* if '-' then look for '>' to end the comment */
if (c != '-')
break end_comment;
}
/* otherwise continue to look for --> */
this.lexbuf[this.lexsize - 2] = (byte)'=';
continue;
case LEX_DOCTYPE: /* seen <!d so look for '>' munging whitespace */
map = MAP((char)c);
if ((map & WHITE) != 0)
{
if (this.waswhite)
this.lexsize -= 1;
this.waswhite = true;
}
else
this.waswhite = false;
if (c != '>')
continue;
this.lexsize -= 1;
this.txtend = this.lexsize;
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.DocTypeTag,
this.lexbuf,
this.txtstart,
this.txtend);
/* make a note of the version named by the doctype */
this.doctype = findGivenVersion(this.token);
return this.token;
case LEX_PROCINSTR: /* seen <? so look for '>' */
/* check for PHP preprocessor instructions <?php ... ?> */
if (this.lexsize - this.txtstart == 3)
{
if ((getString(this.lexbuf, this.txtstart, 3)).equals("php"))
{
this.state = LEX_PHP;
continue;
}
}
if (this.configuration.XmlPIs) /* insist on ?> as terminator */
{
if (c != '?')
continue;
/* now look for '>' */
c = this.in.readChar();
if (c == StreamIn.EndOfStream)
{
Report.warning(this, null, null, Report.UNEXPECTED_END_OF_FILE);
this.in.ungetChar(c);
continue;
}
addCharToLexer(c);
}
if (c != '>')
continue;
this.lexsize -= 1;
this.txtend = this.lexsize;
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.ProcInsTag,
this.lexbuf,
this.txtstart,
this.txtend);
return this.token;
case LEX_ASP: /* seen <% so look for "%>" */
if (c != '%')
continue;
/* now look for '>' */
c = this.in.readChar();
if (c != '>')
{
this.in.ungetChar(c);
continue;
}
this.lexsize -= 1;
this.txtend = this.lexsize;
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.AspTag,
this.lexbuf,
this.txtstart,
this.txtend);
return this.token;
case LEX_JSTE: /* seen <# so look for "#>" */
if (c != '#')
continue;
/* now look for '>' */
c = this.in.readChar();
if (c != '>')
{
this.in.ungetChar(c);
continue;
}
this.lexsize -= 1;
this.txtend = this.lexsize;
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.JsteTag,
this.lexbuf,
this.txtstart,
this.txtend);
return this.token;
case LEX_PHP: /* seen "<?php" so look for "?>" */
if (c != '?')
continue;
/* now look for '>' */
c = this.in.readChar();
if (c != '>')
{
this.in.ungetChar(c);
continue;
}
this.lexsize -= 1;
this.txtend = this.lexsize;
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.PhpTag,
this.lexbuf,
this.txtstart,
this.txtend);
return this.token;
case LEX_SECTION: /* seen "<![" so look for "]>" */
if (c == '[')
{
if (this.lexsize == (this.txtstart + 6) &&
(getString(this.lexbuf, this.txtstart, 6)).equals("CDATA["))
{
this.state = LEX_CDATA;
this.lexsize -= 6;
continue;
}
}
if (c != ']')
continue;
/* now look for '>' */
c = this.in.readChar();
if (c != '>')
{
this.in.ungetChar(c);
continue;
}
this.lexsize -= 1;
this.txtend = this.lexsize;
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.SectionTag,
this.lexbuf,
this.txtstart,
this.txtend);
return this.token;
case LEX_CDATA: /* seen "<![CDATA[" so look for "]]>" */
if (c != ']')
continue;
/* now look for ']' */
c = this.in.readChar();
if (c != ']')
{
this.in.ungetChar(c);
continue;
}
/* now look for '>' */
c = this.in.readChar();
if (c != '>')
{
this.in.ungetChar(c);
continue;
}
this.lexsize -= 1;
this.txtend = this.lexsize;
this.lexbuf[this.lexsize] = (byte)'\0';
this.state = LEX_CONTENT;
this.waswhite = false;
this.token = newNode(Node.CDATATag,
this.lexbuf,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -