mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-30 15:18:02 +00:00
numerous refactoring
- Split parser core and compiler core. Fix #14 - AST int type to `u32` - Updated asdl_rs.py and update_asdl.sh fix #6 - Use `ruff_python_ast::SourceLocation` for Python source location. Deleted our own Location. - Renamed ast::Located to ast::Attributed to distinguish terms for TextSize and SourceLocation - `ast::<Node>`s for TextSize located ast. `ast::located::<Node>` for Python source located ast. - And also strictly renaming `located` to refer only python location related interfaces. - `SourceLocator` to convert locations. - New `source-code` features of to disable python locations when unnecessary. - Also including fully merging https://github.com/astral-sh/RustPython/pull/4 closes #9
This commit is contained in:
parent
09a6afdd04
commit
a3d9d8cb14
29 changed files with 9737 additions and 12000 deletions
|
@ -7,53 +7,21 @@ mod generic {
|
|||
include!("gen/generic.rs");
|
||||
}
|
||||
mod impls;
|
||||
#[cfg(feature = "location")]
|
||||
pub mod located {
|
||||
include!("gen/located.rs");
|
||||
}
|
||||
#[cfg(feature = "location")]
|
||||
mod locator;
|
||||
#[cfg(feature = "location")]
|
||||
pub use crate::locator::locate;
|
||||
#[cfg(feature = "location")]
|
||||
pub use rustpython_compiler_core::SourceLocator;
|
||||
|
||||
#[cfg(feature = "source-code")]
|
||||
mod source_locator;
|
||||
#[cfg(feature = "unparse")]
|
||||
mod unparse;
|
||||
|
||||
pub use attributed::Attributed;
|
||||
pub use constant::{Constant, ConversionFlag};
|
||||
pub use constant::Constant;
|
||||
pub use generic::*;
|
||||
pub use rustpython_parser_core::{text_size, ConversionFlag};
|
||||
|
||||
pub type Suite<U = ()> = Vec<Stmt<U>>;
|
||||
|
||||
pub mod location {
|
||||
pub use rustpython_compiler_core::source_code::{OneIndexed, SourceLocation};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SourceRange {
|
||||
pub start: SourceLocation,
|
||||
pub end: Option<SourceLocation>,
|
||||
}
|
||||
|
||||
impl SourceRange {
|
||||
pub fn new(start: SourceLocation, end: SourceLocation) -> Self {
|
||||
Self {
|
||||
start,
|
||||
end: Some(end),
|
||||
}
|
||||
}
|
||||
pub fn unwrap_end(&self) -> SourceLocation {
|
||||
self.end.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::ops::Range<SourceLocation>> for SourceRange {
|
||||
fn from(value: std::ops::Range<SourceLocation>) -> Self {
|
||||
Self {
|
||||
start: value.start,
|
||||
end: Some(value.end),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "source-code")]
|
||||
pub mod located {
|
||||
include!("gen/located.rs");
|
||||
}
|
||||
|
||||
pub use rustpython_parser_core::source_code;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue