-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
9 changed files
with
82 additions
and
94 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
19 changes: 0 additions & 19 deletions
19
ecosystem/python/parser/src/macro_attributes/attributes/attribute.rs
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,21 +1,2 @@ | ||
use crate::literal::LiteralParser; | ||
pub type AttributeParser = ligen::parsing::parser::universal::attributes::attribute::AttributeParser<LiteralParser>; | ||
|
||
// use rustpython_parser::ast::ExprAttribute; | ||
// use ligen::ir::Attribute; | ||
// use crate::identifier::IdentifierParser; | ||
// use crate::macro_attributes::attributes::AttributesParser; | ||
// use crate::prelude::*; | ||
// | ||
// pub struct AttributeParser; | ||
// | ||
// impl Parser<WithSource<ExprAttribute>> for AttributeParser { | ||
// type Output = Attribute; | ||
// fn parse(&self, input: WithSource<ExprAttribute>) -> Result<Self::Output> { | ||
// let source = input.source; | ||
// let input = input.ast; | ||
// let identifier = IdentifierParser::new().parse(input.attr)?; | ||
// let attributes = AttributesParser::default().parse(WithSource::new(&source, input.value))?; | ||
// Ok(Attribute::Group(identifier, attributes)) | ||
// } | ||
// } |
68 changes: 20 additions & 48 deletions
68
ecosystem/python/parser/src/macro_attributes/attributes/mod.rs
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,52 +1,24 @@ | ||
pub mod attribute; | ||
|
||
use crate::prelude::*; | ||
use crate::literal::LiteralParser; | ||
pub type AttributesParser = ligen::parsing::parser::universal::attributes::AttributesParser<LiteralParser>; | ||
use ligen::parsing::parser::universal::attributes::AttributesParser as InternalParser; | ||
use ligen::ir::Attributes; | ||
use rustpython_parser::ast::{Expr, Ranged}; | ||
|
||
// pub mod attribute; | ||
// | ||
// use rustpython_parser::ast::{Expr, ExprCall, Ranged}; | ||
// use ligen::ir::Attributes; | ||
// use crate::macro_attributes::attributes::attribute::AttributeParser; | ||
// use crate::prelude::*; | ||
// | ||
// pub struct AttributesParser; | ||
// | ||
// impl Parser<WithSource<Vec<Expr>>> for AttributesParser { | ||
// type Output = Attributes; | ||
// fn parse(&self, input: WithSource<Vec<Expr>>) -> Result<Self::Output> { | ||
// let source = input.source; | ||
// let input = input.ast; | ||
// if !input.is_empty() { | ||
// println!("{}", &source[input.first().unwrap().start().to_usize()..input.last().unwrap().end().to_usize()]); | ||
// } | ||
// let mut attributes = Attributes::default(); | ||
// for expr in input { | ||
// if let Expr::Attribute(expr) = expr { | ||
// attributes.attributes.push(AttributeParser.parse(WithSource::new(&source, expr))?); | ||
// } | ||
// } | ||
// Ok(attributes) | ||
// } | ||
// } | ||
// | ||
// impl Parser<WithSource<Box<Expr>>> for AttributesParser { | ||
// type Output = Attributes; | ||
// fn parse(&self, input: WithSource<Box<Expr>>) -> Result<Self::Output> { | ||
// let source = input.source; | ||
// let input = input.ast; | ||
// let mut attributes = Attributes::default(); | ||
// match input.as_ref() { | ||
// Expr::Call(call) => attributes.attributes.append(&mut AttributesParser::default().parse(WithSource::new(&source, call.clone()))?.attributes), | ||
// _ => () | ||
// } | ||
// Ok(attributes) | ||
// } | ||
// } | ||
// | ||
// impl Parser<WithSource<ExprCall>> for AttributesParser { | ||
// type Output = Attributes; | ||
// fn parse(&self, _input: WithSource<ExprCall>) -> Result<Self::Output> { | ||
// Ok(Default::default()) | ||
// } | ||
// } | ||
#[derive(Default)] | ||
pub struct AttributesParser { | ||
parser: InternalParser<LiteralParser> | ||
} | ||
|
||
impl Parser<WithSource<Vec<Expr>>> for AttributesParser { | ||
type Output = Attributes; | ||
fn parse(&self, input: WithSource<Vec<Expr>>) -> Result<Self::Output> { | ||
let source = if input.ast.is_empty() { | ||
Default::default() | ||
} else { | ||
input.source[input.ast.first().unwrap().start().to_usize()..input.ast.last().unwrap().end().to_usize()].to_string() | ||
}; | ||
self.parser.parse(source) | ||
} | ||
} |
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
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