From f8bba1b9871544fd1378ca808d5e71a4260ea41c Mon Sep 17 00:00:00 2001 From: azur Date: Fri, 3 Mar 2023 16:31:11 +0700 Subject: [PATCH] restructure folders --- sketch.hlm | 21 +++++++++++++++++++++ src/{trans => asts}/ast.rs | 2 +- src/{trans => asts}/js.rs | 2 +- src/asts/mod.rs | 3 +++ src/{read => asts}/past.rs | 2 +- src/main.rs | 1 + src/read/mod.rs | 3 +-- src/read/parse.rs | 2 +- src/trans/low.rs | 8 ++++---- src/trans/mod.rs | 2 -- 10 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 sketch.hlm rename src/{trans => asts}/ast.rs (98%) rename src/{trans => asts}/js.rs (99%) create mode 100644 src/asts/mod.rs rename src/{read => asts}/past.rs (96%) diff --git a/sketch.hlm b/sketch.hlm new file mode 100644 index 0000000..a5a20a2 --- /dev/null +++ b/sketch.hlm @@ -0,0 +1,21 @@ +println({ + println("Hello"); + return let x: num = 17 * 2 in + x + 1; +} + 34); + +//---------- + +let stack = []; + +push("Hello"); +console.log(pop()); +push(17) +push(2) +push(pop() * pop()); +push(pop() + 1); +// [35] + +push(34) +push(pop() + pop()) // [35] + 34 +console.log(pop()); \ No newline at end of file diff --git a/src/trans/ast.rs b/src/asts/ast.rs similarity index 98% rename from src/trans/ast.rs rename to src/asts/ast.rs index d2db545..715915f 100644 --- a/src/trans/ast.rs +++ b/src/asts/ast.rs @@ -1,5 +1,5 @@ use std::fmt::{Display, Formatter, Result as FmtResult}; -use super::ty::Type; +use crate::trans::ty::Type; #[derive(Clone, Debug)] pub enum UnaryOp { diff --git a/src/trans/js.rs b/src/asts/js.rs similarity index 99% rename from src/trans/js.rs rename to src/asts/js.rs index 294b710..7ecada1 100644 --- a/src/trans/js.rs +++ b/src/asts/js.rs @@ -1,5 +1,5 @@ use std::fmt::{Display, Formatter, Result as FmtResult}; -use super::ty::Type; +use crate::trans::ty::Type; #[derive(Clone, Debug)] pub enum JSLiteral { Num(i64), Str(String), Bool(bool) } diff --git a/src/asts/mod.rs b/src/asts/mod.rs new file mode 100644 index 0000000..80a8284 --- /dev/null +++ b/src/asts/mod.rs @@ -0,0 +1,3 @@ +pub mod past; +pub mod ast; +pub mod js; \ No newline at end of file diff --git a/src/read/past.rs b/src/asts/past.rs similarity index 96% rename from src/read/past.rs rename to src/asts/past.rs index 5a6bc43..38fb626 100644 --- a/src/read/past.rs +++ b/src/asts/past.rs @@ -1,6 +1,6 @@ use crate::trans::ty::*; -use super::parse::Spanned; +use crate::read::parse::Spanned; #[derive(Clone, Debug)] pub enum PUnaryOp { diff --git a/src/main.rs b/src/main.rs index b953628..8594433 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![feature(trait_alias)] +pub mod asts; pub mod read; pub mod trans; pub mod args; diff --git a/src/read/mod.rs b/src/read/mod.rs index 0c737d8..329584d 100644 --- a/src/read/mod.rs +++ b/src/read/mod.rs @@ -1,2 +1 @@ -pub mod parse; -pub mod past; \ No newline at end of file +pub mod parse; \ No newline at end of file diff --git a/src/read/parse.rs b/src/read/parse.rs index 3918eba..e316d07 100644 --- a/src/read/parse.rs +++ b/src/read/parse.rs @@ -3,7 +3,7 @@ use chumsky::{prelude::*, Stream}; use std::fmt::{Display, Formatter, Result as FmtResult}; use crate::trans::ty::Type; -use super::past::*; +use crate::asts::past::*; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum Delim { Paren, Brack, Brace } diff --git a/src/trans/low.rs b/src/trans/low.rs index f55fbf6..6b0ae85 100644 --- a/src/trans/low.rs +++ b/src/trans/low.rs @@ -1,7 +1,7 @@ -use crate::read::past::{PExpr, PLiteral, PBinaryOp, PUnaryOp}; -use super::{ - ast::{Expr, Literal, BinaryOp, UnaryOp}, - js::{JSExpr, JSLiteral}, +use crate::asts::{ + past::*, + ast::*, + js::*, }; pub fn translate_expr(expr: PExpr) -> Expr { diff --git a/src/trans/mod.rs b/src/trans/mod.rs index e0d5a1b..a5a7890 100644 --- a/src/trans/mod.rs +++ b/src/trans/mod.rs @@ -1,4 +1,2 @@ pub mod ty; -pub mod ast; -pub mod js; pub mod low; \ No newline at end of file