import { Lexer , Token , TokenType } from './lexer/' ; import { Parser } from './parser/parser' ; import { Compiler } from './compiler/compiler' ; import { AstNode } from './parser/ast' ; import { ConcreteNodes } from './compiler/cst' ; import * as path from 'path' ; import * as util from 'util' ; import * as fs from 'fs' ; export class export class IdyllicCompiler { text : string ; type { Token [ ] } memberof tokens : Token [ ] ; type { AstNode [ ] } memberof ast : AstNode [ ] = [ ] ; type { any [ ] } memberof cst : any [ ] = [ ] ; type { ConcreteNodes } memberof compiled : ConcreteNodes ; param { string } text memberof constructor ( text ) { this . text = text ; } public async compile ( ) { const l = new Lexer ( this . text ) ; this . tokens = l . collectTokens ( ) ; const p = new Parser ( this . tokens ) ; this . ast = p . collectNodes ( ) ; const c = new Compiler ( this . ast ) ; c . desugar ( ) ; const validated = await c . validate ( ) ; this . cst = validated . compiledNodes ; this . compiled = c . objectify ( ) . idyllic ; return this . compiled ; } static param { string } route returns memberof public static async fromFile ( route ) { const readFile = util . promisify ( fs . readFile ) ; const text = ( await readFile ( path . join ( process . cwd ( ) , route ) ) ) . toString ( 'utf-8' ) ; return new IdyllicCompiler ( text ) ; } }