-
-
Save takeoutweight/2338894 to your computer and use it in GitHub Desktop.
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
;Hrm... I actually tried a similar approach before but: | |
(def identifier2 | |
(around | |
whitespaces | |
(choice | |
[(*> (string "#") | |
(<* number (string "#"))) | |
(*> (string "#") | |
(<* number (string "=")))]))) | |
(z/parse-once identifier2 "#234=") | |
#zetta.core.ResultFailure{:remainder (\=), :stack [], :msg "Failed reading: take-with"} | |
parse> (z/parse-once identifier2 "#234#") | |
#zetta.core.ResultDone{:remainder (), :result 234} | |
;I think i probably should read some attoparsec tutorials -- I'm pretty ignorant of the basics so I'm not ;sure where to begin fixing (i.e. maybe I've just built things wrong or loaded something incorrectly...) |
(def id3
(around whitespaces (*> (char \#)
(<* number (choice [(char \=)
char \#)])))))
Try this one out
Yep that parses for me now. Am I able to distinguish between which choice is made with this approach? (i.e I want #'s to mean reference ids and ='s to mean id definitions)
I guess the trick would be not to throw away the parsed = and #, but throw the number and the matched char to a higher function with <$> ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you change the order on the choice vector, the = works but the # doesn't...
uhmm it seems we have an issue here with the buffer not having the content back after going to the next choice :-/
Need to figure out why that's happening