org.basex.query
Class QueryParser

java.lang.Object
  extended by org.basex.util.InputParser
      extended by org.basex.query.QueryParser
Direct Known Subclasses:
QuerySuggest

public class QueryParser
extends InputParser

Parser for XQuery expressions.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 java.util.ArrayList<StaticFunc> funcs
          Parsed functions.
 TokenSet modules
          Modules loaded by the current file.
 TokenMap namespaces
          Namespaces.
 java.util.ArrayList<StaticVar> vars
          Parsed variables.
 
Fields inherited from class org.basex.util.InputParser
file, input, length, mark, pos
 
Constructor Summary
QueryParser(java.lang.String in, java.lang.String path, QueryContext c)
          Constructor.
 
Method Summary
protected  void checkAxis(Axis axis)
          Performs an optional axis check.
protected  void checkInit()
          Performs an optional check init.
protected  void checkPred(boolean open)
          Checks a predicate.
protected  void checkTest(Test test, boolean attr)
          Performs an optional test check.
 QueryException error(Err err, java.lang.Object... arg)
          Throws the specified error.
 void module(byte[] path, byte[] uri)
          Parses the specified module.
 LibraryModule parseLibrary(boolean check)
          Parses a library module.
 MainModule parseMain()
          Parses a main module.
 
Methods inherited from class org.basex.util.InputParser
consume, consume, consume, curr, curr, file, found, info, mark, more, next, quote, rest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modules

public final TokenSet modules
Modules loaded by the current file.


vars

public final java.util.ArrayList<StaticVar> vars
Parsed variables.


funcs

public final java.util.ArrayList<StaticFunc> funcs
Parsed functions.


namespaces

public final TokenMap namespaces
Namespaces.

Constructor Detail

QueryParser

public QueryParser(java.lang.String in,
                   java.lang.String path,
                   QueryContext c)
            throws QueryException
Constructor.

Parameters:
in - input
path - file path (if null, Prop.QUERYPATH will be assigned)
c - query context
Throws:
QueryException - query exception
Method Detail

parseMain

public final MainModule parseMain()
                           throws QueryException
Parses a main module. Parses the "MainModule" rule. Parses the "Setter" rule. Parses the "QueryBody (= Expr)" rule.

Returns:
resulting root expression
Throws:
QueryException - query exception

parseLibrary

public final LibraryModule parseLibrary(boolean check)
                                 throws QueryException
Parses a library module. Parses the "ModuleDecl" rule.

Parameters:
check - if functions and variables should be checked
Returns:
name of the module
Throws:
QueryException - query exception

module

public void module(byte[] path,
                   byte[] uri)
            throws QueryException
Parses the specified module.

Parameters:
path - file path
uri - module uri
Throws:
QueryException - query exception

checkInit

protected void checkInit()
Performs an optional check init.


checkAxis

protected void checkAxis(Axis axis)
Performs an optional axis check.

Parameters:
axis - axis

checkTest

protected void checkTest(Test test,
                         boolean attr)
Performs an optional test check.

Parameters:
test - node test
attr - attribute flag

checkPred

protected void checkPred(boolean open)
Checks a predicate.

Parameters:
open - open flag

error

public QueryException error(Err err,
                            java.lang.Object... arg)
                     throws QueryException
Throws the specified error.

Parameters:
err - error to be thrown
arg - error arguments
Returns:
never
Throws:
QueryException - query exception