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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 =).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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
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 =).