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