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)


Constructor Index

 o Parser(Scanner)
Initializer

Method Index

 o addListener(XMLListener)
Register an XMLListener with the parser.
 o deletion(int)

Print error message for unexpected token.

 o handleAttribute(String, String)
This function is called by the parser when it has recognized an attribute name/value pair.
 o handleComment(String)
This function is called by the parser when it has recognized a comment.
 o handleData(String)
This function is called by the parser when it has recognized character data.
 o handleEndDoc(String)
This function is called by the parser when it has recognized the end of a document or subdocument.
 o handleEndTag(String)
This function is called by the parser when it has recognized an end tag or the end of an empty tag.
 o handlePI(String)
This function is called by the parser when it has recognized a processing instruction.
 o handleStartDoc(String, String)
This function is called by the parser when it has recognized a doctype declaration.
 o handleStartTag(String)
This function is called by the parser when it has recognized a start tag.
 o insertion(int)

Print error message for missing token.

 o parse()
 o protect(String)
Encode a string with certain characters replaced by numerical character entities.

Constructors

 o Parser
 public Parser(Scanner s)
Initializer

Methods

 o 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
 o 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 <!-- -->)
 o 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
 o 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
 o 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
 o 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
 o 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 <? ?>)
 o 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)
 o 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
 o 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
 o 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.

 o 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");
 

 o parse
 public final int parse() throws IOException

All Packages  Class Hierarchy  This Package  Previous  Next  Index