Skip to content
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

Make eval comment parsing more consistent #257

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/comment-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ Single-line eval comments have the following grammar:

```
[ \t]* # Leading whitespace
"-- $> " # Eval comment marker
"-- $>" # Eval comment marker
[ \t]* # Optional whitespace
[^\n]+ \n # Rest of line
```

Expand Down
12 changes: 11 additions & 1 deletion src/ghci/parse/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ fn eval_commands(input: &mut Located<&str>) -> PResult<VecDeque<ByteSpanCommand>
fn line_eval_command(input: &mut Located<&str>) -> PResult<ByteSpanCommand> {
let _ = space0.parse_next(input)?;
// TODO: Perhaps these eval markers should be customizable?
let _ = "-- $> ".parse_next(input)?;
let _ = "-- $>".parse_next(input)?;
let _ = space0.parse_next(input)?;
let (command, span) = until_newline.with_span().parse_next(input)?;
let command: GhciCommand = command.to_owned().into();

Expand Down Expand Up @@ -203,6 +204,15 @@ mod tests {
}
);

assert_eq!(
line_eval_command.parse(Located::new("-- $>foo\n")).unwrap(),
ByteSpanCommand {
command: "foo".to_owned().into(),
display_command: "foo".into(),
span: 5..9,
}
);

// Leading whitespace.
assert_eq!(
line_eval_command
Expand Down
Loading