-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix AST node produced by a single semicolon
Add a script to manually inspect results of parsing a short string. ref #187
- Loading branch information
Showing
5 changed files
with
45 additions
and
3 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
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,30 @@ | ||
const {parse} = require('../src/sonic-weave-ast'); | ||
|
||
console.log( | ||
'Iterating over all printable ASCII character to see which are accepted by the parser.' | ||
); | ||
|
||
const ASCII = ['\t', '\n', '\r']; | ||
|
||
for (let i = 32; i < 127; ++i) { | ||
ASCII.push(String.fromCharCode(i)); | ||
} | ||
|
||
for (const source of ASCII) { | ||
let result = '*Empty program*'; | ||
try { | ||
const ast = parse(source); | ||
if (ast.body.length) { | ||
result = ast.body[0].type; | ||
if (ast.body.length > 1) { | ||
result += '+'; | ||
} | ||
if (result === 'ExpressionStatement') { | ||
result += '->' + ast.body[0].expression.type; | ||
} | ||
} | ||
} catch { | ||
result = '*Rejects*'; | ||
} | ||
console.log(JSON.stringify(source) + '\t' + result); | ||
} |
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
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
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