summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2019-03-02 17:12:41 +0100
committerNadrieril2019-03-02 17:13:01 +0100
commit17fd0dd6d7ab9ef9529be0b0d70fcea683c08603 (patch)
tree3d08f31e012e6399b503717028eb593abd651989
parent92b2aa7b84ec8211a1078c75c39806d1e79cf78c (diff)
Move part of parser into its own crate to limit recompilation times
Diffstat (limited to '')
-rw-r--r--Cargo.lock30
-rw-r--r--Cargo.toml3
-rw-r--r--dhall/Cargo.toml3
-rw-r--r--dhall/build.rs35
-rw-r--r--dhall/src/dhall.pest.visibility188
-rw-r--r--dhall/src/lib.rs3
-rw-r--r--dhall_parser/.gitignore (renamed from dhall/.gitignore)0
-rw-r--r--dhall_parser/Cargo.toml13
-rw-r--r--dhall_parser/build.rs34
-rw-r--r--dhall_parser/src/dhall.pest.visibility154
-rw-r--r--dhall_parser/src/lib.rs (renamed from dhall/src/generated_parser.rs)0
11 files changed, 221 insertions, 242 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 2ccf37d..c2e4b55 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -134,17 +134,25 @@ dependencies = [
name = "dhall"
version = "0.1.0"
dependencies = [
- "abnf_to_pest 0.1.0",
"bytecount 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dhall_parser 0.1.0",
"lalrpop 0.16.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lalrpop-util 0.16.3 (registry+https://github.com/rust-lang/crates.io-index)",
"nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 2.1.0 (git+https://github.com/pest-parser/pest)",
- "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"term-painter 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "dhall_parser"
+version = "0.1.0"
+dependencies = [
+ "abnf_to_pest 0.1.0",
+ "pest 2.1.0 (git+https://github.com/pest-parser/pest)",
+ "pest_derive 2.1.0",
+]
+
+[[package]]
name = "diff"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -346,7 +354,6 @@ dependencies = [
[[package]]
name = "pest"
version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -354,19 +361,17 @@ dependencies = [
[[package]]
name = "pest_derive"
version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pest 2.1.0",
+ "pest_generator 2.1.0",
]
[[package]]
name = "pest_generator"
version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "pest_meta 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pest 2.1.0",
+ "pest_meta 2.1.0",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -375,10 +380,9 @@ dependencies = [
[[package]]
name = "pest_meta"
version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pest 2.1.0",
"sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -807,10 +811,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409"
"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
"checksum pest 2.1.0 (git+https://github.com/pest-parser/pest)" = "<none>"
-"checksum pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54f0c72a98d8ab3c99560bfd16df8059cc10e1f9a8e83e6e3b97718dd766e9c3"
-"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
-"checksum pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646"
-"checksum pest_meta 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5a3492a4ed208ffc247adcdcc7ba2a95be3104f58877d0d02f0df39bf3efb5e"
"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662"
"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0"
diff --git a/Cargo.toml b/Cargo.toml
index 9aff88d..38d54f7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,7 @@
[workspace]
members = [
+ "abnf_to_pest",
"dhall",
- "abnf_to_pest"
+ "dhall_parser",
]
diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml
index d55d04e..4c6be34 100644
--- a/dhall/Cargo.toml
+++ b/dhall/Cargo.toml
@@ -7,7 +7,6 @@ build = "build.rs"
[build-dependencies]
lalrpop = "0.16.3"
-abnf_to_pest = { path = "../abnf_to_pest" }
[dependencies]
bytecount = "0.5.1"
@@ -15,4 +14,4 @@ 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"
+dhall_parser = { path = "../dhall_parser" }
diff --git a/dhall/build.rs b/dhall/build.rs
index 9d5d8f7..946841a 100644
--- a/dhall/build.rs
+++ b/dhall/build.rs
@@ -1,39 +1,6 @@
-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<()> {
+fn main() {
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/dhall/src/dhall.pest.visibility b/dhall/src/dhall.pest.visibility
deleted file mode 100644
index c09fccf..0000000
--- a/dhall/src/dhall.pest.visibility
+++ /dev/null
@@ -1,188 +0,0 @@
-# end_of_line
-# tab
-# block_comment
-# block_comment_chunk
-# block_comment_continue
-# not_end_of_line
-# line_comment
-# whitespace_chunk
-# whitespace
-# nonempty_whitespace
-# ALPHA
-# DIGIT
-# HEXDIG
-# simple_label
-# quoted_label
-# label
-# double_quote_chunk
-# double_quote_literal
-# single_quote_continue
-# single_quote_literal
-# text_literal
-# if_raw
-# then_raw
-# else_raw
-# let_raw
-# in_raw
-# as_raw
-# using_raw
-# merge_raw
-# missing_raw
-# Some_raw
-# constructors_raw
-# Natural_fold_raw
-# Natural_build_raw
-# Natural_isZero_raw
-# Natural_even_raw
-# Natural_odd_raw
-# Natural_toInteger_raw
-# Natural_show_raw
-# Integer_toDouble_raw
-# Integer_show_raw
-# Double_show_raw
-# List_build_raw
-# List_fold_raw
-# List_length_raw
-# List_head_raw
-# List_last_raw
-# List_indexed_raw
-# List_reverse_raw
-# Optional_fold_raw
-# Optional_build_raw
-# Text_show_raw
-# Bool_raw
-# Optional_raw
-# None_raw
-# Natural_raw
-# Integer_raw
-# Double_raw
-# Text_raw
-# List_raw
-# True_raw
-# False_raw
-# NaN_raw
-# Infinity_raw
-# Type_raw
-# Kind_raw
-# Sort_raw
-# reserved_raw
-# reserved_namespaced_raw
-# reserved
-# reserved_namespaced
-# if_
-# then_
-# else_
-# let_
-# in_
-# as_
-# using
-# merge
-# constructors
-# Some
-# Optional
-# Text
-# List
-# equal
-# or
-# plus
-# text_append
-# list_append
-# and
-# times
-# double_equal
-# not_equal
-# dot
-# open_brace
-# close_brace
-# open_bracket
-# close_bracket
-# open_angle
-# close_angle
-# bar
-# comma
-# open_parens
-# close_parens
-# at
-# colon
-# import_alt
-# combine
-# combine_types
-# prefer
-# lambda
-# forall
-# arrow
-# exponent
-# double_literal
-# natural_literal_raw
-integer_literal
-natural_literal
-# identifier
-# identifier_reserved_prefix
-# identifier_reserved_namespaced_prefix
-# missing
-# path_character
-# quoted_path_character
-# path_component
-# directory
-# file
-# local_raw
-# local
-# scheme
-# http_raw
-# authority
-# userinfo
-# host
-# port
-# IP_literal
-# IPvFuture
-# IPv6address
-# h16
-# ls32
-# IPv4address
-# dec_octet
-# reg_name
-# pchar
-# query
-# fragment
-# pct_encoded
-# unreserved
-# sub_delims
-# http
-# env
-# bash_environment_variable
-# posix_environment_variable
-# posix_environment_variable_character
-# import_type
-# hash
-# import_hashed
-# import
-# expression
-# annotated_expression
-# empty_collection
-# non_empty_optional
-# operator_expression
-# import_alt_expression
-# or_expression
-plus_expression
-# text_append_expression
-# list_append_expression
-# and_expression
-# combine_expression
-# prefer_expression
-# combine_types_expression
-times_expression
-# equal_expression
-# not_equal_expression
-# application_expression
-# import_expression
-# selector_expression
-# primitive_expression
-# labels
-# record_type_or_literal
-# non_empty_record_type_or_literal
-# non_empty_record_type
-# non_empty_record_literal
-# union_type_or_literal
-# non_empty_union_type_or_literal
-# non_empty_list_literal
-# complete_expression
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index e07071d..9dbd3a6 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -4,9 +4,8 @@ pub mod context;
mod core;
pub use crate::core::*;
use lalrpop_util::lalrpop_mod;
-lalrpop_mod!(pub grammar); // synthesized by LALRPOP
+lalrpop_mod!(pub grammar);
mod grammar_util;
-mod generated_parser;
pub mod lexer;
pub mod parser;
pub mod typecheck;
diff --git a/dhall/.gitignore b/dhall_parser/.gitignore
index 8a0bac6..8a0bac6 100644
--- a/dhall/.gitignore
+++ b/dhall_parser/.gitignore
diff --git a/dhall_parser/Cargo.toml b/dhall_parser/Cargo.toml
new file mode 100644
index 0000000..9993dce
--- /dev/null
+++ b/dhall_parser/Cargo.toml
@@ -0,0 +1,13 @@
+[package]
+name = "dhall_parser"
+version = "0.1.0"
+authors = ["Nadrieril <nadrieril@users.noreply.github.com>"]
+edition = "2018"
+build = "build.rs"
+
+[build-dependencies]
+abnf_to_pest = { path = "../abnf_to_pest" }
+
+[dependencies]
+pest = { git = "https://github.com/pest-parser/pest" }
+pest_derive = { version = "2.1", path = "../../pest/derive" }
diff --git a/dhall_parser/build.rs b/dhall_parser/build.rs
new file mode 100644
index 0000000..6001efe
--- /dev/null
+++ b/dhall_parser/build.rs
@@ -0,0 +1,34 @@
+use std::fs::File;
+use std::io::{Read,Write,BufReader,BufRead};
+use std::collections::HashMap;
+
+use abnf_to_pest::{PestRuleSettings, abnf_to_pest};
+
+fn main() -> std::io::Result<()> {
+ 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/dhall_parser/src/dhall.pest.visibility b/dhall_parser/src/dhall.pest.visibility
new file mode 100644
index 0000000..3e6ba45
--- /dev/null
+++ b/dhall_parser/src/dhall.pest.visibility
@@ -0,0 +1,154 @@
+end_of_line
+tab
+block_comment
+block_comment_chunk
+block_comment_continue
+not_end_of_line
+line_comment
+whitespace_chunk
+whitespace
+nonempty_whitespace
+ALPHA
+DIGIT
+HEXDIG
+simple_label_first_char
+simple_label_next_other_char
+simple_label_next_char
+simple_label_start
+simple_label
+quoted_label
+label_raw
+label
+double_quote_chunk
+double_quote_literal
+single_quote_continue
+single_quote_literal
+text_literal_raw
+if_raw
+then_raw
+else_raw
+let_raw
+in_raw
+as_raw
+using_raw
+merge_raw
+missing_raw
+Optional_raw
+Text_raw
+List_raw
+Infinity_raw
+if_
+then
+else_
+let_
+in_
+as_
+using
+merge
+Optional
+Text
+List
+equal
+or
+plus
+text_append
+list_append
+and
+times
+double_equal
+not_equal
+dot
+bar
+comma
+at
+colon
+import_alt
+open_parens
+close_parens_raw
+close_parens
+open_brace
+close_brace_raw
+close_brace
+open_bracket
+close_bracket_raw
+close_bracket
+open_angle
+close_angle_raw
+close_angle
+combine
+combine_types
+prefer
+lambda
+forall
+arrow
+exponent
+double_literal_raw
+natural_literal_raw
+integer_literal_raw
+identifier_raw
+identifier
+path_character
+quoted_path_character
+path_component
+path
+local_raw
+scheme
+http_raw
+authority
+userinfo
+host
+port
+IP_literal
+IPvFuture
+IPv6address
+h16
+ls32
+IPv4address
+dec_octet
+reg_name
+pchar
+query
+fragment
+pct_encoded
+unreserved
+sub_delims
+http
+env_raw
+bash_environment_variable
+posix_environment_variable
+posix_environment_variable_character
+import_type_raw
+hash_raw
+import_hashed_raw
+import_raw
+expression
+annotated_expression
+empty_collection
+non_empty_optional
+operator_expression
+import_alt_expression
+or_expression
+plus_expression
+text_append_expression
+list_append_expression
+and_expression
+combine_expression
+prefer_expression
+combine_types_expression
+times_expression
+equal_expression
+not_equal_expression
+application_expression
+import_expression_raw
+import_expression
+selector_expression_raw
+primitive_expression_raw
+labels_raw
+record_type_or_literal
+non_empty_record_type_or_literal
+non_empty_record_type
+non_empty_record_literal
+union_type_or_literal
+non_empty_union_type_or_literal
+non_empty_list_literal
+complete_expression
diff --git a/dhall/src/generated_parser.rs b/dhall_parser/src/lib.rs
index 452b4cd..452b4cd 100644
--- a/dhall/src/generated_parser.rs
+++ b/dhall_parser/src/lib.rs