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
           
 Namespace[] functionNamespacePath
           
static InstanceOf instanceOf
           
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 error(char severity, java.lang.String message)
           
 void getDelimited(java.lang.String delimiter)
          Scan until a given delimiter.
static boolean isNamePart(char ch)
           
static boolean isNameStart(char ch)
           
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)
           
 Expression parse(Compilation comp)
          Parse an expression.
 Expression parseDataType()
           
 Type parseElementType()
           
 Expression parseFLWRExpression(boolean isFor)
           
 Expression parseFLWRInner(boolean isFor)
          Parse a let- or a for-expression.
 Expression parseFunctionDefinition(int declLine, int declColumn)
           
 Expression parseIfExpr()
           
 Type parseItemType()
           
 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)
           
 void setType(Declaration decl, Expression type)
           
static Expression stringValue(Expression exp)
          Coerce the value of an expresison to a string value.
 Expression syntaxError(java.lang.String message)
          Handle syntax errors (at rewrite time).
 
Methods inherited from class gnu.text.Lexer
checkErrors, checkNext, clearErrors, close, eofError, 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

instanceOf

public static final InstanceOf instanceOf

functionNamespacePath

public Namespace[] functionNamespacePath

axisNames

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

XQParser

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

isNameStart

public static boolean isNameStart(char ch)

isNamePart

public static boolean isNamePart(char ch)

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

parseElementType

public Type parseElementType()
                      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

setType

public void setType(Declaration decl,
                    Expression type)

parseDataType

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

parseItemType

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

stringValue

public static Expression stringValue(Expression exp)
Coerce the value of an expresison to a string value.


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 top parsing, and return a result as if we instead saw a 'return make-tuple($x, ...)'. The 'order by' clause will get parser by the outer-mot '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

parse

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

Throws:
java.io.IOException
SyntaxException

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)
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)
                       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