Skip to content

Add other Clojure accepted whitespace to reader  #4

@Tko1

Description

@Tko1

File affected: reader.rs

Reader right now is

  1. Often using nom's ws macro to consume whitespace around a read, and to my knowledge this is deprecated.

  2. Only looking for traditional whitespace. In Clojure, however, , is considered whitespace as well, and this case needs to be added, as well as any edge case I've never heard of if one exists

So, the preferable solution is to create a parsing function for clojure whitespace, ie something like

// This is named clojure_whitespace rather than whitespace to emphasize this is consuming
// what Clojure considers to be whitespace, including the , 
// Am open to a better name 
pub fn clojure_whitespace_parser(input:&[u8]) -> IResult<&[u8], String> {
   ...
}

And then, instead of combining this with another parser with nom's macros like

    named!(someParserThatConsumesWhitespaceFirst,
	   ws!(tag!("}")));

We would use some function combinator, like preceded

let someParserThatConsumesWhitespaceFirst = preceded(clojure_whitespace_parser, ... )

This would involve updating all spots that currently consume whitespace, which should be

  1. try_read
  2. try_read_map
  3. try_read_string
  4. try_read_vector
  5. try_read_list

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions