gnu.xquery.lang
Class XQParser

java.lang.Object
  extended by java.io.Reader
      extended by gnu.text.Lexer
          extended by gnu.xquery.lang.XQParser
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class XQParser
extends Lexer

A class to read xquery forms.


Field Summary
static java.lang.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
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
XQParser(InPort port, SourceMessages messages, XQuery interp)
           
 
Method Summary
 void appendNamedEntity(java.lang.String name)
           
static Expression booleanValue(Expression exp)
          Coerce the value of an expresison to a boolean value.
 Expression declError(java.lang.String message)
           
 void eofError(java.lang.String msg)
           
 void error(char severity, java.lang.String message)
           
 void error(char severity, java.lang.String message, java.lang.String code)
           
 void fatal(java.lang.String msg, java.lang.String code)
           
 void getDelimited(java.lang.String delimiter)
          Scan until a given delimiter.
 java.lang.String getStaticBaseUri()
           
 void handleOption(Symbol name, java.lang.String value)
           
static Expression makeFunctionExp(java.lang.String className, java.lang.String name)
           
static Expression makeFunctionExp(java.lang.String className, java.lang.String fieldName, java.lang.String name)
           
 void mark()
          Start tentative parsing.
 boolean match(java.lang.String word)
           
 void maybeSetLine(Declaration decl, int line, int column)
           
 void maybeSetLine(Expression exp, int line, int column)
           
protected  Symbol namespaceResolve(java.lang.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.
 java.lang.Object parseVariable()
          Parse a Variable.
 Declaration parseVariableDeclaration()
           
 java.lang.Object readObject()
           
 void reset()
          Stop tentative parsing.
 void setInteractive(boolean v)
           
 Expression syntaxError(java.lang.String message)
           
 Expression syntaxError(java.lang.String message, java.lang.String code)
          Handle syntax errors (at rewrite time).
 
Methods inherited from class gnu.text.Lexer
checkErrors, checkNext, clearErrors, close, eofError, error, error, fatal, getColumnNumber, getErrors, getLineNumber, getMessages, getName, getPort, isInteractive, peek, popNesting, pushNesting, read, read, readDigitsInBuffer, readOptionalExponent, seenErrors, setMessages, skip_quick, skip, tokenBufferAppend, unread_quick, unread, unread
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

warnOldVersion

public static boolean warnOldVersion

warnHidePreviousDeclaration

public static boolean warnHidePreviousDeclaration

instanceOf

public static final InstanceOf instanceOf

castableAs

public static final CastableAs castableAs

treatAs

public static final Convert treatAs

functionNamespacePath

public Namespace[] functionNamespacePath

makeChildAxisStep

public static QuoteExp makeChildAxisStep

makeDescendantAxisStep

public static QuoteExp makeDescendantAxisStep

getExternalFunction

public static final QuoteExp getExternalFunction

axisNames

public static final java.lang.String[] axisNames
Constructor Detail

XQParser

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

getStaticBaseUri

public java.lang.String getStaticBaseUri()

mark

public void mark()
          throws java.io.IOException
Description copied from class: Lexer
Start tentative parsing. Must be followed by a reset.

Overrides:
mark in class Lexer
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Description copied from class: Lexer
Stop tentative parsing. Return to position where we called mark.

Overrides:
reset in class Lexer
Throws:
java.io.IOException

getDelimited

public void getDelimited(java.lang.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.

Throws:
java.io.IOException
SyntaxException

appendNamedEntity

public void appendNamedEntity(java.lang.String name)

setInteractive

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

parseNamedNodeType

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

parseOptionalTypeDeclaration

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

Throws:
java.io.IOException
SyntaxException

parseDataType

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

parseMaybeKindTest

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

parseItemType

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

booleanValue

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


parseIfExpr

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

match

public boolean match(java.lang.String word)

parseVariable

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

Throws:
java.io.IOException
SyntaxException

parseVariableDeclaration

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

parseFLWRExpression

public Expression parseFLWRExpression(boolean isFor)
                               throws java.io.IOException,
                                      SyntaxException
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'.

Throws:
java.io.IOException
SyntaxException

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 '$'.

Throws:
java.io.IOException
SyntaxException

parseFunctionDefinition

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

readObject

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

namespaceResolve

protected Symbol namespaceResolve(java.lang.String name,
                                  boolean function)

parse

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

Throws:
java.io.IOException
SyntaxException

handleOption

public void handleOption(Symbol name,
                         java.lang.String value)

makeFunctionExp

public static Expression makeFunctionExp(java.lang.String className,
                                         java.lang.String name)

makeFunctionExp

public static Expression makeFunctionExp(java.lang.String className,
                                         java.lang.String fieldName,
                                         java.lang.String name)

error

public void error(char severity,
                  java.lang.String message,
                  java.lang.String code)

error

public void error(char severity,
                  java.lang.String message)
Overrides:
error in class Lexer

declError

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

syntaxError

public Expression syntaxError(java.lang.String message,
                              java.lang.String code)
                       throws java.io.IOException,
                              SyntaxException
Handle syntax errors (at rewrite time).

Parameters:
message - an error message to print out
Returns:
an ErrorExp
Throws:
java.io.IOException
SyntaxException

syntaxError

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

eofError

public void eofError(java.lang.String msg)
              throws SyntaxException
Overrides:
eofError in class Lexer
Throws:
SyntaxException

fatal

public void fatal(java.lang.String msg,
                  java.lang.String code)
           throws SyntaxException
Throws:
SyntaxException

maybeSetLine

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

maybeSetLine

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