Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scanner: disable printing for WASM #94

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,34 @@ jobs:
with:
command: build

wasm:
needs: [generate]
runs-on: ubuntu-latest
name: Run WASM test build
steps:
- uses: actions/checkout@v4
- name: Download generated parser
uses: actions/download-artifact@v4
with:
name: parser
path: src/
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
cache: "npm"
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Run test build
run: npx tree-sitter build --wasm

success:
needs:
- compare-parser
- generate
- tests
- rust
- wasm
if: always()
runs-on: ubuntu-latest
name: "All checks passed"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ target/
*.so
*.pc
*.a
*.wasm
22 changes: 15 additions & 7 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,21 @@ static bool debug_mode = false; /* NOLINT(*-global-variables) */
static const bool debug_mode = false;
#endif

#define RUNTIME_ASSERT(cond) \
if (!(cond)) { \
(void)fprintf( \
stderr, "lex_nim: %s():%d: Assertion `%s' failed.\n", __func__, \
__LINE__, #cond); \
abort(); \
}
#ifndef __wasm__
# define RUNTIME_ASSERT(cond) \
if (!(cond)) { \
(void)fprintf( \
stderr, "lex_nim: %s():%d: Assertion `%s' failed.\n", __func__, \
__LINE__, #cond); \
abort(); \
}
#else
// WASM doesn't have printing enabled
# define RUNTIME_ASSERT(cond) \
if (!(cond)) { \
abort(); \
}
#endif

#define MIN(left, right) ((left) > (right) ? (right) : (left))
#define MAX(left, right) ((left) < (right) ? (right) : (left))
Expand Down
Loading