1 package net.sourceforge.phpdt.sql.sql;
3 import java.util.Vector;
5 import net.sourceforge.phpdt.sql.sql.parser.SQLLexx;
6 import net.sourceforge.phpdt.sql.sql.parser.Token;
8 public class SQLParser {
9 public static final String COMMENT = "--"; //$NON-NLS-1$
10 public static final String ENDLINE = ";"; //$NON-NLS-1$
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() == Token.COMMENT) {
23 } else if (t.getType() == Token.SEPARATOR) {
24 String newCommand = buffer.toString().trim();
25 if (!newCommand.equals("")) { //$NON-NLS-1$
26 commands.addElement(newCommand);
28 buffer = new StringBuffer();
30 buffer.append(t.getValue());
33 String newCommand = buffer.toString().trim();
34 if (!newCommand.equals("")) { //$NON-NLS-1$
35 commands.addElement(newCommand);
37 } catch (Throwable e) {
40 System.out.println("Returning"); //$NON-NLS-1$