1 package uba.db.sql.parser;
2
3 import java.io.StringReader;
4
5 import uba.db.sql.language.Sentence;
6 import uba.db.sql.parser.impl.SQLLexer;
7
8 /***
9 * Parser de SQL.
10 *
11 * @version $Revision: 1.4 $
12 */
13 public class SQLParser {
14 /***
15 * Crea una representación en objetos de un comando SQL a partir de un
16 * String.
17 *
18 * @param sqlCommand
19 * el String a parsear.
20 * @return una implementación concreta de {@link Sentence} que representa el
21 * comando SQL.
22 * @throws SQLParserException
23 * ocurrio una excepción durante el parsing.
24 */
25 public Sentence parse(String sqlCommand) throws SQLParserException {
26 SQLLexer lexer = new SQLLexer(new StringReader(sqlCommand));
27 uba.db.sql.parser.impl.SQLParser parser = new uba.db.sql.parser.impl.SQLParser(
28 lexer);
29 try {
30 return parser.sqlSentence();
31 } catch (Throwable t) {
32 throw new SQLParserException(sqlCommand, t);
33 }
34 }
35 }