From 72ad56209fe10e3120c19ca5b820ff267423ab1d Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 11 Apr 2020 15:41:21 +0100 Subject: spec: fix precedence of `===` and `with` --- dhall/src/syntax/text/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dhall/src/syntax/text/parser.rs') diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index 1e1449c..e870db3 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -130,6 +130,7 @@ lazy_static::lazy_static! { use Rule::*; // In order of precedence let operators = vec![ + equivalent, import_alt, bool_or, natural_plus, @@ -142,7 +143,6 @@ lazy_static::lazy_static! { natural_times, bool_eq, bool_ne, - equivalent, ]; PrecClimber::new( operators -- cgit v1.2.3 From e3cdf3f386b6a682981e6bdf6ca6d215b0d0788d Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 25 Jun 2020 14:06:24 +0100 Subject: spec: not all ABNF parsers like empty rules --- dhall/src/syntax/text/parser.rs | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'dhall/src/syntax/text/parser.rs') diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index e870db3..1c51ca2 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -909,26 +909,19 @@ impl DhallParser { )) } - #[alias(record_type_or_literal)] - fn empty_record_literal(input: ParseInput) -> ParseResult { - Ok(RecordLit(Default::default())) - } - - #[alias(record_type_or_literal)] - fn empty_record_type(input: ParseInput) -> ParseResult { - Ok(RecordType(Default::default())) - } - - #[alias(record_type_or_literal)] - fn non_empty_record_type_or_literal( - input: ParseInput, - ) -> ParseResult { + fn record_type_or_literal(input: ParseInput) -> ParseResult { Ok(match_nodes!(input.children(); + [empty_record_literal(_)] => RecordLit(Default::default()), [non_empty_record_type(map)] => RecordType(map), [non_empty_record_literal(map)] => RecordLit(map), + [] => RecordType(Default::default()), )) } + fn empty_record_literal(input: ParseInput) -> ParseResult<()> { + Ok(()) + } + fn non_empty_record_type( input: ParseInput, ) -> ParseResult> { @@ -997,8 +990,7 @@ impl DhallParser { } fn union_type(input: ParseInput) -> ParseResult { - let map = match_nodes!(input.children(); - [empty_union_type(_)] => Default::default(), + Ok(match_nodes!(input.children(); [union_type_entry(entries)..] => { let mut map = BTreeMap::default(); for (l, t) in entries { @@ -1015,14 +1007,9 @@ impl DhallParser { } } } - map + UnionType(map) }, - ); - Ok(UnionType(map)) - } - - fn empty_union_type(_input: ParseInput) -> ParseResult<()> { - Ok(()) + )) } fn union_type_entry( @@ -1065,7 +1052,7 @@ pub fn parse_expr(input_str: &str) -> ParseResult { } #[test] -#[ignore] +#[cfg_attr(windows, ignore)] // Check that the local copy of the grammar file is in sync with the one from dhall-lang. fn test_grammar_files_in_sync() { use std::process::Command; @@ -1079,8 +1066,8 @@ fn test_grammar_files_in_sync() { .arg("--ignore-space-change") .arg("--color") .arg("--") - .arg(spec_abnf_path) .arg(local_abnf_path) + .arg(spec_abnf_path) .output() .expect("failed to run `git diff` command"); -- cgit v1.2.3 From 8fd2fb4871335c72b9448da4a66144fd7f986f09 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 25 Jun 2020 14:21:02 +0100 Subject: spec!: remove the ability to quote paths in URLs --- dhall/src/syntax/text/parser.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'dhall/src/syntax/text/parser.rs') diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index 1c51ca2..06c1ac3 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -514,14 +514,14 @@ impl DhallParser { fn http_raw(input: ParseInput) -> ParseResult> { Ok(match_nodes!(input.into_children(); - [scheme(sch), authority(auth), url_path(p)] => URL { + [scheme(sch), authority(auth), path_abempty(p)] => URL { scheme: sch, authority: auth, path: p, query: None, headers: None, }, - [scheme(sch), authority(auth), url_path(p), query(q)] => URL { + [scheme(sch), authority(auth), path_abempty(p), query(q)] => URL { scheme: sch, authority: auth, path: p, @@ -531,10 +531,10 @@ impl DhallParser { )) } - fn url_path(input: ParseInput) -> ParseResult { + fn path_abempty(input: ParseInput) -> ParseResult { Ok(match_nodes!(input.into_children(); - [path_component(components)..] => { - let mut file_path: Vec<_> = components.collect(); + [segment(segments)..] => { + let mut file_path: Vec<_> = segments.collect(); // An empty path normalizes to "/" if file_path.is_empty() { file_path = vec!["".to_owned()]; @@ -548,7 +548,6 @@ impl DhallParser { Ok(input.as_str().to_owned()) } - #[alias(path_component)] fn segment(input: ParseInput) -> ParseResult { Ok(input.as_str().to_string()) } -- cgit v1.2.3