/**
 * Copyright 2018 Twitter, Inc.
 * Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 */ import * as pegjs from "pegjs" ; import * as tspegjs from "ts-pegjs" ; import { readFileSync } from "fs" ; import { join } from "path" ; const source = readFileSync ( join ( __dirname , "sqrl.pegjs" ) , { encoding : "utf-8" , } ) ; const allowedStartRules = [ "SqrlExpr" , "SqrlRepl" , "SqrlScript" , "Expr" ] ; const pegOptions = { allowedStartRules , cache : true , output : "source" , format : "commonjs" , plugins : [ tspegjs ] , } ; const returnTypes = { RepeatClause : "number" , } ; for ( const rule of allowedStartRules ) { returnTypes [ rule ] = "Ast" ; } ( pegOptions as any ) . returnTypes = returnTypes ; ( pegOptions as any ) . tspegjs = { noTslint : false , tslintIgnores : [ "ban-comma-operator" , "no-empty" , "no-unused-expression" , "only-arrow-functions" , "object-literal-shorthand" , "trailing-comma" , "object-literal-sort-keys" , "one-variable-per-declaration" , "max-line-length" , "no-consecutive-blank-lines" , "align" , ] . join ( "," ) , customHeader : `
  import { buildSqrlError } from '../compile/buildSqrlError';
  import { Ast, AstLocation, mapAst } from '../ast/Ast';
  ` . replace ( /^ */gm , "" ) , returnTypes , } ; const output = pegjs . generate ( source , pegOptions ) ; process . stdout . write ( output ) ;