All Packages Class Hierarchy This Package Previous Next Index
Class w3c.xmlOnline.parser.Parser
java.lang.Object
|
+----w3c.xmlOnline.parser.Parser
- public class Parser
- extends Object
- implements ParserDef
(Generated by ll1genj)
-
Parser(Scanner)
- Initializer
-
addListener(XMLListener)
- Register an XMLListener with the parser.
-
deletion(int)
-
Print error message for unexpected token.
-
handleAttribute(String, String)
- This function is called by the parser when it has
recognized an attribute name/value pair.
-
handleComment(String)
- This function is called by the parser when it has recognized a
comment.
-
handleData(String)
- This function is called by the parser when it has
recognized character data.
-
handleEndDoc(String)
- This function is called by the parser when it has
recognized the end of a document or subdocument.
-
handleEndTag(String)
- This function is called by the parser when it has
recognized an end tag or the end of an empty tag.
-
handlePI(String)
- This function is called by the parser when it has recognized a
processing instruction.
-
handleStartDoc(String, String)
- This function is called by the parser when it has
recognized a doctype declaration.
-
handleStartTag(String)
- This function is called by the parser when it has
recognized a start tag.
-
insertion(int)
-
Print error message for missing token.
-
parse()
-
-
protect(String)
- Encode a string with certain characters replaced by
numerical character entities.
Parser
public Parser(Scanner s)
- Initializer
addListener
public Parser addListener(XMLListener listener)
- Register an XMLListener with the parser. An XMLListener is
an object that will be called whenever an XML-event occurs:
the parser finds a start tag, an end tag, an attribute,
a PI, etc. There may be any number of listeners registered.
See Parser.ll1 for the grammar
accepted by this parser.
- Parameters:
- listener - the listener to register
- Returns:
- this
handleComment
protected void handleComment(String comment)
- This function is called by the parser when it has recognized a
comment. It calls each of the listeners in turn. Note that
comments are not part of the data model, but they are passed on
anyway, for the benefit of XML editors and similar programs.
- Parameters:
- comment - the comment string (without <!-- -->)
handleStartTag
protected void handleStartTag(String tag)
- This function is called by the parser when it has
recognized a start tag. This is the beginning of
a lexical scope: if any <?xml default... ?>
declarations are found, they only apply to elements
in this scope.
- Parameters:
- tag - the tag name in lowercase
handleAttribute
protected void handleAttribute(String attribute,
String value)
- This function is called by the parser when it has
recognized an attribute name/value pair. The attribute
belongs to the tag that was handled by the most recent
call to handleStartTag().
Note that there is no indication of whether this
attribute was actually on the tag, or whether it
is the declared default value for the attribute on
this tag (<?XML DEFAULT...?>)
- Parameters:
- attribute - the name of the attribute in lowercase
- value - the value of the attribute
handleEndTag
protected void handleEndTag(String tag)
- This function is called by the parser when it has
recognized an end tag or the end of an empty tag.
This is also the end of a lexical scope.
- Parameters:
- tag - the name of the tag in lowercase
handleData
protected void handleData(String data)
- This function is called by the parser when it has
recognized character data. The function may be called
several times without intervening calls to handleStartTag()
or handleEndTag(). The content of an element is thus the
concatenation of all consecutive calls to handleData().
- Parameters:
- data - the character data
handlePI
protected void handlePI(String pi)
- This function is called by the parser when it has recognized a
processing instruction. Note that PIs are not part of the data
model, but they are passed on anyway, for the benefit of XML
editors and similar programs.
- Parameters:
- pi - the processing instruction (without <? ?>)
handleStartDoc
protected void handleStartDoc(String root,
String doctype)
- This function is called by the parser when it has
recognized a doctype declaration. Documents can be nested
and there may thus be a doctype in the middle of a
document. A document constitutes a scope for the
default attributes, just like an element.
- Parameters:
- root - the name of the start tag
- doctype - the URL defining the document type (may be null)
handleEndDoc
protected void handleEndDoc(String root)
- This function is called by the parser when it has
recognized the end of a document or subdocument.
- Parameters:
- root - the name of the start tag
protect
protected String protect(String s)
- Encode a string with certain characters replaced by
numerical character entities.
- Parameters:
- s - string to encode
- Returns:
- the encoded string
insertion
protected void insertion(int sym)
-
Print error message for missing token. Subclasses often override
this method. If they don't, the default does this:
System.err.println(this.in.getLineno() + ":" + this.in.getColno() +
": " + symbolName[sym] + " expected");
symbolName can be found in the generated interface xxxDef.
deletion
protected void deletion(int sym)
-
Print error message for unexpected token. Subclasses often override
this method. If they don't, the default does this:
System.err.println(this.in.getLineno() + ":" + this.in.getColno() +
": " + symbolName[sym] + " unexpected");
parse
public final int parse() throws IOException
All Packages Class Hierarchy This Package Previous Next Index