Move files to common directory
This commit is contained in:
15
rustpython_original/ruff_python_ast/Cargo.toml
Normal file
15
rustpython_original/ruff_python_ast/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "ruff_python_ast"
|
||||
version = "0.2.0"
|
||||
description = "AST definitions for Ruff"
|
||||
authors = ["Charlie Marsh <charlie.r.marsh@gmail.com>"]
|
||||
edition = "2021"
|
||||
repository = "https://github.com/astral-sh/ruff"
|
||||
license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
ruff_text_size = { workspace = true }
|
||||
|
||||
is-macro = { workspace = true }
|
||||
num-bigint = { workspace = true }
|
||||
static_assertions = { workspace = true }
|
||||
48
rustpython_original/ruff_python_ast/src/lib.rs
Normal file
48
rustpython_original/ruff_python_ast/src/lib.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
//! Python AST node definitions and utilities.
|
||||
//!
|
||||
//! AST nodes are very similary defined like [Python AST](https://docs.python.org/3/library/ast.html).
|
||||
//! But a few exceptions exist due to ruff_python_parser optimization.
|
||||
//! They can be transformed to matching Python-styled AST in reasonable cost.
|
||||
//!
|
||||
//! [PythonArguments] is replaced by [Arguments]. The new [Arguments] type representation uses a new type
|
||||
//! [ArgWithDefault] to represent arguments with default values. See each type documentation for more details.
|
||||
//!
|
||||
//! A few top-level sum types are renamed to human friendly names.
|
||||
//! [CmpOp] refers `cmpop`
|
||||
//! [UnaryOp] refers `unaryop`
|
||||
//! [BoolOp] refers `boolop`
|
||||
//! [WithItem] refers `withitem`
|
||||
//! [ExceptHandler] refers `excepthandler`
|
||||
//!
|
||||
|
||||
mod nodes;
|
||||
|
||||
pub use nodes::*;
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
|
||||
pub trait Ranged {
|
||||
fn range(&self) -> TextRange;
|
||||
|
||||
fn start(&self) -> TextSize {
|
||||
self.range().start()
|
||||
}
|
||||
|
||||
fn end(&self) -> TextSize {
|
||||
self.range().end()
|
||||
}
|
||||
}
|
||||
|
||||
impl Ranged for TextRange {
|
||||
fn range(&self) -> TextRange {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Ranged for &T
|
||||
where
|
||||
T: Ranged,
|
||||
{
|
||||
fn range(&self) -> TextRange {
|
||||
T::range(self)
|
||||
}
|
||||
}
|
||||
3036
rustpython_original/ruff_python_ast/src/nodes.rs
Normal file
3036
rustpython_original/ruff_python_ast/src/nodes.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user