diff --git a/trixy/trixy-lang_parser/src/command_spec/unchecked.rs b/trixy/trixy-lang_parser/src/command_spec/unchecked.rs index ef88fb7..5757ee0 100644 --- a/trixy/trixy-lang_parser/src/command_spec/unchecked.rs +++ b/trixy/trixy-lang_parser/src/command_spec/unchecked.rs @@ -50,7 +50,7 @@ pub enum Declaration { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)] pub enum Attribute { #[allow(non_camel_case_types)] - doc{content: String, span: TokenSpan}, + doc { content: String, span: TokenSpan }, } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)] diff --git a/trixy/trixy-lang_parser/src/error.rs b/trixy/trixy-lang_parser/src/error.rs index c6fd486..7e9a92e 100644 --- a/trixy/trixy-lang_parser/src/error.rs +++ b/trixy/trixy-lang_parser/src/error.rs @@ -2,12 +2,17 @@ use core::fmt; use thiserror::Error; -use crate::lexing::{error::SpannedLexingError, TokenSpan}; +use crate::{ + lexing::{error::SpannedLexingError, TokenSpan}, + parsing::checked::error::SpannedParsingError, +}; #[derive(Error, Debug)] pub enum TrixyError { #[error(transparent)] - Parsing(#[from] SpannedLexingError), + Lexing(#[from] SpannedLexingError), + #[error(transparent)] + Parsing(#[from] SpannedParsingError), } /// The context of an Error. diff --git a/trixy/trixy-lang_parser/src/lib.rs b/trixy/trixy-lang_parser/src/lib.rs index 247fa8b..406d554 100644 --- a/trixy/trixy-lang_parser/src/lib.rs +++ b/trixy/trixy-lang_parser/src/lib.rs @@ -2,7 +2,7 @@ use error::TrixyError; use crate::lexing::TokenStream; -use self::command_spec::unchecked::CommandSpec; +use self::command_spec::checked::CommandSpec; mod command_spec; pub mod error; @@ -10,50 +10,6 @@ pub mod lexing; pub mod parsing; pub fn parse_trixy_lang(input: &str) -> Result { - let input_tokens = TokenStream::lex(input)?; - - todo!() + let input_tokens = TokenStream::lex(input)?.parse()?; + Ok(input_tokens) } - -// #[cfg(test)] -// mod test { -// use crate::{ -// command_spec::unchecked::{CommandSpec, Declaration, Genus, Namespace}, -// parse_trixy_lang, -// }; -// -// #[test] -// fn test_function_with_namespace() { -// let expected = parse_trixy_lang( -// " -// nasp commands { -// fn say_something(name_to_greet: String, what_to_say: String) -> String; -// } -// ", -// ) -// .unwrap(); -// let correct: CommandSpec = { -// let declarations = vec![Declaration { -// namespace: vec![Namespace { -// name: "commands".to_owned(), -// }], -// genus: Genus::Function { -// name: "say_something".to_owned(), -// inputs: vec![ -// NamedType { -// name: "name_to_greet".to_owned(), -// base: Type::String, -// }, -// NamedType { -// name: "what_to_say".to_owned(), -// base: Type::String, -// }, -// ], -// output: Type::String, -// }, -// }]; -// CommandSpec { declarations } -// }; -// assert_eq!(expected, correct); -// } -// } diff --git a/trixy/trixy-lang_parser/src/main.rs b/trixy/trixy-lang_parser/src/main.rs index 2d80a87..aefc806 100644 --- a/trixy/trixy-lang_parser/src/main.rs +++ b/trixy/trixy-lang_parser/src/main.rs @@ -105,6 +105,6 @@ pub fn main() { } }; println!("{:#?}", processed); - }, + } } } diff --git a/trixy/trixy-lang_parser/src/parsing/checked/mod.rs b/trixy/trixy-lang_parser/src/parsing/checked/mod.rs index 1e44d4f..841ba30 100644 --- a/trixy/trixy-lang_parser/src/parsing/checked/mod.rs +++ b/trixy/trixy-lang_parser/src/parsing/checked/mod.rs @@ -19,7 +19,7 @@ use crate::{ use self::error::{ParsingError, SpannedParsingError}; -mod error; +pub mod error; #[cfg(test)] mod test; diff --git a/trixy/trixy-lang_parser/src/parsing/mod.rs b/trixy/trixy-lang_parser/src/parsing/mod.rs index d6a8fef..f1506dc 100644 --- a/trixy/trixy-lang_parser/src/parsing/mod.rs +++ b/trixy/trixy-lang_parser/src/parsing/mod.rs @@ -1,2 +1,2 @@ +pub mod checked; mod unchecked; -mod checked;