A tiny (~ 26kb) Javascript/Typescript compiler written in vanilla Typescript as a hobby project.
- Tokens: Maximum Munch, RegEx matching
- Syntax:
- Recursive descent parser
- β linear time complexity
- β support for LL-Type Context Free Grammars
- Quantifier support (β see example SyntaxRuleset):
?
= zero or one*
= zero or more+
= one or more
- Recursive descent parser
- Semantics: Bottom-up, demand driven evaluation
- β support for arbitrary, non-recursive Attribute Grammars
Create an object that implements AttributeGrammar:
- Define a lexical ruleset by creating an object that implements LexicalRuleset
- Define a syntax ruleset by creating an object that implements SyntaxRuleset
- Define a semantic ruleset by creating an object that implements SemanticRuleset
- Create an object that implements TinyCompOptions
- Create an instance of TinyComp using the AttributeGrammar and TinyCompOptions object
- Use
compiler.compile(input: string)
to compile input
β see example.ts
import TinyComp, {...} from "https://deno.land/x/tiny_comp_ts/ts/TinyComp.ts";
npm i tiny-comp
import TinyComp, {...} from "tiny-comp";
- Install the JS/TS runtime Deno
- Clone this repo & navigate into the root directory
deno run ./example.ts
Alternatively, run via docker
- Clone this repo & navigate into the root directory
docker run -it -v $PWD:/app denoland/deno:1.17.1 run --allow-net /app/example.ts
Feel free to make a pull request if you like. Keep it minimal and efficient.