[antlr-interest] Error in the method specialStateTransition(int, IntStream)

preitz sharma p4rst2 at gmail.com
Sun Jun 5 22:24:09 PDT 2011


Hi Jim,
Thanks for the solution..
But I am facing one problem.

If I say

expr: SET VALUE ( i = Int  { setValue($i.getText());} |
                            v = SPL_CHARS+ {
displayErrorMessage($v.getText());})
       ;
SPL_CHARS  :  ('\U0000' .. '\UFFFF')+;

When I give some non numeric input and call the method
displayErrorMessage($v.getText()) , I get a null pointer exception. It says
that v is null.
What should I do?
I need to capture this value and display the error message..

PS: It is not a simple grammar for SET command. In our product, we are
migrating from manual parsing to ANTLR Parser. So I don't think it is an
over kill :)

On Fri, May 20, 2011 at 9:34 PM, Jim Idle <jimi at temporal-wave.com> wrote:

> SPL_CHARS  :  ('\U0000' .. '\UFFFF')+;
>
>
> The '+' in this means match everything and keep matching everything. You
> cannot use + here, you need:
>
> SPL_CHARS  : .;
>
> Then use SPL_CHARS+ in your grammar not (.)+
>
> Though I think you would be better writing a small piece of code to
> process this really; ANTLR is a bit overkill for "set x y"
>
> Jim
>
> > -----Original Message-----
> > From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> > bounces at antlr.org] On Behalf Of preitz sharma
> > Sent: Friday, May 20, 2011 1:28 AM
> > To: antlr-interest at antlr.org
> > Subject: [antlr-interest] Error in the method
> > specialStateTransition(int, IntStream)
> >
> > Hi,
> > I need to develop a grammar with the following structure:
> >
> > set <Param-Name> <Param-Val>
> >
> > The grammar which I have developed is working fine except for one
> > Problem:
> >
> > -> If the Param-Val does not match the constraints defined for certain
> > Param_Name, then I need to throw an error.
> >
> >     I am doing it like this:
> >
> >     command:    SET ARRAYSIZE ( Int  {/*Process the arraysize*/}
> >                     | (.)+ {/*Display eror message*/})
> >                   ;
> >     Int:    ('0'..'9')+;
> >     Char:    ('a'..'z');
> >     SPL_CHARS  :  ('\U0000' .. '\UFFFF')+;
> >
> > The problem is that I am getting an error: "The code of method
> > specialStateTransition(int, IntStream) is exceeding the 65535 bytes
> > limit"
> > What should I do?
> > PS: The grammar which I have to write is pretty big.. If I make
> > SPL_CHARS
> > :  ('\U0000' .. '\UFFFF')  then its working fine Please suggest some
> > solution..
> >
> > Thanks
> > Preeti Sharma
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> > email-address
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>



-- 
Regards
Preeti Sharma


More information about the antlr-interest mailing list