Skip to content

Commit

Permalink
added stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFireBlast committed Jun 30, 2022
1 parent 957099a commit e14014c
Show file tree
Hide file tree
Showing 26 changed files with 2,879 additions and 1,901 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
dist/
# Testing
out/
out/
src/rion.js
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extension": ["ts"],
"spec": "test/**/*.test.ts",
"require": "@swc/register"
}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/
7 changes: 7 additions & 0 deletions .prettierignore
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
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"printWidth": 120
}
50 changes: 25 additions & 25 deletions .swcrc
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"
}
38 changes: 19 additions & 19 deletions .vscode/launch.json
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"
}
]
}
63 changes: 61 additions & 2 deletions README.md
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.
1 change: 1 addition & 0 deletions iro.cmd
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 %*
71 changes: 45 additions & 26 deletions package.json
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"
}
}
Loading

0 comments on commit e14014c

Please sign in to comment.