Added directfs

Added a very rudimentary file I/O system suitable for experimenting
with the language further. A better one will be designed when we have
sensible error management.
This commit is contained in:
2023-09-17 16:37:39 +01:00
parent 1078835e8b
commit 7396078304
84 changed files with 563 additions and 721 deletions

View File

@@ -23,6 +23,7 @@ pub enum RuleError {
}
impl RuleError {
/// Convert into a unified error trait object shared by all Orchid errors
#[must_use]
pub fn to_project_error(self, rule: &Rule<Sym>) -> Rc<dyn ProjectError> {
match self {
RuleError::Missing(name) => Missing::new(rule, name).rc(),
@@ -58,6 +59,7 @@ pub struct Missing {
name: Tok<String>,
}
impl Missing {
#[must_use]
pub fn new(rule: &ast::Rule<Sym>, name: Tok<String>) -> Self {
let mut locations = HashSet::new();
for expr in rule.template.iter() {
@@ -99,6 +101,7 @@ pub struct Multiple {
name: Tok<String>,
}
impl Multiple {
#[must_use]
pub fn new(rule: &ast::Rule<Sym>, name: Tok<String>) -> Self {
let mut locations = HashSet::new();
for expr in rule.template.iter() {
@@ -137,6 +140,7 @@ pub struct ArityMismatch {
name: Tok<String>,
}
impl ArityMismatch {
#[must_use]
pub fn new(rule: &ast::Rule<Sym>, name: Tok<String>) -> Self {
let mut locations = HashSet::new();
for expr in rule.template.iter() {
@@ -188,6 +192,7 @@ pub struct VecNeighbors {
n2: Tok<String>,
}
impl VecNeighbors {
#[must_use]
pub fn new(rule: &ast::Rule<Sym>, n1: Tok<String>, n2: Tok<String>) -> Self {
let mut locations = HashSet::new();
search_all_slcs(&rule.template[..], &mut |ev| {