Skip to content

Example of registers usage #176

Answered by j-mie6
Truedrog asked this question in Q&A
Apr 2, 2023 · 4 comments · 4 replies
Discussion options

You must be logged in to vote

What you want is basically a charReg combinator, as I understand it:

def charReg(r: Reg[Char]): Parsley[Char] = r.gets(char(_)).flatten

The problem is that this combinator would be implemented by flatten (or join as you'd call it), and as you note this is inefficient. I haven't implemented a built-in version of charReg/satisfyReg yet, which would be efficient, but that is something I do want to add when I get some spare time again!

I would also love to add some examples of registers too, it is absolutely on my TODO list. To be clear about the charReg combinator above, I'm envisioning you'd use it like sepReg.put(datesepchar) and then use charReg(sepReg) for the second invokation.

Instead,…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@j-mie6
Comment options

@j-mie6
Comment options

Comment options

You must be logged in to vote
2 replies
@j-mie6
Comment options

@j-mie6
Comment options

Answer selected by j-mie6
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants