Skip to content

Commit

Permalink
configure ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed Feb 23, 2024
1 parent 751af02 commit 49b8710
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 20 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Checks

on:
pull_request:
push:
branches:
- main

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/cache@v2
with:
path: ~/.cargo/registry ~/.cargo/git target
key: ${{ runner.os }}-client-${{ hashFiles('**/Cargo.lock') }}
- run: RUSTFLAGS="-D warnings" cargo check --all-targets
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/cache@v2
with:
path: ~/.cargo/registry ~/.cargo/git target
key: ${{ runner.os }}-client-${{ hashFiles('**/Cargo.lock') }}
- run: cargo test
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: actions/cache@v2
with:
path: ~/.cargo/registry ~/.cargo/git target
key: ${{ runner.os }}-client-${{ hashFiles('**/Cargo.lock') }}
- run: cargo clippy
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: actions/cache@v2
with:
path: ~/.cargo/registry ~/.cargo/git target
key: ${{ runner.os }}-client-${{ hashFiles('**/Cargo.lock') }}
- run: cargo fmt --check
cspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: streetsidesoftware/cspell-action@v5
with:
incremental_files_only: false
config: ./cspell.json
files: "**/*.rs **/*.md"
85 changes: 85 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"version": "0.2",
"language": "en",
"words": [
"anni",
"annihilations",
"appllication's",
"arities",
"arity",
"behaviour",
"bitand",
"builtins",
"callcc",
"chumsky",
"combinators",
"ctrs",
"datatypes",
"desugared",
"dref",
"dups",
"effectful",
"foldl",
"hasher",
"hvm's",
"hvmc",
"hvml",
"indexmap",
"inet",
"inets",
"inlineable",
"inlineables",
"inlines",
"inodes",
"insta",
"interner",
"itertools",
"lcons",
"linearizes",
"linearizing",
"lnet",
"lnil",
"maximium",
"mult",
"namegen",
"nams",
"numop",
"oper",
"opre",
"oprune",
"oref",
"postcondition",
"rdex",
"redex",
"redexes",
"readback",
"redexes",
"resugar",
"resugared",
"resugaring",
"rfold",
"rsplit",
"rwts",
"scons",
"scopeless",
"scrutinee",
"snil",
"stdext",
"subcmd",
"submatch",
"subpattern",
"subpatterns",
"subterm",
"subterms",
"succ",
"supercombinator",
"supercombinators",
"unbounds",
"vectorize",
"vectorizes",
"walkdir",
"wopts"
],
"files": ["**/*.rs", "**/*.md"],
"ignoreRegExpList": ["HexValues", "/λ/g", "/-O/g"]
}
2 changes: 1 addition & 1 deletion docs/compilation-and-readback.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ A superposition `{a b}` compiles to a Constructor node too. The difference here
Additionally, nodes have labels. We use the label to store data in the node's memory, which can be used for various purposes.

```
0 - Points to the sup occurence 0 - Points to the duplicated value
0 - Points to the sup occurrence 0 - Points to the duplicated value
| |
# Superposition # Duplication
/ \ / \
Expand Down
2 changes: 1 addition & 1 deletion docs/defining-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data Option = (Some val) | None

If the data type has a single constructor, it can be destructured using `let`:
```rs
// A Box is a wrapper around a valuee.
// A Box is a wrapper around a value.
data Boxed = (Box val)

let (Box value) = boxed; value
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ fn execute_cli_mode(mut cli: Cli) -> Result<(), Info> {
Mode::Desugar { path, comp_opts } => {
let opts = OptArgs::opts_from_cli(&comp_opts);
let mut book = load_book(&path)?;
// TODO: Shoudn't the desugar have `warn_opts` too? maybe WarningOpts::allow_all() by default
// TODO: Shouldn't the desugar have `warn_opts` too? maybe WarningOpts::allow_all() by default
let _warns = desugar_book(&mut book, opts)?;
println!("{}", book);
}
Expand Down Expand Up @@ -264,9 +264,9 @@ impl CliWarnOpts {
let matches = cmd.get_matches();

let subcmd_name = matches.subcommand_name().expect("To have a subcommand");
let argm = matches.subcommand_matches(subcmd_name).expect("To have a subcommand");
let arg_matches = matches.subcommand_matches(subcmd_name).expect("To have a subcommand");

if let Some(wopts_id_seq) = argm.get_many::<clap::Id>("CliWarnOpts") {
if let Some(wopts_id_seq) = arg_matches.get_many::<clap::Id>("CliWarnOpts") {
let allows = &mut self.allows.into_iter();
let denies = &mut self.denies.into_iter();
let warns = &mut self.warns.into_iter();
Expand Down
24 changes: 12 additions & 12 deletions src/net/net_to_hvmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn nets_to_hvmc(nets: HashMap<String, INet>) -> Result<Book, String> {

/// Convert an inet-encoded definition into an hvmc AST inet.
pub fn net_to_hvmc(inet: &INet) -> Result<Net, String> {
let (net_root, redxs) = get_tree_roots(inet)?;
let (net_root, redexes) = get_tree_roots(inet)?;
let mut port_to_var_id: HashMap<Port, VarId> = HashMap::new();
let root = if let Some(net_root) = net_root {
// If there is a root tree connected to the root node
Expand All @@ -27,7 +27,7 @@ pub fn net_to_hvmc(inet: &INet) -> Result<Net, String> {
Tree::Var { nam: num_to_name(0) }
};
let mut rdex = vec![];
for [root0, root1] in redxs {
for [root0, root1] in redexes {
let rdex0 = net_tree_to_hvmc_tree(inet, root0, &mut port_to_var_id);
let rdex1 = net_tree_to_hvmc_tree(inet, root1, &mut port_to_var_id);
rdex.push((rdex0, rdex1));
Expand Down Expand Up @@ -99,7 +99,7 @@ type VarId = NodeId;
/// Returns them as the root of the root tree and the active pairs of the net.
/// Active pairs are found by a right-to-left, depth-first search.
fn get_tree_roots(inet: &INet) -> Result<(Option<NodeId>, Vec<[NodeId; 2]>), String> {
let mut redx_roots: Vec<[NodeId; 2]> = vec![];
let mut redex_roots: Vec<[NodeId; 2]> = vec![];
let mut movements: Vec<Movement> = vec![];
let mut root_set = HashSet::from([ROOT.node()]);
let mut explored_nodes = vec![false; inet.nodes.len()];
Expand All @@ -124,12 +124,12 @@ fn get_tree_roots(inet: &INet) -> Result<(Option<NodeId>, Vec<[NodeId; 2]>), Str
match movement {
Movement::Down(node_id) => explore_down_link(inet, node_id, &mut explored_nodes, &mut movements),
Movement::Side(node_id) => {
explore_side_link(inet, node_id, &mut movements, &mut redx_roots, &mut root_set)?;
explore_side_link(inet, node_id, &mut movements, &mut redex_roots, &mut root_set)?;
}
}
}

Ok((root_tree_root, redx_roots))
Ok((root_tree_root, redex_roots))
}

enum Movement {
Expand Down Expand Up @@ -164,15 +164,15 @@ fn explore_side_link(
inet: &INet,
node_id: NodeId,
movements: &mut Vec<Movement>,
redx_roots: &mut Vec<[NodeId; 2]>,
redex_roots: &mut Vec<[NodeId; 2]>,
root_set: &mut HashSet<NodeId>,
) -> Result<(), String> {
let new_roots = go_up_tree(inet, node_id)?;
// If this is a new tree, explore it downwards
if !root_set.contains(&new_roots[0]) && !root_set.contains(&new_roots[1]) {
movements.push(Movement::Down(new_roots[0]));
movements.push(Movement::Down(new_roots[1]));
redx_roots.push(new_roots);
redex_roots.push(new_roots);
root_set.insert(new_roots[0]);
root_set.insert(new_roots[1]);
}
Expand All @@ -183,18 +183,18 @@ fn explore_side_link(
/// Returns the active pair at the root of this tree.
fn go_up_tree(inet: &INet, start_node: NodeId) -> Result<[NodeId; 2], String> {
let mut explored_nodes = HashSet::new();
let mut crnt_node = start_node;
let mut cur_node = start_node;
loop {
if !explored_nodes.insert(crnt_node) {
if !explored_nodes.insert(cur_node) {
return Err("Found term that compiles into an inet with a vicious cycle".to_string());
}

let up = inet.enter_port(Port(crnt_node, 0));
let up = inet.enter_port(Port(cur_node, 0));

if up.slot() == 0 || up == ROOT {
return Ok([up.node(), crnt_node]);
return Ok([up.node(), cur_node]);
}

crnt_node = up.node();
cur_node = up.node();
}
}
4 changes: 2 additions & 2 deletions src/term/term_to_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ impl<'a> EncodeTermState<'a> {
"Unbound variable {nam}. Expected this check to be already done"
);
let var_stack = &self.scope[nam];
let crnt_var = *var_stack.last().unwrap();
let (declare_port, use_port) = self.vars.get_mut(crnt_var).unwrap();
let cur_var = *var_stack.last().unwrap();
let (declare_port, use_port) = self.vars.get_mut(cur_var).unwrap();
debug_assert!(use_port.is_none(), "Variable {nam} used more than once");
self.inet.link(up, *declare_port);
*use_port = Some(up);
Expand Down
2 changes: 1 addition & 1 deletion src/term/transform/simplify_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fn switch_rule_submatch(
let args = new_args.clone().chain(old_args).collect::<Vec<_>>();

// Make the match cases of the nested submatch, filtering out the rules
// that don't match the crnt ctr.
// that don't match the current ctr.
let rules =
rules.iter().filter_map(|rule| switch_rule_submatch_arm(rule, ctr, nested_fields)).collect::<Vec<_>>();

Expand Down

0 comments on commit 49b8710

Please sign in to comment.