diff --git a/examples/Gwt/pom.xml b/examples/Gwt/pom.xml index 6c62cc6..668658b 100644 --- a/examples/Gwt/pom.xml +++ b/examples/Gwt/pom.xml @@ -114,6 +114,26 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + true + true + missing + + + + + javadoc + generate-sources + + javadoc + + + + JavaCC examples Java Simple diff --git a/examples/Gwt/src/main/javacc/GwtSimpleParser.jj b/examples/Gwt/src/main/javacc/GwtSimpleParser.jj index 09658fc..fd57eb8 100644 --- a/examples/Gwt/src/main/javacc/GwtSimpleParser.jj +++ b/examples/Gwt/src/main/javacc/GwtSimpleParser.jj @@ -56,7 +56,12 @@ import java.io.PrintStream; /** Simple brace matcher. */ public class GwtSimpleParser { - /** Main entry point. */ + /** Main entry point. + * + * @param args command line args + * @throws IOException if IO error occurs + * @throws ParseException if parsing fails + */ public static void main(String[] args) throws ParseException, IOException { PrintStream output = System.out; PrintStream error = System.err; @@ -89,7 +94,10 @@ public class GwtSimpleParser { PARSER_END(GwtSimpleParser) -/** Root production. */ + /** Root production. + * + * @throws ParseException if parsing fails + */ void Input() : {} { diff --git a/examples/Gwt/src/main/javacc/GwtUnicodeParser.jj b/examples/Gwt/src/main/javacc/GwtUnicodeParser.jj index 43164a3..3f0d337 100644 --- a/examples/Gwt/src/main/javacc/GwtUnicodeParser.jj +++ b/examples/Gwt/src/main/javacc/GwtUnicodeParser.jj @@ -56,7 +56,12 @@ import java.io.PrintStream; /** Simple brace matcher. */ public class GwtUnicodeParser { - /** Main entry point. */ + /** Main entry point. + * + * @param args command line args + * @throws IOException if IO error occurs + * @throws ParseException if parsing fails + */ public static void main(String[] args) throws ParseException, IOException { PrintStream output = System.out; PrintStream error = System.err; @@ -89,7 +94,11 @@ public class GwtUnicodeParser { PARSER_END(GwtUnicodeParser) -/** Root production. */ + + /** Root production. + * + * @throws ParseException if parsing fails + */ void Input() : {} { diff --git a/examples/JavaCC/pom.xml b/examples/JavaCC/pom.xml index 5d360f9..983291a 100644 --- a/examples/JavaCC/pom.xml +++ b/examples/JavaCC/pom.xml @@ -53,6 +53,26 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + true + true + missing + + + + + javadoc + generate-sources + + javadoc + + + + \ No newline at end of file diff --git a/src/main/java/org/javacc/java/ParserCodeGenerator.java b/src/main/java/org/javacc/java/ParserCodeGenerator.java index a6b47d5..f9bad6d 100644 --- a/src/main/java/org/javacc/java/ParserCodeGenerator.java +++ b/src/main/java/org/javacc/java/ParserCodeGenerator.java @@ -303,7 +303,10 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) } codeGenerator.println(" }"); codeGenerator.println(""); - codeGenerator.println(" /** Reinitialise. */"); + codeGenerator.println(" /** Reinitialise."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param stream input stream"); + codeGenerator.println(" */"); codeGenerator.println(" public " + JavaUtil.getStatic() + "void ReInit(CharStream stream) {"); if (Options.isTokenManagerRequiresParserAccess()) { @@ -345,12 +348,19 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) } else { if (!isJavaModernMode) { - codeGenerator.println(" /** Constructor with InputStream. */"); + codeGenerator.println(" /** Constructor with InputStream."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param stream input stream"); + codeGenerator.println(" */"); codeGenerator.println(" public " + context.globals().cu_name + "(java.io.InputStream stream) {"); - codeGenerator.println(" this(stream, null);"); + codeGenerator.println(" this(stream, null);"); codeGenerator.println(" }"); codeGenerator.println(); - codeGenerator.println(" /** Constructor with InputStream and supplied encoding. */"); + codeGenerator.println(" /** Constructor with InputStream and supplied encoding."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param stream input stream"); + codeGenerator.println(" * @param encoding character encoding"); + codeGenerator.println(" */"); codeGenerator .println(" public " + context.globals().cu_name + "(java.io.InputStream stream, String encoding) {"); if (Options.getStatic()) { @@ -418,14 +428,22 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) codeGenerator.println(" }"); codeGenerator.println(""); - codeGenerator.println(" /** Reinitialise. */"); + codeGenerator.println(" /** Reinitialise."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param stream input stream"); + codeGenerator.println(" */"); codeGenerator .println(" public " + JavaUtil.getStatic() + "void ReInit(java.io.InputStream stream) {"); codeGenerator.println(" ReInit(stream, null);"); codeGenerator.println(" }"); codeGenerator.println(); - codeGenerator.println(" /** Reinitialise. */"); + + codeGenerator.println(" /** Reinitialise."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param stream input stream"); + codeGenerator.println(" * @param encoding encoding"); + codeGenerator.println(" */"); codeGenerator.println( " public " + JavaUtil.getStatic() + "void ReInit(java.io.InputStream stream, String encoding) {"); @@ -477,7 +495,10 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) final String stringReaderClass = isJavaModernMode ? "StringProvider" : "java.io.StringReader"; - codeGenerator.println(" /** Constructor. */"); + codeGenerator.println(" /** Constructor."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param stream provider of the input stream"); + codeGenerator.println(" */"); codeGenerator.println(" public " + context.globals().cu_name + "(" + readerInterfaceName + " stream) {"); if (Options.getStatic()) { codeGenerator.println(" if (jj_initialized_once) {"); @@ -530,7 +551,13 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) // only to prevent regressions) if (isJavaModernMode) { codeGenerator.println(""); - codeGenerator.println(" /** Constructor. */"); + codeGenerator.println(" /** Constructor. "); + codeGenerator.println(" *"); + codeGenerator.println(" * @param dsl string to be parsed"); + codeGenerator.println(" * @throws ParseException if parsing fails"); + codeGenerator.println(" * @throws " + JavaTemplates.getTokenMgrErrorClass() + + " if tokenization fails"); + codeGenerator.println(" */ "); codeGenerator.println(" public " + context.globals().cu_name + "(String dsl) throws ParseException, " + JavaTemplates.getTokenMgrErrorClass() + " {"); codeGenerator.println(" this(new " + stringReaderClass + "(dsl));"); @@ -544,7 +571,10 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) } codeGenerator.println(); - codeGenerator.println(" /** Reinitialise. */"); + codeGenerator.println(" /** Reinitialise."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param stream input stream"); + codeGenerator.println(" */ "); codeGenerator .println(" public " + JavaUtil.getStatic() + "void ReInit(" + readerInterfaceName + " stream) {"); if (Options.getJavaUnicodeEscape()) { @@ -609,13 +639,19 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) } } codeGenerator.println(""); - if (Options.getUserTokenManager()) { - codeGenerator.println(" /** Constructor with user supplied Token Manager. */"); - codeGenerator.println(" public " + context.globals().cu_name + "(TokenManager tm) {"); - } else { - codeGenerator.println(" /** Constructor with generated Token Manager. */"); - codeGenerator.println(" public " + context.globals().cu_name + "(" + context.globals().cu_name + "TokenManager tm) {"); + String managerType = "user supplied"; + String managerClassName = "TokenManager"; + if (!Options.getUserTokenManager()) { + managerType = "generated"; + managerClassName = context.globals().cu_name + managerClassName; } + codeGenerator.println(" /** Constructor with " + managerType + " Token Manager."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param tm token manager"); + codeGenerator.println(" */"); + codeGenerator.println(" public " + context.globals().cu_name + + "(" + managerClassName + " tm) {"); + if (Options.getStatic()) { codeGenerator.println(" if (jj_initialized_once) {"); codeGenerator.println(" System.out.println(\"ERROR: Second call to constructor of static parser. \");"); @@ -652,11 +688,13 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) } codeGenerator.println(" }"); codeGenerator.println(""); + codeGenerator.println(" /** Reinitialise."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param tm token manager"); + codeGenerator.println(" */"); if (Options.getUserTokenManager()) { - codeGenerator.println(" /** Reinitialise. */"); codeGenerator.println(" public void ReInit(TokenManager tm) {"); } else { - codeGenerator.println(" /** Reinitialise. */"); codeGenerator.println(" public void ReInit(" + context.globals().cu_name + "TokenManager tm) {"); } codeGenerator.println(" token_source = tm;"); @@ -792,7 +830,10 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) codeGenerator.println(""); } codeGenerator.println(""); - codeGenerator.println("/** Get the next Token. */"); + codeGenerator.println(" /** Get the next Token."); + codeGenerator.println(" *"); + codeGenerator.println(" * @return the next token"); + codeGenerator.println(" */"); codeGenerator.println(" public " + JavaUtil.getStatic() + "final Token getNextToken() {"); if (Options.getCacheTokens()) { codeGenerator.println(" if ((token = jj_nt).next != null) {"); @@ -817,7 +858,11 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) codeGenerator.println(" return token;"); codeGenerator.println(" }"); codeGenerator.println(""); - codeGenerator.println("/** Get the specific Token. */"); + codeGenerator.println(" /** Get the specific Token."); + codeGenerator.println(" *"); + codeGenerator.println(" * @param index token index"); + codeGenerator.println(" * @return token at given index"); + codeGenerator.println(" */"); codeGenerator.println(" public " + JavaUtil.getStatic() + "final Token getToken(int index) {"); if (context.globals().lookaheadNeeded) { codeGenerator.println(" Token t = jj_lookingAhead ? jj_scanpos : token;"); @@ -904,7 +949,10 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) codeGenerator.println(" }"); } codeGenerator.println(""); - codeGenerator.println(" /** Generate ParseException. */"); + codeGenerator.println(" /** Generate ParseException."); + codeGenerator.println(" *"); + codeGenerator.println(" * @return the parse exception"); + codeGenerator.println(" */"); codeGenerator.println(" public " + JavaUtil.getStatic() + "ParseException generateParseException() {"); codeGenerator.println(" jj_expentries.clear();"); codeGenerator.println(" " + JavaUtil.getBooleanType() + "[] la1tokens = new " + JavaUtil.getBooleanType() + "[" @@ -982,7 +1030,10 @@ public void generateCode(CodeGeneratorSettings settings, ParserData parserData) codeGenerator .println(" private " + JavaUtil.getStatic() + JavaUtil.getBooleanType() + " trace_enabled;"); codeGenerator.println(""); - codeGenerator.println("/** Trace enabled. */"); + codeGenerator.println(" /** Trace enabled."); + codeGenerator.println(" *"); + codeGenerator.println(" * @return whether trace is enabled"); + codeGenerator.println(" */"); codeGenerator.println(" public " + JavaUtil.getStatic() + "final boolean trace_enabled() {"); codeGenerator.println(" return trace_enabled;"); codeGenerator.println(" }"); diff --git a/src/main/resources/templates/JavaCharStream.template b/src/main/resources/templates/JavaCharStream.template index 9aa6dda..bd65a28 100644 --- a/src/main/resources/templates/JavaCharStream.template +++ b/src/main/resources/templates/JavaCharStream.template @@ -179,7 +179,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; @@ -250,7 +252,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; @@ -351,6 +358,7 @@ class JavaCharStream { /** * Gets end column. * + * @return end column * @deprecated see {@link #getEndColumn} */ #if GENERATE_ANNOTATIONS @@ -430,7 +438,11 @@ class JavaCharStream { #fi } - /** Retreat. */ + /** + * Retreat. + * + * @param amount number of characters to back up + */ ${PREFIX}public void backup(int amount) { inBuf += amount; @@ -482,7 +494,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(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; @@ -507,18 +526,35 @@ 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(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } - /** Reinitialise. */ + /** + * Reinitialise. + * + * @param dstream the underlying data source. + */ public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } - /** Constructor. */ + /** Constructor. + * + * @param dstream the underlying data source. + * @param encoding stream encoding + * @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 + * @throws java.io.UnsupportedEncodingException if encoding is not supported + */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { this(encoding == null ? new java.io.InputStreamReader(dstream) @@ -543,7 +579,7 @@ class JavaCharStream { * @param encoding the character encoding of the data stream. * @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. - * @throws UnsupportedEncodingException encoding is invalid or unsupported. + * @throws java.io.UnsupportedEncodingException encoding is invalid or unsupported. */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { @@ -565,7 +601,7 @@ class JavaCharStream { * * @param dstream the underlying data source. * @param encoding the character encoding of the data stream. - * @throws UnsupportedEncodingException encoding is invalid or unsupported. + * @throws java.io.UnsupportedEncodingException encoding is invalid or unsupported. */ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { @@ -587,6 +623,7 @@ class JavaCharStream { * @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 size of the buffer + * @throws java.io.UnsupportedEncodingException if encoding is not supported */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { @@ -612,7 +649,7 @@ class JavaCharStream { * @param encoding the character encoding of the data stream. * @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. - * @throws UnsupportedEncodingException encoding is invalid or unsupported. + * @throws java.io.UnsupportedEncodingException encoding is invalid or unsupported. */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { @@ -634,7 +671,7 @@ class JavaCharStream { * * @param dstream the underlying data source. * @param encoding the character encoding of the data stream. - * @throws UnsupportedEncodingException encoding is invalid or unsupported. + * @throws java.io.UnsupportedEncodingException encoding is invalid or unsupported. */ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { diff --git a/src/main/resources/templates/ParseException.template b/src/main/resources/templates/ParseException.template index f03b2e0..da4b2fb 100644 --- a/src/main/resources/templates/ParseException.template +++ b/src/main/resources/templates/ParseException.template @@ -26,6 +26,10 @@ 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 */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, @@ -49,7 +53,11 @@ public class ParseException extends Exception { super(); } - /** Constructor with message. */ + /** + * Constructor with message. + * + * @param message error message + */ public ParseException(String message) { super(message); } diff --git a/src/main/resources/templates/Token.template b/src/main/resources/templates/Token.template index dcbb616..46dd71d 100644 --- a/src/main/resources/templates/Token.template +++ b/src/main/resources/templates/Token.template @@ -62,6 +62,8 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class Token { * interpreter. This attribute value is often different from the image. * Any subclass of Token that actually wants to return a non-null value can * override this method as appropriate. + * + * @return semantic value, null by default */ public Object getValue() { return null; @@ -74,6 +76,8 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class Token { /** * Constructs a new token for the specified Image. + * + * @param kind token kind */ public Token(int kind) { this(kind, null); @@ -81,6 +85,9 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class Token { /** * Constructs a new token for the specified Image and Kind. + * + * @param kind token kind + * @param image string representation of this token */ public Token(int kind, String image) { this.kind = kind; @@ -89,6 +96,8 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class Token { /** * Returns the image. + * + * @return string representation of this token */ @Override public String toString() { @@ -106,6 +115,10 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class Token { * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use sit in your lexical actions. + * + * @param ofKind token kind + * @param image string representation of this token + * @return new token */ public static Token newToken(int ofKind, String image) { switch (ofKind) { diff --git a/src/main/resources/templates/TokenManager.template b/src/main/resources/templates/TokenManager.template index 329bb15..67b018f 100644 --- a/src/main/resources/templates/TokenManager.template +++ b/src/main/resources/templates/TokenManager.template @@ -8,6 +8,8 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}interface TokenManager { /** This gets the next token from the input stream. * A token of kind 0 () should be returned on EOF. + * + * @return next token */ public Token getNextToken(); diff --git a/src/main/resources/templates/TokenManagerDriver.template b/src/main/resources/templates/TokenManagerDriver.template index 9b80de3..ae54e30 100644 --- a/src/main/resources/templates/TokenManagerDriver.template +++ b/src/main/resources/templates/TokenManagerDriver.template @@ -21,11 +21,18 @@ ${decls} /* Declarations from the TOKEN_MGR_DECLS section */ - /** Constructor with parser. */ + /** Constructor with parser. + * + * @param parserArgs parser + * @param stream input stream + */ public ${parserName}TokenManager(${parserName} parserArg, ${charStreamName} stream) { parser = parserArg; #else - /** Constructor. */ + /** Constructor. + * + * @param stream input stream + */ public ${parserName}TokenManager(${charStreamName} stream) { #fi @@ -47,23 +54,36 @@ ${decls} } #if TOKEN_MANAGER_USES_PARSER && !STATIC - /** Constructor with parser. */ + /** Constructor with parser. + * + * @param parserArg parser + * @param stream input stream + * @param lexState lexical state + */ public ${parserName}TokenManager(${parserName} parserArg, ${charStreamName} stream, int lexState) { ReInit(parserArg, stream); } #else - /** Constructor. */ + /** Constructor. + * + * @param stream input stream + * @param lexState lexical state + */ public ${parserName}TokenManager(${charStreamName} stream, int lexState) { ReInit(stream); SwitchTo(lexState); } #fi - /** Reinitialise parser. */ - + /** Reinitialise parser. + * + * @param stream input stream #if TOKEN_MANAGER_USES_PARSER && !STATIC + * @param parserArg parser + */ public void ReInit(${parserName} parserArg, ${charStreamName} stream) { #else + */ public ${STATIC?static :}void ReInit(${charStreamName} stream) { #fi #if TOKEN_MANAGER_USES_PARSER && !STATIC @@ -75,10 +95,16 @@ ${decls} input_stream = stream; } - /** Reinitialise parser. */ + /** Reinitialise parser. + * + * @param stream input stream + * @param lexState lexical state #if TOKEN_MANAGER_USES_PARSER && !STATIC + * @param parserArg parser + */ public void ReInit( ${parserName} parserArg, ${charStreamName} stream, int lexState) { #else + */ public ${STATIC?static :}void ReInit(${charStreamName} stream, int lexState) { #fi #if TOKEN_MANAGER_USES_PARSER && !STATIC @@ -89,7 +115,11 @@ ${decls} SwitchTo(lexState); } - /** Switch to specified lex state. */ + /** + * Switch to specified lex state. + * + * @param lexState lexical state + */ public ${STATIC?static :}void SwitchTo(int lexState) { curLexState = lexState; } @@ -370,7 +400,10 @@ protected ${STATIC?static :} Token jjFillToken() { return t; } -/** Get the next Token. */ + /** Get the next Token. + * + * @return next token + */ public ${STATIC?static :} Token getNextToken() { Token specialToken = null; Token matchedToken; diff --git a/src/main/resources/templates/TokenMgrError.template b/src/main/resources/templates/TokenMgrError.template index 451e4ad..712e08a 100644 --- a/src/main/resources/templates/TokenMgrError.template +++ b/src/main/resources/templates/TokenMgrError.template @@ -41,6 +41,9 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class ${LEGACY_EXCEPTION_HANDLING?Tok /** * Replaces unprintable characters by their escaped (or unicode escaped) * equivalents in the given string. + * + * @param str string to be escaped + * @return escaped string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); @@ -87,14 +90,16 @@ ${SUPPORT_CLASS_VISIBILITY_PUBLIC?public :}class ${LEGACY_EXCEPTION_HANDLING?Tok /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. - * Parameters : - * eofSeen : indicates if EOF caused the lexical error - * curLexState : lexical state in which this error occurred - * errorLine : line number when the error occurred - * errorColumn : column number when the error occurred - * errorAfter : prefix that was seen before this error occurred - * curchar : the offending character - * Note: You can customize the lexical error message by modifying this method. + * + *

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;