gnu.xquery.lang

Class XQParser


public class XQParser
extends Lexer

A class to read xquery forms.

Field Summary

static String[]
axisNames
static CastableAs
castableAs
Namespace[]
functionNamespacePath
static QuoteExp
getExternalFunction
static InstanceOf
instanceOf
static QuoteExp
makeChildAxisStep
static QuoteExp
makeDescendantAxisStep
static Convert
treatAs
static boolean
warnHidePreviousDeclaration
static boolean
warnOldVersion

Fields inherited from class gnu.text.Lexer

interactive, nesting, port, tokenBuffer, tokenBufferLength

Constructor Summary

XQParser(InPort port, SourceMessages messages, XQuery interp)

Method Summary

void
appendNamedEntity(String name)
static Expression
booleanValue(Expression exp)
Coerce the value of an expresison to a boolean value.
Expression
declError(String message)
void
eofError(String msg)
void
error(char severity, String message)
void
error(char severity, String message, String code)
void
fatal(String msg, String code)
void
getDelimited(String delimiter)
Scan until a given delimiter.
String
getStaticBaseUri()
void
handleOption(Symbol name, String value)
static Expression
makeFunctionExp(String className, String name)
static Expression
makeFunctionExp(String className, String fieldName, String name)
void
mark()
boolean
match(String word)
void
maybeSetLine(Declaration decl, int line, int column)
void
maybeSetLine(Expression exp, int line, int column)
protected Symbol
namespaceResolve(String name, boolean function)
Expression
parse(Compilation comp)
Parse an expression.
Expression
parseDataType()
Expression
parseFLWRExpression(boolean isFor)
Expression
parseFLWRInner(boolean isFor)
Parse a let- or a for-expression.
Expression
parseFunctionDefinition(int declLine, int declColumn)
Expression
parseIfExpr()
Expression
parseItemType()
Expression
parseMaybeKindTest()
Expression
parseNamedNodeType(boolean attribute)
Expression
parseOptionalTypeDeclaration()
Parse: ["as" SequenceType]
Expression
parseQuantifiedExpr(boolean isEvery)
Parse a some- or an every-expression.
Object
parseVariable()
Parse a Variable.
Declaration
parseVariableDeclaration()
Object
readObject()
void
reset()
String
resolveAgainstBaseUri(String uri)
void
setInteractive(boolean v)
void
setStaticBaseUri(String uri)
Expression
syntaxError(String message)
Expression
syntaxError(String message, String code)
Handle syntax errors (at rewrite time).

Methods inherited from class gnu.text.Lexer

checkErrors, checkNext, clearErrors, close, eofError, eofError, error, error, error, fatal, getColumnNumber, getErrors, getLineNumber, getMessages, getName, getPort, isInteractive, mark, peek, popNesting, pushNesting, read, read, readDigitsInBuffer, readOptionalExponent, reset, seenErrors, setInteractive, setMessages, skip, skip_quick, tokenBufferAppend, unread, unread, unread_quick

Field Details

axisNames

public static final String[] axisNames

castableAs

public static final CastableAs castableAs

functionNamespacePath

public Namespace[] functionNamespacePath

getExternalFunction

public static final QuoteExp getExternalFunction

instanceOf

public static final InstanceOf instanceOf

makeChildAxisStep

public static QuoteExp makeChildAxisStep

makeDescendantAxisStep

public static QuoteExp makeDescendantAxisStep

treatAs

public static final Convert treatAs

warnHidePreviousDeclaration

public static boolean warnHidePreviousDeclaration

warnOldVersion

public static boolean warnOldVersion

Constructor Details

XQParser

public XQParser(InPort port,
                SourceMessages messages,
                XQuery interp)

Method Details

appendNamedEntity

public void appendNamedEntity(String name)

booleanValue

public static Expression booleanValue(Expression exp)
Coerce the value of an expresison to a boolean value.

declError

public Expression declError(String message)
            throws java.io.IOException,
                   SyntaxException

eofError

public void eofError(String msg)
            throws SyntaxException
Overrides:
eofError in interface Lexer

error

public void error(char severity,
                  String message)
Overrides:
error in interface Lexer

error

public void error(char severity,
                  String message,
                  String code)

fatal

public void fatal(String msg,
                  String code)
            throws SyntaxException

getDelimited

public void getDelimited(String delimiter)
            throws java.io.IOException,
                   SyntaxException
Scan until a given delimiter. On success, text upto the delimiter is in then tokenBuffer (with tokenBufferLength marking its length); the delimiter is not included.

getStaticBaseUri

public String getStaticBaseUri()

handleOption

public void handleOption(Symbol name,
                         String value)

makeFunctionExp

public static Expression makeFunctionExp(String className,
                                         String name)

makeFunctionExp

public static Expression makeFunctionExp(String className,
                                         String fieldName,
                                         String name)

mark

public void mark()
            throws java.io.IOException
Overrides:
mark in interface Lexer

match

public boolean match(String word)

maybeSetLine

public void maybeSetLine(Declaration decl,
                         int line,
                         int column)

maybeSetLine

public void maybeSetLine(Expression exp,
                         int line,
                         int column)

namespaceResolve

protected Symbol namespaceResolve(String name,
                                  boolean function)

parse

public Expression parse(Compilation comp)
            throws java.io.IOException,
                   SyntaxException
Parse an expression. Return null on EOF.

parseDataType

public Expression parseDataType()
            throws java.io.IOException,
                   SyntaxException

parseFLWRExpression

public Expression parseFLWRExpression(boolean isFor)
            throws java.io.IOException,
                   SyntaxException

parseFLWRInner

public Expression parseFLWRInner(boolean isFor)
            throws java.io.IOException,
                   SyntaxException
Parse a let- or a for-expression. Assume the 'let'/'for'-token has been seen, and we've read '$'. If we see the 'order' keyword of an 'order by' clause then we stop parsing, and return a result as if we instead saw a 'return make-tuple($x, ...)'. The 'order by' clause will get parsed by the outer-most 'for' or 'let'.

parseFunctionDefinition

public Expression parseFunctionDefinition(int declLine,
                                          int declColumn)
            throws java.io.IOException,
                   SyntaxException

parseIfExpr

public Expression parseIfExpr()
            throws java.io.IOException,
                   SyntaxException

parseItemType

public Expression parseItemType()
            throws java.io.IOException,
                   SyntaxException

parseMaybeKindTest

public Expression parseMaybeKindTest()
            throws java.io.IOException,
                   SyntaxException

parseNamedNodeType

public Expression parseNamedNodeType(boolean attribute)
            throws java.io.IOException,
                   SyntaxException

parseOptionalTypeDeclaration

public Expression parseOptionalTypeDeclaration()
            throws java.io.IOException,
                   SyntaxException
Parse: ["as" SequenceType]

parseQuantifiedExpr

public Expression parseQuantifiedExpr(boolean isEvery)
            throws java.io.IOException,
                   SyntaxException
Parse a some- or an every-expression. Assume the 'some'/'every'-token has been seen, and we've read '$'.

parseVariable

public Object parseVariable()
            throws java.io.IOException,
                   SyntaxException
Parse a Variable.

parseVariableDeclaration

public Declaration parseVariableDeclaration()
            throws java.io.IOException,
                   SyntaxException

readObject

public Object readObject()
            throws java.io.IOException,
                   SyntaxException

reset

public void reset()
            throws java.io.IOException
Overrides:
reset in interface Lexer

resolveAgainstBaseUri

public String resolveAgainstBaseUri(String uri)

setInteractive

public void setInteractive(boolean v)
Overrides:
setInteractive in interface Lexer

setStaticBaseUri

public void setStaticBaseUri(String uri)

syntaxError

public Expression syntaxError(String message)
            throws java.io.IOException,
                   SyntaxException

syntaxError

public Expression syntaxError(String message,
                              String code)
            throws java.io.IOException,
                   SyntaxException
Handle syntax errors (at rewrite time).
Parameters:
message - an error message to print out
Returns:
an ErrorExp