Skip to content

Commit

Permalink
Reorganizing ligen-parser to match ligen-generator API
Browse files Browse the repository at this point in the history
  • Loading branch information
notdanilo committed Nov 7, 2023
1 parent 2897671 commit 6c6fa75
Show file tree
Hide file tree
Showing 70 changed files with 127 additions and 95 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ members = [
"ligen",
"ligen/common",
"ligen/ir",
"ligen/parsing",
"ligen/parser",
"ligen/generator",
"ligen/utils",
"ligen/traits",
"ecosystem/python/parser",
Expand Down Expand Up @@ -34,7 +35,8 @@ ligen = { path = "ligen" }
ligen-common = { path = "ligen/common" }
ligen-ir = { path = "ligen/ir" }
ligen-macro = { path = "ligen/macro" }
ligen-parsing = { path = "ligen/parsing" }
ligen-parser = { path = "ligen/parser" }
ligen-generator = { path = "ligen/generator" }
ligen-traits = { path = "ligen/traits" }
ligen-utils = { path = "ligen/utils" }
#ligen-c = { path = "ecosystem/c/generator" }
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/function/method.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ligen::parsing::parser::ParserConfig;
use ligen::parser::ParserConfig;
use rustpython_parser::ast::{StmtAsyncFunctionDef, StmtFunctionDef};
use ligen::ir::{Method, Mutability};
use crate::parser::PythonParser;
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/python/parser/src/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod parameter;
pub mod method;

use crate::prelude::*;
use ligen::parsing::parser::ParserConfig;
use ligen::parser::ParserConfig;
use rustpython_parser::ast::{Arguments, Expr, Stmt, StmtAsyncFunctionDef, StmtFunctionDef};
use ligen::ir::{Function, Synchrony, Visibility, Parameter, Type};
use crate::function::parameter::ParameterParser;
Expand Down Expand Up @@ -85,7 +85,7 @@ impl FunctionParser {
mod test {
use crate::function::FunctionParser;
use ligen::prelude::*;
use ligen::parsing::assert::assert_eq;
use ligen::parser::assert::assert_eq;
use ligen_ir::function::mock;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/function/parameter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ligen::parsing::parser::ParserConfig;
use ligen::parser::ParserConfig;
use rustpython_parser::ast::ArgWithDefault;
use ligen::ir::Parameter;
use crate::identifier::IdentifierParser;
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/python/parser/src/identifier.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ligen::ir::{Identifier, Mutability};
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parsing::parser::universal::identifier::IdentifierParser as InternalParser;
use ligen::parser::{Parser, ParserConfig};
use ligen::parser::universal::identifier::IdentifierParser as InternalParser;
use crate::prelude::*;

#[derive(Default)]
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::prelude::*;
use ligen::parsing::parser::ParserConfig;
use ligen::parser::ParserConfig;
use rustpython_parser::ast::StmtClassDef;
use ligen::ir::Interface;
use crate::identifier::IdentifierParser;
Expand Down
3 changes: 2 additions & 1 deletion ecosystem/python/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ pub mod literal;
pub mod scope;
pub mod interface;
pub mod object;
pub mod parser;
mod parser;
pub use parser::*;
6 changes: 3 additions & 3 deletions ecosystem/python/parser/src/literal.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use rustpython_parser::ast::{Constant, ExprConstant};
use ligen::ir::Literal;
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::prelude::*;

#[derive(Default)]
pub struct LiteralParser;

impl ligen::parsing::parser::universal::literal::LiteralParser for LiteralParser {}
impl ligen::parser::universal::literal::LiteralParser for LiteralParser {}

impl Parser<String> for LiteralParser {
type Output = Literal;
Expand Down Expand Up @@ -45,7 +45,7 @@ mod test {
use crate::literal::LiteralParser;
use crate::prelude::*;
use ligen::ir::literal::mock;
use ligen::parsing::assert::*;
use ligen::parser::assert::*;

#[test]
fn literal_string() -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
use crate::literal::LiteralParser;
pub type AttributeParser = ligen::parsing::parser::universal::attributes::attribute::AttributeParser<LiteralParser>;
pub type AttributeParser = ligen::parser::universal::attributes::attribute::AttributeParser<LiteralParser>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod attribute;

use crate::prelude::*;
use crate::literal::LiteralParser;
use ligen::parsing::parser::{universal::attributes::AttributesParser as InternalParser, ParserConfig};
use ligen::parser::{universal::attributes::AttributesParser as InternalParser, ParserConfig};
use ligen::ir::Attributes;
use rustpython_parser::ast::{Expr, Ranged};

Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/module/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::prelude::*;
use ligen::{ir::Module, parsing::parser::ParserConfig};
use ligen::{ir::Module, parser::ParserConfig};
use rustpython_parser::ast::ModModule;
use crate::parser::PythonParser;

Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/object.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ligen::parsing::parser::ParserConfig;
use ligen::parser::ParserConfig;
use rustpython_parser::ast::{Expr, StmtAnnAssign, StmtAssign, StmtAugAssign};
use ligen::ir::Object;
use crate::identifier::IdentifierParser;
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/parser/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ligen::parsing::parser::{ParserConfigSet, ParserConfigGet, ParserConfig};
use ligen::parser::{ParserConfigSet, ParserConfigGet, ParserConfig};

use crate::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod config;
pub use config::*;

use ligen::ir::Library;
use ligen::parsing::parser::ParserConfig;
use ligen::parser::ParserConfig;

#[derive(Default)]
pub struct PythonParser {
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/python/parser/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub(crate) use ligen::parsing::parser::Parser;
pub(crate) use ligen::parsing::utils::WithSource;
pub(crate) use ligen::parser::Parser;
pub(crate) use ligen::parser::utils::WithSource;
pub(crate) use ligen::prelude::*;
pub(crate) use rustpython_parser::Mode;
pub(crate) use rustpython_parser::{parse, Parse};
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/scope/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod scope_type;

use rustpython_parser::ast::{Arguments, Expr, Stmt};
use ligen::{ir::{Interface, Object, Function, Method, TypeDefinition}, parsing::parser::ParserConfig};
use ligen::{ir::{Interface, Object, Function, Method, TypeDefinition}, parser::ParserConfig};
use crate::{prelude::*, parser::PythonParserConfig};

pub use scope_type::*;
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/types/type_.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use rustpython_parser::ast::{ExprName, Expr, ExprSubscript, ExprTuple};
use ligen::{ir::Type, parsing::parser::ParserConfig};
use ligen::{ir::Type, parser::ParserConfig};
use crate::prelude::*;

pub struct TypeParser {
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/python/parser/src/types/type_definition.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{prelude::*, identifier::IdentifierParser, macro_attributes::attributes::AttributesParser, function::FunctionParser, types::type_::TypeParser, parser::PythonParserConfig};
use ligen::{ir::{TypeDefinition, Visibility, Path, KindDefinition, Structure, Attribute, Field}, parsing::parser::ParserConfig};
use ligen::{ir::{TypeDefinition, Visibility, Path, KindDefinition, Structure, Attribute, Field}, parser::ParserConfig};
use ligen::ir::macro_attributes::Group;
use rustpython_parser::ast::{StmtClassDef, Expr, Stmt, StmtAnnAssign, StmtAugAssign, StmtAssign};

Expand Down
2 changes: 1 addition & 1 deletion ecosystem/rust/cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ license.workspace = true
ligen-ir.workspace = true
ligen-traits.workspace = true
ligen-utils.workspace = true
ligen-parsing.workspace = true
ligen-parser.workspace = true
ligen-rust-parser.workspace = true
cargo_toml = "0.16.0"
4 changes: 2 additions & 2 deletions ecosystem/rust/cargo/src/parser/library.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use ligen_ir::Identifier;
use ligen_ir::prelude::*;
use ligen_ir::Library;
use ligen_parsing::parser::Parser;
use ligen_parsing::parser::ParserConfig;
use ligen_parser::Parser;
use ligen_parser::ParserConfig;
use ligen_rust_parser::module::ModuleParser;

pub struct LibraryParser;
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/rust/parser/src/function/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ligen::ir::Mutability;
use crate::prelude::*;

use ligen::ir::{Attributes, Method, Parameter, Type};
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::function::parameter::ParameterParser;
use crate::function::SynchronyParser;
use crate::identifier::IdentifierParser;
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/rust/parser/src/function/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::*;

use ligen::ir::{Function, Parameter, Type};
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::function::parameter::ParameterParser;
use crate::identifier::IdentifierParser;
use crate::macro_attributes::attributes::AttributesParser;
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Parser<&str> for FunctionParser {

#[cfg(test)]
mod test {
use ligen::parsing::assert::assert_eq;
use ligen::parser::assert::assert_eq;
use crate::function::FunctionParser;
use crate::prelude::*;

Expand Down
4 changes: 2 additions & 2 deletions ecosystem/rust/parser/src/function/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::prelude::*;
use ligen::ir::{Identifier, Reference, Type, Mutability, Parameter};
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::identifier::IdentifierParser;
use crate::macro_attributes::attributes::AttributesParser;
use crate::types::TypeParser;
Expand Down Expand Up @@ -81,7 +81,7 @@ mod test {
use crate::prelude::*;

use ligen::ir::function::parameter::mock;
use ligen::parsing::assert::assert_eq;
use ligen::parser::assert::assert_eq;

#[test]
fn primitive_parameter() -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/rust/parser/src/function/synchrony.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ligen::ir::Synchrony;
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::prelude::*;

pub struct SynchronyParser;
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/rust/parser/src/identifier.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub type IdentifierParser = ligen::parsing::parser::universal::identifier::IdentifierParser;
pub type IdentifierParser = ligen::parser::universal::identifier::IdentifierParser;
6 changes: 3 additions & 3 deletions ecosystem/rust/parser/src/literal.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use ligen::ir::Literal;
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::prelude::*;

#[derive(Default)]
pub struct LiteralParser;

impl ligen::parsing::parser::universal::literal::LiteralParser for LiteralParser {}
impl ligen::parser::universal::literal::LiteralParser for LiteralParser {}

impl Parser<syn::Lit> for LiteralParser {
type Output = Literal;
Expand Down Expand Up @@ -67,7 +67,7 @@ mod test {
use crate::literal::LiteralParser;
use crate::prelude::*;
use ligen::ir::literal::mock;
use ligen::parsing::assert::*;
use ligen::parser::assert::*;

#[test]
fn literal_verbatim() -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
use crate::literal::LiteralParser;

pub type AttributeParser = ligen::parsing::parser::universal::attributes::attribute::AttributeParser<LiteralParser>;
pub type AttributeParser = ligen::parser::universal::attributes::attribute::AttributeParser<LiteralParser>;

#[cfg(test)]
mod test {
use crate::prelude::*;
use super::*;
use ligen::parsing::assert::assert_eq;
use ligen::parser::assert::assert_eq;
use ligen::ir::attribute::mock;

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/rust/parser/src/macro_attributes/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ mod attribute;
pub use attribute::*;

use crate::literal::LiteralParser;
pub type AttributesParser = ligen::parsing::parser::universal::attributes::AttributesParser<LiteralParser>;
pub type AttributesParser = ligen::parser::universal::attributes::AttributesParser<LiteralParser>;

#[cfg(test)]
mod test {
use crate::prelude::*;
use super::*;
use ligen::ir::attributes::mock;
use ligen::parsing::assert::assert_eq;
use ligen::parser::assert::assert_eq;

#[test]
fn parse_literals() -> Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/rust/parser/src/module/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::prelude::*;
use ligen::ir::{Path, Attributes, Visibility, Import};
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::identifier::IdentifierParser;
use crate::macro_attributes::attributes::AttributesParser;
use crate::visibility::VisibilityParser;
Expand Down Expand Up @@ -98,7 +98,7 @@ impl Parser<ImportsBuilder> for ImportsParser {
#[cfg(test)]
mod tests {
use super::*;
use ligen::parsing::assert::*;
use ligen::parser::assert::*;
use ligen::ir::module::import::mock;

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/rust/parser/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod import;

use syn::spanned::Spanned;
use ligen::ir::Object;
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::prelude::*;
use ligen::ir::{Function, Module, Import, TypeDefinition, Interface};
use crate::object::ObjectParser;
Expand Down Expand Up @@ -142,7 +142,7 @@ mod tests {
use super::*;
use quote::quote;
use ligen::ir::module::mock;
use ligen::parsing::assert::*;
use ligen::parser::assert::*;

#[test]
fn module_file() -> Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/rust/parser/src/object.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ligen::ir::{Object, Mutability};
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::identifier::IdentifierParser;
use crate::literal::LiteralParser;
use crate::prelude::*;
Expand Down Expand Up @@ -59,7 +59,7 @@ mod test {
use crate::object::ObjectParser;
use crate::prelude::*;

use ligen::parsing::assert::assert_eq;
use ligen::parser::assert::assert_eq;
use ligen::ir::object::mock;

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/rust/parser/src/path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ligen::ir::{Path, PathSegment};
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::identifier::IdentifierParser;
use crate::prelude::*;

Expand Down Expand Up @@ -55,7 +55,7 @@ mod test {
use crate::path::PathParser;
use crate::prelude::*;

use ligen::parsing::assert::*;
use ligen::parser::assert::*;
use ligen::ir::path::mock;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/rust/parser/src/prelude/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use ligen::common::*;
pub use ligen::utils::prelude::*;
pub use quote::{quote, TokenStreamExt};
pub(crate) use ligen::parsing::parser::Parser;
pub(crate) use ligen::parser::Parser;

pub mod syn2;
2 changes: 1 addition & 1 deletion ecosystem/rust/parser/src/types/generics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ligen::ir::Generics;
use ligen::parsing::parser::{Parser, ParserConfig};
use ligen::parser::{Parser, ParserConfig};
use crate::prelude::*;
use crate::types::type_::TypeParser;

Expand Down
Loading

0 comments on commit 6c6fa75

Please sign in to comment.