Skip to content

Commit

Permalink
Ensuring the WebAssembly module is ready before any interaction (#64)
Browse files Browse the repository at this point in the history
* fixed wasm wait

* linter error
  • Loading branch information
jnyfah authored Dec 11, 2024
1 parent 9d5724c commit 9cb3260
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
11 changes: 9 additions & 2 deletions CompilerEditor/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ document.querySelector(".clear-btn").addEventListener("click", () => {
.forEach((pane) => (pane.innerHTML = ""));
});

// compile button click
document.getElementById("run-btn").addEventListener("click", handleCompile);
// Disable the compile button initially
document.getElementById("run-btn").disabled = true;

Module.onRuntimeInitialized = () => {
console.log("WebAssembly runtime initialized!");
document.getElementById("run-btn").disabled = false;
};

function handleCompile() {
const code = editor.getValue();
Expand All @@ -82,6 +87,8 @@ function handleCompile() {
}
}

document.getElementById("run-btn").addEventListener("click", handleCompile);

// Display compilation results in the output panes
function clearResults() {
document.getElementById("lexer-output").innerHTML =
Expand Down
4 changes: 0 additions & 4 deletions CuriousX/Generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,3 @@ if // Start if block
call $print // Call print
end // End if block
```

# Learn More
For detailed information about the Code Generation process, visit:
[CuriousX Lexical Analyzer Blog](https://jenniferchukwu.com/posts/codeGen)
4 changes: 0 additions & 4 deletions CuriousX/Lexer/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,3 @@ while ((token = lexer.nextToken()).type != LexerTokenType::Eof) {
// Process token
}
```
## Learn More
For detailed information about the lexical analysis process, visit:
[CuriousX Lexical Analyzer Blog](https://jenniferchukwu.com/posts/lexicalAnalysis)
3 changes: 0 additions & 3 deletions CuriousX/Parser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,3 @@ Error at line 3: Expected ')' after expression
if (x > 0 {
^
```
# Learn More
For detailed information about the syntax analysis process, visit:
[CuriousX Lexical Analyzer Blog](https://jenniferchukwu.com/posts/syntaxAnalysis)
4 changes: 0 additions & 4 deletions CuriousX/Semantic/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,3 @@ if (x) { // Error: Condition must be boolean

- Division by zero checking is planned but not yet implemented
- if statement cannot start a program

# Learn More
For detailed information about the semantic analysis process, visit:
[CuriousX Lexical Analyzer Blog](https://jenniferchukwu.com/posts/semanticAnalysis)
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ cmake --build build
```

#### WebAssembly Build

*NB: Make sure emscripten is active before building*
```bash
# Configure with Emscripten
mkdir build
emcmake cmake -B build -S .

# Build
Expand Down Expand Up @@ -138,4 +141,6 @@ cd build && ctest -C Debug -V

## Further Reading
- [Lexer Design Documentation](CuriousX\Lexer\Readme.md)
- [Grammar Design Documentation](CuriousX\Parser\README.md)
- [SEmantic Design](CuriousX\Semantic\Readme.md)
- [WebAssembly Output Format](CuriousX\Generation\README.md)

0 comments on commit 9cb3260

Please sign in to comment.