Menu

Matching space with Literal

2006-01-24
2013-05-14
  • Jacek Sieka

    Jacek Sieka - 2006-01-24

    Hi,

    I'm working on a simple parser for a format where whitespace is significant, so I've used setDefaultWhitespaceChars to "" (empty string), and I'd like to use a Literal to match a space, but unfortunately I've found that Literal strips spaces.  I've reverted to using a Regex, but that seems like overkill to me, so I was hoping there'd be some what around this?

    Best regards
    Jacek Sieka

     
    • Paul McGuire

      Paul McGuire - 2006-01-26

      If you want to match whitespace, you should use the White class.

      I realize now, though, that Literal should *not* strip leading whitespace.  I'll fix this for 1.4.1.

      -- Paul

       
    • Jacek Sieka

      Jacek Sieka - 2006-01-26

      Thanks for the reply.

      I wasn't very clear, but actually the format is a semi-binary one where whitespace just isn't special in any way - just another character code. Sometimes tokens start with a space or another whitespace character, sometimes they don't, so in many cases the most 'natural' way of mapping it would be with a Literal (I think =).

       

Log in to post a comment.