Note: You can customize the lexical error message by modifying this method. + * + * @param eofSeen : indicates if EOF caused the lexical error + * @param lexState : lexical state in which this error occurred + * @param errorLine : line number when the error occurred + * @param errorColumn : column number when the error occurred + * @param errorAfter : prefix that was seen before this error occurred + * @param curChar : the offending character + * @return error message */ protected static String LexicalErr(boolean eofSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) { @@ -115,6 +120,8 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class ${LEGACY_EXCEPTION_HANDLING?Tok *
"Internal Error : Please file a bug report .... " * *
from this method for such cases in the release version of your parser. + * + * @return the error message */ @Override public String getMessage() { @@ -129,13 +136,27 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class ${LEGACY_EXCEPTION_HANDLING?Tok public ${LEGACY_EXCEPTION_HANDLING?TokenMgrError:TokenMgrException}() { } - /** Constructor with message and reason. */ + /** + * Constructor with message and reason. + * + * @param message error message + * @param reason error code + */ public ${LEGACY_EXCEPTION_HANDLING?TokenMgrError:TokenMgrException}(String message, int reason) { super(message); errorCode = reason; } - /** Full Constructor. */ + /** Full Constructor. + * + * @param eofSeen indicates if EOF caused the lexical error + * @param lexState lexical state in which this error occurred + * @param errorLine line number when the error occurred + * @param errorColumn column number when the error occurred + * @param errorAfter prefix that was seen before this error occurred + * @param curChar the offending character + * @param reason error code + */ public ${LEGACY_EXCEPTION_HANDLING?TokenMgrError:TokenMgrException}(boolean eofSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) { this(LexicalErr(eofSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); diff --git a/src/main/resources/templates/gwt/JavaCharStream.template b/src/main/resources/templates/gwt/JavaCharStream.template index c825276..628c209 100644 --- a/src/main/resources/templates/gwt/JavaCharStream.template +++ b/src/main/resources/templates/gwt/JavaCharStream.template @@ -178,7 +178,9 @@ class JavaCharStream { /** * Gets starting character for token. * - * @return starting character for token. */ + * @return starting character for token. + * @throws java.io.IOException when IO error occurs or EOF is encountered + */ ${PREFIX}public char BeginToken() throws java.io.IOException { if (inBuf > 0) { --inBuf; @@ -249,7 +251,12 @@ class JavaCharStream { } #fi - /** Read a character. */ + /** + * Read a character. + * + * @return the character read + * @throws java.io.IOException when IO error occurs or EOF is encountered + */ ${PREFIX}public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; @@ -350,6 +357,7 @@ class JavaCharStream { /** * Gets end column. * + * @return end column * @deprecated see {@link #getEndColumn} */ #if GENERATE_ANNOTATIONS @@ -429,7 +437,11 @@ class JavaCharStream { #fi } - /** Retreat. */ + /** + * Retreat. + * + * @param amount number of characters to back up + */ ${PREFIX}public void backup(int amount) { inBuf += amount; @@ -480,7 +492,14 @@ class JavaCharStream { this(dstream, 1, 1, 4096); } - /** Reinitialise. */ + /** + * Reinitialise. + * + * @param dstream the underlying data source. + * @param startline line number of the first character of the stream, mostly for error messages. + * @param startcolumn column number of the first character of the stream. + * @param buffersize buffer size in bytes + */ public void ReInit(Provider dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; @@ -505,12 +524,20 @@ class JavaCharStream { nextCharInd = bufpos = -1; } - /** Reinitialise. */ + /** Reinitialise. + * + * @param dstream the underlying data source. + * @param startline line number of the first character of the stream, mostly for error messages. + * @param startcolumn column number of the first character of the stream. + */ public void ReInit(Provider dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } - /** Reinitialise. */ + /** Reinitialise. + * + * @param dstream the underlying data source. + */ public void ReInit(Provider dstream) { ReInit(dstream, 1, 1, 4096); } diff --git a/src/main/resources/templates/gwt/ParseException.template b/src/main/resources/templates/gwt/ParseException.template index d0a718c..7419c97 100644 --- a/src/main/resources/templates/gwt/ParseException.template +++ b/src/main/resources/templates/gwt/ParseException.template @@ -35,6 +35,11 @@ public class ParseException extends Exception { * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. + * + * @param currentTokenVal current token value + * @param expectedTokenSequencesVal expected token sequences + * @param tokenImageVal token image value + * @param lexicalStateName lexical state name */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, @@ -59,7 +64,11 @@ public class ParseException extends Exception { super(); } - /** Constructor with message. */ + /** + * Constructor with message. + * + * @param message error message + */ public ParseException(String message) { super(message); } @@ -91,6 +100,11 @@ public class ParseException extends Exception { * due to a parse error, and you do not catch it (it gets thrown * from the parser) the correct error message * gets displayed. + * + * @param currentTokenVal current token value + * @param expectedTokenSequencesVal expected token sequences + * @param tokenImage token image + * @param lexicalStateName lexical state name */ private static String initialise(Token currentToken, int[][] expectedTokenSequences, @@ -156,6 +170,8 @@ public class ParseException extends Exception { * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. + * + * @param str string to be escaped */ static String add_escapes(String str) { StringBuffer retval = new StringBuffer(); diff --git a/src/main/resources/templates/gwt/SimpleCharStream.template b/src/main/resources/templates/gwt/SimpleCharStream.template index 0506c73..e7f4dd1 100644 --- a/src/main/resources/templates/gwt/SimpleCharStream.template +++ b/src/main/resources/templates/gwt/SimpleCharStream.template @@ -127,7 +127,12 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { } } - /** Start. */ + /** + * Start. + * + * @return first token + * @throws java.io.IOException if IO error occurs or EOF is encountered + */ ${PREFIX}public char BeginToken() throws java.io.IOException { tokenBegin = -1; char c = readChar(); @@ -172,7 +177,12 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { } #fi - /** Read a character. */ + /** + * Read a character. + * + * @return last character read + * @throws java.io.IOException on EOF + */ ${PREFIX}public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; @@ -197,7 +207,9 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { } /** - * Returns end column of the token. + * Get end column of the token. + * + * @return end column of the token. * * @deprecated see {@link #getEndColumn} */ @@ -213,7 +225,9 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { } /** - * Returns end line of the token. + * Get end line of the token. + * + * @return end line of the token. * * @deprecated see {@link #getEndLine} */ @@ -228,7 +242,11 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { #fi } - /** Get token end column number. */ + /** + * Get token end column number. + * + * @return token end column number + */ ${PREFIX}public int getEndColumn() { #if KEEP_LINE_COLUMN return bufcolumn[bufpos]; @@ -237,7 +255,11 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { #fi } - /** Get token end line number. */ + /** + * Get token end line number. + * + * @return token end line number + */ ${PREFIX}public int getEndLine() { #if KEEP_LINE_COLUMN return bufline[bufpos]; @@ -246,7 +268,11 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { #fi } - /** Get token beginning column number. */ + /** + * Get token beginning column number. + * + * @return token beginning column number. + */ ${PREFIX}public int getBeginColumn() { #if KEEP_LINE_COLUMN return bufcolumn[tokenBegin]; @@ -255,7 +281,11 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { #fi } - /** Get token beginning line number. */ + /** + * Get token beginning line number. + * + * @return token beginning line number. + */ ${PREFIX}public int getBeginLine() { #if KEEP_LINE_COLUMN return bufline[tokenBegin]; @@ -264,7 +294,11 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { #fi } - /** Backup a number of characters. */ + /** + * Backup a number of characters. + * + * @param amount number of characters + */ ${PREFIX}public void backup(int amount) { inBuf += amount; @@ -273,7 +307,14 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { } } - /** Constructor. */ + /** + * Constructor. + * + * @param dstream character provider (string or stream based) + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size in bytes + */ public SimpleCharStream(Provider dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; @@ -290,18 +331,37 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { #fi } - /** Constructor. */ + + /** + * Constructor. + * + * @param dstream character provider (string or stream based) + * @param startline start line + * @param startcolumn start column + */ public SimpleCharStream(Provider dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } - /** Constructor. */ + + /** + * Constructor. + * + * @param dstream character provider (string or stream based) + */ public SimpleCharStream(Provider dstream) { this(dstream, 1, 1, 4096); } - /** Reinitialise. */ + /** + * Reinitialise. + * + * @param dstream character provider (string or stream based) + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size in bytes + */ public void ReInit(Provider dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; @@ -325,18 +385,32 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { bufpos = -1; } - /** Reinitialise. */ + /** + * Reinitialise. + * + * @param dstream character provider (string or stream based) + * @param startline start line + * @param startcolumn start column + */ public void ReInit(Provider dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } - /** Reinitialise. */ + /** + * Reinitialise. + * + * @param dstream character provider (string or stream based) + */ public void ReInit(Provider dstream) { ReInit(dstream, 1, 1, 4096); } - /** Get token literal value. */ + /** + * Get token literal value. + * + * @return token literal value. + */ ${PREFIX}public String GetImage() { if (bufpos >= tokenBegin) { return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); @@ -346,7 +420,12 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { } } - /** Get the suffix. */ + /** + * Get the suffix. + * + * @param len number of characters + * @return the suffix. + */ ${PREFIX}public char[] GetSuffix(int len) { char[] ret = new char[len]; @@ -373,6 +452,9 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class SimpleCharStream { /** * Method to adjust line and column numbers for the start of a token. + * + * @param newLine line + * @param newCol column */ ${PREFIX}public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin;