Skip to content

Commit 39e98b6

Browse files
committed
browser-rs: clean up js
1 parent 0809419 commit 39e98b6

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

app/browser-rs/src/renderer/js/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/browser-rs/src/renderer/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod css;
22
pub mod html;
3-
pub mod js;
43
pub mod layout;
54

65
use crate::gui::ApplicationWindow;
@@ -13,9 +12,9 @@ use alloc::rc::Rc;
1312
use alloc::string::String;
1413
use core::cell::RefCell;
1514
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;
1918

2019
pub fn render(html: String, window: &ApplicationWindow) {
2120
//println!("Input HTML:\n{}", html);
@@ -38,14 +37,14 @@ pub fn render(html: String, window: &ApplicationWindow) {
3837

3938
// js
4039
let js = get_js_content(dom_root.clone());
41-
let lexer = Lexer::new(js);
40+
let lexer = JsLexer::new(js);
4241
//println!("JS lexer {:?}", lexer);
4342

44-
let mut parser = Parser::new(lexer);
43+
let mut parser = JsParser::new(lexer);
4544
let ast = parser.parse_ast();
4645
//println!("JS ast {:?}", ast);
4746

48-
let mut runtime = Runtime::new();
47+
let mut runtime = JsRuntime::new();
4948
runtime.execute(&ast);
5049

5150
// apply css to html and create RenderTree

app/saji/src/ast.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! https://astexplorer.net/
33
44
use crate::alloc::string::ToString;
5-
use crate::token::{Lexer, Token};
5+
use crate::token::{JsLexer, Token};
66
use alloc::rc::Rc;
77
use alloc::string::String;
88
use alloc::vec::Vec;
@@ -137,13 +137,13 @@ impl Node {
137137
}
138138
}
139139

140-
pub struct Parser {
141-
t: Lexer,
140+
pub struct JsParser {
141+
t: JsLexer,
142142
}
143143

144144
#[allow(dead_code)]
145-
impl Parser {
146-
pub fn new(t: Lexer) -> Self {
145+
impl JsParser {
146+
pub fn new(t: JsLexer) -> Self {
147147
Self { t }
148148
}
149149

app/saji/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ mod token;
99
extern crate alloc;
1010

1111
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;
1515
use liumlib::*;
1616

1717
entry_point!(main);
@@ -22,13 +22,13 @@ fn main() {
2222
exit(0);
2323
}
2424

25-
let lexer = Lexer::new(args[1].to_string());
25+
let lexer = JsLexer::new(args[1].to_string());
2626
println!("lexer {:?}", lexer);
2727

28-
let mut parser = Parser::new(lexer);
28+
let mut parser = JsParser::new(lexer);
2929
let ast = parser.parse_ast();
3030
println!("ast {:?}", ast);
3131

32-
let mut runtime = Runtime::new();
32+
let mut runtime = JsRuntime::new();
3333
runtime.execute(&ast);
3434
}

app/saji/src/runtime.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use alloc::string::String;
77
use alloc::vec::Vec;
88
use core::borrow::Borrow;
99
use core::cell::RefCell;
10-
use hashbrown::hash_map::Entry;
10+
//use hashbrown::hash_map::Entry;
1111
use hashbrown::HashMap;
1212
#[allow(unused_imports)]
1313
use liumlib::*;
@@ -61,6 +61,7 @@ impl Environment {
6161
self.variables.insert(name, value);
6262
}
6363

64+
/*
6465
fn assign_variable(&mut self, name: String, value: Option<RuntimeValue>) {
6566
let entry = self.variables.entry(name.clone());
6667
match entry {
@@ -76,6 +77,7 @@ impl Environment {
7677
}
7778
}
7879
}
80+
*/
7981
}
8082

8183
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -92,13 +94,13 @@ impl Function {
9294
}
9395

9496
#[derive(Debug, Clone, PartialEq, Eq)]
95-
pub struct Runtime {
97+
pub struct JsRuntime {
9698
pub global_variables: HashMap<String, Option<RuntimeValue>>,
9799
pub functions: Vec<Function>,
98100
pub env: Rc<RefCell<Environment>>,
99101
}
100102

101-
impl Runtime {
103+
impl JsRuntime {
102104
pub fn new() -> Self {
103105
Self {
104106
global_variables: HashMap::new(),

app/saji/src/token.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ pub enum Token {
2424
}
2525

2626
#[derive(Debug, Clone, PartialEq, Eq)]
27-
pub struct Lexer {
27+
pub struct JsLexer {
2828
pos: usize,
2929
input: Vec<char>,
3030
}
3131

3232
#[allow(dead_code)]
33-
impl Lexer {
33+
impl JsLexer {
3434
pub fn new(js: String) -> Self {
3535
Self {
3636
pos: 0,
@@ -175,7 +175,7 @@ impl Lexer {
175175
}
176176
}
177177

178-
impl Iterator for Lexer {
178+
impl Iterator for JsLexer {
179179
type Item = Token;
180180

181181
fn next(&mut self) -> Option<Self::Item> {

0 commit comments

Comments
 (0)