Skip to content

Commit

Permalink
update calc
Browse files Browse the repository at this point in the history
  • Loading branch information
luisespino committed Sep 3, 2024
1 parent c3934ca commit afca004
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions peggy/riscv/01-calc/calc.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<html>
<head>
<script type="text/javascript" src="parser.js"></script>
<script type="text/javascript" src="calc.js"></script>
</head>

Expand Down
4 changes: 1 addition & 3 deletions peggy/riscv/01-calc/calc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// import model
import { StartRules, SyntaxError, parse } from './parser.mjs'

let x;

document.getElementById("x").addEventListener("keydown", function(e) {
if (e.key === "Enter") {
x = document.getElementById("x").value;
document.getElementById("log").innerHTML = parse(x);
document.getElementById("log").innerHTML = PEG.parse(x);
}
});
21 changes: 10 additions & 11 deletions peggy/riscv/01-calc/parser.mjs → peggy/riscv/01-calc/parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @generated by Peggy 4.0.3.
window.PEG = // @generated by Peggy 4.0.3.
//
// https://peggyjs.org/

(function() {
"use strict";

function peg$subclass(child, parent) {
function C() { this.constructor = child; }
Expand Down Expand Up @@ -603,12 +604,10 @@ function peg$parse(input, options) {
}
}

const peg$allowedStartRules = [
"s"
];

export {
peg$allowedStartRules as StartRules,
peg$SyntaxError as SyntaxError,
peg$parse as parse
};
return {
StartRules: ["s"],
SyntaxError: peg$SyntaxError,
parse: peg$parse
};
})()
;

0 comments on commit afca004

Please sign in to comment.