mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Migrated the project to the Rust 2018 edition
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
name = "rustpython"
|
||||
version = "0.0.1"
|
||||
authors = ["Windel Bouwman", "Shing Lyu <shing.lyu@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
members = [".", "vm", "wasm/lib", "parser"]
|
||||
|
||||
@@ -3,6 +3,7 @@ name = "rustpython_parser"
|
||||
version = "0.0.1"
|
||||
authors = [ "Shing Lyu", "Windel Bouwman" ]
|
||||
build = "build.rs"
|
||||
edition = "2018"
|
||||
|
||||
[build-dependencies]
|
||||
lalrpop="0.15.1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
extern crate lalrpop;
|
||||
use lalrpop;
|
||||
|
||||
fn main() {
|
||||
lalrpop::process_root().unwrap();
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
extern crate lalrpop_util;
|
||||
use self::lalrpop_util::ParseError as InnerError;
|
||||
|
||||
use lexer::{LexicalError, Location};
|
||||
use token::Tok;
|
||||
use crate::lexer::{LexicalError, Location};
|
||||
use crate::token::Tok;
|
||||
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
|
||||
@@ -541,7 +541,7 @@ where
|
||||
|
||||
fn is_char(&self) -> bool {
|
||||
match self.chr0 {
|
||||
Some('a'...'z') | Some('A'...'Z') | Some('_') | Some('0'...'9') => true,
|
||||
Some('a'..='z') | Some('A'..='Z') | Some('_') | Some('0'..='9') => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -549,19 +549,19 @@ where
|
||||
fn is_number(&self, radix: u32) -> bool {
|
||||
match radix {
|
||||
2 => match self.chr0 {
|
||||
Some('0'...'1') => true,
|
||||
Some('0'..='1') => true,
|
||||
_ => false,
|
||||
},
|
||||
8 => match self.chr0 {
|
||||
Some('0'...'7') => true,
|
||||
Some('0'..='7') => true,
|
||||
_ => false,
|
||||
},
|
||||
10 => match self.chr0 {
|
||||
Some('0'...'9') => true,
|
||||
Some('0'..='9') => true,
|
||||
_ => false,
|
||||
},
|
||||
16 => match self.chr0 {
|
||||
Some('0'...'9') | Some('a'...'f') | Some('A'...'F') => true,
|
||||
Some('0'..='9') | Some('a'..='f') | Some('A'..='F') => true,
|
||||
_ => false,
|
||||
},
|
||||
x => unimplemented!("Radix not implemented: {}", x),
|
||||
@@ -686,8 +686,8 @@ where
|
||||
}
|
||||
|
||||
match self.chr0 {
|
||||
Some('0'...'9') => return Some(self.lex_number()),
|
||||
Some('_') | Some('a'...'z') | Some('A'...'Z') => return Some(self.lex_identifier()),
|
||||
Some('0'..='9') => return Some(self.lex_number()),
|
||||
Some('_') | Some('a'..='z') | Some('A'..='Z') => return Some(self.lex_identifier()),
|
||||
Some('#') => {
|
||||
self.lex_comment();
|
||||
continue;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
extern crate num_bigint;
|
||||
extern crate num_traits;
|
||||
|
||||
pub mod ast;
|
||||
pub mod error;
|
||||
pub mod lexer;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
extern crate lalrpop_util;
|
||||
|
||||
use std::iter;
|
||||
|
||||
use super::ast;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "py_code_object"
|
||||
version = "0.1.0"
|
||||
authors = ["Shing Lyu <shing.lyu@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "python_compiler"
|
||||
version = "0.1.0"
|
||||
authors = ["Shing Lyu <shing.lyu@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cpython = { git = "https://github.com/dgrunwald/rust-cpython.git" }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "rustpython_vm"
|
||||
version = "0.1.0"
|
||||
authors = ["Shing Lyu <shing.lyu@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.0.4"
|
||||
|
||||
@@ -9,7 +9,7 @@ use super::compile;
|
||||
use super::pyobject::{DictProtocol, PyResult};
|
||||
use super::util;
|
||||
use super::vm::VirtualMachine;
|
||||
use obj::{objsequence, objstr};
|
||||
use crate::obj::{objsequence, objstr};
|
||||
|
||||
fn import_uncached_module(
|
||||
vm: &mut VirtualMachine,
|
||||
|
||||
@@ -5,7 +5,7 @@ extern crate rand;
|
||||
use super::super::obj::{objfloat, objtype};
|
||||
use super::super::pyobject::{PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeProtocol};
|
||||
use super::super::VirtualMachine;
|
||||
use stdlib::random::rand::distributions::{Distribution, Normal};
|
||||
use crate::stdlib::random::rand::distributions::{Distribution, Normal};
|
||||
|
||||
pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
|
||||
let py_mod = ctx.new_module(&"random".to_string(), ctx.new_scope(None));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use obj::objtype;
|
||||
use pyobject::{PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeProtocol};
|
||||
use crate::obj::objtype;
|
||||
use crate::pyobject::{PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeProtocol};
|
||||
use crate::vm::VirtualMachine;
|
||||
use std::rc::Rc;
|
||||
use std::{env, mem};
|
||||
use vm::VirtualMachine;
|
||||
|
||||
/*
|
||||
* The magic sys module.
|
||||
|
||||
@@ -5,6 +5,7 @@ authors = ["Ryan Liddle <ryan@rmliddle.com>"]
|
||||
license = "MIT"
|
||||
description = "A Python-3 (CPython >= 3.5.0) Interpreter written in Rust, compiled to WASM"
|
||||
repository = "https://github.com/RustPython/RustPython/tree/master/wasm/lib"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
Reference in New Issue
Block a user