Browse Source

updating wasm output

pull/18/head
Jason Williams 6 years ago
parent
commit
618dda518d
  1. 19
      index.html
  2. 2
      index.js
  3. 3
      src/lib/lib.rs

19
index.html

@ -19,18 +19,33 @@
height: 400px;
border: 1px solid #8db5e4;
margin-bottom: 16px;
flex: 2;
margin-right: 16px;
}
.container {
margin: 0 auto;
}
.demo__repl {
display: flex;
}
.output {
flex: 1;
border: 1px solid black;
padding: 8px;
font-size: 2rem;
}
</style>
<body>
<div class="container">
<img class="demo__img" src="assets/01_rust_loves_js.png" />
<textarea class="form-control textbox"> </textarea>
<div class="demo__repl">
<textarea class="form-control textbox"> </textarea>
<p class="output"></p>
</div>
<button type="buttont" class="btn btn-primary">Evaluate</button>
<p class="output">Test</p>
</div>
</body>
</html>

2
index.js

@ -15,6 +15,6 @@ function clickHandler(evt) {
let t0 = performance.now();
let result = window.evaluate(text);
let t1 = performance.now();
p.textContent = `${t1 - t0}ms: ${result}`;
p.textContent = `> ${result}`;
console.log(result);
}

3
src/lib/lib.rs

@ -28,6 +28,7 @@ pub fn exec(src: String) {
let mut lexer = Lexer::new(&src);
lexer.lex().unwrap();
let tokens = lexer.tokens;
// dbg!(&tokens);
// Setup executor
let expr = Parser::new(tokens).parse_all().unwrap();
@ -58,7 +59,7 @@ pub fn evaluate(src: &str) -> String {
Ok(v) => {
expr = v;
}
Err(v) => {
Err(_v) => {
log("parsing fail");
return String::from("parsing failed");
}

Loading…
Cancel
Save