-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the script to parse quint with ohmjs
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
|
||
// A test script to make sure that our Ohmjs grammar conforms to the Antlr4 | ||
// grammar. Since we do not allow the user to parse files via Ohmjs directly, | ||
// we have this script, for debugging purposes. | ||
|
||
const fs = require('fs') | ||
const quint = require('../src/generated/quint.ohm-bundle.js') | ||
const filename = process.argv[2] | ||
if (!filename) { | ||
console.error('Expected an input file as my first argument') | ||
process.exit(1) | ||
} | ||
|
||
const text = fs.readFileSync(filename, 'utf-8') | ||
const m = quint.match(text) | ||
if (m.failed()) { | ||
console.error(m.message) | ||
process.exit(2) | ||
} else { | ||
// nothing to report | ||
process.exit(0) | ||
} |