test.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <script type="text/javascript" src="toolkit.js"></script>
  7. <script type="text/javascript" src="scanner.js"></script>
  8. <script type="text/javascript" src="parser.js"></script>
  9. <script type="text/javascript" src="syntax.js"></script>
  10. <script type="text/javascript" src="translator.js"></script>
  11. <script type="text/javascript" src="runtime-detail.js"></script>
  12. <script type="text/javascript" src="runtime-core.js"></script>
  13. <script type="text/javascript" src="runtime-prelude.js"></script>
  14. <script type="text/javascript" src="runtime-tools.js"></script>
  15. <script type="text/kumachan" src="modules/calc.k"></script>
  16. <script type="text/javascript">
  17. function init () {
  18. function load (file) {
  19. let xhr = new XMLHttpRequest()
  20. console.log(`loading ${file}`)
  21. xhr.open('GET', file)
  22. xhr.send()
  23. xhr.addEventListener('readystatechange', function (ev) {
  24. if (this.readyState == 4 && this.status == 200) {
  25. let k_code = this.responseText
  26. console.log(`parsing ${file}`)
  27. let t0 = performance.now()
  28. let tree = parse(k_code)
  29. let t1 = performance.now()
  30. console.log("time", t1-t0)
  31. console.log(tree)
  32. /*
  33. console.log(print_tree(tree))
  34. let code = translate(tree)
  35. let script = document.createElement('script')
  36. script.type = 'text/javascript'
  37. script.innerText = code
  38. document.head.appendChild(script)
  39. */
  40. }
  41. })
  42. }
  43. let tags = document.querySelectorAll('script[type="text/kumachan"]')
  44. map(tags, tag => load(tag.src))
  45. }
  46. window.addEventListener('DOMContentLoaded', init)
  47. </script>
  48. </head>
  49. <body>
  50. <h1>Test Page</h1>
  51. <p>The quick brown fox jumps over lazy dog.</p>
  52. </body>
  53. </html>