Loading ...
Sorry, an error occurred while loading the content.
 

Re: Help ignoring parts of the input

Expand Messages
  • Peter Williams
    Just as an aside, if you want this rule to really work fully, then you need to add additional logic to body to ignore // ... and /* ... */ comments.
    Message 1 of 11 , Sep 7 4:37 PM
      Just as an aside, if you want this rule to really work fully, then you need to
      add additional logic to 'body' to ignore // ... and /* ... */ comments.
      Otherwise, brackets inside comments will screw you up.

      -Peter

      > The above rule , even though correct in spirit, has too much of it.
      >
      > Should really read
      >
      > nestedPair:
      > LBRACE
      > (~(LBRACE | RBRACE) )*
      > (nestedPair)? RBRACE
      > ;
      >
      > or , the way you want to do it
      >
      > ----------------------
      >
      > bracketed:
      > LBRACE
      > body
      > RBRACE
      > ;
      > body:
      > (~(LBRACE | RBRACE) )*
      > (bracketed)?
      > ;

      --
      Pete Williams mailto:pete.williams@...
      Sun Microsystems, Inc.
      Menlo Park, CA 94025 http://www.netdynamics.com
    • mzukowski@bco.com
      ... Yes, but presumably the lexer is already doing that when it recognizes comments. The parser should just see a COMMENT token and not know of any braces
      Message 2 of 11 , Sep 7 4:41 PM
        > From: Peter Williams <pete.williams@...>
        >
        > Just as an aside, if you want this rule to really work fully,
        > then you need to
        > add additional logic to 'body' to ignore // ... and /* ... */
        > comments.
        > Otherwise, brackets inside comments will screw you up.

        Yes, but presumably the lexer is already doing that when it recognizes
        comments. The parser should just see a COMMENT token and not know of any
        braces within it.

        However, this would be a problem if you were trying to match nested braces
        in the lexer instead of the parser.

        >
        > > The above rule , even though correct in spirit, has too much of it.
        > >
        > > Should really read
        > >
        > > nestedPair:
        > > LBRACE
        > > (~(LBRACE | RBRACE) )*
        > > (nestedPair)? RBRACE
        > > ;

        Thanks for the correction Sinan! Right on the money.

        Monty
      • William J. Koscho
        thanks for the advice, but my lexer, just eats up the comments. I dont pay any attention to them. thanks -bill ... From: Peter Williams
        Message 3 of 11 , Sep 7 5:57 PM
          thanks for the advice, but my lexer, just eats up the comments.
          I dont pay any attention to them.

          thanks

          -bill

          ----- Original Message -----
          From: Peter Williams <pete.williams@...>
          To: <antlr-interest@onelist.com>
          Sent: Tuesday, September 07, 1999 7:37 PM
          Subject: Re: [antlr-interest] Help ignoring parts of the input


          > From: Peter Williams <pete.williams@...>
          >
          > Just as an aside, if you want this rule to really work fully, then you
          need to
          > add additional logic to 'body' to ignore // ... and /* ... */ comments.
          > Otherwise, brackets inside comments will screw you up.
          >
          > -Peter
          >
          > > The above rule , even though correct in spirit, has too much of it.
          > >
          > > Should really read
          > >
          > > nestedPair:
          > > LBRACE
          > > (~(LBRACE | RBRACE) )*
          > > (nestedPair)? RBRACE
          > > ;
          > >
          > > or , the way you want to do it
          > >
          > > ----------------------
          > >
          > > bracketed:
          > > LBRACE
          > > body
          > > RBRACE
          > > ;
          > > body:
          > > (~(LBRACE | RBRACE) )*
          > > (bracketed)?
          > > ;
          >
          > --
          > Pete Williams mailto:pete.williams@...
          > Sun Microsystems, Inc.
          > Menlo Park, CA 94025 http://www.netdynamics.com
          >
          >
          >
          > --------------------------- ONElist Sponsor ----------------------------
          >
          > Enter ONElist's Friends & Family Program
          > WIN $100 to Amazon.com! Through Sept. 17. To enter, click here
          > <a href=" http://clickme.onelist.com/ad/ff ">Click Here</a>
          >
          > ------------------------------------------------------------------------
          >
        • William J. Koscho
          Sinan & Monty, thanks for the help -bill ... From: To: Sent: Tuesday, September 07, 1999 7:41 PM Subject: RE:
          Message 4 of 11 , Sep 7 5:58 PM
            Sinan & Monty,

            thanks for the help

            -bill

            ----- Original Message -----
            From: <mzukowski@...>
            To: <antlr-interest@onelist.com>
            Sent: Tuesday, September 07, 1999 7:41 PM
            Subject: RE: [antlr-interest] Help ignoring parts of the input


            > From: mzukowski@...
            >
            > > From: Peter Williams <pete.williams@...>
            > >
            > > Just as an aside, if you want this rule to really work fully,
            > > then you need to
            > > add additional logic to 'body' to ignore // ... and /* ... */
            > > comments.
            > > Otherwise, brackets inside comments will screw you up.
            >
            > Yes, but presumably the lexer is already doing that when it recognizes
            > comments. The parser should just see a COMMENT token and not know of any
            > braces within it.
            >
            > However, this would be a problem if you were trying to match nested braces
            > in the lexer instead of the parser.
            >
            > >
            > > > The above rule , even though correct in spirit, has too much of it.
            > > >
            > > > Should really read
            > > >
            > > > nestedPair:
            > > > LBRACE
            > > > (~(LBRACE | RBRACE) )*
            > > > (nestedPair)? RBRACE
            > > > ;
            >
            > Thanks for the correction Sinan! Right on the money.
            >
            > Monty
            >
            > --------------------------- ONElist Sponsor ----------------------------
            >
            > Enter ONElist's Friends & Family Program
            > WIN $100 to Amazon.com! Through Sept. 17. To enter, click here
            > <a href=" http://clickme.onelist.com/ad/ff ">Click Here</a>
            >
            > ------------------------------------------------------------------------
            >
          • Luke Blanshard
            Actually, even Sinan s solution still falls a bit short. Consider applying it to this block: { {} {} } You need to include the recursion in the loop,
            Message 5 of 11 , Sep 8 6:24 AM
              Actually, even Sinan's solution still falls a bit short. Consider
              applying it to this block:

              { {} {} }

              You need to include the recursion in the loop, something like this:

              nestedPair:
              LBRACE
              ( ~(LBRACE | RBRACE)
              | nestedPair
              )*
              RBRACE
              ;


              I tried sending this yesterday, but @#$%#@ Onelist screwed me over. Hope
              this one gets out.

              Luke

              > -----Original Message-----
              > From: William J. Koscho [mailto:wkoscho@...]
              > Sent: Tuesday, September 07, 1999 7:58 PM
              > To: antlr-interest@onelist.com
              > Subject: Re: [antlr-interest] Help ignoring parts of the input
              >
              >
              > From: "William J. Koscho" <wkoscho@...>
              >
              > Sinan & Monty,
              >
              > thanks for the help
              >
              > -bill
              >
            • William Koscho
              Luke, yeah...you re right...I tried Sinan s solution and it died. This one definately looks right. Sinans solution gave me an idea similar to yours that I was
              Message 6 of 11 , Sep 8 6:39 AM
                Luke,

                yeah...you're right...I tried Sinan's solution and it died.
                This one definately looks right. Sinans solution
                gave me an idea similar to yours that I was using...
                but yours is cleaner...so I think Ill use it.

                thanks to everyone on all the help

                -bill

                Luke Blanshard wrote:

                > From: "Luke Blanshard" <Luke.Blanshard@...>
                >
                > Actually, even Sinan's solution still falls a bit short. Consider
                > applying it to this block:
                >
                > { {} {} }
                >
                > You need to include the recursion in the loop, something like this:
                >
                > nestedPair:
                > LBRACE
                > ( ~(LBRACE | RBRACE)
                > | nestedPair
                > )*
                > RBRACE
                > ;
                >
                > I tried sending this yesterday, but @#$%#@ Onelist screwed me over. Hope
                > this one gets out.
                >
                > Luke
                >
                > > -----Original Message-----
                > > From: William J. Koscho [mailto:wkoscho@...]
                > > Sent: Tuesday, September 07, 1999 7:58 PM
                > > To: antlr-interest@onelist.com
                > > Subject: Re: [antlr-interest] Help ignoring parts of the input
                > >
                > >
                > > From: "William J. Koscho" <wkoscho@...>
                > >
                > > Sinan & Monty,
                > >
                > > thanks for the help
                > >
                > > -bill
                > >
                >
                > --------------------------- ONElist Sponsor ----------------------------
                >
                > ONElist now has T-SHIRTS!
                > For details and to order, go to:
                > <a href=" http://clickme.onelist.com/ad/tshirt1 ">Click Here</a>
                >
                > ------------------------------------------------------------------------



                --

                William J. Koscho
                Software Engineer
                Syncsort Inc.

                email@work: wkoscho@...
                email@home: wkoscho@...

                --

                "They call their favorite software Satan,
                they call their computers demons,
                and the website of their leaders is called satanic.org."

                -The Linux Riots
              • Peter Williams
                Good point. I forgot about that. I actually have a lexer (not my java one though) that does return comments because I need the parse tree to be able to
                Message 7 of 11 , Sep 8 4:16 PM
                  Good point. I forgot about that.

                  I actually have a lexer (not my java one though) that does return comments
                  because I need the parse tree to be able to reconstruct an exact duplicate of
                  the user's code, comments included. It's a real pain, but fortunately, the
                  parser is not too complicated so it's not that bad.

                  -Peter

                  mzukowski@... wrote:

                  > From: mzukowski@...
                  >
                  > ? From: Peter Williams ?pete.williams@...?
                  > ?
                  > ? Just as an aside, if you want this rule to really work fully,
                  > ? then you need to
                  > ? add additional logic to 'body' to ignore // ... and /* ... */
                  > ? comments.
                  > ? Otherwise, brackets inside comments will screw you up.
                  >
                  > Yes, but presumably the lexer is already doing that when it recognizes
                  > comments. The parser should just see a COMMENT token and not know of any
                  > braces within it.
                  >
                  > However, this would be a problem if you were trying to match nested braces
                  > in the lexer instead of the parser.
                  >
                  > ?
                  > ? ? The above rule , even though correct in spirit, has too much of it.
                  > ? ?
                  > ? ? Should really read
                  > ? ?
                  > ? ? nestedPair:
                  > ? ? LBRACE
                  > ? ? (~(LBRACE | RBRACE) )*
                  > ? ? (nestedPair)? RBRACE
                  > ? ? ;
                  >
                  > Thanks for the correction Sinan! Right on the money.
                  >
                  > Monty
                  >
                  > --------------------------- ONElist Sponsor ----------------------------
                  >
                  > Enter ONElist's Friends ? Family Program
                  > WIN $100 to Amazon.com! Through Sept. 17. To enter, click here
                  > ?a href=" http://clickme.onelist.com/ad/ff "?Click Here?/a?
                  >
                  > ------------------------------------------------------------------------

                  --
                  Peter Williams mailto:pete.williams@...
                  Sun Microsystems, Inc. http://www.netdynamics.com/
                  MPK-30 Phone: (650) 463-7721
                  185 Constitution Drive Fax: (650) 617-5920
                  Menlo Park, CA 94025
                Your message has been successfully submitted and would be delivered to recipients shortly.