summaryrefslogtreecommitdiff
path: root/dhall_generated_parser
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall_generated_parser/build.rs61
-rw-r--r--dhall_generated_parser/src/dhall.pest.visibility16
2 files changed, 50 insertions, 27 deletions
diff --git a/dhall_generated_parser/build.rs b/dhall_generated_parser/build.rs
index 5275097..c562fad 100644
--- a/dhall_generated_parser/build.rs
+++ b/dhall_generated_parser/build.rs
@@ -26,16 +26,15 @@ fn main() -> std::io::Result<()> {
rules.get_mut(&line[2..]).map(|x| x.silent = true);
}
}
- rules.remove("http");
- rules.remove("url_path");
- rules.remove("simple_label");
- rules.remove("nonreserved_label");
let mut file = File::create(pest_path)?;
writeln!(&mut file, "// AUTO-GENERATED FILE. See build.rs.")?;
- writeln!(&mut file, "{}", render_rules_to_pest(rules).pretty(80))?;
- writeln!(&mut file)?;
+ // TODO: this is a cheat; properly support RFC3986 URLs instead
+ rules.remove("url_path");
+ writeln!(&mut file, "url_path = _{{ path }}")?;
+
+ rules.remove("simple_label");
writeln!(
&mut file,
"simple_label = {{
@@ -43,30 +42,54 @@ fn main() -> std::io::Result<()> {
| !keyword ~ simple_label_first_char ~ simple_label_next_char*
}}"
)?;
- // TODO: this is a cheat; actually implement inline headers instead
- writeln!(
- &mut file,
- "http = {{
- http_raw
- ~ (whsp
- ~ using
- ~ whsp1
- ~ (import_hashed | ^\"(\" ~ whsp ~ import_hashed ~ whsp ~ ^\")\"))?
- }}"
- )?;
- // TODO: this is a cheat; properly support RFC3986 URLs instead
- writeln!(&mut file, "url_path = _{{ path }}")?;
+
+ rules.remove("nonreserved_label");
writeln!(
&mut file,
"nonreserved_label = _{{
!(builtin ~ !simple_label_next_char) ~ label
}}"
)?;
+
+ // Setup grammar for precedence climbing
+ rules.remove("operator_expression");
+ writeln!(&mut file, r##"
+ import_alt = {{ "?" ~ whsp1 }}
+ bool_or = {{ "||" }}
+ natural_plus = {{ "+" ~ whsp1 }}
+ text_append = {{ "++" }}
+ list_append = {{ "#" }}
+ bool_and = {{ "&&" }}
+ natural_times = {{ "*" }}
+ bool_eq = {{ "==" }}
+ bool_ne = {{ "!=" }}
+
+ operator = _{{
+ equivalent |
+ bool_ne |
+ bool_eq |
+ natural_times |
+ combine_types |
+ prefer |
+ combine |
+ bool_and |
+ list_append |
+ text_append |
+ natural_plus |
+ bool_or |
+ import_alt
+ }}
+ operator_expression = {{ application_expression ~ (whsp ~ operator ~ whsp ~ application_expression)* }}
+ "##)?;
+
writeln!(
&mut file,
"final_expression = ${{ SOI ~ complete_expression ~ EOI }}"
)?;
+ writeln!(&mut file)?;
+ writeln!(&mut file, "{}", render_rules_to_pest(rules).pretty(80))?;
+
// Generate pest parser manually to avoid spurious recompilations
let derived = {
let pest_path = "dhall.pest";
diff --git a/dhall_generated_parser/src/dhall.pest.visibility b/dhall_generated_parser/src/dhall.pest.visibility
index 6b4c974..dcebf45 100644
--- a/dhall_generated_parser/src/dhall.pest.visibility
+++ b/dhall_generated_parser/src/dhall.pest.visibility
@@ -84,10 +84,10 @@ Location
# Optional_fold
# Optional_build
# Text_show
-# combine
-# combine_types
-# equivalent
-# prefer
+combine
+combine_types
+equivalent
+prefer
lambda
forall
arrow
@@ -106,7 +106,7 @@ unquoted_path_component
quoted_path_component
path_component
path
-# local
+local
parent_path
here_path
home_path
@@ -141,10 +141,10 @@ hash
import_hashed
import
expression
-annotated_expression
+# annotated_expression
let_binding
empty_list_literal
-# operator_expression
+operator_expression
import_alt_expression
or_expression
plus_expression
@@ -160,7 +160,7 @@ not_equal_expression
equivalent_expression
application_expression
first_application_expression
-# import_expression
+import_expression
selector_expression
selector
labels