Package gnu.xquery.lang
Class XQParser
- java.lang.Object
-
- java.io.Reader
-
- gnu.text.Lexer
-
- gnu.xquery.lang.XQParser
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class XQParser extends Lexer
A class to read xquery forms.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]axisNamesstatic CastableAscastableAsNamespace[]functionNamespacePathstatic QuoteExpgetExternalFunctionstatic InstanceOfinstanceOfstatic QuoteExpmakeChildAxisStepstatic QuoteExpmakeDescendantAxisStepstatic ExpressionmakeTextstatic ConverttreatAsstatic booleanwarnHidePreviousDeclarationstatic booleanwarnOldVersion-
Fields inherited from class gnu.text.Lexer
nesting, port, tentative, tokenBuffer, tokenBufferLength
-
-
Constructor Summary
Constructors Constructor Description XQParser(gnu.kawa.io.InPort port, SourceMessages messages, XQuery interp)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendNamedEntity(java.lang.String name)static ExpressionbooleanValue(Expression exp)Coerce the value of an expresison to a boolean value.ExpressiondeclError(java.lang.String message)voideofError(java.lang.String msg)voiderror(char severity, java.lang.String message)voiderror(char severity, java.lang.String message, java.lang.String code)voidfatal(java.lang.String msg, java.lang.String code)voidgetDelimited(java.lang.String delimiter)Scan until a given delimiter.java.lang.StringgetStaticBaseUri()voidhandleOption(Symbol name, java.lang.String value)static ExpressionmakeFunctionExp(java.lang.String className, java.lang.String name)static ExpressionmakeFunctionExp(java.lang.String className, java.lang.String fieldName, java.lang.String name)voidmark()Start tentative parsing.booleanmatch(java.lang.String word)voidmaybeSetLine(Declaration decl, int line, int column)voidmaybeSetLine(Expression exp, int line, int column)voidmaybeSetLine(Expression exp, int startLine, int startColumn, int endLine, int endColumn)protected SymbolnamespaceResolve(java.lang.String name, boolean function)Expressionparse(Compilation comp)Parse an expression.ExpressionparseDataType()ExpressionparseFLWRExpression(boolean isFor)ExpressionparseFLWRInner(boolean isFor)Parse a let- or a for-expression.ExpressionparseFunctionDefinition(int declLine, int declColumn)ExpressionparseIfExpr()ExpressionparseItemType()ExpressionparseMaybeKindTest()ExpressionparseNamedNodeType(boolean attribute)ExpressionparseOptionalTypeDeclaration()Parse: ["as" SequenceType]ExpressionparseQuantifiedExpr(boolean isEvery)Parse a some- or an every-expression.java.lang.ObjectparseVariable()Parse a Variable.DeclarationparseVariableDeclaration()java.lang.ObjectreadObject()voidreset()Stop tentative parsing.java.lang.StringresolveAgainstBaseUri(java.lang.String uri)voidsetInteractive(boolean v)voidsetStaticBaseUri(java.lang.String uri)ExpressionsyntaxError(java.lang.String message)ExpressionsyntaxError(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, isTentative, peek, popNesting, pushNesting, read, read, readCodePoint, readDelimited, readDigits, readDigitsInBuffer, readIntDigits, readOptionalExponent, readUnicodeChar, seenErrors, setMessages, setTentative, skip, skip_quick, tokenBufferAppend, tokenBufferString, unread, unread, unread_quick
-
-
-
-
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
-
makeText
public static Expression makeText
-
getExternalFunction
public static final QuoteExp getExternalFunction
-
axisNames
public static final java.lang.String[] axisNames
-
-
Constructor Detail
-
XQParser
public XQParser(gnu.kawa.io.InPort port, SourceMessages messages, XQuery interp)
-
-
Method Detail
-
setStaticBaseUri
public void setStaticBaseUri(java.lang.String uri)
-
getStaticBaseUri
public java.lang.String getStaticBaseUri()
-
resolveAgainstBaseUri
public java.lang.String resolveAgainstBaseUri(java.lang.String uri)
-
mark
public void mark() throws java.io.IOExceptionDescription copied from class:LexerStart tentative parsing. Must be followed by a reset.
-
reset
public void reset() throws java.io.IOExceptionDescription copied from class:LexerStop tentative parsing. Return to position where we called mark.
-
getDelimited
public void getDelimited(java.lang.String delimiter) throws java.io.IOException, SyntaxExceptionScan 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.IOExceptionSyntaxException
-
appendNamedEntity
public void appendNamedEntity(java.lang.String name)
-
setInteractive
public void setInteractive(boolean v)
- Overrides:
setInteractivein classLexer
-
parseNamedNodeType
public Expression parseNamedNodeType(boolean attribute) throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
parseOptionalTypeDeclaration
public Expression parseOptionalTypeDeclaration() throws java.io.IOException, SyntaxException
Parse: ["as" SequenceType]- Throws:
java.io.IOExceptionSyntaxException
-
parseDataType
public Expression parseDataType() throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
parseMaybeKindTest
public Expression parseMaybeKindTest() throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
parseItemType
public Expression parseItemType() throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
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.IOExceptionSyntaxException
-
match
public boolean match(java.lang.String word)
-
parseVariable
public java.lang.Object parseVariable() throws java.io.IOException, SyntaxExceptionParse a Variable.- Throws:
java.io.IOExceptionSyntaxException
-
parseVariableDeclaration
public Declaration parseVariableDeclaration() throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
parseFLWRExpression
public Expression parseFLWRExpression(boolean isFor) throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
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.IOExceptionSyntaxException
-
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.IOExceptionSyntaxException
-
parseFunctionDefinition
public Expression parseFunctionDefinition(int declLine, int declColumn) throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
readObject
public java.lang.Object readObject() throws java.io.IOException, SyntaxException- Throws:
java.io.IOExceptionSyntaxException
-
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.IOExceptionSyntaxException
-
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)
-
declError
public Expression declError(java.lang.String message) throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
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.IOExceptionSyntaxException
-
syntaxError
public Expression syntaxError(java.lang.String message) throws java.io.IOException, SyntaxException
- Throws:
java.io.IOExceptionSyntaxException
-
eofError
public void eofError(java.lang.String msg) throws SyntaxException- Overrides:
eofErrorin classLexer- 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(Expression exp, int startLine, int startColumn, int endLine, int endColumn)
-
maybeSetLine
public void maybeSetLine(Declaration decl, int line, int column)
-
-