| Summary: | Make OQL parser rebuildable from javacc grammar file | ||
|---|---|---|---|
| Product: | [Tools] MAT | Reporter: | Andrew Johnson <andrew_johnson> |
| Component: | Core | Assignee: | Andrew Johnson <andrew_johnson> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 241154, 287268 | ||
|
Description
Andrew Johnson
I have written an ant file which runs javacc, then fix up the generated code:
<!-- javacc converts backslash to a unicode escape, which works but looks messy, so reverse it -->
<replaceregex pattern="u005c" replace="" flags="g" />
<!-- avoid problems with the Turkish locale with toUpperCase -->
<replaceregex pattern="toUpperCase\(\)" replace="toUpperCase\(Locale.ENGLISH\)" flags="g" />
<!-- internationalize the missing return message -->
<replaceregex pattern='"Missing return statement in function"' replace="Messages.OQLParser_Missing_return_statement_in_function" flags="g" />
<!-- avoid warnings by adding suppressWarnings -->
<replaceregex pattern="public class OQLParser" replace='@SuppressWarnings({"nls", "unused"}) \0' />
<!-- remove semicolon on its own -->
<replaceregex pattern="^\s*;$" replace="" />
The generated code then needs to be reformatted into the project conventions and the imports organized.
The differences then are quite small.
The smallest differences are when using javacc 4.1
Changes made to generate files:
OQLParser.java
Added copyright header
Added @SuppressWarnings("serial") to LookaheadSuccess
Added @SuppressWarnings("unchecked") to some methods which don't use generics (javacc 5.0 will fix this)
OQLParserConstants.java
Added copyright header
Added @SuppressWarnings("nls") to public interface OQLParserConstants
OQLParserTokenManager.java
Added copyright header
Added some @SuppressWarnings("cast")
Added some @SuppressWarnings("unused")
ParseException.java
Added copyright header
Added @SuppressWarnings( { "serial", "nls" }) to ParseException
SimpleCharStream.java
Added copyright header
Added @SuppressWarnings("unused") to getTabSize(int i)
Changed JavaCC - OriginalChecksum=5a86e00a0b941ec037f0713e69ba91c3 (do not edit this
line)
Token.java
Added copyright header
Added @SuppressWarnings( { "serial", "nls" }) to TokenMgrError
Added @SuppressWarnings("unused") to some methods
Changed JavaCC - OriginalChecksum=c1af33c36aa1c949195f80d1cbfbfd9a (do not edit this
line)
We should check in versions of these files generated by a reproducible process with javacc 4.1 then move up to javacc 5.0
Build instructions are now here: http://wiki.eclipse.org/index.php?title=MemoryAnalyzer/Contributor_Reference#Build_OQL_Parser_using_JavaCC |