wipe backup

This commit is contained in:
Michael Zhang 2022-05-09 12:09:57 -05:00
parent afcf9577d2
commit 40ed90b60a
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
7 changed files with 55 additions and 46 deletions

60
Cargo.lock generated
View file

@ -2,18 +2,18 @@
# It is not intended for manual editing.
[[package]]
name = "aho-corasick"
version = "0.7.13"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.32"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b"
checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
[[package]]
name = "capgen"
@ -25,12 +25,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "maplit"
version = "1.0.2"
@ -39,51 +33,50 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "memchr"
version = "2.3.3"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "proc-macro2"
version = "1.0.21"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c"
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.3.9"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
name = "regex-syntax"
version = "0.6.18"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "syn"
version = "1.0.41"
version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b"
checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
dependencies = [
"proc-macro2",
"quote",
@ -92,35 +85,26 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.20"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08"
checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.20"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "thread_local"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
dependencies = [
"lazy_static",
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"

View file

@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.32"
regex = "1.3.9"
thiserror = "1.0.20"
anyhow = "1.0.40"
regex = "1.5.4"
thiserror = "1.0.25"
maplit = "1.0.2"

View file

@ -4,8 +4,8 @@ use crate::grammar::Grammar;
use crate::lr0item::Lr0Item;
pub struct CanonicalCollection<'g> {
grammar: &'g Grammar,
sets: HashSet<HashSet<Lr0Item>>,
pub grammar: &'g Grammar,
pub sets: HashSet<HashSet<Lr0Item>>,
}
impl<'g> CanonicalCollection<'g> {
@ -25,4 +25,8 @@ impl<'g> CanonicalCollection<'g> {
// add the start items
}
pub fn run(&self, input: &[u8]) {
}
}

View file

@ -27,8 +27,7 @@ impl Grammar {
}
} else if self.is_nonterminal(name) {
let x = name;
let productions =
self.productions.get(name).unwrap();
let productions = self.productions.get(name).unwrap();
for production in productions.iter() {
// has ε shown up in every FIRST set so far?
let mut is_epsilon_in_all_sets = false;

View file

@ -4,6 +4,7 @@ use std::collections::{HashMap, HashSet};
use regex::Regex;
use crate::canonical_collection::CanonicalCollection;
use crate::lr0item::Lr0Item;
use crate::utils::MapOfSet;
@ -38,8 +39,15 @@ impl Grammar {
self.productions.contains_key(name.as_ref())
}
pub fn build(&mut self) {
pub fn build(&mut self) -> CanonicalCollection {
self.build_context_sets();
let sets = HashSet::new();
CanonicalCollection {
grammar: self,
sets,
}
}
pub fn closure(&self, I: HashSet<Lr0Item>) -> HashSet<Lr0Item> {

View file

@ -22,6 +22,20 @@ fn main() -> Result<()> {
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let mut grammar = make_grammar! {
E_ -> E,
E -> E p T | T,
T -> T a F | F,
F -> lp E rp | num,
%
p -> r"\+",
a -> r"\*",
lp -> r"\(",
rp -> r"\)",
num -> r"[0-9]+",
};
grammar.build();
println!("Hello, world!");
Ok(())
}

0
test.bnf Normal file
View file