[antlr-interest] specialStateTransition too big for Java(AntLR3)

Ulf Ochsenfahrt ulf at ofahrt.de
Sat Aug 11 12:55:40 PDT 2007


Jim Idle wrote:
> Show us your lexer rules and maybe we can help simplify them a little.
> That usually helps as you can express the differences in a more natural
> manner and reduce the number of lexer states.
> 
> Jim

Sure.

The grammar is here:
http://users.conquer-space.net/~ulf/jphp/Php.g3
(for now, I assume that the grammar falls under the PHP license)

The state enum for the lexer is here:
http://users.conquer-space.net/~ulf/jphp/LexicalState.java

If you want to compile the parser, you'll have to remove the actions 
from the parser rules.

The lexer is far from complete, and it needs several states (I count 13 
different states in the original PHP grammar). If you know a way to 
achieve the same with fewer or no lexer states, I'd be very interested 
to hear that.

The goal is for the grammar to accept the same language as the original 
PHP grammar. I believe that it does not do it right now: the keywords 
probably also need to be predicated on the current lexer state. I havn't 
tested it, but at this time, they probably also match T_INLINE_HTML tokens.

Any feedback is welcome.

Cheers,

-- Ulf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3715 bytes
Desc: S/MIME Cryptographic Signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20070811/6d8c1950/attachment.bin 


More information about the antlr-interest mailing list