[antlr-interest] java.lang.OutOfMemoryError

loic.lefevre at bnpparibas.com loic.lefevre at bnpparibas.com
Mon Jul 25 03:33:12 PDT 2005


Hello,
My grammar to handle expressions is now finished but now I'm facing a
strange behaviour:
When I try to validate hand typed expressions, I get the terrible
java.lang.OutOfMemoryError when
parsing the expression: //    (two chars)

Here is my grammar:
(See attached file: RosterExpression.g)

It appears that the lexer loops forever:

      public final void mSL_COMMENT(boolean _createToken) throws
RecognitionException, CharStreamException, TokenStreamException {
            int _ttype; Token _token=null; int _begin=text.length();
            _ttype = SL_COMMENT;
            int _saveIndex;

            match("//");
            {
            _loop59:


//--> begin of loop forever
            do {
                  if ((_tokenSet_0.member(LA(1)))) {
                        {
                        match(_tokenSet_0);
                        }
                  }
                  else {
                        break _loop59;
                  }

            } while (true);
//--> end of loop forever


            }
            {
            switch ( LA(1)) {
            case '\n':
            {
                  match('\n');
                  break;
            }
            case '\r':
            {
                  match('\r');
                  {
                  if ((LA(1)=='\n')) {
                        match('\n');
                  }
                  else {
                  }

                  }
                  break;
            }
            default:
                  {
                  }
            }
            }
            if ( inputState.guessing==0 ) {
                  _ttype = Token.SKIP; newline();
            }
            if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
                  _token = makeToken(_ttype);
                  _token.setText(new String(text.getBuffer(), _begin,
text.length()-_begin));
            }
            _returnToken = _token;
      }


Thanks in advance for your help.
Loïc

This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 

                ---------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: =?ISO-8859-1?Q?RosterExpression=2Eg?=
Type: application/octet-stream
Size: 14597 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050725/4c527649/ISO-8859-1QRosterExpression2Eg-0001.obj


More information about the antlr-interest mailing list