[antlr-interest] java.lang.OutOfMemoryError

Alexey Demakov demakov at ispras.ru
Mon Jul 25 04:19:33 PDT 2005


Here is shortened version of your parser with main() reading System.in
I don't see any problems with it

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com


----- Original Message ----- 
From: <loic.lefevre at bnpparibas.com>
To: <antlr-interest at antlr.org>
Sent: Monday, July 25, 2005 2:33 PM
Subject: [antlr-interest] java.lang.OutOfMemoryError



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: RosterExpression.g
Type: application/octet-stream
Size: 5227 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050725/70259556/RosterExpression.obj


More information about the antlr-interest mailing list