Skip to content

Is matching EOF considered a "consume" for the repeat combinator? #523

Answered by Nahor
DavidAntliff asked this question in Q&A
Discussion options

You must be logged in to vote

eof doesn't not consume because it can't, by definition. It means "end-of-file", i.e "there-is-nothing-left-to-consume".

As for your problem, you have "repeat(line_w_newline or line_wo_newline)", which implies that you could have "<line_wo_newline><line_w_newline>", which makes no sense. So what you need is "repeat(line_w_newline) then maybe line_wo_newline" (as you said yourself in your BNF grammar)

But probably a better way of thinking is to not see the newline character as part of the line, but as a separator (see separated())

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
6 replies
@DavidAntliff
Comment options

@DavidAntliff
Comment options

@epage
Comment options

@DavidAntliff
Comment options

@epage
Comment options

Comment options

You must be logged in to vote
3 replies
@DavidAntliff
Comment options

@Nahor
Comment options

@DavidAntliff
Comment options

Answer selected by DavidAntliff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants