Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] ECJ scanner and parser - how to modify the scanner?

Thanks, that helped :)

Stephan Herrmann <stephan@xxxxxxxxxxxxxxx> schrieb:
On Sunday 17 June 2007 11:55, Marco Kaufmann wrote:
> Hi,
>
> I'm currently working on a modified version of the ecj compiler and
> thereto need to modify the compiler's scanner and parser. That works
> fine for the parser: I use the java grammar file (grammar/java.g) from
> the reporsitory and jikespg to generate the parser source (or parts of
> it respectively), and the Parser.buildFilesFromLPG - method in order
> to generate the RSC files which contain the parser tables.
>
> However, I'm having a problem with the scanner. I can't create new
> keywords, because Parser.buildFilesFromLPG() generates only the
> parser table files, not the files for the scanner. These are (as I assume)
> part1.rsc, part14.rsc, part2.rsc, start1.rsc and start2.rsc. I found no
> method in Scanner.java which was similar to Parser.buildFilesFromLPG.
> Is there a way to generate the files nevertheless?
Do you already generate/update the file TerminalTokens.java?
(I currently don't have the link to the howto to check whether this step
is included in that document).

The scanner itself is implemented manually in class Scanner.
It has a method internalScanIdentifierOrKeyword() with a long switch
statement, that needs to be extended for new keywords.

Whenever you make changes to Scanner beware of a duplicate called
PublicScanner, which needs to be kept in sync with Scanner.

hope this helps,
Stephan

--
--------------------------------------------------------------------------
Dr. Stephan Herrmann
Organizing Chair of ECOOP 2007 (July 30 - August 3)
http://2007.ecoop.org
----------------
Technische Universität Berlin
Software Engineering Research Group
http://swt.cs.tu-berlin.de/~stephan
phone: ++49 30 314 73174
--------------------------------------------------------------------------


Der neue Internet Explorer 7 in deutscher Ausführung ist da !

Back to the top