Package gnu.xquery.lang
Class XQParser
- java.lang.Object
-
- java.io.Reader
-
- gnu.text.Lexer
-
- gnu.xquery.lang.XQParser
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
public class XQParser extends Lexer
A class to read xquery forms.
-
-
Field Summary
Fields Modifier and Type Field Description static 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(String name)static ExpressionbooleanValue(Expression exp)Coerce the value of an expresison to a boolean value.ExpressiondeclError(String message)voideofError(String msg)voiderror(char severity, String message)voiderror(char severity, String message, String code)voidfatal(String msg, String code)voidgetDelimited(String delimiter)Scan until a given delimiter.StringgetStaticBaseUri()voidhandleOption(Symbol name, String value)static ExpressionmakeFunctionExp(String className, String name)static ExpressionmakeFunctionExp(String className, String fieldName, String name)voidmark()Start tentative parsing.booleanmatch(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(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.ObjectparseVariable()Parse a Variable.DeclarationparseVariableDeclaration()ObjectreadObject()voidreset()Stop tentative parsing.StringresolveAgainstBaseUri(String uri)voidsetInteractive(boolean v)voidsetStaticBaseUri(String uri)ExpressionsyntaxError(String message)ExpressionsyntaxError(String message, 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
-
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, skip, transferTo
-
-
-
-
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 String[] axisNames
-
-
Constructor Detail
-
XQParser
public XQParser(gnu.kawa.io.InPort port, SourceMessages messages, XQuery interp)
-
-
Method Detail
-
setStaticBaseUri
public void setStaticBaseUri(String uri)
-
getStaticBaseUri
public String getStaticBaseUri()
-
mark
public void mark() throws IOExceptionDescription copied from class:LexerStart tentative parsing. Must be followed by a reset.- Overrides:
markin classLexer- Throws:
IOException
-
reset
public void reset() throws IOExceptionDescription copied from class:LexerStop tentative parsing. Return to position where we called mark.- Overrides:
resetin classLexer- Throws:
IOException
-
getDelimited
public void getDelimited(String delimiter) throws 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:
IOExceptionSyntaxException
-
appendNamedEntity
public void appendNamedEntity(String name)
-
setInteractive
public void setInteractive(boolean v)
- Overrides:
setInteractivein classLexer
-
parseNamedNodeType
public Expression parseNamedNodeType(boolean attribute) throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
parseOptionalTypeDeclaration
public Expression parseOptionalTypeDeclaration() throws IOException, SyntaxException
Parse: ["as" SequenceType]- Throws:
IOExceptionSyntaxException
-
parseDataType
public Expression parseDataType() throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
parseMaybeKindTest
public Expression parseMaybeKindTest() throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
parseItemType
public Expression parseItemType() throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
booleanValue
public static Expression booleanValue(Expression exp)
Coerce the value of an expresison to a boolean value.
-
parseIfExpr
public Expression parseIfExpr() throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
match
public boolean match(String word)
-
parseVariable
public Object parseVariable() throws IOException, SyntaxException
Parse a Variable.- Throws:
IOExceptionSyntaxException
-
parseVariableDeclaration
public Declaration parseVariableDeclaration() throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
parseFLWRExpression
public Expression parseFLWRExpression(boolean isFor) throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
parseFLWRInner
public Expression parseFLWRInner(boolean isFor) throws 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:
IOExceptionSyntaxException
-
parseQuantifiedExpr
public Expression parseQuantifiedExpr(boolean isEvery) throws IOException, SyntaxException
Parse a some- or an every-expression. Assume the 'some'/'every'-token has been seen, and we've read '$'.- Throws:
IOExceptionSyntaxException
-
parseFunctionDefinition
public Expression parseFunctionDefinition(int declLine, int declColumn) throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
readObject
public Object readObject() throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
parse
public Expression parse(Compilation comp) throws IOException, SyntaxException
Parse an expression. Return null on EOF.- Throws:
IOExceptionSyntaxException
-
makeFunctionExp
public static Expression makeFunctionExp(String className, String name)
-
makeFunctionExp
public static Expression makeFunctionExp(String className, String fieldName, String name)
-
declError
public Expression declError(String message) throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
syntaxError
public Expression syntaxError(String message, String code) throws IOException, SyntaxException
Handle syntax errors (at rewrite time).- Parameters:
message- an error message to print out- Returns:
- an ErrorExp
- Throws:
IOExceptionSyntaxException
-
syntaxError
public Expression syntaxError(String message) throws IOException, SyntaxException
- Throws:
IOExceptionSyntaxException
-
eofError
public void eofError(String msg) throws SyntaxException
- Overrides:
eofErrorin classLexer- Throws:
SyntaxException
-
fatal
public void fatal(String msg, 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)
-
-