X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java index e901266..543b1ef 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java @@ -2,6 +2,21 @@ package com.quantum.sql.parser; import java.util.Vector; +/** + *
An SQL Lexer. From + * dictionary.com: + * + *
+ *+ * + *lexer + * + *
/lek'sr/ n. Common hacker shorthand for 'lexical + * analyzer', the input-tokenizing stage in the parser for a language + * (the part that breaks it into word-like pieces). + *
Note that this class has nothing to do with the Sci-fi channel's + * Lexx TV series. + */ public class SQLLexx { private static String endline = ";"; //$NON-NLS-1$ private static String dash = "-"; //$NON-NLS-1$ @@ -130,22 +145,12 @@ public class SQLLexx { p.mark(); // If we have '/*', it's a comment till '*/' found or eof if (p.peek() == '*') { - StringBuffer value = new StringBuffer(); - c = p.getNext(); - value.append('/'); - while (!( c == '*' && p.peek() == '/' ) && !p.isDone()) { - value.append(c); - c = p.getNext(); - } - if (!p.isDone()){ - value.append(c); - c = p.getNext(); - value.append(c); - } - tokens.addElement(new Token(Token.COMMENT, value.toString(), offset, offset + value.length())); + tokens.addElement(tokenizeComment(p, offset)); } else { // It's not '/*' , so it's a group token - tokens.addElement(new Token(Token.GROUP, group, offset, offset + 1)); + // BCH ??? what's this business about groups? + // Shouldn't '/' be a divide operator? + tokens.addElement(new Token(Token.SYMBOL, new String(new char[] {c}) /*group*/, offset, offset + 1)); p.reset(); } // Adds SYMBOL token; @@ -163,4 +168,25 @@ public class SQLLexx { // } return tokens; } + /** + * @param tokens + * @param p + * @param offset + */ + private static Token tokenizeComment(StringPointer p, int offset) { + char c; + StringBuffer value = new StringBuffer(); + c = p.getNext(); + value.append('/'); + while (!( c == '*' && p.peek() == '/' ) && !p.isDone()) { + value.append(c); + c = p.getNext(); + } + if (!p.isDone()){ + value.append(c); + c = p.getNext(); + value.append(c); + } + return new Token(Token.COMMENT, value.toString(), offset, offset + value.length()); + } }