-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: Use 4 spaces for indentation. #390
Conversation
|
token_with_location(value(Token::Indentation, tag(" "))), | ||
preceded(many0(tag(" ")), lex_token), | ||
), | ||
(lex_indent, preceded(many0(tag(" ")), lex_token)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking we should remove the preceded(many0(tag(" "))
part, since we're being more strict about indentation being four spaces.
(lex_indent, preceded(many0(tag(" ")), lex_token)), | |
(lex_indent, lex_token), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was expecting to remove that too, but it becomes clear pretty quickly that the preceded
parser in question is actually necessary to catch spaces between instructions tokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a concrete example of this? Instructions should not be separated by spaces afaik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, instructions was the wrong word there, I meant tokens
. Having an issue with my environment, but I'll share an example of how removing the preceded parser causes an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that makes more sense. In that case, it seems like separated_list0
or separated_list1
seems more correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I could be missing my shot in nom golf, but I can't figure out how to make that combinator work for this case. It doesn't satisfy the trait bounds of the other wrapping combinators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe my intent was something like this, which does change the signature of the right-hand parser from TokenWithLocation
to Vec<TokenWithLocation>
, but also seems more correct?
(lex_indent, preceded(many0(tag(" ")), lex_token)), | |
(lex_indent, separated_list1(space1, lex_token)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose, in order to make this "more correct", newline parsing would have to be handled by lex_indent
(since an indent is specifically a newline followed by four spaces). That seems like it would cause more code changes, since it seems like newlines are currently handled by lex_token
?
closes #385
TODO