-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
60 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::term::{Book, Pattern, Term}; | ||
|
||
impl Book { | ||
pub fn apply_args(&mut self, args: Option<Vec<Term>>) -> Result<(), String> { | ||
if let Some(main) = &self.entrypoint | ||
&& let Some(args) = args | ||
{ | ||
let mut args = args.into_iter(); | ||
let main_rule = &mut self.defs[main].rules[0]; | ||
let main_body = &mut main_rule.body; | ||
|
||
for pat in &main_rule.pats { | ||
if let Pattern::Var(Some(x)) = pat { | ||
main_body.subst(x, &args.next().unwrap()); | ||
} else { | ||
return Err(format!("Expected a variable pattern, but found '{pat}'.")); | ||
} | ||
} | ||
|
||
main_rule.pats.clear(); | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod apply_args; | ||
pub mod definition_merge; | ||
pub mod definition_pruning; | ||
pub mod desugar_implicit_match_binds; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters