Friday, April 16, 2010

JDT Uses Jikes Parser Generator (jikespg)

Eclipse JDT Uses Jikes PG to generate Java Parser as it declared here in developer resources [1]. It is implements techniques that allow to reduce memory consumption, to increase speed and support automatic error recovery.
Follow the links below to get it compiled, if JDT parser generation fails with something looking like this
eskimo@dgolovin-desktop:~/Projects/jbds-build/addition/org.eclipse.jdt.core/grammar$ ~/bin/jikespg java.g

 IBM Research Jikes Parser Generator            Mon Apr 26 16:06:10 2010
%OPTIONS ACTION, AN=JavaAction.java, GP=java, 
%OPTIONS FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 ,
%OPTIONS NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE, 
%OPTIONS ERROR_MAPS 
%OPTIONS first follow
%OPTIONS TRACE=FULL ,
%OPTIONS VERBOSE
%OPTIONS DEFERRED
%OPTIONS NAMES=MAX
%OPTIONS SCOPES
Options in effect:
    ACTION  ACTFILE-NAME=JavaAction.java  BLOCKB=/.  BLOCKE=./  BYTE  CONFLICTS
    DEFAULT=5  NODEBUG  DEFERRED  NOEDIT  ERROR-MAPS  ESCAPE=$  
    FILE-PREFIX=java  FIRST  FOLLOW  GENERATE-PARSER=JAVA  NOGOTO-DEFAULT  
    HACTFILE-NAME=javahdr.java  HBLOCKB=/:  HBLOCKE=:/  LALR=1  LIST  
    MAX-DISTANCE=30  MIN-DISTANCE=3  NAMES=MAXIMUM  NONT-CHECK  ORMARK=|  
    OUTPUT-SIZE=125  PREFIX=TokenName  READ-REDUCE  SCOPES  NOSHIFT-DEFAULT  
    SINGLE-PRODUCTIONS  STACK-SIZE=128  STATES  SUFFIX=  TABLE=SPACE  
    TRACE=FULL  VERBOSE  WARNINGS  XREF  

*** buffer overflow detected ***: /home/eskimo/bin/jikespg terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb7821ed8]
/lib/tls/i686/cmov/libc.so.6[0xb7820f10]
/lib/tls/i686/cmov/libc.so.6[0xb782023a]
/home/eskimo/bin/jikespg[0x805be3a]
/home/eskimo/bin/jikespg[0x805cd7e]
/home/eskimo/bin/jikespg[0x805d4f6]
/home/eskimo/bin/jikespg[0x805dc9d]
/home/eskimo/bin/jikespg[0x805f850]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb7757b56]
/home/eskimo/bin/jikespg[0x8048bc1]
======= Memory map: ========
08048000-08089000 r-xp 00000000 08:03 9437834    /home/eskimo/bin/jikespg
08089000-0808a000 r--p 00040000 08:03 9437834    /home/eskimo/bin/jikespg
0808a000-0808b000 rw-p 00041000 08:03 9437834    /home/eskimo/bin/jikespg
0808b000-0808c000 rw-p 00000000 00:00 0 
086e6000-0872a000 rw-p 00000000 00:00 0          [heap]
b7710000-b772c000 r-xp 00000000 08:02 9088       /lib/libgcc_s.so.1
b772c000-b772d000 r--p 0001b000 08:02 9088       /lib/libgcc_s.so.1
b772d000-b772e000 rw-p 0001c000 08:02 9088       /lib/libgcc_s.so.1
b7740000-b7741000 rw-p 00000000 00:00 0 
b7741000-b787f000 r-xp 00000000 08:02 9011       /lib/tls/i686/cmov/libc-2.10.1.so
b787f000-b7880000 ---p 0013e000 08:02 9011       /lib/tls/i686/cmov/libc-2.10.1.so
b7880000-b7882000 r--p 0013e000 08:02 9011       /lib/tls/i686/cmov/libc-2.10.1.so
b7882000-b7883000 rw-p 00140000 08:02 9011       /lib/tls/i686/cmov/libc-2.10.1.so
b7883000-b7886000 rw-p 00000000 00:00 0 
b7895000-b789a000 rw-p 00000000 00:00 0 
b789a000-b789b000 r-xp 00000000 00:00 0          [vdso]
b789b000-b78b6000 r-xp 00000000 08:02 22970      /lib/ld-2.10.1.so
b78b6000-b78b7000 r--p 0001a000 08:02 22970      /lib/ld-2.10.1.so
b78b7000-b78b8000 rw-p 0001b000 08:02 22970      /lib/ld-2.10.1.so
bfc3f000-bfc54000 rw-p 00000000 00:00 0          [stack]
Aborted
remove optimization flag
-O1
from
jikespg/src/Makefile
and compile it again. It should be enough to fix it and get parser generated. Output for generating JDT parser based on java.g grammar should look like this:
eskimo@dgolovin-desktop:~/Projects/jbds-build/addition/org.eclipse.jdt.core/grammar$ ~/bin/jikespg java.g

 IBM Research Jikes Parser Generator            Mon Apr 26 16:18:22 2010
%OPTIONS ACTION, AN=JavaAction.java, GP=java, 
%OPTIONS FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 ,
%OPTIONS NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE, 
%OPTIONS ERROR_MAPS 
%OPTIONS first follow
%OPTIONS TRACE=FULL ,
%OPTIONS VERBOSE
%OPTIONS DEFERRED
%OPTIONS NAMES=MAX
%OPTIONS SCOPES
Options in effect:
    ACTION  ACTFILE-NAME=JavaAction.java  BLOCKB=/.  BLOCKE=./  BYTE  CONFLICTS
    DEFAULT=5  NODEBUG  DEFERRED  NOEDIT  ERROR-MAPS  ESCAPE=$  
    FILE-PREFIX=java  FIRST  FOLLOW  GENERATE-PARSER=JAVA  NOGOTO-DEFAULT  
    HACTFILE-NAME=javahdr.java  HBLOCKB=/:  HBLOCKE=:/  LALR=1  LIST  
    MAX-DISTANCE=30  MIN-DISTANCE=3  NAMES=MAXIMUM  NONT-CHECK  ORMARK=|  
    OUTPUT-SIZE=125  PREFIX=TokenName  READ-REDUCE  SCOPES  NOSHIFT-DEFAULT  
    SINGLE-PRODUCTIONS  STACK-SIZE=128  STATES  SUFFIX=  TABLE=SPACE  
    TRACE=FULL  VERBOSE  WARNINGS  XREF  

*** The following Terminals are useless: 
        const  goto  

This grammar is LALR(1).

Number of Terminals: 110
Number of Nonterminals: 312
Number of Productions: 704
Number of Single Productions: 232
Number of Items: 2203
Number of Scopes: 134
Number of States: 970
Number of Shift actions: 6060
Number of Goto actions: 7523
Number of Shift/Reduce actions: 590
Number of Goto/Reduce actions: 1047
Number of Reduce actions: 14139
Number of Shift-Reduce conflicts: 0
Number of Reduce-Reduce conflicts: 0

Length of base Action Table: 12223
Number of entries in base Action Table: 9540
Percentage of increase: 28.1%
Storage required for base Tables: 24446 Bytes, 24K
Storage required for Rules: 2109 Bytes
Number of unique terminal states: 743
Number of Shift actions saved by merging: 4084
Number of Reduce actions saved by merging: 912
Number of Reduce saved by default: 9127

Length of Terminal Check Table: 8110
Length of Terminal Action Table: 8072
Number of entries in Terminal Action Table: 7409
Percentage of increase: 8.9%
Storage required for Terminal Tables: 24254 Bytes, 24K
Total storage required for Tables: 48700 Bytes, 48K


Actions in Compressed Tables:
     Number of Shifts: 2241
     Number of Shift/Reduces: 325
     Number of Gotos: 7523
     Number of Goto/Reduces: 1047
     Number of Reduces: 4100
     Number of Defaults: 491

Error maps storage:
    Storage required for ACTION_SYMBOLS_BASE map: 1940 Bytes
    Storage required for ACTION_SYMBOLS_RANGE map: 1707 Bytes
    Storage required for NACTION_SYMBOLS_BASE map: 1940 Bytes
    Storage required for NACTION_SYMBOLS_RANGE map: 984 Bytes
    Storage required for TERMINAL_INDEX map: 220 Bytes
    Storage required for NON_TERMINAL_INDEX map: 626 Bytes
    Storage required for STRING_BUFFER map: 12328 Bytes

***Warning: Base Check vector contains value > 127. 16-bit words used.
Escaped symbol $eof is an invalid C variable.

Escaped symbol $error is an invalid C variable.
Links:

1 comment:

  1. right CVS location is
    :pserver:anonymous@jikes.cvs.sourceforge.net:/cvsroot/jikes

    ReplyDelete