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

Skipping white space when necessary.

Expand Messages
  • jagee@mmcable.com
    Thanks for reading this, My basic problem is that I need to skip all white space in about 95% of the language, but there is an instance where the n is
    Message 1 of 2 , Mar 20, 2001
    View Source
    • 0 Attachment
      Thanks for reading this,

      My basic problem is that I need to skip all white space in about 95%
      of the language, but there is an instance where the '\n' is
      important. Particularly, it is as follows:

      dictionaryContent
      :
      (
      name
      EOL
      |
      name
      dictionaryEntry
      EOL
      )*
      ;

      name
      :
      (
      FORWARD_SLASH STRING
      )
      ;

      dictionaryEntry
      :

      (
      array
      |
      CHAR
      |
      STRING
      |
      name
      )
      ;

      WS currently skips all white space in the lexer, and this works for
      the rest of the language, so I don't want to turn off skipping white
      space, but I also don't want to have to put EOL (defined as '\n' in
      the Lexer) throughout the entire rest of the language. Every time I
      try to parse the line:

      /test1
      /test2 /atribute

      it picks up test2 as an dictionaryEntry to test1, rather than
      returning and beginning the new rule with /test2 (i.e. it goes to
      option2 of dictionaryContent rule). Could anyone help? Thanks in
      advance.
    • mzukowski@bco.com
      You may have to move these rules from the parser into the lexer so you can get that EOL when you need it. Otherwise you have to somehow have the lexer detect
      Message 2 of 2 , Mar 20, 2001
      View Source
      • 0 Attachment
        RE: [antlr-interest] Skipping white space when necessary.

        You may have to move these rules from the parser into the lexer so you can get that EOL when you need it.  Otherwise you have to somehow have the lexer detect that it needs to preserve that newline.  Instead of using the ignore option you should handle whitespace with its own rule and setting its token type to Token.SKIP.  See examples/java/java.g for an example.

        Monty

        > -----Original Message-----
        > From: jagee@... [mailto:jagee@...]
        > Sent: Tuesday, March 20, 2001 9:45 AM
        > To: antlr-interest@yahoogroups.com
        > Subject: [antlr-interest] Skipping white space when necessary.
        >
        >
        > Thanks for reading this,
        >
        > My basic problem is that I need to skip all white space in about 95%
        > of the language, but there is an instance where the '\n' is
        > important.  Particularly, it is as follows:
        >
        > dictionaryContent
        >       :
        >           (
        >               name
        >               EOL
        >           |
        >               name
        >               dictionaryEntry        
        >               EOL
        >            )*        
        >       ;
        >
        > name
        >       :
        >           (  
        >               FORWARD_SLASH STRING
        >           )  
        >       ;
        >
        > dictionaryEntry
        >       :
        >      
        >           (
        >               array
        >           |
        >               CHAR
        >           |
        >               STRING
        >           |  
        >               name   
        >           )
        >       ;
        >
        > WS currently skips all white space in the lexer, and this works for
        > the rest of the language, so I don't want to turn off skipping white
        > space, but I also don't want to have to put EOL (defined as '\n' in
        > the Lexer) throughout the entire rest of the language. Every time I
        > try to parse the line:
        >
        > /test1
        > /test2 /atribute
        >
        > it picks up test2 as an dictionaryEntry to test1, rather than
        > returning and beginning the new rule with /test2 (i.e. it goes to
        > option2 of dictionaryContent rule).  Could anyone help?  Thanks in
        > advance.
        >
        >

        >
        > Your use of Yahoo! Groups is subject to
        > http://docs.yahoo.com/info/terms/
        >
        >
        >

      Your message has been successfully submitted and would be delivered to recipients shortly.