net.sf.farrago.parser
Class FarragoAbstractParser

java.lang.Object
  extended by net.sf.farrago.parser.FarragoAbstractParser
All Implemented Interfaces:
FarragoSessionParser
Direct Known Subclasses:
FarragoParser, FarragoRngParser

public abstract class FarragoAbstractParser
extends Object
implements FarragoSessionParser

FarragoAbstractParser is an abstract base for implementations of the FarragoSessionParser interface.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/parser/FarragoAbstractParser.java#18 $
Author:
John V. Sichi

Field Summary
protected  FarragoSessionDdlValidator ddlValidator
           
protected  FarragoAbstractParserImpl parserImpl
           
private  boolean parsingComplete
           
protected  String sourceString
           
protected  FarragoSessionStmtValidator stmtValidator
           
 
Constructor Summary
FarragoAbstractParser()
           
 
Method Summary
 SqlParserPos getCurrentPosition()
           
 FarragoSessionDdlValidator getDdlValidator()
           
 String getJdbcKeywords()
           
 String getSourceString()
           
 FarragoSessionStmtValidator getStmtValidator()
           
 String getSubstring(SqlParserPos start, SqlParserPos end)
          Gets a substring from the text currently being parsed.
protected abstract  FarragoAbstractParserImpl newParserImpl(Reader reader)
          Factory method to instantiate a dialect-specific generated parser.
 EigenbaseException newPositionalError(SqlValidatorException ex)
          Wraps a validation error with the current position information of the parser.
 Object parseSqlText(FarragoSessionStmtValidator stmtValidator, FarragoSessionDdlValidator ddlValidator, String sql, boolean expectStatement)
          Parses an SQL expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stmtValidator

protected FarragoSessionStmtValidator stmtValidator

ddlValidator

protected FarragoSessionDdlValidator ddlValidator

parserImpl

protected FarragoAbstractParserImpl parserImpl

sourceString

protected String sourceString

parsingComplete

private boolean parsingComplete
Constructor Detail

FarragoAbstractParser

public FarragoAbstractParser()
Method Detail

getCurrentPosition

public SqlParserPos getCurrentPosition()
Specified by:
getCurrentPosition in interface FarragoSessionParser
Returns:
the current position, or null if done parsing

newPositionalError

public EigenbaseException newPositionalError(SqlValidatorException ex)
Description copied from interface: FarragoSessionParser
Wraps a validation error with the current position information of the parser.

Specified by:
newPositionalError in interface FarragoSessionParser
Parameters:
ex - exception to be wrapped
Returns:
wrapping exception

getDdlValidator

public FarragoSessionDdlValidator getDdlValidator()
Specified by:
getDdlValidator in interface FarragoSessionParser
Returns:
validator to use for validating DDL statements as they are parsed

getStmtValidator

public FarragoSessionStmtValidator getStmtValidator()
Specified by:
getStmtValidator in interface FarragoSessionParser
Returns:
validator to use for validating statements as they are parsed

getSourceString

public String getSourceString()
Specified by:
getSourceString in interface FarragoSessionParser
Returns:
Last string processed by the parser.

newParserImpl

protected abstract FarragoAbstractParserImpl newParserImpl(Reader reader)
Factory method to instantiate a dialect-specific generated parser.

Parameters:
reader - Reader that provides the input to the parser
Returns:
Dialect-specific generated parser

getJdbcKeywords

public String getJdbcKeywords()
Specified by:
getJdbcKeywords in interface FarragoSessionParser
Returns:
a comma-separated list of all a database's SQL keywords that are NOT also SQL92 keywords (as defined by JDBC getSQLKeywords)

parseSqlText

public Object parseSqlText(FarragoSessionStmtValidator stmtValidator,
                           FarragoSessionDdlValidator ddlValidator,
                           String sql,
                           boolean expectStatement)
Description copied from interface: FarragoSessionParser
Parses an SQL expression. If a DDL statement, implicitly performs uncommitted catalog updates.

Specified by:
parseSqlText in interface FarragoSessionParser
Parameters:
stmtValidator - the statement validator to use
ddlValidator - the validator to use for lookup during parsing if this turns out to be a DDL statement; may be null if DDL is not allowed
sql - the SQL text to be parsed
expectStatement - if true, expect a statement; if false, expect a row-expression
Returns:
for DDL, a FarragoSessionDdlStmt; for DML or query, top-level SqlNode

getSubstring

public String getSubstring(SqlParserPos start,
                           SqlParserPos end)
Description copied from interface: FarragoSessionParser
Gets a substring from the text currently being parsed.

Specified by:
getSubstring in interface FarragoSessionParser
Parameters:
start - start position (inclusive) of substring
end - end position (exclusive) of substring
Returns:
substring