Skip to content

Commit

Permalink
feat(parse): add more whitespace presets
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Apr 18, 2020
1 parent 2708bbf commit 1398e2b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/parse/src/presets/whitespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { oneOf } from "../prims/one-of";
*/
export const WS = oneOf(" \t\n\r", "ws");

/**
* Matches single space or tab char.
*/
export const SPACE = oneOf(" \t", "space");

/**
* Matches single `\n` or `\r` char.
*/
Expand All @@ -20,9 +25,19 @@ export const DNL = discard(NL);
/**
* Zero or more {@link WS}. Result will be discarded.
*/
export const WS_0 = discard(zeroOrMore(WS, "ws0"));
export const WS_0 = discard(zeroOrMore(WS));

/**
* One or more {@link WS}. Result will be discarded.
*/
export const WS_1 = discard(oneOrMore(WS, "ws1"));
export const WS_1 = discard(oneOrMore(WS));

/**
* Zero or more {@link SPACE}. Result will be discarded.
*/
export const SPACE_0 = discard(zeroOrMore(SPACE));

/**
* One or more {@link SPACE}. Result will be discarded.
*/
export const SPACE_1 = discard(oneOrMore(SPACE));

0 comments on commit 1398e2b

Please sign in to comment.