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gy2xW}LQZ1{CTmU2ClB
zqBhV)p^h5IihQQvM79CuRe@j1u=P}*X$gXV$-^vhF6K$-#pdPsyd0k=_%!$D9M02^
zby>4Q6InAYLGVT!CXFyFJ$T3e?c_3#c$q?#W3T`Di>3R2tUMi=y0iIR?S&f-Wn1tS
zIO=#DG-uGY9V2QmC;218!%vMr@#OGiv2eIJyuUC$L6~k#9xys!!l^Z}pcH>Twtbcw%%U7S0H5im5du7EW<$8z_^82V!tG;Ay{zmQAKQG)=r_Z@f
zljM5YSoED^F1eQ%ik|ZfC@+srUl_gVT&tSoQ_KIvuWq;^>(mXu$Ps@FEjh@h(TCs^<5fRcd&?;2G-n+zdo=wKjlACJs)@F9j7!oL?ezKcBm45@>;pf
z%Em-~A7r#>Xz6;n+>8jxR>~~pIDXd$F_oHdDE5p4%LlJ51pauS
zp(7dBwm-aYM9US5TB6-Z7>QjSE#QmCJefzk+Ycs^9dURz-snI_n6df%NAV`=5%1-Ie4~N?7
z@AZ;t9*!qSk|;>TyK#~N&!Ip`fH<)p7>N^p#FFdq%)V-?Z}k$wSF@aOc-68i8)q)?
zcR+6o(6emxd}8^?m)B30)y#}-$wd3S&OJmA1cnN#^o9PY26{+F2
zg=g6UQZ@XMx(J2tNx0gbf@IIP!SRXlA~A~lj^H?o3Na2J7%3DB(6f8-!`?i_w@~Pd
zDQ>5|jGHIe31<*BIcjpW0#*>saWuzK4fJ%(Gse*|cr4utpQU%xw}6^zrV2N2CCey5Ej
G81fHZqc!pX
diff --git a/main.why b/main.why
index c328c4b..44fb610 100644
--- a/main.why
+++ b/main.why
@@ -1,17 +1,10 @@
use linked_list;
-struct Test {
- a: int
-}
-
-impl Test {
- fn static() {
-
- }
-}
fn main() -> int {
- let x: Test = Test { a: 3 };
+ let x: LL = LL::new();
+ x.add(12);
+ x.print();
return 8;
}
diff --git a/src/root/errors/parser_errors.rs b/src/root/errors/parser_errors.rs
index 3e76768..b631090 100644
--- a/src/root/errors/parser_errors.rs
+++ b/src/root/errors/parser_errors.rs
@@ -13,6 +13,8 @@ pub enum ParseError {
Expected(String),
#[error("Failed parsing {0}")]
NomErrorKind(String),
+ #[error("Failed to open file [{0}]")]
+ FailedToOpenFile(String)
}
pub fn create_custom_error(e: String, l: Span) -> nom::Err {
diff --git a/src/root/parser/handle_errors.rs b/src/root/parser/handle_errors.rs
index 8c54119..6dbde53 100644
--- a/src/root/parser/handle_errors.rs
+++ b/src/root/parser/handle_errors.rs
@@ -6,9 +6,9 @@ use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_toplevel::TopLevelTokens;
-pub fn handle_error<'a>(
- res: ParseResult<'a, Span<'a>, Vec>,
-) -> Result<(Span<'a>, Vec), WErr> {
+pub fn handle_error(
+ res: ParseResult,
+) -> Result<(A, B), WErr> {
match res {
Ok(v) => Ok(v),
Err(e) => match &e {
diff --git a/src/root/parser/location.rs b/src/root/parser/location.rs
index dedadd9..7add73e 100644
--- a/src/root/parser/location.rs
+++ b/src/root/parser/location.rs
@@ -8,6 +8,28 @@ use color_print::cformat;
use nom::InputTake;
use crate::root::parser::parse::Span;
+pub enum ToLocation<'a> {
+ Location(Location),
+ Span(Span<'a>)
+}
+
+impl<'a> ToLocation<'a> {
+ pub fn from_location(location: Location) -> ToLocation<'a> {
+ ToLocation::Location(location)
+ }
+
+ pub fn from_span(span: Span<'a>) -> ToLocation<'a> {
+ ToLocation::Span(span)
+ }
+
+ pub fn to_location(self) -> Location {
+ match self {
+ ToLocation::Location(location) => location,
+ ToLocation::Span(s) => Location::from_span(&s)
+ }
+ }
+}
+
#[derive(Debug, Clone, Hash)]
struct InnerLocation {
/// Path of file
diff --git a/src/root/parser/parse.rs b/src/root/parser/parse.rs
index 438ea89..48b7203 100644
--- a/src/root/parser/parse.rs
+++ b/src/root/parser/parse.rs
@@ -5,11 +5,13 @@ use std::rc::Rc;
use nom::IResult;
use nom_locate::LocatedSpan;
use nom_supreme::error::GenericErrorTree;
-
+use crate::root::errors::parser_errors::ParseError;
use crate::root::errors::WErr;
use crate::root::parser::handle_errors::handle_error;
+use crate::root::parser::location::{Location, ToLocation};
use crate::root::parser::parse_toplevel;
use crate::root::parser::parse_toplevel::TopLevelTokens;
+use crate::root::parser::use_parser::parse_uses;
pub type Span<'a> = LocatedSpan<&'a str, &'a Rc>;
@@ -17,14 +19,30 @@ pub type ParseResult<'a, I = Span<'a>, O = Span<'a>, E = ErrorTree<'a>> = IResul
pub type ErrorTree<'a> = GenericErrorTree, &'static str, &'static str, String>;
pub fn parse(path: PathBuf) -> Result, WErr> {
- let text = fs::read_to_string(&path).unwrap();
- let path = Rc::new(path);
- let base = Span::new_extra(&text, &path);
-
- let res = parse_toplevel::parse_toplevel(base);
- let (remaining, output) = handle_error(res)?;
-
- debug_assert!(remaining.is_empty());
+ let mut path_queue = vec![(path, Location::builtin())];
+ let mut output = Vec::new();
+
+ while let Some((path, location)) = path_queue.pop() {
+ print!("\n - {}", path.display());
+ let Ok(text) = fs::read_to_string(path.as_path()) else {
+ return WErr::ne(
+ ParseError::FailedToOpenFile(format!("{}", path.display())),
+ location
+ );
+ };
+
+ let path = Rc::new(path);
+ let base = Span::new_extra(&text, &path);
+
+ let (after_use, found_paths) = handle_error(parse_uses(base))?;
+ path_queue.extend(found_paths);
+
+ let res = parse_toplevel::parse_toplevel(after_use);
+ let (remaining, new_output) = handle_error(res)?;
+ debug_assert!(remaining.is_empty());
+ output.extend(new_output);
+ }
+ println!();
Ok(output)
}
diff --git a/src/root/parser/use_parser.rs b/src/root/parser/use_parser.rs
index e69de29..e28a964 100644
--- a/src/root/parser/use_parser.rs
+++ b/src/root/parser/use_parser.rs
@@ -0,0 +1,41 @@
+use std::fmt::format;
+use std::path::PathBuf;
+use nom::bytes::complete::{tag, take_till};
+use nom::character::complete::anychar;
+use nom::complete::take;
+use crate::root::errors::parser_errors::create_custom_error;
+use crate::root::parser::location::{Location, ToLocation};
+use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
+use crate::root::parser::parse_util::discard_ignored;
+
+pub fn parse_uses(s: Span) -> ParseResult> {
+ let mut s = s;
+ let mut found_paths = Vec::new();
+ loop {
+ let (ns, _) = discard_ignored(s)?;
+ let Ok((ns, _)) = tag::<_, _, ErrorTree>("use")(ns) else {
+ return Ok((ns, found_paths));
+ };
+
+ let (ns, _) = discard_ignored(ns)?;
+ let Ok((pre_s, path)) = take_till::<_, _, ErrorTree>(|c| c == ';' || c =='\n' || c=='\r')(ns) else {
+ return Err(create_custom_error(
+ "Did not find ending ';' when parsing path".to_string(),
+ ns,
+ ));
+ };
+
+ let (ns, next) = anychar::<_, ErrorTree>(pre_s).unwrap();
+ if next != ';' {
+ return Err(create_custom_error(
+ "Use path cannot be broken by newline".to_string(),
+ pre_s,
+ ));
+ }
+
+ let path_buf = PathBuf::from(format!("{}.why", path));
+ found_paths.push((path_buf, Location::from_span(&path)));
+
+ s = ns;
+ }
+}
\ No newline at end of file
diff --git a/todo.md b/todo.md
index 959d0d6..8c7865f 100644
--- a/todo.md
+++ b/todo.md
@@ -1,3 +1,3 @@
- Add array support
-- Add support for multiple files
+- Namespacing
From 843edb17ba8cd31c2be8422d7b5f20ac370e25e0 Mon Sep 17 00:00:00 2001
From: Robert-M-Lucas <100799838+Robert-M-Lucas@users.noreply.github.com>
Date: Tue, 6 Aug 2024 16:21:27 +0100
Subject: [PATCH 4/4] fmt
---
src/root.rs | 4 +--
src/root/errors/parser_errors.rs | 2 +-
src/root/name_resolver/resolve_names.rs | 4 +--
src/root/parser/handle_errors.rs | 4 +--
src/root/parser/location.rs | 24 ++++++++---------
src/root/parser/mod.rs | 2 +-
src/root/parser/parse.rs | 14 +++++-----
src/root/parser/parse_function.rs | 12 ++++-----
src/root/parser/parse_function/parse_break.rs | 6 ++---
.../parser/parse_function/parse_evaluable.rs | 6 ++---
src/root/parser/parse_function/parse_if.rs | 12 ++++-----
.../parse_function/parse_initialisation.rs | 4 +--
.../parser/parse_function/parse_literal.rs | 2 +-
.../parser/parse_function/parse_operator.rs | 2 +-
.../parser/parse_function/parse_return.rs | 10 +++----
.../parse_function/parse_struct_init.rs | 10 +++----
src/root/parser/parse_function/parse_while.rs | 12 ++++-----
src/root/parser/parse_impl.rs | 8 +++---
src/root/parser/parse_name.rs | 2 +-
src/root/parser/parse_struct.rs | 8 +++---
src/root/parser/use_parser.rs | 26 ++++++++++---------
21 files changed, 87 insertions(+), 87 deletions(-)
diff --git a/src/root.rs b/src/root.rs
index cef8d05..41b3475 100644
--- a/src/root.rs
+++ b/src/root.rs
@@ -1,7 +1,7 @@
-use crate::root::parser::parse::parse;
use crate::root::compiler::compile::compile;
use crate::root::errors::WErr;
use crate::root::name_resolver::resolve::resolve;
+use crate::root::parser::parse::parse;
use crate::root::runner::{assemble, link_gcc, run};
use crate::time;
use clap::Parser;
@@ -101,7 +101,7 @@ pub fn main_args(args: Args) -> Result<(), WErr> {
.unwrap()
.len()
.to_formatted_string(&Locale::en);
-
+
cprintln!("Completed [{:?}] - {} bytes>", end, size);
if args.build {
diff --git a/src/root/errors/parser_errors.rs b/src/root/errors/parser_errors.rs
index b631090..10e8c4e 100644
--- a/src/root/errors/parser_errors.rs
+++ b/src/root/errors/parser_errors.rs
@@ -14,7 +14,7 @@ pub enum ParseError {
#[error("Failed parsing {0}")]
NomErrorKind(String),
#[error("Failed to open file [{0}]")]
- FailedToOpenFile(String)
+ FailedToOpenFile(String),
}
pub fn create_custom_error(e: String, l: Span) -> nom::Err {
diff --git a/src/root/name_resolver/resolve_names.rs b/src/root/name_resolver/resolve_names.rs
index 1f5455d..4f9a2b9 100644
--- a/src/root/name_resolver/resolve_names.rs
+++ b/src/root/name_resolver/resolve_names.rs
@@ -1,5 +1,3 @@
-use std::collections::HashMap;
-use b_box::b;
use crate::root::errors::evaluable_errors::EvalErrs;
use crate::root::errors::name_resolver_errors::NRErrs;
use crate::root::errors::WErr;
@@ -16,8 +14,10 @@ use crate::root::shared::common::{ByteSize, FunctionID, TypeID};
use crate::root::shared::common::{LocalAddress, TypeRef};
use crate::root::shared::types::Type;
use crate::root::unrandom::new_hashmap;
+use b_box::b;
use derive_getters::Getters;
use itertools::Itertools;
+use std::collections::HashMap;
/// A Whython-code defined type
#[derive(Getters)]
diff --git a/src/root/parser/handle_errors.rs b/src/root/parser/handle_errors.rs
index 6dbde53..2c093bf 100644
--- a/src/root/parser/handle_errors.rs
+++ b/src/root/parser/handle_errors.rs
@@ -6,9 +6,7 @@ use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_toplevel::TopLevelTokens;
-pub fn handle_error(
- res: ParseResult,
-) -> Result<(A, B), WErr> {
+pub fn handle_error(res: ParseResult) -> Result<(A, B), WErr> {
match res {
Ok(v) => Ok(v),
Err(e) => match &e {
diff --git a/src/root/parser/location.rs b/src/root/parser/location.rs
index 7add73e..324c38c 100644
--- a/src/root/parser/location.rs
+++ b/src/root/parser/location.rs
@@ -1,31 +1,31 @@
-use std::marker::PhantomData;
-use std::rc::Rc;
-use std::path::PathBuf;
-use std::fmt::{Display, Formatter};
-use std::fs;
-use std::cmp::min;
+use crate::root::parser::parse::Span;
use color_print::cformat;
use nom::InputTake;
-use crate::root::parser::parse::Span;
+use std::cmp::min;
+use std::fmt::{Display, Formatter};
+use std::fs;
+use std::marker::PhantomData;
+use std::path::PathBuf;
+use std::rc::Rc;
pub enum ToLocation<'a> {
Location(Location),
- Span(Span<'a>)
+ Span(Span<'a>),
}
impl<'a> ToLocation<'a> {
pub fn from_location(location: Location) -> ToLocation<'a> {
ToLocation::Location(location)
}
-
+
pub fn from_span(span: Span<'a>) -> ToLocation<'a> {
ToLocation::Span(span)
}
-
+
pub fn to_location(self) -> Location {
match self {
ToLocation::Location(location) => location,
- ToLocation::Span(s) => Location::from_span(&s)
+ ToLocation::Span(s) => Location::from_span(&s),
}
}
}
@@ -293,4 +293,4 @@ impl Display for LocationTyped {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
self.fmt_choice(f, true)
}
-}
\ No newline at end of file
+}
diff --git a/src/root/parser/mod.rs b/src/root/parser/mod.rs
index 96c051f..d8e9c0e 100644
--- a/src/root/parser/mod.rs
+++ b/src/root/parser/mod.rs
@@ -1,4 +1,5 @@
mod handle_errors;
+pub mod location;
pub mod parse;
pub mod parse_arguments;
pub mod parse_blocks;
@@ -13,4 +14,3 @@ pub mod parse_toplevel;
pub mod parse_util;
pub mod soft_alt;
mod use_parser;
-pub mod location;
diff --git a/src/root/parser/parse.rs b/src/root/parser/parse.rs
index 48b7203..f1832dc 100644
--- a/src/root/parser/parse.rs
+++ b/src/root/parser/parse.rs
@@ -2,9 +2,6 @@ use std::fs;
use std::path::PathBuf;
use std::rc::Rc;
-use nom::IResult;
-use nom_locate::LocatedSpan;
-use nom_supreme::error::GenericErrorTree;
use crate::root::errors::parser_errors::ParseError;
use crate::root::errors::WErr;
use crate::root::parser::handle_errors::handle_error;
@@ -12,6 +9,9 @@ use crate::root::parser::location::{Location, ToLocation};
use crate::root::parser::parse_toplevel;
use crate::root::parser::parse_toplevel::TopLevelTokens;
use crate::root::parser::use_parser::parse_uses;
+use nom::IResult;
+use nom_locate::LocatedSpan;
+use nom_supreme::error::GenericErrorTree;
pub type Span<'a> = LocatedSpan<&'a str, &'a Rc>;
@@ -21,22 +21,22 @@ pub type ErrorTree<'a> = GenericErrorTree, &'static str, &'static str,
pub fn parse(path: PathBuf) -> Result, WErr> {
let mut path_queue = vec![(path, Location::builtin())];
let mut output = Vec::new();
-
+
while let Some((path, location)) = path_queue.pop() {
print!("\n - {}", path.display());
let Ok(text) = fs::read_to_string(path.as_path()) else {
return WErr::ne(
ParseError::FailedToOpenFile(format!("{}", path.display())),
- location
+ location,
);
};
let path = Rc::new(path);
let base = Span::new_extra(&text, &path);
-
+
let (after_use, found_paths) = handle_error(parse_uses(base))?;
path_queue.extend(found_paths);
-
+
let res = parse_toplevel::parse_toplevel(after_use);
let (remaining, new_output) = handle_error(res)?;
debug_assert!(remaining.is_empty());
diff --git a/src/root/parser/parse_function.rs b/src/root/parser/parse_function.rs
index 63e2612..fbfdebb 100644
--- a/src/root/parser/parse_function.rs
+++ b/src/root/parser/parse_function.rs
@@ -1,20 +1,20 @@
+use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_blocks::{
- BRACE_TERMINATOR, BRACKET_TERMINATOR, parse_terminator_default_set,
+ parse_terminator_default_set, BRACE_TERMINATOR, BRACKET_TERMINATOR,
};
use crate::root::parser::parse_function::parse_evaluable::{
- FullNameWithIndirectionToken, parse_full_name,
+ parse_full_name, FullNameWithIndirectionToken,
};
-use crate::root::parser::parse_function::parse_line::{LineTokens, parse_lines};
+use crate::root::parser::parse_function::parse_line::{parse_lines, LineTokens};
use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken};
-use crate::root::parser::parse_parameters::{Parameters, parse_parameters, SelfType};
-use crate::root::parser::parse_toplevel::{ToplevelTestFn, TopLevelTokens};
+use crate::root::parser::parse_parameters::{parse_parameters, Parameters, SelfType};
+use crate::root::parser::parse_toplevel::{TopLevelTokens, ToplevelTestFn};
use crate::root::parser::parse_util::{discard_ignored, require_ignored};
use derive_getters::{Dissolve, Getters};
use nom::sequence::Tuple;
use nom::Parser;
use nom_supreme::tag::complete::tag;
-use crate::root::parser::location::Location;
pub mod parse_assigner;
pub mod parse_assignment;
diff --git a/src/root/parser/parse_function/parse_break.rs b/src/root/parser/parse_function/parse_break.rs
index 5953fcc..d2f2f0f 100644
--- a/src/root/parser/parse_function/parse_break.rs
+++ b/src/root/parser/parse_function/parse_break.rs
@@ -1,10 +1,10 @@
-use derive_getters::Getters;
-use nom::character::complete::char;
-use nom_supreme::tag::complete::tag;
use crate::root::parser::location::Location;
use crate::root::parser::parse::{ParseResult, Span};
use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens};
use crate::root::parser::parse_util::discard_ignored;
+use derive_getters::Getters;
+use nom::character::complete::char;
+use nom_supreme::tag::complete::tag;
#[derive(Debug, Getters)]
pub struct BreakToken {
diff --git a/src/root/parser/parse_function/parse_evaluable.rs b/src/root/parser/parse_function/parse_evaluable.rs
index cf114da..75e1474 100644
--- a/src/root/parser/parse_function/parse_evaluable.rs
+++ b/src/root/parser/parse_function/parse_evaluable.rs
@@ -8,9 +8,9 @@ use crate::root::errors::parser_errors::create_custom_error;
use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_arguments::parse_arguments;
-use crate::root::parser::parse_blocks::{BRACKET_TERMINATOR, parse_terminator_default_set};
-use crate::root::parser::parse_function::parse_literal::{LiteralToken, parse_literal};
-use crate::root::parser::parse_function::parse_operator::{OperatorToken, parse_operator};
+use crate::root::parser::parse_blocks::{parse_terminator_default_set, BRACKET_TERMINATOR};
+use crate::root::parser::parse_function::parse_literal::{parse_literal, LiteralToken};
+use crate::root::parser::parse_function::parse_operator::{parse_operator, OperatorToken};
use crate::root::parser::parse_function::parse_struct_init::{parse_struct_init, StructInitToken};
use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken};
use crate::root::parser::parse_util::discard_ignored;
diff --git a/src/root/parser/parse_function/parse_if.rs b/src/root/parser/parse_function/parse_if.rs
index 08c805d..93d2e45 100644
--- a/src/root/parser/parse_function/parse_if.rs
+++ b/src/root/parser/parse_function/parse_if.rs
@@ -1,15 +1,15 @@
-use derive_getters::Getters;
-use nom::sequence::Tuple;
-use nom_supreme::tag::complete::tag;
use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_blocks::{
- BRACE_TERMINATOR, BRACKET_TERMINATOR, parse_terminator_default_set,
+ parse_terminator_default_set, BRACE_TERMINATOR, BRACKET_TERMINATOR,
};
-use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, parse_evaluable};
-use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens, parse_lines};
+use crate::root::parser::parse_function::parse_evaluable::{parse_evaluable, EvaluableToken};
+use crate::root::parser::parse_function::parse_line::{parse_lines, LineTestFn, LineTokens};
use crate::root::parser::parse_name::SimpleNameToken;
use crate::root::parser::parse_util::{discard_ignored, require_ignored};
+use derive_getters::Getters;
+use nom::sequence::Tuple;
+use nom_supreme::tag::complete::tag;
#[derive(Debug, Getters)]
pub struct IfToken {
diff --git a/src/root/parser/parse_function/parse_initialisation.rs b/src/root/parser/parse_function/parse_initialisation.rs
index 2983de1..ef06803 100644
--- a/src/root/parser/parse_function/parse_initialisation.rs
+++ b/src/root/parser/parse_function/parse_initialisation.rs
@@ -1,6 +1,7 @@
+use crate::root::parser::location::Location;
use crate::root::parser::parse::{ParseResult, Span};
use crate::root::parser::parse_function::parse_evaluable::{
- EvaluableToken, FullNameWithIndirectionToken, parse_evaluable, parse_full_name,
+ parse_evaluable, parse_full_name, EvaluableToken, FullNameWithIndirectionToken,
};
use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens};
use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken};
@@ -9,7 +10,6 @@ use derive_getters::Getters;
use nom::character::complete::char;
use nom::sequence::Tuple;
use nom_supreme::tag::complete::tag;
-use crate::root::parser::location::Location;
#[derive(Debug, Getters)]
pub struct InitialisationToken {
diff --git a/src/root/parser/parse_function/parse_literal.rs b/src/root/parser/parse_function/parse_literal.rs
index 69b930e..2a1c92d 100644
--- a/src/root/parser/parse_function/parse_literal.rs
+++ b/src/root/parser/parse_function/parse_literal.rs
@@ -1,12 +1,12 @@
use crate::root::builtin::types::bool::BoolType;
use crate::root::builtin::types::int::IntType;
+use crate::root::parser::location::Location;
use crate::root::parser::parse::{ParseResult, Span};
use crate::root::parser::parse_util::discard_ignored;
use crate::root::shared::common::TypeID;
use derive_getters::{Dissolve, Getters};
use nom::branch::alt;
use nom::bytes::complete::tag;
-use crate::root::parser::location::Location;
#[derive(Debug, Dissolve, Getters)]
pub struct LiteralToken {
diff --git a/src/root/parser/parse_function/parse_operator.rs b/src/root/parser/parse_function/parse_operator.rs
index 7754c62..0da38d7 100644
--- a/src/root/parser/parse_function/parse_operator.rs
+++ b/src/root/parser/parse_function/parse_operator.rs
@@ -1,10 +1,10 @@
+use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use derive_getters::Getters;
use nom::Err::Error;
use nom_supreme::error::GenericErrorTree;
use nom_supreme::tag::complete::tag;
use nom_supreme::tag::TagError;
-use crate::root::parser::location::Location;
#[derive(PartialEq, Debug)]
pub enum PrefixOrInfix {
diff --git a/src/root/parser/parse_function/parse_return.rs b/src/root/parser/parse_function/parse_return.rs
index 3ffd02b..75e87d9 100644
--- a/src/root/parser/parse_function/parse_return.rs
+++ b/src/root/parser/parse_function/parse_return.rs
@@ -1,13 +1,13 @@
-use derive_getters::Getters;
-use nom::character::complete::char;
-use nom::sequence::Tuple;
-use nom_supreme::tag::complete::tag;
use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
-use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, parse_evaluable};
+use crate::root::parser::parse_function::parse_evaluable::{parse_evaluable, EvaluableToken};
use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens};
use crate::root::parser::parse_name::SimpleNameToken;
use crate::root::parser::parse_util::require_ignored;
+use derive_getters::Getters;
+use nom::character::complete::char;
+use nom::sequence::Tuple;
+use nom_supreme::tag::complete::tag;
#[derive(Debug, Getters)]
pub struct ReturnToken {
diff --git a/src/root/parser/parse_function/parse_struct_init.rs b/src/root/parser/parse_function/parse_struct_init.rs
index 73f74ce..f82bbe2 100644
--- a/src/root/parser/parse_function/parse_struct_init.rs
+++ b/src/root/parser/parse_function/parse_struct_init.rs
@@ -1,17 +1,17 @@
-use derive_getters::{Dissolve, Getters};
-use nom::bytes::complete::tag;
-use nom::character::streaming::char;
use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_blocks::{
- BRACE_TERMINATOR, parse_terminator_default_set, take_until_or_end_discard_smart,
+ parse_terminator_default_set, take_until_or_end_discard_smart, BRACE_TERMINATOR,
};
use crate::root::parser::parse_function::parse_evaluable::{
- EvaluableToken, FullNameWithIndirectionToken, parse_evaluable, parse_full_name,
+ parse_evaluable, parse_full_name, EvaluableToken, FullNameWithIndirectionToken,
};
use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken};
use crate::root::parser::parse_util::discard_ignored;
use crate::root::shared::common::Indirection;
+use derive_getters::{Dissolve, Getters};
+use nom::bytes::complete::tag;
+use nom::character::streaming::char;
#[derive(Debug, Dissolve, Getters)]
pub struct StructInitToken {
diff --git a/src/root/parser/parse_function/parse_while.rs b/src/root/parser/parse_function/parse_while.rs
index 7244bcb..8f342f6 100644
--- a/src/root/parser/parse_function/parse_while.rs
+++ b/src/root/parser/parse_function/parse_while.rs
@@ -1,15 +1,15 @@
-use derive_getters::Getters;
-use nom::sequence::Tuple;
-use nom_supreme::tag::complete::tag;
use crate::root::parser::location::Location;
use crate::root::parser::parse::{ParseResult, Span};
use crate::root::parser::parse_blocks::{
- BRACE_TERMINATOR, BRACKET_TERMINATOR, parse_terminator_default_set,
+ parse_terminator_default_set, BRACE_TERMINATOR, BRACKET_TERMINATOR,
};
-use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, parse_evaluable};
-use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens, parse_lines};
+use crate::root::parser::parse_function::parse_evaluable::{parse_evaluable, EvaluableToken};
+use crate::root::parser::parse_function::parse_line::{parse_lines, LineTestFn, LineTokens};
use crate::root::parser::parse_name::SimpleNameToken;
use crate::root::parser::parse_util::{discard_ignored, require_ignored};
+use derive_getters::Getters;
+use nom::sequence::Tuple;
+use nom_supreme::tag::complete::tag;
#[derive(Debug, Getters)]
pub struct WhileToken {
diff --git a/src/root/parser/parse_impl.rs b/src/root/parser/parse_impl.rs
index 93b19d6..d594e4a 100644
--- a/src/root/parser/parse_impl.rs
+++ b/src/root/parser/parse_impl.rs
@@ -1,14 +1,14 @@
+use crate::root::parser::location::Location;
use crate::root::parser::parse::{ParseResult, Span};
-use crate::root::parser::parse_blocks::{BRACE_TERMINATOR, parse_terminator_default_set};
-use crate::root::parser::parse_function::{FunctionToken, parse_function};
+use crate::root::parser::parse_blocks::{parse_terminator_default_set, BRACE_TERMINATOR};
+use crate::root::parser::parse_function::{parse_function, FunctionToken};
use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken};
-use crate::root::parser::parse_toplevel::{ToplevelTestFn, TopLevelTokens};
+use crate::root::parser::parse_toplevel::{TopLevelTokens, ToplevelTestFn};
use crate::root::parser::parse_util::{discard_ignored, require_ignored};
use derive_getters::{Dissolve, Getters};
use nom::sequence::Tuple;
use nom::Parser;
use nom_supreme::tag::complete::tag;
-use crate::root::parser::location::Location;
#[derive(Debug, Getters, Dissolve)]
pub struct ImplToken {
diff --git a/src/root/parser/parse_name.rs b/src/root/parser/parse_name.rs
index dddfd14..a553604 100644
--- a/src/root/parser/parse_name.rs
+++ b/src/root/parser/parse_name.rs
@@ -1,9 +1,9 @@
+use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use derive_getters::Getters;
use nom::bytes::complete::take_till;
use nom::Err::Error;
use nom_supreme::error::{BaseErrorKind, Expectation};
-use crate::root::parser::location::Location;
#[derive(Debug, Getters, Clone)]
pub struct SimpleNameToken {
diff --git a/src/root/parser/parse_struct.rs b/src/root/parser/parse_struct.rs
index f135b3a..a5eb217 100644
--- a/src/root/parser/parse_struct.rs
+++ b/src/root/parser/parse_struct.rs
@@ -1,15 +1,15 @@
+use crate::root::parser::location::Location;
use crate::root::parser::parse::{ParseResult, Span};
-use crate::root::parser::parse_blocks::{BRACE_TERMINATOR, parse_terminator_default_set};
+use crate::root::parser::parse_blocks::{parse_terminator_default_set, BRACE_TERMINATOR};
use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken};
-use crate::root::parser::parse_parameters::{Parameters, parse_parameters};
-use crate::root::parser::parse_toplevel::{ToplevelTestFn, TopLevelTokens};
+use crate::root::parser::parse_parameters::{parse_parameters, Parameters};
+use crate::root::parser::parse_toplevel::{TopLevelTokens, ToplevelTestFn};
use crate::root::parser::parse_util::{discard_ignored, require_ignored};
use crate::root::shared::common::TypeID;
use derive_getters::{Dissolve, Getters};
use nom::sequence::Tuple;
use nom::Parser;
use nom_supreme::tag::complete::tag;
-use crate::root::parser::location::Location;
#[derive(Debug, Getters, Dissolve)]
pub struct StructToken {
diff --git a/src/root/parser/use_parser.rs b/src/root/parser/use_parser.rs
index e28a964..70daa2f 100644
--- a/src/root/parser/use_parser.rs
+++ b/src/root/parser/use_parser.rs
@@ -1,30 +1,32 @@
-use std::fmt::format;
-use std::path::PathBuf;
-use nom::bytes::complete::{tag, take_till};
-use nom::character::complete::anychar;
-use nom::complete::take;
use crate::root::errors::parser_errors::create_custom_error;
use crate::root::parser::location::{Location, ToLocation};
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_util::discard_ignored;
+use nom::bytes::complete::{tag, take_till};
+use nom::character::complete::anychar;
+use nom::complete::take;
+use std::fmt::format;
+use std::path::PathBuf;
pub fn parse_uses(s: Span) -> ParseResult> {
let mut s = s;
let mut found_paths = Vec::new();
loop {
let (ns, _) = discard_ignored(s)?;
- let Ok((ns, _)) = tag::<_, _, ErrorTree>("use")(ns) else {
+ let Ok((ns, _)) = tag::<_, _, ErrorTree>("use")(ns) else {
return Ok((ns, found_paths));
};
-
+
let (ns, _) = discard_ignored(ns)?;
- let Ok((pre_s, path)) = take_till::<_, _, ErrorTree>(|c| c == ';' || c =='\n' || c=='\r')(ns) else {
+ let Ok((pre_s, path)) =
+ take_till::<_, _, ErrorTree>(|c| c == ';' || c == '\n' || c == '\r')(ns)
+ else {
return Err(create_custom_error(
"Did not find ending ';' when parsing path".to_string(),
ns,
));
};
-
+
let (ns, next) = anychar::<_, ErrorTree>(pre_s).unwrap();
if next != ';' {
return Err(create_custom_error(
@@ -32,10 +34,10 @@ pub fn parse_uses(s: Span) -> ParseResult> {
pre_s,
));
}
-
+
let path_buf = PathBuf::from(format!("{}.why", path));
found_paths.push((path_buf, Location::from_span(&path)));
-
+
s = ns;
}
-}
\ No newline at end of file
+}