1 package net.sourceforge.phpdt.sql.sql;
3 import java.util.Vector;
5 import net.sourceforge.phpdt.sql.parser.SQLLexx;
6 import net.sourceforge.phpdt.sql.parser.Token;
8 public class SQLParser {
9 public static final String COMMENT = "--";
10 public static final String ENDLINE = ";";
11 public static Vector parse(String query) {
12 Vector commands = new Vector();
14 //System.out.println("-------------------1");
15 Vector tokens = SQLLexx.parse(query);
16 //System.out.println("-------------------2");
17 StringBuffer buffer = new StringBuffer();
18 for (int i = 0; i < tokens.size(); i++) {
19 //System.out.println("-------------------3");
20 Token t = (Token) tokens.elementAt(i);
21 if (t.getType() == t.COMMENT) {
23 } else if (t.getType() == t.SEPARATOR) {
24 String newCommand = buffer.toString().trim();
25 if (!newCommand.equals("")) {
26 commands.addElement(newCommand);
28 buffer = new StringBuffer();
30 buffer.append(t.getValue());
33 String newCommand = buffer.toString().trim();
34 if (!newCommand.equals("")) {
35 commands.addElement(newCommand);
37 } catch (Throwable e) {
40 System.out.println("Returning");