Skip to content

Commit ccd1534

Browse files
committed
Merge branch 'master' into bojan/objobject-__and__-default
2 parents e7cd832 + c4cbeda commit ccd1534

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2829
-895
lines changed

Cargo.lock

+39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ Or use the interactive shell:
2626
- Full Python-3 environment entirely in Rust (not CPython bindings)
2727
- A clean implementation without compatibility hacks
2828

29+
# Documentation
30+
31+
Currently the project is in an early phase, and so is the documentation.
32+
33+
You can generate documentation by running:
34+
35+
```shell
36+
$ cargo doc
37+
```
38+
39+
Documentation HTML files can then be found in the `target/doc` directory.
40+
2941
# Code organization
3042

3143
- `parser`: python lexing, parsing and ast
@@ -64,6 +76,24 @@ There also are some unittests, you can run those will cargo:
6476
$ cargo test --all
6577
```
6678

79+
# Using another standard library
80+
81+
As of now the standard library is under construction.
82+
83+
You can play around
84+
with other standard libraries for python. For example,
85+
the [ouroboros library](https://github.com/pybee/ouroboros).
86+
87+
To do this, follow this method:
88+
89+
```shell
90+
$ cd ~/GIT
91+
$ git clone git@github.com:pybee/ouroboros.git
92+
$ export PYTHONPATH=~/GIT/ouroboros/ouroboros
93+
$ cd RustPython
94+
$ cargo run -- -c 'import statistics'
95+
```
96+
6797
# Compiling to WebAssembly
6898

6999
## Setup

parser/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ lalrpop="0.15.1"
1111
lalrpop-util="0.15.1"
1212
log="0.4.1"
1313
regex="0.2.2"
14+
num-bigint = "0.2"
15+
num-traits = "0.2"
1416

parser/src/ast.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
/*
2-
* Implement abstract syntax tree nodes for the python language.
3-
*/
1+
//! Implement abstract syntax tree nodes for the python language.
2+
//!
3+
//! Roughly equivalent to this: https://docs.python.org/3/library/ast.html
44
55
pub use super::lexer::Location;
6+
use num_bigint::BigInt;
67
/*
78
#[derive(Debug)]
89
@@ -40,6 +41,7 @@ pub struct Located<T> {
4041

4142
pub type LocatedStatement = Located<Statement>;
4243

44+
/// Abstract syntax tree nodes for python statements.
4345
#[derive(Debug, PartialEq)]
4446
pub enum Statement {
4547
Break,
@@ -70,6 +72,12 @@ pub enum Statement {
7072
Expression {
7173
expression: Expression,
7274
},
75+
Global {
76+
names: Vec<String>,
77+
},
78+
Nonlocal {
79+
names: Vec<String>,
80+
},
7381
If {
7482
test: Expression,
7583
body: Vec<LocatedStatement>,
@@ -191,6 +199,9 @@ pub enum Expression {
191199
String {
192200
value: String,
193201
},
202+
Bytes {
203+
value: Vec<u8>,
204+
},
194205
Identifier {
195206
name: String,
196207
},
@@ -275,8 +286,10 @@ pub enum BooleanOperator {
275286

276287
#[derive(Debug, PartialEq)]
277288
pub enum UnaryOperator {
289+
Pos,
278290
Neg,
279291
Not,
292+
Inv,
280293
}
281294

282295
#[derive(Debug, PartialEq)]
@@ -295,6 +308,7 @@ pub enum Comparison {
295308

296309
#[derive(Debug, PartialEq)]
297310
pub enum Number {
298-
Integer { value: i32 },
311+
Integer { value: BigInt },
299312
Float { value: f64 },
313+
Complex { real: f64, imag: f64 },
300314
}

0 commit comments

Comments
 (0)