<html> <input type="text" id="bakusnaur"></input> <input type="submit" onclick="onClick ()"></input> <script> /* expr ::= term + expr | term term ::= factor * term | factor factor ::= (expr) | id | const */ function onClick () { p = document.getElementById ("bakusnaur").value; j = 0; alert(expr ()); } let p = "(5+6)*2"; var j = 0; function expr () { var x; var y = 0; x = term (); if (p [j] == '+') { j++; y = expr (); } return x+y; } function term () { var x; var y = 1; x = factor (); if (p [j] == '*') { j++; y = term (); } return x*y; } function factor () { var x; if (p [j] == '(') { j++; x = expr (); if (p [j] != ')') { alert ("Error"); } j++; } if ((p [j] >= '0') \&\& (p [j] <= '9')) { x = parseInt (p [j]); j++; } return x; } </script> </html>