-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f78b820
commit 06e41f9
Showing
20 changed files
with
401 additions
and
776 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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_modules/ | ||
dist/ | ||
out/ | ||
/dist/ | ||
/out/ | ||
/test/out/ | ||
# for running with @swc/register | ||
src/rion.js |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "test/**/*.test.ts", | ||
"require": "@swc/register" | ||
} | ||
"spec": "test/**/*.spec.ts", | ||
"require": ["@swc/register"] | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
const { createCommand } = require("../dist/cli"); | ||
|
||
createCommand(true).parse(); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { expect } from "chai"; | ||
import * as fs from "fs/promises"; | ||
import * as path from "path"; | ||
import { createCommand } from "../src/cli"; | ||
|
||
const OUT_PATH = path.join(__dirname, "out"); | ||
|
||
//TODO: use in-memory fs? | ||
|
||
const noop = () => {}; | ||
function runCLI(args: string[], output: (out: string) => void = noop) { | ||
const _log = console.log; | ||
console.log = output; | ||
|
||
var cli = createCommand(); | ||
cli.parse([process.argv[0], process.argv[1], ...args]); | ||
|
||
console.log = _log; | ||
} | ||
|
||
async function cleanOutput() { | ||
await Promise.all( | ||
(await fs.readdir(OUT_PATH)).map((fname) => fs.rm(path.join(OUT_PATH, fname), { recursive: true, force: true })) | ||
); | ||
} | ||
|
||
before(async () => { | ||
await fs.mkdir(OUT_PATH, { recursive: true }); | ||
await cleanOutput(); | ||
}); | ||
|
||
describe("CLI", function () { | ||
beforeEach(async function () { | ||
await cleanOutput(); | ||
}); | ||
it("should output all targets", async function () { | ||
runCLI(["compile", path.join(__dirname, "grammars/rion.iro"), "-o", OUT_PATH, "-t", "all"]); | ||
expect(await fs.readdir(OUT_PATH)).to.have.members( | ||
[ | ||
// | ||
"rion.ace.js", | ||
"rion.ace.json", | ||
"rion.tmlanguage", | ||
"rion.tmlanguage.json", | ||
], | ||
"expected output directory to have all target files" | ||
); | ||
}); | ||
it("should not output files on fail", async function () { | ||
runCLI(["compile", path.join(__dirname, "grammars/should_fail/fail_parser.iro"), "-o", OUT_PATH, "-t", "all"]); | ||
expect(await fs.readdir(OUT_PATH)).to.be.empty; | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,66 +1,66 @@ | ||
name = mylang | ||
file_extensions []= hello, world; | ||
#__rec1 \= $${__rec2} | ||
#__rec2 \= $${__rec1} | ||
__Identifier \= [a-z0-1_]+ | ||
contexts [] { | ||
main : context { | ||
: push { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
context [] = inside_quotes; | ||
} | ||
} | ||
inside_quotes : context { | ||
: pop { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
} | ||
: pattern { | ||
regex \= (\\(?:\\|")) | ||
styles [] = .escaped_text; | ||
} | ||
: pattern { | ||
regex \= ([^"\\]+) | ||
styles [] = .quoted_text; | ||
} | ||
} | ||
} | ||
styles [] { | ||
.punctuation : style { | ||
color = brown | ||
ace_scope = punctuation | ||
textmate_scope = punctuation | ||
pygments_scope = Punctuation | ||
} | ||
.escaped_text : style { | ||
color = white | ||
ace_scope = punctuation | ||
textmate_scope = punctuation | ||
pygments_scope = Punctuation | ||
} | ||
.keyword : style { | ||
color = cyan | ||
ace_scope = keyword | ||
textmate_scope = keywordd | ||
pygments_scope = Keyword | ||
} | ||
.quoted_text : style { | ||
color = yellow | ||
ace_scope = text | ||
textmate_scope = text | ||
pygments_scope = String | ||
} | ||
name = mylang | ||
file_extensions []= hello, world; | ||
#__rec1 \= $${__rec2} | ||
#__rec2 \= $${__rec1} | ||
|
||
__Identifier \= [a-z0-1_]+ | ||
|
||
contexts [] { | ||
|
||
|
||
|
||
main : context { | ||
: push { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
context [] = inside_quotes; | ||
} | ||
} | ||
|
||
inside_quotes : context { | ||
: pop { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
} | ||
: pattern { | ||
regex \= (\\(?:\\|")) | ||
styles [] = .escaped_text; | ||
} | ||
: pattern { | ||
regex \= ([^"\\]+) | ||
styles [] = .quoted_text; | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
styles [] { | ||
|
||
.punctuation : style { | ||
color = brown | ||
ace_scope = punctuation | ||
textmate_scope = punctuation | ||
pygments_scope = Punctuation | ||
} | ||
.escaped_text : style { | ||
color = white | ||
ace_scope = punctuation | ||
textmate_scope = punctuation | ||
pygments_scope = Punctuation | ||
} | ||
.keyword : style { | ||
color = cyan | ||
ace_scope = keyword | ||
textmate_scope = keywordd | ||
pygments_scope = Keyword | ||
} | ||
.quoted_text : style { | ||
color = yellow | ||
ace_scope = text | ||
textmate_scope = text | ||
pygments_scope = String | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,49 +1,49 @@ | ||
name = mylang | ||
file_extensions []= hello, world; | ||
__rec1 \= $${__rec2} | ||
__rec2 \= $${__rec1} | ||
__Identifier \= [a-z0-1_]+ | ||
contexts [] { | ||
main : context { | ||
: push { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
context [] = inside_quotes; | ||
} | ||
} | ||
inside_quotes : context { | ||
: pop { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
} | ||
: pattern { | ||
regex \= (\\(?:\\|")) | ||
styles [] = .punctuation; | ||
} | ||
: pattern { | ||
regex \= ([^"\\]+) | ||
styles [] = .quoted_text; | ||
} | ||
} | ||
} | ||
styles [] { | ||
.punctuation : style { | ||
color = brown | ||
} | ||
.quoted_text : style { | ||
color = yellow | ||
pygments_scope = String | ||
} | ||
name = mylang | ||
file_extensions []= hello, world; | ||
__rec1 \= $${__rec2} | ||
__rec2 \= $${__rec1} | ||
|
||
__Identifier \= [a-z0-1_]+ | ||
|
||
contexts [] { | ||
|
||
|
||
|
||
main : context { | ||
: push { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
context [] = inside_quotes; | ||
} | ||
} | ||
|
||
inside_quotes : context { | ||
: pop { | ||
regex \= (") | ||
styles [] = .punctuation; | ||
} | ||
: pattern { | ||
regex \= (\\(?:\\|")) | ||
styles [] = .punctuation; | ||
} | ||
: pattern { | ||
regex \= ([^"\\]+) | ||
styles [] = .quoted_text; | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
styles [] { | ||
|
||
.punctuation : style { | ||
color = brown | ||
} | ||
.quoted_text : style { | ||
color = yellow | ||
pygments_scope = String | ||
} | ||
|
||
} |
File renamed without changes.
Oops, something went wrong.