You have three choices:
-
Use in package.json script (RECOMMENDED):
npm install --save-dev tyson
package.json:{ "scripts": { "tyson": "tyson ./myGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.ts" } } -
Use npx:
npx tyson -- ./myGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.ts
-
Install globally:
npm install -g tyson tyson ./myGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.ts
tyson <grammar-file> <type-dict-file> --out <output-file> [--type-dict-interface <type-dict-interface>] [--emit-unused-locations] [--emit-unused-semantic-value-params]| Flag | Argument | Description | Example value |
|---|---|---|---|
None required (but you can optionally use --in if you find it more readable) |
<grammar-file> |
A path to the .jison file you want Tyson to use. |
./grammar/myAwesomeGrammar.jison |
None required (but you can optionally use --in if you find it more readable) |
<type-dict-file> |
A path to a TypeScript file exporting the type dictionary interface you want Tyson to use. For more info on type dictionaries, please refer to Concepts. |
./src/typeDict.ts |
--out |
<output-file> |
A path pointing to where you want Tyson to emit the generated TypeScript file. The file does not need to already exist, but the containing directory does (e.g., if you want to pass ./src/generated/semanticActions.generated.ts, then the directory ./src/generated/ must exist prior to running tyson). |
./src/generated/semanticActions.generated.ts |
--type-dict-interface |
<type-dict-interface> (optional) |
The name of the type dictionary interface the generated file should import from your type dictionary file. If this argument is omitted, it will default to TysonTypeDictionary. |
YourTysonTypeDict |
--emit-unused-locations |
None | If this flag is enabled, yylstack will have a location field for each symbol in the production RHS, regardless of whether that symbol's location is used by the semantic action or not. |
N/A |
--emit-unused-semantic-value-params |
None | If this flag is enabled, a semantic value parameter will be emitted for each symbol in a production's RHS, regardless of whether the semantic action uses it or not. | N/A |
Simple:
tyson ./grammar/myAwesomeGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.tsWith explicit --in flag (behaves exactly the same as the first example):
tyson --in ./grammar/myAwesomeGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.tsCustom type dictionary interface name:
tyson ./grammar/myAwesomeGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.ts --type-dict-interface MyCustomTysonTypeDictEmit unused symbol locations:
tyson ./grammar/myAwesomeGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.ts --emit-unused-locationsEmit unused semantic value parameters:
tyson ./grammar/myAwesomeGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.ts --emit-unused-semantic-value-paramsEmit unused symbol locations and unused semantic value parameters:
tyson ./grammar/myAwesomeGrammar.jison ./src/typeDict.ts --out ./src/generated/semanticActions.generated.ts --emit-unused-locations --emit-unused-semantic-value-params