File tree Expand file tree Collapse file tree 6 files changed +25
-25
lines changed Expand file tree Collapse file tree 6 files changed +25
-25
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
pub mod css;
2
2
pub mod html;
3
- pub mod js;
4
3
pub mod layout;
5
4
6
5
use crate :: gui:: ApplicationWindow ;
@@ -13,9 +12,9 @@ use alloc::rc::Rc;
13
12
use alloc:: string:: String ;
14
13
use core:: cell:: RefCell ;
15
14
use liumlib:: * ;
16
- use saji:: ast:: Parser ;
17
- use saji:: runtime:: Runtime ;
18
- use saji:: token:: Lexer ;
15
+ use saji:: ast:: JsParser ;
16
+ use saji:: runtime:: JsRuntime ;
17
+ use saji:: token:: JsLexer ;
19
18
20
19
pub fn render ( html : String , window : & ApplicationWindow ) {
21
20
//println!("Input HTML:\n{}", html);
@@ -38,14 +37,14 @@ pub fn render(html: String, window: &ApplicationWindow) {
38
37
39
38
// js
40
39
let js = get_js_content ( dom_root. clone ( ) ) ;
41
- let lexer = Lexer :: new ( js) ;
40
+ let lexer = JsLexer :: new ( js) ;
42
41
//println!("JS lexer {:?}", lexer);
43
42
44
- let mut parser = Parser :: new ( lexer) ;
43
+ let mut parser = JsParser :: new ( lexer) ;
45
44
let ast = parser. parse_ast ( ) ;
46
45
//println!("JS ast {:?}", ast);
47
46
48
- let mut runtime = Runtime :: new ( ) ;
47
+ let mut runtime = JsRuntime :: new ( ) ;
49
48
runtime. execute ( & ast) ;
50
49
51
50
// apply css to html and create RenderTree
Original file line number Diff line number Diff line change 2
2
//! https://astexplorer.net/
3
3
4
4
use crate :: alloc:: string:: ToString ;
5
- use crate :: token:: { Lexer , Token } ;
5
+ use crate :: token:: { JsLexer , Token } ;
6
6
use alloc:: rc:: Rc ;
7
7
use alloc:: string:: String ;
8
8
use alloc:: vec:: Vec ;
@@ -137,13 +137,13 @@ impl Node {
137
137
}
138
138
}
139
139
140
- pub struct Parser {
141
- t : Lexer ,
140
+ pub struct JsParser {
141
+ t : JsLexer ,
142
142
}
143
143
144
144
#[ allow( dead_code) ]
145
- impl Parser {
146
- pub fn new ( t : Lexer ) -> Self {
145
+ impl JsParser {
146
+ pub fn new ( t : JsLexer ) -> Self {
147
147
Self { t }
148
148
}
149
149
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ mod token;
9
9
extern crate alloc;
10
10
11
11
use crate :: alloc:: string:: ToString ;
12
- use crate :: ast:: Parser ;
13
- use crate :: runtime:: Runtime ;
14
- use crate :: token:: Lexer ;
12
+ use crate :: ast:: JsParser ;
13
+ use crate :: runtime:: JsRuntime ;
14
+ use crate :: token:: JsLexer ;
15
15
use liumlib:: * ;
16
16
17
17
entry_point ! ( main) ;
@@ -22,13 +22,13 @@ fn main() {
22
22
exit ( 0 ) ;
23
23
}
24
24
25
- let lexer = Lexer :: new ( args[ 1 ] . to_string ( ) ) ;
25
+ let lexer = JsLexer :: new ( args[ 1 ] . to_string ( ) ) ;
26
26
println ! ( "lexer {:?}" , lexer) ;
27
27
28
- let mut parser = Parser :: new ( lexer) ;
28
+ let mut parser = JsParser :: new ( lexer) ;
29
29
let ast = parser. parse_ast ( ) ;
30
30
println ! ( "ast {:?}" , ast) ;
31
31
32
- let mut runtime = Runtime :: new ( ) ;
32
+ let mut runtime = JsRuntime :: new ( ) ;
33
33
runtime. execute ( & ast) ;
34
34
}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use alloc::string::String;
7
7
use alloc:: vec:: Vec ;
8
8
use core:: borrow:: Borrow ;
9
9
use core:: cell:: RefCell ;
10
- use hashbrown:: hash_map:: Entry ;
10
+ // use hashbrown::hash_map::Entry;
11
11
use hashbrown:: HashMap ;
12
12
#[ allow( unused_imports) ]
13
13
use liumlib:: * ;
@@ -61,6 +61,7 @@ impl Environment {
61
61
self . variables . insert ( name, value) ;
62
62
}
63
63
64
+ /*
64
65
fn assign_variable(&mut self, name: String, value: Option<RuntimeValue>) {
65
66
let entry = self.variables.entry(name.clone());
66
67
match entry {
@@ -76,6 +77,7 @@ impl Environment {
76
77
}
77
78
}
78
79
}
80
+ */
79
81
}
80
82
81
83
#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -92,13 +94,13 @@ impl Function {
92
94
}
93
95
94
96
#[ derive( Debug , Clone , PartialEq , Eq ) ]
95
- pub struct Runtime {
97
+ pub struct JsRuntime {
96
98
pub global_variables : HashMap < String , Option < RuntimeValue > > ,
97
99
pub functions : Vec < Function > ,
98
100
pub env : Rc < RefCell < Environment > > ,
99
101
}
100
102
101
- impl Runtime {
103
+ impl JsRuntime {
102
104
pub fn new ( ) -> Self {
103
105
Self {
104
106
global_variables : HashMap :: new ( ) ,
Original file line number Diff line number Diff line change @@ -24,13 +24,13 @@ pub enum Token {
24
24
}
25
25
26
26
#[ derive( Debug , Clone , PartialEq , Eq ) ]
27
- pub struct Lexer {
27
+ pub struct JsLexer {
28
28
pos : usize ,
29
29
input : Vec < char > ,
30
30
}
31
31
32
32
#[ allow( dead_code) ]
33
- impl Lexer {
33
+ impl JsLexer {
34
34
pub fn new ( js : String ) -> Self {
35
35
Self {
36
36
pos : 0 ,
@@ -175,7 +175,7 @@ impl Lexer {
175
175
}
176
176
}
177
177
178
- impl Iterator for Lexer {
178
+ impl Iterator for JsLexer {
179
179
type Item = Token ;
180
180
181
181
fn next ( & mut self ) -> Option < Self :: Item > {
You can’t perform that action at this time.
0 commit comments