You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Replace architecture overview image with mermaid graph
* Update architecture.md with correct paths and links
- Fix file paths to reflect crates/ directory structure
- Update GitHub permalink references to current commit
- Remove trailing slashes from package names
- Use archive.org for broken desosa.nl link
- Change master to main branch reference
* Update architecture documentation for ruff_python_parser
RustPython now uses ruff_python_parser from astral-sh/ruff instead of
the separate RustPython/Parser project. Update architecture documentation
to reflect this change.
@@ -36,17 +72,17 @@ The main entry point of RustPython is located in `src/main.rs` and simply forwar
36
72
37
73
For each of the three components, the entry point is as follows:
38
74
39
-
- Parser: The Parser is located in a separate project, [RustPython/Parser][10]. See the documentation there for more information.
40
-
- Compiler: `compile`, located in [`vm/src/vm/compile.rs`][11], this eventually forwards a call to [`compiler::compile`][12].
41
-
- VM: `run_code_obj`, located in [`vm/src/vm/mod.rs`][13]. This creates a new frame in which the bytecode is executed.
75
+
- Parser: The Parser is located in a separate project, [ruff_python_parser][10]. See the documentation there for more information.
76
+
- Compiler: `compile`, located in [`crates/vm/src/vm/compile.rs`][11], this eventually forwards a call to [`compiler::compile`][12].
77
+
- VM: `run_code_obj`, located in [`crates/vm/src/vm/mod.rs`][13]. This creates a new frame in which the bytecode is executed.
42
78
43
79
## Components
44
80
45
81
Here we give a brief overview of each component and its function. For more details for the separate crates please take a look at their respective READMEs.
46
82
47
83
### Compiler
48
84
49
-
This component, implemented as the `rustpython-compiler/` package, is responsible for translating a Python source file into its equivalent bytecode representation. As an example, the following Python file:
85
+
This component, implemented as the `rustpython-compiler` package, is responsible for translating a Python source file into its equivalent bytecode representation. As an example, the following Python file:
50
86
51
87
```python
52
88
deff(x):
@@ -71,11 +107,11 @@ The Parser is the main sub-component of the compiler. All the functionality requ
71
107
1. Lexical Analysis
72
108
2. Parsing
73
109
74
-
The functionality for parsing resides in the RustPython/Parser project. See the documentation there for more information.
110
+
The functionality for parsing resides in the ruff_python_parser project in the astral-sh/ruff repository. See the documentation there for more information.
75
111
76
112
### VM
77
113
78
-
The Virtual Machine (VM) is responsible for executing the bytecode generated by the compiler. It is implemented in the `rustpython-vm/` package. The VM is currently implemented as a stack machine, meaning that it uses a stack to store intermediate results. In the `rustpython-vm/` package, additional sub-components are present, for example:
114
+
The Virtual Machine (VM) is responsible for executing the bytecode generated by the compiler. It is implemented in the `rustpython-vm` package. The VM is currently implemented as a stack machine, meaning that it uses a stack to store intermediate results. In the `rustpython-vm` package, additional sub-components are present, for example:
79
115
80
116
- builtins: the built in objects of Python, such as `int` and `str`.
81
117
- stdlib: parts of the standard library that contains built-in modules needed for the VM to function, such as `sys`.
@@ -122,7 +158,7 @@ The RustPython executable/REPL (Read-Eval-Print-Loop) is implemented here, which
122
158
Some things to note:
123
159
124
160
- The CLI is defined in the [`run` function of `src/lib.rs`][16].
125
-
- The interface and helper for the REPL are defined in this package, but the actual REPL can be found in `vm/src/readline.rs`
161
+
- The interface and helper for the REPL are defined in this package, but the actual REPL can be found in `crates/vm/src/readline.rs`
126
162
127
163
### WASM
128
164
@@ -133,18 +169,18 @@ Crate for WebAssembly build, which compiles the RustPython package to a format t
133
169
Integration and snippets that test for additional edge-cases, implementation specific functionality and bug report snippets.
0 commit comments