-
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
957099a
commit e14014c
Showing
26 changed files
with
2,879 additions
and
1,901 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,4 @@ | ||
node_modules/ | ||
dist/ | ||
# Testing | ||
out/ | ||
out/ | ||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "test/**/*.test.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
test/ |
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,7 @@ | ||
node_modules/ | ||
dist/ | ||
out/ | ||
package.json | ||
pnpm-ignore.yaml | ||
pnpm-lock.yaml | ||
README.md |
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,4 @@ | ||
{ | ||
"tabWidth": 4, | ||
"printWidth": 120 | ||
} |
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,25 +1,25 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true, | ||
"dynamicImport": true | ||
}, | ||
"transform": { | ||
"legacyDecorator": true, | ||
"decoratorMetadata": true | ||
}, | ||
"target": "es2020", | ||
"keepClassNames": true, | ||
"loose": true, | ||
"externalHelpers": false | ||
}, | ||
"module": { | ||
"type": "commonjs", | ||
"strict": true, | ||
"strictMode": true, | ||
"lazy": false, | ||
"noInterop": true | ||
}, | ||
"sourceMaps": "inline" | ||
} | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true, | ||
"dynamicImport": true | ||
}, | ||
"transform": { | ||
"legacyDecorator": true, | ||
"decoratorMetadata": true | ||
}, | ||
"target": "es2020", | ||
"keepClassNames": true, | ||
"loose": true, | ||
"externalHelpers": false | ||
}, | ||
"module": { | ||
"type": "commonjs", | ||
"strict": true, | ||
"strictMode": true, | ||
"lazy": false, | ||
"noInterop": true | ||
}, | ||
"sourceMaps": "inline" | ||
} |
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,19 +1,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "test.iro", | ||
"type": "pwa-node", | ||
"request": "launch", | ||
"args": ["${workspaceFolder}/dist/cli.js", "test/test.iro"], | ||
"runtimeArgs": ["--nolazy"], | ||
"sourceMaps": true, | ||
"cwd": "${workspaceRoot}", | ||
"protocol": "inspector", | ||
"preLaunchTask": "build" | ||
} | ||
] | ||
} | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "test.iro", | ||
"type": "pwa-node", | ||
"request": "launch", | ||
"args": ["${workspaceFolder}/dist/cli.js", "test/test.iro"], | ||
"runtimeArgs": ["--nolazy"], | ||
"sourceMaps": true, | ||
"cwd": "${workspaceRoot}", | ||
"protocol": "inspector", | ||
"preLaunchTask": "build" | ||
} | ||
] | ||
} |
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,62 @@ | ||
# Iro.js | ||
<center><h1>Iro.js</h1></center> | ||
<center>A language grammar generator for syntax highlighters.</center> | ||
<br> | ||
|
||
> A text highlighter generator | ||
<!-- Check out the live editor at https://fireblast.js.org/irojs --> | ||
|
||
# Installation | ||
|
||
``` | ||
npm install irojs | ||
``` | ||
|
||
# Usage | ||
|
||
## CLI | ||
|
||
Basic syntax | ||
``` | ||
iro compile <source> --targets=<targetlist> | ||
``` | ||
|
||
Valid output targets: | ||
- `textmate` or `tm` | ||
- `textmate.xml` (default) | ||
- `textmate.json` | ||
- `ace` | ||
- `ace.js` (default) | ||
- `ace.json` | ||
- `ast` (outputs the rion ast) | ||
- `none` | ||
|
||
Use `<target>.*` to match all extensions | ||
|
||
Example: | ||
``` | ||
iro compile mygrammar.iro --targets=textmate,ace -o out/ | ||
``` | ||
|
||
## From code | ||
|
||
<!-- TODO: documentation --> | ||
|
||
Example: | ||
```js | ||
import * as iro from "irojs"; | ||
// or | ||
const iro = require("irojs"); | ||
|
||
const myGrammar = "..."; | ||
|
||
var result = iro.compile(myGrammar, { textmate: true }); | ||
|
||
console.log(result.textmate); | ||
``` | ||
|
||
# Development | ||
|
||
<!-- Use `pnpm test` to run the tests. --> | ||
|
||
Use `pnpm build` to build the package. | ||
|
||
Use `pnpm types` to compile the type definition files. |
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 @@ | ||
@.\node_modules\.bin\swc src -d dist -s >NUL && node dist/cli %* |
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,26 +1,45 @@ | ||
{ | ||
"name": "irojs", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
"author": "FireBlast", | ||
"license": "MIT", | ||
"homepage": "https://thefireblast.github.io/irojs", | ||
"scripts": { | ||
"build": "nearleyc src/rion.ne -o dist/rion.js && tsc", | ||
"dev": "nearleyc src/rion.ne -o dist/rion.js && swc src -d dist -s", | ||
"types": "tsc --emitDeclarationOnly" | ||
}, | ||
"dependencies": { | ||
"@types/moo": "^0.5.5", | ||
"chalk": "^4.1.2", | ||
"nearley": "^2.20.1", | ||
"plist2": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"@swc/cli": "^0.1.51", | ||
"@swc/core": "^1.2.108", | ||
"@types/nearley": "^2.11.2", | ||
"@types/node": "^14.17.0", | ||
"typescript": "^4.4.4" | ||
} | ||
} | ||
{ | ||
"name": "irojs", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
"bin": "dist/cli.js", | ||
"author": "FireBlast", | ||
"license": "MIT", | ||
"homepage": "https://thefireblast.github.io/irojs", | ||
"repository": {}, | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build:swc": "swc src -d dist -s", | ||
"build:rion": "nearleyc src/rion.ne -o dist/rion.js", | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"build": "npm-run-all build:*", | ||
"format": "prettier --write .", | ||
"test:build:rion": "nearleyc src/rion.ne -o src/rion.js", | ||
"test:ts": "tsc --noEmit", | ||
"test:mocha": "mocha", | ||
"test": "npm-run-all test:*", | ||
"swc-node": "node -r @swc/register" | ||
}, | ||
"dependencies": { | ||
"chalk": "^4.1.2", | ||
"commander": "^9.3.0", | ||
"moo": "^0.5.1", | ||
"plist2": "^1.1.3" | ||
}, | ||
"devDependencies": { | ||
"@swc/cli": "^0.1.57", | ||
"@swc/core": "^1.2.197", | ||
"@swc/register": "^0.1.10", | ||
"@types/chai": "^4.3.1", | ||
"@types/mocha": "^9.1.1", | ||
"@types/moo": "^0.5.5", | ||
"@types/nearley": "^2.11.2", | ||
"@types/node": "^16.11.39", | ||
"chai": "^4.3.6", | ||
"mocha": "^10.0.0", | ||
"nearley": "^2.20.1", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.6.2", | ||
"typescript": "^4.7.3" | ||
} | ||
} |
Oops, something went wrong.