mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-10-26 14:05:36 +03:00
WIP reorganization
This commit is contained in:
parent
0ac2f2bf2c
commit
e153fa3e1c
@ -1,4 +1,5 @@
|
||||
use super::{hvm_lang::DefNames, DefId};
|
||||
use super::DefId;
|
||||
use crate::term::DefNames;
|
||||
use hvmc::{show_lnet, val_to_name, LNet};
|
||||
use itertools::Itertools;
|
||||
use std::collections::HashMap;
|
||||
|
@ -1,8 +1,6 @@
|
||||
pub mod compat;
|
||||
pub mod core;
|
||||
pub mod hvm_lang;
|
||||
|
||||
pub use hvm_lang::{Definition, DefinitionBook, Rule, Term};
|
||||
pub use crate::term::{Definition, DefinitionBook, Rule, Term};
|
||||
|
||||
use derive_more::{Display, From, Into};
|
||||
use hvmc::Val;
|
||||
|
@ -1,15 +1,15 @@
|
||||
use crate::ast::{
|
||||
compat::{
|
||||
use crate::{
|
||||
ast::{var_id_to_name, DefId, Name, Term},
|
||||
net::inter_net::{
|
||||
addr, enter, kind, link, new_inet, new_node, port, slot, INet, INode, INodes, NodeId, NodeKind, Port,
|
||||
SlotId, CON, DUP, ERA, ITE, LABEL_MASK, REF, ROOT, TAG_MASK,
|
||||
},
|
||||
hvm_lang::Op,
|
||||
var_id_to_name, DefId, DefinitionBook, Name, Term,
|
||||
term::{DefinitionBook, Op},
|
||||
};
|
||||
use hvmc::{LNet, LTree, Val};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use crate::ast::compat::{label_to_op, NUM, OP2};
|
||||
use crate::net::inter_net::{label_to_op, NUM, OP2};
|
||||
|
||||
pub fn readback_net(net: &LNet, book: &DefinitionBook) -> anyhow::Result<(Term, bool)> {
|
||||
/* check_lnet_valid(net)?; */
|
||||
|
@ -3,19 +3,20 @@
|
||||
|
||||
pub mod ast;
|
||||
pub mod from_core;
|
||||
pub mod loader;
|
||||
pub mod parser;
|
||||
pub mod net;
|
||||
pub mod semantic;
|
||||
pub mod term;
|
||||
pub mod to_core;
|
||||
|
||||
use ast::{core::Book, hvm_lang::DefNames, DefinitionBook, Term};
|
||||
use ast::{core::Book, DefinitionBook, Term};
|
||||
use from_core::readback_net;
|
||||
use hvmc::{readback_lnet, LNet};
|
||||
use semantic::check_main;
|
||||
use std::time::Instant;
|
||||
use term::DefNames;
|
||||
use to_core::{book_to_hvm_core, book_to_hvm_internal};
|
||||
|
||||
pub use loader::load_file_to_book;
|
||||
pub use crate::term::load_book::load_file_to_book;
|
||||
|
||||
pub fn check_book(mut book: DefinitionBook) -> anyhow::Result<()> {
|
||||
// TODO: Do the checks without having to do full compilation
|
||||
|
@ -1,6 +1,6 @@
|
||||
// TODO: Refactor to not use this intermediate form
|
||||
|
||||
use super::hvm_lang::Op;
|
||||
use crate::term::Op;
|
||||
use hvmc::Val;
|
||||
|
||||
#[derive(Clone, Debug)]
|
1
src/net/mod.rs
Normal file
1
src/net/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod inter_net;
|
@ -1,11 +1,9 @@
|
||||
/// Semantic checking
|
||||
use crate::ast::{DefinitionBook, Name};
|
||||
|
||||
pub mod combinators;
|
||||
/// Semantic passes for pattern matching on defiinition rules.
|
||||
/// Extract ADTs from patterns in a book, then convert them into lambda calculus.
|
||||
pub mod pattern;
|
||||
pub mod supercombinators;
|
||||
pub mod vars;
|
||||
|
||||
pub fn check_main(book: &DefinitionBook) -> anyhow::Result<()> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::ast::{
|
||||
hvm_lang::{DefNames, Pattern},
|
||||
DefId, Definition, DefinitionBook, Name, Rule, Term,
|
||||
use crate::{
|
||||
ast::{DefId, Definition, DefinitionBook, Name, Rule, Term},
|
||||
term::{DefNames, Pattern},
|
||||
};
|
||||
use hvmc::Val;
|
||||
use std::collections::HashSet;
|
||||
|
@ -1,5 +1,8 @@
|
||||
use super::{Adt, AdtId, Type};
|
||||
use crate::ast::{hvm_lang::Pattern, DefId, Definition, DefinitionBook, Name};
|
||||
use crate::{
|
||||
ast::{DefId, Definition, DefinitionBook, Name},
|
||||
term::Pattern,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use itertools::Itertools;
|
||||
use std::collections::HashMap;
|
||||
|
@ -1,4 +1,7 @@
|
||||
use crate::ast::{hvm_lang::DefNames, var_id_to_name, DefinitionBook, Name, Term};
|
||||
use crate::{
|
||||
ast::{var_id_to_name, DefinitionBook, Name, Term},
|
||||
term::DefNames,
|
||||
};
|
||||
use hvmc::Val;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::{ast::DefinitionBook, parser::parse_definition_book};
|
||||
use super::parser::parse_definition_book;
|
||||
use crate::ast::DefinitionBook;
|
||||
use ariadne::{Color, Label, Report, ReportKind, Source};
|
||||
use chumsky::prelude::Rich;
|
||||
use itertools::Itertools;
|
@ -1,4 +1,8 @@
|
||||
use super::{DefId, Name};
|
||||
pub mod load_book;
|
||||
pub mod parser;
|
||||
pub mod transform;
|
||||
|
||||
use crate::ast::{DefId, Name};
|
||||
use bimap::{BiHashMap, Overwritten};
|
||||
use itertools::Itertools;
|
||||
use std::fmt;
|
0
src/term/net_to_term/.gitkeep
Normal file
0
src/term/net_to_term/.gitkeep
Normal file
@ -1,4 +1,4 @@
|
||||
mod lexer;
|
||||
mod parser;
|
||||
pub mod lexer;
|
||||
pub mod parser;
|
||||
|
||||
pub use parser::{parse_definition_book, parse_term};
|
@ -1,7 +1,7 @@
|
||||
use super::lexer::LexingError;
|
||||
use super::lexer::{LexingError, Token};
|
||||
use crate::{
|
||||
ast::{hvm_lang::Pattern, DefId, Definition, DefinitionBook, Name, Rule, Term},
|
||||
parser::lexer::Token,
|
||||
ast::{DefId, Definition, DefinitionBook, Name, Rule, Term},
|
||||
term::{Op, Pattern},
|
||||
};
|
||||
use chumsky::{
|
||||
extra,
|
||||
@ -17,7 +17,7 @@ use itertools::Itertools;
|
||||
use logos::{Logos, SpannedIter};
|
||||
use std::{iter::Map, ops::Range};
|
||||
|
||||
use crate::ast::hvm_lang::Op;
|
||||
// use crate::ast::hvm_lang::Op;
|
||||
|
||||
// TODO: Pattern matching on rules
|
||||
// TODO: Other types of numbers
|
0
src/term/sanitize/.gitkeep
Normal file
0
src/term/sanitize/.gitkeep
Normal file
0
src/term/term_to_net/.gitkeep
Normal file
0
src/term/term_to_net/.gitkeep
Normal file
@ -1,6 +1,6 @@
|
||||
use crate::ast::{
|
||||
hvm_lang::{DefNames, Op},
|
||||
Definition, DefinitionBook, Name, Rule, Term,
|
||||
use crate::{
|
||||
ast::{Definition, DefinitionBook, Name, Rule, Term},
|
||||
term::{DefNames, Op},
|
||||
};
|
||||
|
||||
impl DefinitionBook {
|
@ -1,4 +1,7 @@
|
||||
use crate::ast::{hvm_lang::DefNames, DefId, Definition, DefinitionBook, Name, Rule, Term};
|
||||
use crate::{
|
||||
ast::{DefId, Definition, DefinitionBook, Name, Rule, Term},
|
||||
term::DefNames,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// Replaces closed Terms (i.e. without free variables) with a Ref to the extracted term
|
2
src/term/transform/mod.rs
Normal file
2
src/term/transform/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod detach_combinators;
|
||||
pub mod detach_supercombinators;
|
0
src/term/unsanitize/.gitkeep
Normal file
0
src/term/unsanitize/.gitkeep
Normal file
@ -1,14 +1,14 @@
|
||||
use crate::ast::{
|
||||
compat::{
|
||||
use crate::{
|
||||
ast::{var_id_to_name, DefId, Name, Term},
|
||||
net::inter_net::{
|
||||
addr, enter, kind, link, new_inet, new_node, port, slot, INet, NodeId, Port, CON, DUP, ERA, ITE,
|
||||
LABEL_MASK, REF, ROOT, TAG_MASK,
|
||||
},
|
||||
var_id_to_name, DefId, Name, Term,
|
||||
};
|
||||
use hvmc::{LNet, LTree, Tag};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use crate::ast::compat::{op_to_label, NodeKind, NUM, OP2};
|
||||
use crate::net::inter_net::{op_to_label, NodeKind, NUM, OP2};
|
||||
|
||||
/// Converts an IC term into an IC net.
|
||||
pub fn term_to_compat_net(term: &Term) -> anyhow::Result<INet> {
|
||||
|
@ -27,7 +27,6 @@ pub fn term_to_hvm_core(term: &Term) -> anyhow::Result<LNet> {
|
||||
}
|
||||
|
||||
pub fn book_to_hvm_internal(book: &Book, mem_size: usize) -> anyhow::Result<(hvmc::Net, hvmc::Book)> {
|
||||
|
||||
// TODO: Don't try to preallocate a huge buffer
|
||||
let mut root = hvmc::Net::new(mem_size);
|
||||
root.boot(book.main.to_internal()); // TODO: Don't use this workaround
|
||||
|
@ -2,9 +2,11 @@ use hvm_lang::{
|
||||
ast::{DefId, DefinitionBook},
|
||||
compile_book,
|
||||
from_core::readback_net,
|
||||
loader::{display_err_for_text, display_miette_err},
|
||||
parser::{parse_definition_book, parse_term},
|
||||
run_book,
|
||||
term::{
|
||||
load_book::{display_err_for_text, display_miette_err},
|
||||
parser::{parse_definition_book, parse_term},
|
||||
},
|
||||
to_core::term_to_hvm_core,
|
||||
};
|
||||
use hvmc::{parse_lnet, show_lnet, Val};
|
||||
|
Loading…
Reference in New Issue
Block a user