-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add startsWith, endsWith, entireLine, entirely - add wrap() - rename dalt/dseq => altD/seqD
- Loading branch information
1 parent
719b437
commit e4eab03
Showing
4 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Parser } from "../api"; | ||
import { inputEnd, inputStart, lineEnd, lineStart } from "../prims/anchor"; | ||
import { seq } from "./seq"; | ||
|
||
export const startsWith = <T>(parser: Parser<T>) => seq([inputStart, parser]); | ||
|
||
export const endsWith = <T>(parser: Parser<T>) => seq([parser, inputEnd]); | ||
|
||
export const entireLine = (parser: Parser<string>) => | ||
seq([lineStart, parser, lineEnd]); | ||
|
||
export const entirely = <T>(parser: Parser<T>) => | ||
seq([inputStart, parser, inputEnd]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Parser } from "../api"; | ||
import { litD } from "../prims/lit"; | ||
import { hoist } from "../xform/hoist"; | ||
import { seq } from "./seq"; | ||
|
||
export const wrap = <T>( | ||
parser: Parser<T>, | ||
pre: T, | ||
post: T = pre, | ||
id = "wrap" | ||
) => hoist(seq([litD(pre), parser, litD(post)], id)); |