[antlr-interest] Composite grammar and memoize

Indhu Bharathi indhu.b at s7software.com
Thu Apr 2 19:15:39 PDT 2009


Hi,

I guess this is the problem Ter talks about in this mail:
http://marc.info/?l=antlr-dev&m=121174142722552&w=2

Wondering if this bug is fixed or is still there...

- Indhu

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Indhu Bharathi
Sent: Thursday, April 02, 2009 10:58 PM
To: antlr-interest
Subject: [antlr-interest] Composite grammar and memoize

Hi,

It looks like memoize at rule level doesn't work in composite grammar. I 
get the error message '!!!!!!!!! memo array is null for ParserPart.g'. 
'state.ruleMemo' is always null.

Also, it looks like this is a known issue. Has this been fixed or is 
there a workaround?

I tried turning on memoize at grammar level and turn it off in the rules 
that doesn't require it. Even that doesn't seem to work.

Here are the files I used:

LexerPart.g
lexer grammar LexPart;

SET    :    'set'
    ;
       
EQ    :    '='
    ;
   
SEMICOLON   
    :    ';'
    ;
   
COLON
    :    ':'
    ;       
   
LPAREN    :    '('
        ;
       
RPAREN    :    ')'
        ;
   
PLUS
    :    '+'
    ;
   
ID    :    'a'..'z'+
    ;
   
INTLIT    :    '0'..'9'+
    ;
   
WS    :    (' ' | '\t'  | '\r') {$channel = HIDDEN;}
    ;
   



ParserPart.g
parser grammar ParserPart;


s   
options {
    backtrack = true;
    memoize = true;
}
    :    r
    |    expr ID
    ;

r
options {
    backtrack = true;
    memoize = true;
}
    :    expr SEMICOLON
    |    expr COLON
    ;
   
expr
        : LPAREN expr RPAREN
        | INTLIT
        ;
   


Child1.g
grammar Child1;

import LexPart, ParserPart;

@header {
    import java.util.LinkedList;
    import org.antlr.runtime.*;
   
}

test    : PLUS
        ;
       

Any pointers?


Thanks, Indhu


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list