Skip to content

Commit

Permalink
Bugfix: Parser could not handle files beginning/ending with newline. …
Browse files Browse the repository at this point in the history
…(Some editors automatically makes newline at EOF)
  • Loading branch information
mortenhaahr committed Jan 3, 2025
1 parent deaac4d commit 701c60e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::BTreeMap;
use std::fmt::Debug;
use winnow::ascii::dec_uint;
use winnow::ascii::line_ending;
use winnow::ascii::multispace0;
use winnow::combinator::*;
use winnow::token::{literal, take_until};
use winnow::PResult;
Expand Down Expand Up @@ -372,13 +373,13 @@ fn var_decls(s: &mut &str) -> PResult<Vec<(VarName, SExpr<VarName>)>> {

pub fn lola_specification(s: &mut &str) -> PResult<LOLASpecification> {
seq!((
_: whitespace,
_: multispace0,
input_decls,
_: alt((linebreak.void(), empty)),
output_decls,
_: alt((linebreak.void(), empty)),
var_decls,
_: whitespace,
_: multispace0,
))
.map(|(input_vars, output_vars, exprs)| LOLASpecification {
input_vars: input_vars.iter().map(|(name, _)| name.clone()).collect(),
Expand Down

0 comments on commit 701c60e

Please sign in to comment.