de.fuberlin.wiwiss.wiqa.parser
Class CustomTokenManager

java.lang.Object
  extended byde.fuberlin.wiwiss.wiqa.parser.javacc.WIQAParserTokenManager
      extended byde.fuberlin.wiwiss.wiqa.parser.CustomTokenManager
All Implemented Interfaces:
WIQAParserConstants

public class CustomTokenManager
extends WIQAParserTokenManager

A custom JavaCC token manager that changes QNAME and URI tokens produced by the lexer into QNAME_EXTENSION and URI_EXTENSION tokens if the QName belongs to a registered extension, and into QNAME_COUNT and URI_COUNT if the QName is wiqa:count.

From the WIQA grammar, normal function calls, extension function calls, and count are indistinguishable. The distinction could be done a) when the QName is first seen, before the parser sees it, or b) after the parse tree has been built. I went for a) because modifying the token stream is easier then manipulating the parse tree later on.

This token manager needs access to the prefix mapping of the parser, and to the extension registry, to check if a QName belongs to a registered extension. The {#setParser} method is used to provide a reference to the parser.

Version:
$Id: CustomTokenManager.java,v 1.4 2006/06/26 21:58:16 cyganiak Exp $
Author:
Richard Cyganiak (richard@cyganiak.de)

Field Summary
 
Fields inherited from class de.fuberlin.wiwiss.wiqa.parser.javacc.WIQAParserTokenManager
curChar, debugStream, input_stream, jjstrLiteralImages, lexStateNames
 
Fields inherited from interface de.fuberlin.wiwiss.wiqa.parser.javacc.WIQAParserConstants
A2Z, A2ZN, AND, ANON, ANY, ASC, ASK, AT, BANG, BASE, BLANK_NODE_LABEL, BOUND, BY, COLON, COMMA, CONSTRUCT, DATATYPE, DEFAULT, DESC, DESCRIBE, DESCRIPTION, DIGITS, DISTINCT, DOT, DTYPE, ECHAR, EOF, EQ, EXPL, EXPLANATION, EXPONENT, FALSE, FILTER, FLOATING_POINT, FROM, GE, GRAPH, GT, HEX, INTEGER, IS_BLANK, IS_LITERAL, IS_URI, KW_A, LANG, LANGTAG, LBRACE, LBRACKET, LE, LIMIT, LPAREN, LT, MINUS, NAME, NAMED, NCCHAR, NCCHAR1, NCCHAR1p, NCNAME, NCNAME_PREFIX, NE, NIL, OFFSET, OPTIONAL, ORDER, PATTERN, PLUS, PREFIX, Q_IRIref, Q_IRIref_COUNT, Q_IRIref_EXTENSION, QNAME, QNAME_COUNT, QNAME_EXTENSION, QNAME_NS, QUOTE_3D, QUOTE_3S, RBRACE, RBRACKET, REGEX, RPAREN, SC_AND, SC_OR, SELECT, SEMICOLON, SINGLE_LINE_COMMENT, SLASH, STAR, STR, STRING_LITERAL_LONG1, STRING_LITERAL_LONG2, STRING_LITERAL1, STRING_LITERAL2, TILDE, tokenImage, TRUE, UNION, VAR1, VAR2, VARNAME, WHERE, WS
 
Constructor Summary
CustomTokenManager(InputStream in)
           
CustomTokenManager(Reader in)
           
 
Method Summary
 Token getNextToken()
           
static boolean isExtension(String candidateURI)
           
 void setParser(WIQAParser parser)
           
 
Methods inherited from class de.fuberlin.wiwiss.wiqa.parser.javacc.WIQAParserTokenManager
jjFillToken, ReInit, ReInit, setDebugStream, SwitchTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomTokenManager

public CustomTokenManager(InputStream in)

CustomTokenManager

public CustomTokenManager(Reader in)
Method Detail

setParser

public void setParser(WIQAParser parser)

getNextToken

public Token getNextToken()
Overrides:
getNextToken in class WIQAParserTokenManager

isExtension

public static boolean isExtension(String candidateURI)