summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2019-03-01 17:28:19 +0100
committerNadrieril2019-03-01 17:28:19 +0100
commite5d9aee00b0c775df1d8e2d8819aeb80dffa73c2 (patch)
treee763a24a0d635048232e72e167ca37eafec69369 /dhall
parent8a2b7536902831079eddd7b00291b718f5dd7186 (diff)
Split abnf_to_pest and dhall into their own crates
Diffstat (limited to '')
-rw-r--r--dhall/.gitignore1
-rw-r--r--dhall/Cargo.toml18
-rw-r--r--dhall/build.rs39
-rwxr-xr-xdhall/compare.fish (renamed from compare.fish)0
-rw-r--r--dhall/src/context.rs (renamed from src/context.rs)0
-rw-r--r--dhall/src/core.rs (renamed from src/core.rs)0
-rw-r--r--dhall/src/dhall.pest.visibility (renamed from src/dhall.pest.visibility)0
-rw-r--r--dhall/src/errors/AnnotMismatch.txt (renamed from src/errors/AnnotMismatch.txt)0
-rw-r--r--dhall/src/errors/CantTextAppend.txt (renamed from src/errors/CantTextAppend.txt)0
-rw-r--r--dhall/src/errors/DuplicateAlternative.txt (renamed from src/errors/DuplicateAlternative.txt)0
-rw-r--r--dhall/src/errors/FieldCollision.txt (renamed from src/errors/FieldCollision.txt)0
-rw-r--r--dhall/src/errors/HandlerInputTypeMismatch.txt (renamed from src/errors/HandlerInputTypeMismatch.txt)0
-rw-r--r--dhall/src/errors/HandlerNotAFunction.txt (renamed from src/errors/HandlerNotAFunction.txt)0
-rw-r--r--dhall/src/errors/HandlerOutputTypeMismatch.txt (renamed from src/errors/HandlerOutputTypeMismatch.txt)0
-rw-r--r--dhall/src/errors/IfBranchMismatch.txt (renamed from src/errors/IfBranchMismatch.txt)0
-rw-r--r--dhall/src/errors/IfBranchMustBeTerm.txt (renamed from src/errors/IfBranchMustBeTerm.txt)0
-rw-r--r--dhall/src/errors/InvalidAlterantive.txt (renamed from src/errors/InvalidAlterantive.txt)0
-rw-r--r--dhall/src/errors/InvalidAlterantiveType.txt (renamed from src/errors/InvalidAlterantiveType.txt)0
-rw-r--r--dhall/src/errors/InvalidField.txt (renamed from src/errors/InvalidField.txt)0
-rw-r--r--dhall/src/errors/InvalidFieldType.txt (renamed from src/errors/InvalidFieldType.txt)0
-rw-r--r--dhall/src/errors/InvalidInputType.txt (renamed from src/errors/InvalidInputType.txt)0
-rw-r--r--dhall/src/errors/InvalidListElement.txt (renamed from src/errors/InvalidListElement.txt)0
-rw-r--r--dhall/src/errors/InvalidListType.txt (renamed from src/errors/InvalidListType.txt)0
-rw-r--r--dhall/src/errors/InvalidOptionType.txt (renamed from src/errors/InvalidOptionType.txt)0
-rw-r--r--dhall/src/errors/InvalidOptionalElement.txt (renamed from src/errors/InvalidOptionalElement.txt)0
-rw-r--r--dhall/src/errors/InvalidOptionalLiteral.txt (renamed from src/errors/InvalidOptionalLiteral.txt)0
-rw-r--r--dhall/src/errors/InvalidOutputType.txt (renamed from src/errors/InvalidOutputType.txt)0
-rw-r--r--dhall/src/errors/InvalidPredicate.txt (renamed from src/errors/InvalidPredicate.txt)0
-rw-r--r--dhall/src/errors/MissingField.txt (renamed from src/errors/MissingField.txt)0
-rw-r--r--dhall/src/errors/MissingHandler.txt (renamed from src/errors/MissingHandler.txt)0
-rw-r--r--dhall/src/errors/MustCombineARecord.txt (renamed from src/errors/MustCombineARecord.txt)0
-rw-r--r--dhall/src/errors/MustMergeARecord.txt (renamed from src/errors/MustMergeARecord.txt)0
-rw-r--r--dhall/src/errors/MustMergeUnion.txt (renamed from src/errors/MustMergeUnion.txt)0
-rw-r--r--dhall/src/errors/NoDependentLet.txt (renamed from src/errors/NoDependentLet.txt)0
-rw-r--r--dhall/src/errors/NoDependentTypes.txt (renamed from src/errors/NoDependentTypes.txt)0
-rw-r--r--dhall/src/errors/NotAFunction.txt (renamed from src/errors/NotAFunction.txt)0
-rw-r--r--dhall/src/errors/NotARecord.txt (renamed from src/errors/NotARecord.txt)0
-rw-r--r--dhall/src/errors/TypeMismatch.txt (renamed from src/errors/TypeMismatch.txt)0
-rw-r--r--dhall/src/errors/UnboundVariable.txt (renamed from src/errors/UnboundVariable.txt)0
-rw-r--r--dhall/src/errors/Untyped.txt (renamed from src/errors/Untyped.txt)0
-rw-r--r--dhall/src/errors/UnusedHandler.txt (renamed from src/errors/UnusedHandler.txt)0
-rw-r--r--dhall/src/generated_parser.rs (renamed from src/generated_parser.rs)0
-rw-r--r--dhall/src/grammar.lalrpop (renamed from src/grammar.lalrpop)0
-rw-r--r--dhall/src/grammar_util.rs (renamed from src/grammar_util.rs)0
-rw-r--r--dhall/src/lexer.rs (renamed from src/lexer.rs)0
-rw-r--r--dhall/src/lib.rs (renamed from src/lib.rs)0
-rw-r--r--dhall/src/main.rs (renamed from src/main.rs)0
-rw-r--r--dhall/src/parser.rs (renamed from src/parser.rs)0
-rw-r--r--dhall/src/typecheck.rs (renamed from src/typecheck.rs)0
-rw-r--r--dhall/tests/macros.rs (renamed from tests/macros.rs)2
-rw-r--r--dhall/tests/tests.rs (renamed from tests/tests.rs)0
51 files changed, 59 insertions, 1 deletions
diff --git a/dhall/.gitignore b/dhall/.gitignore
new file mode 100644
index 0000000..8a0bac6
--- /dev/null
+++ b/dhall/.gitignore
@@ -0,0 +1 @@
+src/dhall.pest
diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml
new file mode 100644
index 0000000..d55d04e
--- /dev/null
+++ b/dhall/Cargo.toml
@@ -0,0 +1,18 @@
+[package]
+name = "dhall"
+version = "0.1.0"
+authors = ["NanoTech <nanotech@nanotechcorp.net>"]
+edition = "2018"
+build = "build.rs"
+
+[build-dependencies]
+lalrpop = "0.16.3"
+abnf_to_pest = { path = "../abnf_to_pest" }
+
+[dependencies]
+bytecount = "0.5.1"
+lalrpop-util = "0.16.3"
+nom = "3.0.0"
+term-painter = "0.2.3"
+pest = { git = "https://github.com/pest-parser/pest" }
+pest_derive = "2.0"
diff --git a/dhall/build.rs b/dhall/build.rs
new file mode 100644
index 0000000..9d5d8f7
--- /dev/null
+++ b/dhall/build.rs
@@ -0,0 +1,39 @@
+use std::fs::File;
+use std::io::{Read,Write,BufReader,BufRead};
+use std::collections::HashMap;
+
+use lalrpop;
+use abnf_to_pest::{PestRuleSettings, abnf_to_pest};
+
+fn main() -> std::io::Result<()> {
+ lalrpop::process_root().unwrap();
+ println!("cargo:rerun-if-changed=src/grammar.lalrpop");
+
+
+ let abnf_path = "../dhall-lang/standard/dhall.abnf";
+ let visibility_path = "src/dhall.pest.visibility";
+ let pest_path = "src/dhall.pest";
+ println!("cargo:rerun-if-changed={}", abnf_path);
+ println!("cargo:rerun-if-changed={}", visibility_path);
+
+ let mut file = File::open(abnf_path)?;
+ let mut data = Vec::new();
+ file.read_to_end(&mut data)?;
+ data.push('\n' as u8);
+
+ let mut rule_settings: HashMap<String, PestRuleSettings> = HashMap::new();
+ for line in BufReader::new(File::open(visibility_path)?).lines() {
+ let line = line?;
+ if line.len() >= 2 && &line[0..2] == "# " {
+ rule_settings.insert(line[2..].into(), PestRuleSettings { visible: false, ..Default::default() });
+ } else {
+ rule_settings.insert(line, PestRuleSettings { visible: true, ..Default::default() });
+ }
+ }
+
+ let mut file = File::create(pest_path)?;
+ writeln!(&mut file, "{}", abnf_to_pest(&data, &rule_settings)?)?;
+ writeln!(&mut file, "final_expression = _{{ SOI ~ complete_expression ~ EOI }}")?;
+
+ Ok(())
+}
diff --git a/compare.fish b/dhall/compare.fish
index 154f06a..154f06a 100755
--- a/compare.fish
+++ b/dhall/compare.fish
diff --git a/src/context.rs b/dhall/src/context.rs
index c2e1913..c2e1913 100644
--- a/src/context.rs
+++ b/dhall/src/context.rs
diff --git a/src/core.rs b/dhall/src/core.rs
index 473a6a6..473a6a6 100644
--- a/src/core.rs
+++ b/dhall/src/core.rs
diff --git a/src/dhall.pest.visibility b/dhall/src/dhall.pest.visibility
index c09fccf..c09fccf 100644
--- a/src/dhall.pest.visibility
+++ b/dhall/src/dhall.pest.visibility
diff --git a/src/errors/AnnotMismatch.txt b/dhall/src/errors/AnnotMismatch.txt
index 4904bf8..4904bf8 100644
--- a/src/errors/AnnotMismatch.txt
+++ b/dhall/src/errors/AnnotMismatch.txt
diff --git a/src/errors/CantTextAppend.txt b/dhall/src/errors/CantTextAppend.txt
index 26b9ceb..26b9ceb 100644
--- a/src/errors/CantTextAppend.txt
+++ b/dhall/src/errors/CantTextAppend.txt
diff --git a/src/errors/DuplicateAlternative.txt b/dhall/src/errors/DuplicateAlternative.txt
index 077f8aa..077f8aa 100644
--- a/src/errors/DuplicateAlternative.txt
+++ b/dhall/src/errors/DuplicateAlternative.txt
diff --git a/src/errors/FieldCollision.txt b/dhall/src/errors/FieldCollision.txt
index 2b2d260..2b2d260 100644
--- a/src/errors/FieldCollision.txt
+++ b/dhall/src/errors/FieldCollision.txt
diff --git a/src/errors/HandlerInputTypeMismatch.txt b/dhall/src/errors/HandlerInputTypeMismatch.txt
index 7d3525b..7d3525b 100644
--- a/src/errors/HandlerInputTypeMismatch.txt
+++ b/dhall/src/errors/HandlerInputTypeMismatch.txt
diff --git a/src/errors/HandlerNotAFunction.txt b/dhall/src/errors/HandlerNotAFunction.txt
index ff87443..ff87443 100644
--- a/src/errors/HandlerNotAFunction.txt
+++ b/dhall/src/errors/HandlerNotAFunction.txt
diff --git a/src/errors/HandlerOutputTypeMismatch.txt b/dhall/src/errors/HandlerOutputTypeMismatch.txt
index f359459..f359459 100644
--- a/src/errors/HandlerOutputTypeMismatch.txt
+++ b/dhall/src/errors/HandlerOutputTypeMismatch.txt
diff --git a/src/errors/IfBranchMismatch.txt b/dhall/src/errors/IfBranchMismatch.txt
index a95b130..a95b130 100644
--- a/src/errors/IfBranchMismatch.txt
+++ b/dhall/src/errors/IfBranchMismatch.txt
diff --git a/src/errors/IfBranchMustBeTerm.txt b/dhall/src/errors/IfBranchMustBeTerm.txt
index 4c15881..4c15881 100644
--- a/src/errors/IfBranchMustBeTerm.txt
+++ b/dhall/src/errors/IfBranchMustBeTerm.txt
diff --git a/src/errors/InvalidAlterantive.txt b/dhall/src/errors/InvalidAlterantive.txt
index 391fc3a..391fc3a 100644
--- a/src/errors/InvalidAlterantive.txt
+++ b/dhall/src/errors/InvalidAlterantive.txt
diff --git a/src/errors/InvalidAlterantiveType.txt b/dhall/src/errors/InvalidAlterantiveType.txt
index f5dadef..f5dadef 100644
--- a/src/errors/InvalidAlterantiveType.txt
+++ b/dhall/src/errors/InvalidAlterantiveType.txt
diff --git a/src/errors/InvalidField.txt b/dhall/src/errors/InvalidField.txt
index bfbf106..bfbf106 100644
--- a/src/errors/InvalidField.txt
+++ b/dhall/src/errors/InvalidField.txt
diff --git a/src/errors/InvalidFieldType.txt b/dhall/src/errors/InvalidFieldType.txt
index 4f76a64..4f76a64 100644
--- a/src/errors/InvalidFieldType.txt
+++ b/dhall/src/errors/InvalidFieldType.txt
diff --git a/src/errors/InvalidInputType.txt b/dhall/src/errors/InvalidInputType.txt
index eabafa4..eabafa4 100644
--- a/src/errors/InvalidInputType.txt
+++ b/dhall/src/errors/InvalidInputType.txt
diff --git a/src/errors/InvalidListElement.txt b/dhall/src/errors/InvalidListElement.txt
index 59db7b7..59db7b7 100644
--- a/src/errors/InvalidListElement.txt
+++ b/dhall/src/errors/InvalidListElement.txt
diff --git a/src/errors/InvalidListType.txt b/dhall/src/errors/InvalidListType.txt
index 676647e..676647e 100644
--- a/src/errors/InvalidListType.txt
+++ b/dhall/src/errors/InvalidListType.txt
diff --git a/src/errors/InvalidOptionType.txt b/dhall/src/errors/InvalidOptionType.txt
index 3bc81de..3bc81de 100644
--- a/src/errors/InvalidOptionType.txt
+++ b/dhall/src/errors/InvalidOptionType.txt
diff --git a/src/errors/InvalidOptionalElement.txt b/dhall/src/errors/InvalidOptionalElement.txt
index 0254220..0254220 100644
--- a/src/errors/InvalidOptionalElement.txt
+++ b/dhall/src/errors/InvalidOptionalElement.txt
diff --git a/src/errors/InvalidOptionalLiteral.txt b/dhall/src/errors/InvalidOptionalLiteral.txt
index 41c0fdc..41c0fdc 100644
--- a/src/errors/InvalidOptionalLiteral.txt
+++ b/dhall/src/errors/InvalidOptionalLiteral.txt
diff --git a/src/errors/InvalidOutputType.txt b/dhall/src/errors/InvalidOutputType.txt
index dd2695d..dd2695d 100644
--- a/src/errors/InvalidOutputType.txt
+++ b/dhall/src/errors/InvalidOutputType.txt
diff --git a/src/errors/InvalidPredicate.txt b/dhall/src/errors/InvalidPredicate.txt
index 4c15881..4c15881 100644
--- a/src/errors/InvalidPredicate.txt
+++ b/dhall/src/errors/InvalidPredicate.txt
diff --git a/src/errors/MissingField.txt b/dhall/src/errors/MissingField.txt
index de14a33..de14a33 100644
--- a/src/errors/MissingField.txt
+++ b/dhall/src/errors/MissingField.txt
diff --git a/src/errors/MissingHandler.txt b/dhall/src/errors/MissingHandler.txt
index 433445e..433445e 100644
--- a/src/errors/MissingHandler.txt
+++ b/dhall/src/errors/MissingHandler.txt
diff --git a/src/errors/MustCombineARecord.txt b/dhall/src/errors/MustCombineARecord.txt
index 141b969..141b969 100644
--- a/src/errors/MustCombineARecord.txt
+++ b/dhall/src/errors/MustCombineARecord.txt
diff --git a/src/errors/MustMergeARecord.txt b/dhall/src/errors/MustMergeARecord.txt
index 79094bd..79094bd 100644
--- a/src/errors/MustMergeARecord.txt
+++ b/dhall/src/errors/MustMergeARecord.txt
diff --git a/src/errors/MustMergeUnion.txt b/dhall/src/errors/MustMergeUnion.txt
index 68df70c..68df70c 100644
--- a/src/errors/MustMergeUnion.txt
+++ b/dhall/src/errors/MustMergeUnion.txt
diff --git a/src/errors/NoDependentLet.txt b/dhall/src/errors/NoDependentLet.txt
index fdc65b4..fdc65b4 100644
--- a/src/errors/NoDependentLet.txt
+++ b/dhall/src/errors/NoDependentLet.txt
diff --git a/src/errors/NoDependentTypes.txt b/dhall/src/errors/NoDependentTypes.txt
index 435bdcb..435bdcb 100644
--- a/src/errors/NoDependentTypes.txt
+++ b/dhall/src/errors/NoDependentTypes.txt
diff --git a/src/errors/NotAFunction.txt b/dhall/src/errors/NotAFunction.txt
index dd2695d..dd2695d 100644
--- a/src/errors/NotAFunction.txt
+++ b/dhall/src/errors/NotAFunction.txt
diff --git a/src/errors/NotARecord.txt b/dhall/src/errors/NotARecord.txt
index e0eebc8..e0eebc8 100644
--- a/src/errors/NotARecord.txt
+++ b/dhall/src/errors/NotARecord.txt
diff --git a/src/errors/TypeMismatch.txt b/dhall/src/errors/TypeMismatch.txt
index 4904bf8..4904bf8 100644
--- a/src/errors/TypeMismatch.txt
+++ b/dhall/src/errors/TypeMismatch.txt
diff --git a/src/errors/UnboundVariable.txt b/dhall/src/errors/UnboundVariable.txt
index bd7d483..bd7d483 100644
--- a/src/errors/UnboundVariable.txt
+++ b/dhall/src/errors/UnboundVariable.txt
diff --git a/src/errors/Untyped.txt b/dhall/src/errors/Untyped.txt
index 4904bf8..4904bf8 100644
--- a/src/errors/Untyped.txt
+++ b/dhall/src/errors/Untyped.txt
diff --git a/src/errors/UnusedHandler.txt b/dhall/src/errors/UnusedHandler.txt
index 2e46a12..2e46a12 100644
--- a/src/errors/UnusedHandler.txt
+++ b/dhall/src/errors/UnusedHandler.txt
diff --git a/src/generated_parser.rs b/dhall/src/generated_parser.rs
index 452b4cd..452b4cd 100644
--- a/src/generated_parser.rs
+++ b/dhall/src/generated_parser.rs
diff --git a/src/grammar.lalrpop b/dhall/src/grammar.lalrpop
index 150961f..150961f 100644
--- a/src/grammar.lalrpop
+++ b/dhall/src/grammar.lalrpop
diff --git a/src/grammar_util.rs b/dhall/src/grammar_util.rs
index c546a13..c546a13 100644
--- a/src/grammar_util.rs
+++ b/dhall/src/grammar_util.rs
diff --git a/src/lexer.rs b/dhall/src/lexer.rs
index 5b4dcaa..5b4dcaa 100644
--- a/src/lexer.rs
+++ b/dhall/src/lexer.rs
diff --git a/src/lib.rs b/dhall/src/lib.rs
index e07071d..e07071d 100644
--- a/src/lib.rs
+++ b/dhall/src/lib.rs
diff --git a/src/main.rs b/dhall/src/main.rs
index cdab3c0..cdab3c0 100644
--- a/src/main.rs
+++ b/dhall/src/main.rs
diff --git a/src/parser.rs b/dhall/src/parser.rs
index 057fce2..057fce2 100644
--- a/src/parser.rs
+++ b/dhall/src/parser.rs
diff --git a/src/typecheck.rs b/dhall/src/typecheck.rs
index 62ff7d2..62ff7d2 100644
--- a/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
diff --git a/tests/macros.rs b/dhall/tests/macros.rs
index 4b6d0d7..5ad2ab3 100644
--- a/tests/macros.rs
+++ b/dhall/tests/macros.rs
@@ -1,6 +1,6 @@
#[macro_export]
macro_rules! include_test_str {
- ($x:expr) => { include_str!(concat!("../dhall-lang/tests/", $x, ".dhall")) };
+ ($x:expr) => { include_str!(concat!("../../dhall-lang/tests/", $x, ".dhall")) };
}
#[macro_export]
diff --git a/tests/tests.rs b/dhall/tests/tests.rs
index 6a2ada8..6a2ada8 100644
--- a/tests/tests.rs
+++ b/dhall/tests/tests.rs