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[]
axisNames
static CastableAs
castableAs
Namespace[]
functionNamespacePath
static QuoteExp
getExternalFunction
static InstanceOf
instanceOf
static QuoteExp
makeChildAxisStep
static QuoteExp
makeDescendantAxisStep
static Expression
makeText
static Convert
treatAs
static boolean
warnHidePreviousDeclaration
static boolean
warnOldVersion
-
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 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()
Start tentative parsing.boolean
match(String word)
void
maybeSetLine(Declaration decl, int line, int column)
void
maybeSetLine(Expression exp, int line, int column)
void
maybeSetLine(Expression exp, int startLine, int startColumn, int endLine, int endColumn)
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()
Stop tentative parsing.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, 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 IOException
Description copied from class:Lexer
Start tentative parsing. Must be followed by a reset.- Overrides:
mark
in classLexer
- Throws:
IOException
-
reset
public void reset() throws IOException
Description copied from class:Lexer
Stop tentative parsing. Return to position where we called mark.- Overrides:
reset
in 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:
IOException
SyntaxException
-
appendNamedEntity
public void appendNamedEntity(String name)
-
setInteractive
public void setInteractive(boolean v)
- Overrides:
setInteractive
in classLexer
-
parseNamedNodeType
public Expression parseNamedNodeType(boolean attribute) throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
parseOptionalTypeDeclaration
public Expression parseOptionalTypeDeclaration() throws IOException, SyntaxException
Parse: ["as" SequenceType]- Throws:
IOException
SyntaxException
-
parseDataType
public Expression parseDataType() throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
parseMaybeKindTest
public Expression parseMaybeKindTest() throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
parseItemType
public Expression parseItemType() throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
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:
IOException
SyntaxException
-
match
public boolean match(String word)
-
parseVariable
public Object parseVariable() throws IOException, SyntaxException
Parse a Variable.- Throws:
IOException
SyntaxException
-
parseVariableDeclaration
public Declaration parseVariableDeclaration() throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
parseFLWRExpression
public Expression parseFLWRExpression(boolean isFor) throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
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:
IOException
SyntaxException
-
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:
IOException
SyntaxException
-
parseFunctionDefinition
public Expression parseFunctionDefinition(int declLine, int declColumn) throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
readObject
public Object readObject() throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
parse
public Expression parse(Compilation comp) throws IOException, SyntaxException
Parse an expression. Return null on EOF.- Throws:
IOException
SyntaxException
-
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:
IOException
SyntaxException
-
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:
IOException
SyntaxException
-
syntaxError
public Expression syntaxError(String message) throws IOException, SyntaxException
- Throws:
IOException
SyntaxException
-
eofError
public void eofError(String msg) throws SyntaxException
- Overrides:
eofError
in 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)
-
-