Repository navigation
add: CPC_CHAR parser - #21
taimoorzaeem wants to merge 1 commit into
Conversation
Adds a single character parser. It also works with `CPC_LABEL`. Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
bb230d7 to
41c39d4
Compare
| if (input.len == 0) return cpc_res_err(input, "eof", err); \ | ||
| \ | ||
| if (input.ptr[0] == ch) \ | ||
| return cpc_res_take(input, 1); \ | ||
| else \ | ||
| return cpc_res_err(input, "mismatch", err); \ |
There was a problem hiding this comment.
Hm, I had a problem before when having two different error messages on CPC_STRING, check:
(for some reason github previews are not working here 😕 )
So before I also had two different error messages there, one for the short string and another for the mismatch.
The problem comes when overriding the error message with CPC_LABEL, what if we want to override only one? That's one of the reasons why before there was a more complex interface, a _LABEL variant for each parser. I removed those after #4.
So I'm thinking we should only have a single error message for each parser; only to not deal with a more complex interface.
WDYT? In Haskell you usually replace a single message from the original parser right? TBH I haven't researched this part very well, I just thought the current CPC_LABEL is good enough.
There was a problem hiding this comment.
The problem comes when overriding the error message with
CPC_LABEL, what if we want to override only one? That's one of the reasons why before there was a more complex interface, a_LABELvariant for each parser. I removed those after #4.So I'm thinking we should only have a single error message for each parser; only to not deal with a more complex interface.
WDYT? In Haskell you usually replace a single message from the original parser right? TBH I haven't researched this part very well, I just thought the current
CPC_LABELis good enough.
The above makes sense, will try to look into it.
Adds a single character parser. It also works with
CPC_LABEL.Closes #15.