From a735ba76848080e3eb9a0648ae54ab5cf5966067 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Wed, 10 Nov 2021 23:36:15 +0000 Subject: [PATCH] fix: in comments, eof should be allowed in place of eol --- --- a/crates/jrsonnet-parser/src/lib.rs +++ b/crates/jrsonnet-parser/src/lib.rs @@ -30,11 +30,14 @@ grammar jsonnet_parser() for str { use peg::ParseLiteral; + rule eof() = quiet!{![_]} / expected!("") + rule eol() = "\n" / eof() + /// Standard C-like comments rule comment() - = "//" (!['\n'][_])* "\n" + = "//" (!eol()[_])* eol() / "/*" ("\\*/" / "\\\\" / (!("*/")[_]))* "*/" - / "#" (!['\n'][_])* "\n" + / "#" (!eol()[_])* eol() rule single_whitespace() = quiet!{([' ' | '\r' | '\n' | '\t'] / comment())} / expected!("") rule _() = single_whitespace()* @@ -562,6 +565,15 @@ } #[test] + fn missing_newline_between_comment_and_eof() { + parse!( + "{a:1} + + //+213" + ); + } + + #[test] fn default_param_before_nondefault() { parse!("local x(foo = 'foo', bar) = null; null"); } -- gitstuff