Remove unused compiler namespace in parser

This commit is contained in:
Windel Bouwman
2018-07-07 17:36:21 +02:00
parent 377795dbec
commit 4be77bcbc7
13 changed files with 13 additions and 68 deletions

2
parser/.gitignore vendored
View File

@@ -1,3 +1,3 @@
src/compiler/python.rs
src/python.rs
target/

View File

@@ -1,21 +0,0 @@
// This file makes this directory a submodule.
mod parser;
mod python;
pub mod ast;
mod token;
mod lexer;
// mod compile;
// mod bytecode;
mod builtins;
mod pyobject;
// mod vm;
pub use self::parser::parse;
// pub use self::vm::evaluate;
// Mimic eval code objects:
//pub fn eval_code() -> pyobject::PyObjectRef {
//}

View File

@@ -1,4 +1,12 @@
#[macro_use]
extern crate log;
pub mod compiler;
mod parser;
mod python;
pub mod ast;
mod token;
mod lexer;
// mod builtins;
// mod pyobject;
pub use self::parser::parse;

View File

@@ -1,42 +0,0 @@
extern crate clap;
#[macro_use]
extern crate log;
extern crate env_logger;
use clap::{Arg, App};
use std::path::Path;
mod compiler;
fn main() {
env_logger::init();
let matches = App::new("RsPython")
.version("0.0.1")
.author("Windel Bouwman")
.about("Rust implementation of the Python language")
.arg(Arg::with_name("script")
.required(true)
.index(1))
.arg(Arg::with_name("v")
.short("v")
.multiple(true)
.help("Give the verbosity"))
.get_matches();
// Figure out the filename:
let script_file = matches.value_of("script").unwrap_or("foo");
info!("Running file {}", script_file);
// Parse an ast from it:
let filepath = Path::new(script_file);
match compiler::parse(filepath) {
Ok(program) => {
debug!("Got ast: {:?}", program);
let bytecode = compiler::compile(program);
debug!("Code object: {:?}", bytecode);
compiler::evaluate(bytecode);
info!("Great succes!!");
},
Err(msg) => error!("Parsing went horribly wrong: {}", msg),
}
}

View File

@@ -3,7 +3,7 @@
*/
extern crate rustpython_parser;
extern crate py_code_object;
use rustpython_parser::compiler::ast;
use rustpython_parser::ast;
use self::py_code_object::{PyCodeObject, NativeType};
struct Compiler {

View File

@@ -10,7 +10,7 @@ extern crate rustpython_vm;
mod compile_py_code_object;
use clap::{Arg, App};
use std::path::Path;
use rustpython_parser::compiler;
use rustpython_parser::parse;
use rustpython_vm::VirtualMachine;
@@ -35,7 +35,7 @@ fn main() {
// Parse an ast from it:
let filepath = Path::new(script_file);
match compiler::parse(filepath) {
match parse(filepath) {
Ok(program) => {
debug!("Got ast: {:?}", program);
let bytecode = compile_py_code_object::compile(program);