rustpython_ast/
lib.rs

1//! Python AST node definitions and utilities.
2//!
3//! AST nodes are very similary defined like [Python AST](https://docs.python.org/3/library/ast.html).
4//! But a few exceptions exist due to parser optimization.
5//! They can be transformed to matching Python-styled AST in reasonable cost.
6//!
7//! [PythonArguments] is replaced by [Arguments]. The new [Arguments] type representation uses a new type
8//! [ArgWithDefault] to represent arguments with default values. See each type documentation for more details.
9//!
10//! A few top-level sum types are renamed to human friendly names.
11//! [CmpOp] refers `cmpop`
12//! [UnaryOp] refers `unaryop`
13//! [BoolOp] refers `boolop`
14//! [WithItem] refers `withitem`
15//! [ExceptHandler] refers `excepthandler`
16//!
17
18mod builtin;
19mod generic;
20mod impls;
21mod ranged;
22#[cfg(feature = "unparse")]
23pub mod unparse;
24
25#[cfg(feature = "malachite-bigint")]
26pub use malachite_bigint as bigint;
27#[cfg(feature = "num-bigint")]
28pub use num_bigint as bigint;
29
30pub use builtin::*;
31pub use generic::*;
32pub use ranged::Ranged;
33pub use rustpython_parser_core::{text_size, ConversionFlag};
34
35pub trait Node {
36    const NAME: &'static str;
37    const FIELD_NAMES: &'static [&'static str];
38}
39
40#[cfg(feature = "fold")]
41pub mod fold;
42#[cfg(feature = "fold")]
43pub use fold::Fold;
44
45#[cfg(feature = "visitor")]
46mod visitor {
47    use super::generic::*;
48
49    include!("gen/visitor.rs");
50}
51
52#[cfg(feature = "location")]
53pub mod located;
54#[cfg(feature = "location")]
55mod source_locator;
56#[cfg(feature = "location")]
57pub use rustpython_parser_core::source_code;
58
59#[cfg(feature = "visitor")]
60pub use visitor::Visitor;
61
62#[cfg(feature = "constant-optimization")]
63mod optimizer;
64#[cfg(feature = "constant-optimization")]
65pub use optimizer::ConstantOptimizer;