Package ca.phon.xml

Class XMLLexer

java.lang.Object
ca.phon.xml.XMLLexer
All Implemented Interfaces:
org.antlr.runtime.TokenSource

public class XMLLexer extends Object implements org.antlr.runtime.TokenSource

ANTLR3 lexer for XML files using the StAX API (XMLEventReader) to pull tokens from the xml stream.

Tokens are emitted on the following xml events:

Token numbers can be assigned using a properties file. If no file is given or the generated token name is not found, the token ID is given ....

TODO Handle namespaces
  • Constructor Details

    • XMLLexer

      public XMLLexer(XMLEventReader reader)
      Constructor
      Parameters:
      reader -
  • Method Details

    • fromStream

      public static XMLLexer fromStream(InputStream source, String encoding) throws IOException
      Create a new lexer for the given stream.
      Parameters:
      source -
      Throws:
      IOException
    • fromStream

      public static XMLLexer fromStream(InputStream source, String encoding, Properties tokenMap) throws IOException
      Create a new lexer for the given stream. Also provide a token map, can be null.
      Parameters:
      tokenMap -
      stream -
      Throws:
      IOException
    • tokenName

      protected String tokenName(QName qname)
      Turn the given QName into a ANTLR token name.
      Parameters:
      qname -
      Returns:
      the generated token name
    • tokenID

      protected int tokenID(String tokenName)
      Get the token ID for the given token name.
      Parameters:
      tokenName -
      Returns:
      the token ID, if not found in the tokenMap it will be generated.
    • nextToken

      public org.antlr.runtime.Token nextToken()
      Specified by:
      nextToken in interface org.antlr.runtime.TokenSource
    • getSourceName

      public String getSourceName()
      Specified by:
      getSourceName in interface org.antlr.runtime.TokenSource