module.exports = exports = (function() {
var runtime
try { runtime = require('pegs') } catch (e) {}
if (runtime == null) { runtime = require('../runtime') }
var Context = runtime.Context
var Parser = runtime.Parser
var Grammar = runtime.Grammar
var Position = runtime.Position
var Rule = runtime.Rule
var SourceLocation = runtime.SourceLocation
var Terminal = runtime.Terminal
var CharRange = runtime.CharRange
var Regex = runtime.Regex
var Reference = runtime.Reference
var Any = runtime.Any
var Sequence = runtime.Sequence
var Choice = runtime.Choice
var Repeat = runtime.Repeat
var Optional = runtime.Optional
var NotPredicate = runtime.NotPredicate
var AndPredicate = runtime.AndPredicate
var StringValue = runtime.StringValue
var Extract = runtime.Extract
var Group = runtime.Group
var Increment = runtime.Increment
var Action = runtime.Action
var CustomPredicate = runtime.CustomPredicate

    return function(options) {
        if (options == null)
            options = {}
        var parser
        var location = function() {
            return parser.context.location()
        }
        var text = function() {
            let loc = location()
            return parser.context.source.substring(loc.start.offset, loc.end.offset)
        }



    const ast = require("./ast")
    // const types = require("./types")
    const pathSeparator = "/"

    function getLocation() {
        let { start, end, filename } = location()
        return new ast.Location({
            start: new ast.Position(start.offset, start.line, start.column),
            end: new ast.Position(end.offset, end.line, end.column),
            filename
        })
    }

    function isUpperCase(name) {
        let first = name[0]
        return first === first.toUpperCase()
    }

    function isTypeName(name) {
        return isUpperCase(name)
    }

    function getRelativePrefixSteps(relative) {
        if (relative === 0) {
            return []
        }
        if (relative == 1) {
            return ["."]
        }
        return new Array(relative - 1).fill("..")
    }

    function node(type, ...values) {
        // we assign again in case it was overridden by copy values
        let TypeConstructor = ast[type]
        if (TypeConstructor == null) {
            throw new Error(`Missing Type: ${type}`)
        }
        let result = new TypeConstructor(Object.assign({ location: getLocation() }, ...values))
        return result
    }

    function operation(left, operator, right, props) {
        if (right) {
            return node("BinaryExpression", { left, operator, right, ...props })
        }
        else {
            return node("UnaryExpression", { operator, argument:left, ...props })
        }
    }

    function buildBinaryExpression(head, tail) {
        return tail.reduce(
            (left, [,operator,,right]) => {
                return operation(left, operator, right)
            }
            ,head
        )
    }

    function toMap(nodes, getKey = node => node.id.name) {
        return new Map(nodes.map(node => [getKey(node), node]))
    }

    function toChain(head, tail) {
        return tail.reduce(
            (left, right) => {
                if (right.arguments) {
                    return node("CallExpression", {callee:left, ...right})
                }
                else {
                    return node("MemberExpression", { object:left, ...right })
                }
            }
            ,head
        )
    }



       parser = new Parser(new Grammar([new Action(new Sequence(new Optional(new Reference("EOL")), new Repeat(new Reference("ModuleDeclaration")).setName("body"), new Reference("EOL"), new Reference("EOF")), (
function(__context, __values) {
let body = __values[1];

        let location = getLocation()
        let id = node("Declarator", { name: location.filename })
        return node("Program", { sourceType: "module", id, body: body.flat() })
    })).setName("Module"),

new Choice(new Reference("ImportDeclaration"), new Reference("Statement"), new Reference("ExportDeclaration")).setName("ModuleDeclaration"),

new Choice(new Reference("ExportNamedDeclaration"), new Reference("ExportDefaultDeclaration")).setName("ExportDeclaration"),

new Action(new Sequence(new Reference("ExportToken")), (
function(__context, __values) {
;
 return getLocation() })).setName("Export"),

new Action(new Sequence(new Reference("DefaultToken")), (
function(__context, __values) {
;
 return getLocation() })).setName("Default"),

new Action(new Sequence(new Reference("ExportToken"), new Reference("_"), new Choice(new Reference("Declaration"), new Reference("ImportDeclaration")).setName("declaration")), (
function(__context, __values) {
let declaration = __values[2];
 return node(declaration.constructor.name, { ...declaration, location: getLocation(), export: 1 }) })).setName("ExportNamedDeclaration"),

new Action(new Sequence(new Reference("ExportToken"), new Reference("_"), new Optional(new Reference("DefaultToken")).setName("isDefault"), new Reference("_"), new Choice(new Reference("ClassDeclaration"), new Reference("OutlineExpression")).setName("value")), (
function(__context, __values) {
let isDefault = __values[2];
let value = __values[4];

        if (ast.ClassDeclaration.is(value)) {
            return node(value.constructor.name, { ...value, export: isDefault ? 2 : 1 })
        }
        // we NEED to have some Declarator for this default export.
        return node("VariableDeclaration", { kind: "let", id: node("Declarator", { name: "default"}), value, export: isDefault ? 2 : 1})
    })).setName("ExportDefaultDeclaration"),

new Action(new Sequence(new Reference("ImportToken"), new Reference("_"), new Choice(new Reference("StringLiteral"), new Reference("Path")).setName("source"), new Reference("_"), new Choice(new Reference("InlineSpecifiers"), new Reference("OutlineSpecifiers")).setName("specifiers")), (
function(__context, __values) {
let source = __values[2];
let specifiers = __values[4];

        let path = null
        if (Array.isArray(source) /* is Path */) {
            let local = source[source.length - 1]
            if (local.name === "*" || !specifiers.find(d => ast.ImportDefaultSpecifier.is(d) || ast.ImportNamespaceSpecifier.is(d) || d.local.name === local.name)) {
                // smart import
                let type = "ImportDefaultSpecifier"
                if (local.name === "*") {
                    //  remove it from the source path
                    source = source.slice(0, -1)
                    //  make the local the previous name
                    local = source[source.length - 1]
                    //  convert to import namespace
                    type = "ImportNamespaceSpecifier"
                }
                specifiers.push(node(type, { local: new ast.Declarator(local), location: local.location }))
            }
            path = source
            source = node("Literal", { value: source.map(id => id.name || id).join(pathSeparator) })
        }
        return node("ImportDeclaration", { specifiers, path, source })
    })).setName("ImportDeclaration"),

new Action(new Sequence(new Reference("Specifier").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("Specifier").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail"), new Reference("EOL")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return [head, ...tail] })).setName("InlineSpecifiers"),

new Action(new Sequence(new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Reference("Specifier").setName("value"), new Reference("EOL")), (
function(__context, __values) {
let value = __values[1];
return value;}))).setName("value"), new Reference("Outdent")), (
function(__context, __values) {
let value = __values[2];
return value;})).setName("OutlineSpecifiers"),

new Action(new Sequence(new Repeat(new Terminal(".")).setName("relative"), new Reference("AtIdentifier").setName("head"), new Repeat(new Action(new Sequence(new Terminal("."), new Reference("Identifier").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;}))).setName("tail"), new Optional(new Action(new Sequence(new Terminal(".*")), (
function(__context, __values) {
;
 return node("Identifier", { name: "*"})}))).setName("final")), (
function(__context, __values) {
let relative = __values[0];
let head = __values[1];
let tail = __values[2];
let final = __values[3];
 return [...getRelativePrefixSteps(relative.length), head, ...tail, ...(final ? [final] : [])] })).setName("Path"),

new Action(new Sequence(new Optional(new Terminal("@")).setName("at"), new Reference("Identifier").setName("id")), (
function(__context, __values) {
let at = __values[0];
let id = __values[1];
 return at ? id.patch({ name: text() }) : id })).setName("AtIdentifier"),

new Choice(new Reference("ImportDefaultSpecifier"), new Reference("ImportNamespaceSpecifier"), new Reference("ImportSpecifier")).setName("Specifier"),

new Action(new Sequence(new Reference("Identifier").setName("imported"), new Optional(new Action(new Sequence(new Reference("_"), new Reference("AsToken"), new Reference("_"), new Reference("Declarator").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("local")), (
function(__context, __values) {
let imported = __values[0];
let local = __values[1];
 return node("ImportSpecifier", { imported, local: local || node("Declarator", imported) }) })).setName("ImportSpecifier"),

new Choice(new Action(new Sequence(new Reference("DefaultToken"), new Reference("_"), new Reference("AsToken"), new Reference("_"), new Reference("Declarator").setName("local")), (
function(__context, __values) {
let local = __values[4];
 return node("ImportDefaultSpecifier", { local }) })), new Action(new Sequence(new Terminal("as"), new Reference("_"), new Reference("Declarator").setName("local")), (
function(__context, __values) {
let local = __values[2];
 return node("ImportDefaultSpecifier", { local }) }))).setName("ImportDefaultSpecifier"),

new Action(new Sequence(new Terminal("*"), new Reference("_"), new Terminal("as"), new Reference("_"), new Reference("Declarator").setName("local")), (
function(__context, __values) {
let local = __values[4];
 return node("ImportNamespaceSpecifier", { local }) })).setName("ImportNamespaceSpecifier"),

new Choice(new Reference("Declaration"), new Reference("AssignmentStatement"), new Reference("IfStatement"), new Reference("ForOfStatement"), new Reference("ReturnStatement"), new Reference("WhileStatement"), new Reference("BreakStatement"), new Reference("ContinueStatement"), new Reference("ExpressionStatement"), new Reference("ThrowStatement"), new Reference("TryStatement"), new Reference("SwitchStatement"), new Reference("PropertyStatement")).setName("Statement"),

new Action(new Sequence(new Reference("SwitchToken"), new Reference("_"), new Reference("InlineExpression").setName("discriminant"), new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Reference("SwitchCase").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})), 1).setName("cases"), new Reference("Outdent")), (
function(__context, __values) {
let discriminant = __values[2];
let cases = __values[5];
 return node("SwitchStatement", { discriminant, cases: cases.flat() }) })).setName("SwitchStatement"),

new Choice(new Action(new Sequence(new Reference("DefaultToken")), (
function(__context, __values) {
;
 return null })), new Reference("InlineExpression")).setName("SwitchTest"),

new Action(new Sequence(new Reference("SwitchTest").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("SwitchTest").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail"), new Terminal(":"), new Reference("_"), new Choice(new Action(new Sequence(new Reference("Statement").setName("value")), (
function(__context, __values) {
let value = __values[0];
return node("BlockStatement", { body: Array.isArray(value) ? value : [value]}) })), new Reference("BlockStatement")).setName("consequent")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
let consequent = __values[4];

        let tests = [head, ...tail]
        return tests.map((test, index) => node("SwitchCase", { test, consequent: index === tests.length - 1 ? consequent : null }))
    })).setName("SwitchCase"),

new Action(new Sequence(new Reference("TryToken"), new Reference("BlockStatement").setName("block"), new Optional(new Action(new Sequence(new Reference("Dent"), new Reference("CatchClause").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;}))).setName("handler"), new Optional(new Action(new Sequence(new Reference("Dent"), new Reference("FinallyToken"), new Reference("BlockStatement").setName("value")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("finalizer")), (
function(__context, __values) {
let block = __values[1];
let handler = __values[2];
let finalizer = __values[3];
 return node("TryStatement", { block, handler, finalizer }) })).setName("TryStatement"),

new Action(new Sequence(new Reference("CatchToken"), new Reference("_"), new Reference("Pattern").setName("param"), new Reference("_"), new Reference("BlockStatement").setName("body")), (
function(__context, __values) {
let param = __values[2];
let body = __values[4];
 return node("CatchClause", { param, body }) })).setName("CatchClause"),

new Action(new Sequence(new Reference("ThrowToken"), new Reference("_"), new Reference("OutlineExpression").setName("arg")), (
function(__context, __values) {
let arg = __values[2];
 return node("ThrowStatement", { argument: arg }) })).setName("ThrowStatement"),

new Action(new Sequence(new Reference("OutlineExpression").setName("expression")), (
function(__context, __values) {
let expression = __values[0];
 return node("ExpressionStatement", { expression }) })).setName("ExpressionStatement"),

new Choice(new Reference("ClassDeclaration"), new Reference("VariableDeclaration")).setName("Declaration"),

new Choice(new Action(new Sequence(new Reference("VarToken")), (
function(__context, __values) {
;
 return { kind: "var" } })), new Action(new Sequence(new Reference("LetToken")), (
function(__context, __values) {
;
 return { kind: "let" } })), new Action(new Sequence(new Reference("GetToken")), (
function(__context, __values) {
;
 return { kind: "get" } })), new Action(new Sequence(new Reference("SetToken")), (
function(__context, __values) {
;
 return { kind: "set" } }))).setName("VariableDeclarationType"),

new Choice(new Action(new Sequence(new NotPredicate(new NotPredicate(new Reference("StaticToken"))), new Reference("Identifier").setName("id"), new Reference("_")), (
function(__context, __values) {
let id = __values[1];
 return { static: id } })), new Action(new Sequence(new NotPredicate(new NotPredicate(new Any()))), (
function(__context, __values) {
;
 return {} }))).setName("VariableModifiers"),

new Choice(new Action(new Sequence(new Reference("VariableModifiers").setName("modifiers"), new Reference("TypeToken"), new Reference("_"), new Reference("Declarator").setName("id"), new Reference("_"), new Terminal("="), new Reference("_"), new Reference("OutlineType").setName("value")), (
function(__context, __values) {
let modifiers = __values[0];
let id = __values[3];
let value = __values[7];
 return node("VariableDeclaration", { kind: "type", id, value, ...modifiers }) })), new Action(new Sequence(new Reference("MetaProperties").setName("meta"), new Reference("VariableModifiers").setName("modifiers"), new Reference("VariableDeclarationType").setName("declarationType"), new Reference("_"), new Choice(new Reference("Pattern"), new Action(new Sequence(new Terminal("["), new Reference("_"), new Reference("InlineExpression").setName("value"), new Reference("_"), new Terminal("]")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("id"), new Reference("_"), new Optional(new Action(new Sequence(new Terminal(":"), new Reference("_"), new Reference("InlineType").setName("value")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("type"), new Reference("_"), new Optional(new Choice(new Action(new Sequence(new Terminal("="), new Reference("_"), new Reference("OutlineExpression").setName("value")), (
function(__context, __values) {
let value = __values[2];
return value;})), new Action(new Sequence(new Reference("EOL")), (
function(__context, __values) {
;
return null})))).setName("value")), (
function(__context, __values) {
let meta = __values[0];
let modifiers = __values[1];
let declarationType = __values[2];
let id = __values[4];
let type = __values[6];
let value = __values[8];
 return node("VariableDeclaration", { ...declarationType, id, type, value, meta, ...modifiers }) }))).setName("VariableDeclaration"),

new Repeat(new Action(new Sequence(new Reference("DynamicOutlineProperty").setName("value"), new Reference("Dent")), (
function(__context, __values) {
let value = __values[0];
return value;}))).setName("MetaProperties"),

new Action(new Sequence(new Terminal("["), new Reference("_"), new Reference("InlineExpression").setName("key"), new Reference("_"), new Terminal("]"), new Choice(new Action(new Sequence(new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("OutlineExpression").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;})), new Action(new Sequence(new Reference("EOL")), (
function(__context, __values) {
;
 return null }))).setName("value")), (
function(__context, __values) {
let key = __values[2];
let value = __values[5];
 return node("Property", {key, value, computed:true} ) })).setName("DynamicOutlineProperty"),

new Choice(new Terminal("="), new Terminal("+="), new Terminal("-="), new Terminal("*="), new Terminal("/=")).setName("AssignmentOperator"),

new Action(new Sequence(new Reference("InlineExpression").setName("left"), new Reference("_"), new Reference("AssignmentOperator").setName("operator"), new Reference("_"), new Reference("OutlineExpression").setName("right")), (
function(__context, __values) {
let left = __values[0];
let operator = __values[2];
let right = __values[4];

        // if (operator.length > 1) {
        //     right = operation(left, node("Identifier",{ name:operator.slice(0,-1) }), right)
        // }
        return node("AssignmentStatement", {left, operator, right})
    })).setName("AssignmentStatement"),

new Action(new Sequence(new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Reference("Statement").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})), 1).setName("body"), new Reference("Outdent")), (
function(__context, __values) {
let body = __values[2];
 return node("BlockStatement", { body: body.flat() }) })).setName("BlockStatement"),

new Action(new Sequence(new Reference("ForToken"), new Reference("_"), new Reference("Pattern").setName("left"), new Reference("_"), new Optional(new Action(new Sequence(new Terminal(","), new Reference("_"), new Reference("Declarator").setName("value"), new Reference("_")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("count"), new Reference("InToken"), new Reference("_"), new Reference("InlineExpression").setName("right"), new Reference("BlockStatement").setName("body")), (
function(__context, __values) {
let left = __values[2];
let count = __values[4];
let right = __values[7];
let body = __values[8];

        return node("ForOfStatement", {
            left: (node("VariableDeclaration", { id: left, kind: "var" })),
            count: count ? (node("VariableDeclaration", { id: count, kind: "let" })) : null,
            right, body
        })
    })).setName("ForOfStatement"),

new Action(new Sequence(new Reference("WhileToken"), new Reference("_"), new Reference("InlineExpression").setName("test"), new Reference("BlockStatement").setName("body")), (
function(__context, __values) {
let test = __values[2];
let body = __values[3];
 return node("WhileStatement", { test, body }) })).setName("WhileStatement"),

new Action(new Sequence(new Reference("IfToken"), new Reference("_"), new Reference("InlineExpression").setName("test"), new Reference("BlockStatement").setName("consequent"), new Optional(new Action(new Sequence(new Reference("Dent"), new Reference("ElseToken"), new Reference("_"), new Choice(new Reference("BlockStatement"), new Reference("IfStatement")).setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("alternate")), (
function(__context, __values) {
let test = __values[2];
let consequent = __values[3];
let alternate = __values[4];
 return node("IfStatement", { test, consequent, alternate }) })).setName("IfStatement"),

new Choice(new Action(new Sequence(new Reference("ReturnToken"), new Reference("EOL"), new Reference("Indent"), new Reference("Dent"), new Reference("OutlineExpression").setName("argument"), new Reference("Outdent")), (
function(__context, __values) {
let argument = __values[4];
 return node("ReturnStatement", { argument }) })), new Action(new Sequence(new Reference("ReturnToken"), new Reference("_"), new Optional(new Reference("InlineExpression")).setName("argument"), new Reference("EOL")), (
function(__context, __values) {
let argument = __values[2];
 return node("ReturnStatement", { argument: argument || null }) }))).setName("ReturnStatement"),

new Action(new Sequence(new Reference("BreakToken"), new Reference("EOL")), (
function(__context, __values) {
;
 return node("BreakStatement", {}) })).setName("BreakStatement"),

new Action(new Sequence(new Reference("ContinueToken"), new Reference("EOL")), (
function(__context, __values) {
;
 return node("ContinueStatement", {}) })).setName("ContinueStatement"),

new Choice(new Reference("Declarator"), new Reference("ArrayPattern"), new Reference("ObjectPattern"), new Reference("RestElement")).setName("Pattern"),

new Choice(new Action(new Sequence(new Terminal("["), new Reference("_"), new Reference("RestElement").setName("element"), new Reference("_"), new Terminal("]")), (
function(__context, __values) {
let element = __values[2];
 return node("ArrayPattern", { elements: [element] }) })), new Action(new Sequence(new Terminal("["), new Reference("_"), new Optional(new Reference("Pattern")).setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new NotPredicate(new Terminal(".")), new Optional(new Reference("Pattern")).setName("value")), (
function(__context, __values) {
let value = __values[4];
return value;}))).setName("tail"), new Optional(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("RestElement").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("rest"), new Reference("_"), new Terminal("]")), (
function(__context, __values) {
let head = __values[2];
let tail = __values[3];
let rest = __values[4];

        let elements = [head || null, ...tail.map((x) => x || null)]
        if (rest) {
            elements.push(rest)
        }
        return node("ArrayPattern", { elements })
    }))).setName("ArrayPattern"),

new Action(new Sequence(new Terminal("..."), new Reference("Declarator").setName("argument")), (
function(__context, __values) {
let argument = __values[1];
 return node("RestElement", { argument }) })).setName("RestElement"),

new Action(new Sequence(new Terminal("{"), new Reference("_"), new Reference("AssignmentProperty").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("AssignmentProperty").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail"), new Optional(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("RestElement").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("rest"), new Reference("_"), new Terminal("}")), (
function(__context, __values) {
let head = __values[2];
let tail = __values[3];
let rest = __values[4];

        let properties = [head, ...tail]
        if (rest) {
            properties.push(rest)
        }
        return node("ObjectPattern", { properties })
    })).setName("ObjectPattern"),

new Action(new Sequence(new Reference("Identifier").setName("key"), new Optional(new Action(new Sequence(new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("Pattern").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("value")), (
function(__context, __values) {
let key = __values[0];
let value = __values[1];
 return node("Property", { key, value: value || node("Reference", key), shorthand: value == null } ) })).setName("AssignmentProperty"),

new Choice(new Action(new Sequence(new Reference("DataToken"), new Reference("_")), (
function(__context, __values) {
;
 return { isData: true } })), new Action(new Sequence(new NotPredicate(new NotPredicate(new Any()))), (
function(__context, __values) {
;
 return {} }))).setName("ClassModifiers"),

new Action(new Sequence(new Reference("MetaProperties").setName("meta"), new Reference("ClassModifiers").setName("modifiers"), new Choice(new Action(new Sequence(new Reference("ClassToken")), (
function(__context, __values) {
;
 return false })), new Action(new Sequence(new Reference("StructToken")), (
function(__context, __values) {
;
 return true }))).setName("isStruct"), new Reference("_"), new Reference("Declarator").setName("id"), new Optional(new Reference("TemplateParameters")).setName("params"), new Reference("_"), new Optional(new Reference("Extends")).setName("baseClasses"), new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Reference("VariableDeclaration").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;}))).setName("declarations"), new Reference("Outdent")), (
function(__context, __values) {
let meta = __values[0];
let modifiers = __values[1];
let isStruct = __values[2];
let id = __values[4];
let params = __values[5];
let baseClasses = __values[7];
let declarations = __values[10];

            return node("ClassDeclaration", {
                id, ...modifiers, isStruct, params: params || [], baseClasses: baseClasses || [],
                static: declarations.filter(d => d.static),
                instance: node("InstanceDeclarations", { declarations: declarations.filter(d => !d.static).map(d => d.patch({ instance: true })) })
            })
        })).setName("ClassDeclaration"),

new Action(new Sequence(new Terminal("<"), new Reference("_"), new Reference("Parameter").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("Parameter").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail"), new Reference("_"), new Terminal(">")), (
function(__context, __values) {
let head = __values[2];
let tail = __values[3];
 return [head, ...tail] })).setName("TemplateParameters"),

new Action(new Sequence(new Reference("ExtendsToken"), new Reference("_"), new Reference("Reference").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("Reference").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail")), (
function(__context, __values) {
let head = __values[2];
let tail = __values[3];
 return [head, ...tail] })).setName("Extends"),

new Action(new Sequence(new Reference("InlineType").setName("value"), new Reference("EOL")), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("OutlineType"),

new Action(new Sequence(new Reference("UnionType").setName("type")), (
function(__context, __values) {
let type = __values[0];

        let isSimpleReference
            = ast.BinaryExpression.is(type)
            && ast.DotExpression.is(type.left)
            && type.operator === "is"
            && ast.RuntimeType.is(type.right)
        return isSimpleReference ? type.right : node("TypeExpression", { value: type })
    })).setName("InlineType"),

new Action(new Sequence(new Reference("ConstrainedType").setName("left"), new Optional(new Action(new Sequence(new Reference("_"), new Terminal("|"), new Reference("_"), new Reference("UnionType").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("right")), (
function(__context, __values) {
let left = __values[0];
let right = __values[1];
 return right ? node('BinaryExpression', { left, operator: "||", right }) : left })).setName("UnionType"),

new Action(new Sequence(new Reference("Constraint").setName("left"), new Optional(new Action(new Sequence(new Reference("_"), new Terminal("&"), new Reference("_"), new Reference("ConstrainedType").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("right")), (
function(__context, __values) {
let left = __values[0];
let right = __values[1];
 return right ? node('BinaryExpression', { left, operator: "&&", right }) : left })).setName("ConstrainedType"),

new Choice(new Action(new Sequence(new Reference("Literal").setName("right")), (
function(__context, __values) {
let right = __values[0];
 return node('BinaryExpression', { left: node('DotExpression'), operator: ast.RegularExpression.is(right) ? 'is' : '==', right }) })), new Action(new Sequence(new Choice(new Reference("FunctionType"), new Reference("TemplateReference")).setName("right")), (
function(__context, __values) {
let right = __values[0];
 return node('BinaryExpression', { left:node('DotExpression'), operator: 'is', right }) })), new Action(new Sequence(new Optional(new Reference("MemberExpression")).setName("left"), new Reference("_"), new Choice(new Reference("RelationalOperator"), new Reference("EqualityOperator")).setName("operator"), new Reference("_"), new Reference("MemberExpression").setName("right")), (
function(__context, __values) {
let left = __values[0];
let operator = __values[2];
let right = __values[4];
 return node('BinaryExpression', { left: left || node('DotExpression'), operator, right }) })), new Reference("GroupExpression")).setName("Constraint"),

new Choice(new Action(new Sequence(new Reference("FunctionParametersWithParentheses").setName("params"), new Reference("_"), new Terminal("=>"), new Reference("_"), new Reference("InlineType").setName("returnType")), (
function(__context, __values) {
let params = __values[0];
let returnType = __values[4];
 return node("FunctionType", { params, returnType }) })), new Action(new Sequence(new Terminal("("), new Reference("_"), new Reference("FunctionType").setName("value"), new Reference("_"), new Terminal(")")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("FunctionType"),

new Reference("InlineType").setName("TemplateArgument"),

new Action(new Sequence(new Terminal("<"), new Reference("_"), new Reference("TemplateArgument").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("TemplateArgument").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail"), new Reference("_"), new Terminal(">")), (
function(__context, __values) {
let head = __values[2];
let tail = __values[3];
 return [head, ...tail] })).setName("TemplateArguments"),

new Action(new Sequence(new Reference("Reference").setName("reference"), new Optional(new Reference("TemplateArguments")).setName("args")), (
function(__context, __values) {
let reference = __values[0];
let args = __values[1];
 return node("Reference", { ...reference, arguments: args || null }) })).setName("TemplateReference"),

new Choice(new Terminal("++"), new Terminal("--")).setName("UpdateOperator"),

new Choice(new Action(new Sequence(new Reference("UpdateOperator").setName("operator"), new Reference("MemberExpression").setName("argument")), (
function(__context, __values) {
let operator = __values[0];
let argument = __values[1];
 return operation(argument, operator, null, { prefix: true  }) })), new Action(new Sequence(new Reference("MemberExpression").setName("argument"), new Optional(new Reference("UpdateOperator")).setName("operator")), (
function(__context, __values) {
let argument = __values[0];
let operator = __values[1];
 return operator ? operation(argument, operator, null, { prefix: false }) : argument }))).setName("UpdateExpression"),

new Choice(new Terminal("+"), new Terminal("-"), new Terminal("!"), new Reference("TypeofToken"), new Reference("DeleteToken")).setName("UnaryOperator"),

new Action(new Sequence(new Optional(new Reference("UnaryOperator")).setName("operator"), new Reference("_"), new Reference("UpdateExpression").setName("argument")), (
function(__context, __values) {
let operator = __values[0];
let argument = __values[2];
 return operator ? operation(argument, operator) : argument })).setName("UnaryExpression"),

new Choice(new Terminal("**"), new Terminal("<<"), new Terminal(">>")).setLabel("operator").setName("ExponentiationOperator"),

new Action(new Sequence(new Reference("UnaryExpression").setName("left"), new Optional(new Action(new Sequence(new Reference("_"), new Reference("ExponentiationOperator").setName("operator"), new Reference("_"), new Reference("ExponentiationExpression").setName("right")), (
function(__context, __values) {
let operator = __values[1];
let right = __values[3];
return {operator,right}}))).setName("right")), (
function(__context, __values) {
let left = __values[0];
let right = __values[1];
 return right ? node("BinaryExpression", {left, operator:right.operator, right:right.right}) : left })).setName("ExponentiationExpression"),

new Choice(new Terminal("*"), new Terminal("/"), new Terminal("%")).setName("MultiplicativeOperator"),

new Action(new Sequence(new Reference("ExponentiationExpression").setName("head"), new Repeat(new Group(new Sequence(new Reference("_"), new Reference("MultiplicativeOperator"), new Reference("_"), new Reference("ExponentiationExpression")))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return buildBinaryExpression(head, tail) })).setName("MultiplicativeExpression"),

new Choice(new Terminal("+"), new Terminal("-")).setName("AdditiveOperator"),

new Action(new Sequence(new Reference("MultiplicativeExpression").setName("head"), new Repeat(new Group(new Sequence(new Reference("_"), new Reference("AdditiveOperator"), new Reference("_"), new Reference("MultiplicativeExpression")))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return buildBinaryExpression(head, tail) })).setName("AdditiveExpression"),

new Choice(new Terminal("<="), new Terminal(">="), new Terminal("<"), new Terminal(">"), new Reference("IsntToken"), new Reference("IsToken")).setName("RelationalOperator"),

new Choice(new Action(new Sequence(new Reference("AdditiveExpression").setName("head"), new Repeat(new Group(new Sequence(new Reference("_"), new Reference("RelationalOperator"), new Reference("_"), new Reference("AdditiveExpression")))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return buildBinaryExpression(head, tail) })), new Action(new Sequence(new Group(new Sequence(new Reference("_"), new Reference("RelationalOperator"), new Reference("_"), new Reference("AdditiveExpression"))).setName("tail")), (
function(__context, __values) {
let tail = __values[0];
 return buildBinaryExpression(node('DotExpression') , [tail]) }))).setName("RelationalExpression"),

new Choice(new Terminal("=="), new Terminal("!=")).setName("EqualityOperator"),

new Action(new Sequence(new Reference("RelationalExpression").setName("head"), new Repeat(new Group(new Sequence(new Reference("_"), new Reference("EqualityOperator"), new Reference("_"), new Reference("RelationalExpression")))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return buildBinaryExpression(head, tail) })).setName("EqualityExpression"),

new Terminal("&&").setName("LogicalAndOperator"),

new Action(new Sequence(new Reference("EqualityExpression").setName("head"), new Repeat(new Group(new Sequence(new Reference("_"), new Reference("LogicalAndOperator"), new Reference("_"), new Reference("EqualityExpression")))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return buildBinaryExpression(head, tail) })).setName("LogicalAndExpression"),

new Choice(new Terminal("||"), new Terminal("??"), new Reference("XorToken")).setName("LogicalOrOperator"),

new Action(new Sequence(new Reference("LogicalAndExpression").setName("head"), new Repeat(new Group(new Sequence(new Reference("_"), new Reference("LogicalOrOperator"), new Reference("_"), new Reference("LogicalAndExpression")))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return buildBinaryExpression(head, tail) })).setName("LogicalOrExpression"),

new Terminal("?").setName("ConditionalOperator"),

new Action(new Sequence(new Reference("LogicalOrExpression").setName("test"), new Optional(new Action(new Sequence(new Reference("_"), new Reference("ConditionalOperator"), new Reference("_"), new Reference("ConditionalExpression").setName("consequent"), new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("ConditionalExpression").setName("alternate")), (
function(__context, __values) {
let consequent = __values[3];
let alternate = __values[7];
 return {consequent,alternate} }))).setName("body")), (
function(__context, __values) {
let test = __values[0];
let body = __values[1];
 return body ? node('ConditionalExpression', { test, ...body }) : test })).setName("ConditionalExpression"),

new Choice(new Action(new Sequence(new Terminal("...")), (
function(__context, __values) {
;
 return true })), new Action(new Sequence(new Terminal("..")), (
function(__context, __values) {
;
 return false }))).setName("RangeOperator"),

new Action(new Sequence(new Reference("ConditionalExpression").setName("start"), new Reference("_"), new Reference("RangeOperator").setName("inclusive"), new Reference("_"), new Reference("ConditionalExpression").setName("end"), new Optional(new Action(new Sequence(new Reference("_"), new Reference("ByToken"), new Reference("_"), new Reference("ConditionalExpression").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("step")), (
function(__context, __values) {
let start = __values[0];
let inclusive = __values[2];
let end = __values[4];
let step = __values[5];
 return node("Range", { start, end, inclusive, step: step || null }) })).setName("RangeExpression"),

new Action(new Sequence(new Reference("Pattern").setName("id"), new Reference("_"), new Optional(new Action(new Sequence(new Terminal(":"), new Reference("_"), new Reference("InlineType").setName("value")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("type"), new Reference("_"), new Optional(new Action(new Sequence(new Terminal("="), new NotPredicate(new Terminal(">")), new Reference("_"), new Reference("InlineExpression").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("value")), (
function(__context, __values) {
let id = __values[0];
let type = __values[2];
let value = __values[4];
 return node("Parameter", { id, type, value })})).setName("Parameter"),

new Choice(new Action(new Sequence(new Reference("FunctionParametersWithParentheses").setName("params"), new Optional(new Action(new Sequence(new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("InlineType").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("type")), (
function(__context, __values) {
let params = __values[0];
let type = __values[1];
 return { params, type } })), new Action(new Sequence(new Reference("FunctionParametersWithoutParentheses").setName("params")), (
function(__context, __values) {
let params = __values[0];
 return { params } }))).setName("FunctionParametersAndType"),

new Choice(new Action(new Sequence(new Terminal("("), new Reference("_"), new Terminal(")")), (
function(__context, __values) {
;
 return [] })), new Action(new Sequence(new Terminal("("), new Reference("_"), new Reference("Parameter").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("Parameter").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail"), new Reference("_"), new Terminal(")")), (
function(__context, __values) {
let head = __values[2];
let tail = __values[3];
 return [head, ...tail] }))).setName("FunctionParametersWithParentheses"),

new Action(new Sequence(new Reference("Declarator").setName("id")), (
function(__context, __values) {
let id = __values[0];
 return [node("Parameter", { id } )] })).setName("FunctionParametersWithoutParentheses"),

new Choice(new Action(new Sequence(new Terminal("->")), (
function(__context, __values) {
;
 return false })), new Action(new Sequence(new Terminal("=>")), (
function(__context, __values) {
;
 return true }))).setName("FunctionArrow"),

new Action(new Sequence(new Optional(new Reference("AsyncToken")).setName("async"), new Reference("_"), new Optional(new Terminal("*")).setName("generator"), new Optional(new Action(new Sequence(new Reference("Identifier").setName("value"), new NotPredicate(new NotPredicate(new Terminal("(")))), (
function(__context, __values) {
let value = __values[0];
return value;}))).setName("id"), new Optional(new Reference("FunctionParametersAndType")).setName("paramsAndType"), new Reference("_"), new Reference("FunctionArrow").setName("bind")), (
function(__context, __values) {
let async = __values[0];
let generator = __values[2];
let id = __values[3];
let paramsAndType = __values[4];
let bind = __values[6];
 return { id, ...(paramsAndType ?? { params: [] }), async: async != null, generator: generator != null, bind } })).setName("FunctionHead"),

new Action(new Sequence(new Reference("FunctionHead").setName("head"), new Reference("_"), new Optional(new Reference("InlineExpression")).setName("value")), (
function(__context, __values) {
let head = __values[0];
let value = __values[2];
 return node("FunctionExpression", { ...head, body: node("BlockStatement", { body: !value ? [] : [node("ReturnStatement", { argument: value } )] } ) } ) })).setName("InlineFunction"),

new Action(new Sequence(new NotPredicate(new NotPredicate(new Reference("Identifier"))), new Reference("InlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})).setName("NamedInlineFunction"),

new Action(new Sequence(new Reference("FunctionHead").setName("head"), new Reference("_"), new Reference("BlockStatement").setName("body")), (
function(__context, __values) {
let head = __values[0];
let body = __values[2];
 return node("FunctionExpression", { ...head, body }) })).setName("OutlineFunction"),

new Action(new Sequence(new NotPredicate(new NotPredicate(new Reference("Identifier"))), new Reference("OutlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})).setName("NamedOutlineFunction"),

new Choice(new Reference("OutlineMemberExpression"), new Action(new Sequence(new Reference("EOL"), new Reference("Indent"), new Reference("Dent"), new Reference("OutlineMemberExpression").setName("value"), new Reference("Outdent")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("OutlineExpression"),

new Choice(new Reference("OutlineYieldExpression"), new Reference("OutlineAwaitExpression"), new Reference("OutlineDoExpression"), new Reference("OutlineFunction"), new Reference("OutlineArrayExpression"), new Reference("OutlineObjectExpression"), new Reference("OutlineJSXElementExpression"), new Reference("OutlineCallExpression"), new Reference("OutlineNewExpression"), new Reference("OutlineStringLiteral"), new Reference("OutlineSpreadElement"), new Reference("OutlineOperation"), new Action(new Sequence(new Reference("InlineExpression").setName("value"), new Reference("EOL")), (
function(__context, __values) {
let value = __values[0];
return value;}))).setName("OutlineExpressionStartsThisLine"),

new Action(new Sequence(new Reference("OutlineExpressionStartsThisLine").setName("head"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Reference("OutlineChain").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;}))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];

        // we flatten and remove arrays since trailing comments show up as arrays.
        tail = tail.flat().filter(a => !Array.isArray(a))
        return toChain(head, tail)
    })).setName("OutlineMemberExpression"),

new Action(new Sequence(new Reference("DoToken"), new Terminal(" "), new Reference("_"), new Reference("OutlineFunction").setName("callee")), (
function(__context, __values) {
let callee = __values[3];
 return node("CallExpression", { callee, arguments: [] }) })).setName("OutlineDoExpression"),

new Action(new Sequence(new Choice(new Terminal("+"), new Terminal("-"), new Terminal("||"), new Terminal("&&"), new Terminal("|"), new Terminal("&"), new Terminal("**"), new Terminal("*"), new Terminal("/")).setName("operator"), new Reference("OutlineArguments").setName("operands")), (
function(__context, __values) {
let operator = __values[0];
let operands = __values[1];

        if (operands.length === 2 && operands.every(ast.Expression.is)) {
            return node("BinaryExpression", { left: operands[0], operator, right: operands[1] })
        }
        return node("OutlineOperation", { operator, operands })
    })).setName("OutlineOperation"),

new Action(new Sequence(new Reference("YieldToken"), new Optional(new Terminal("*")).setName("delegate"), new Reference("_"), new Reference("OutlineExpression").setName("argument")), (
function(__context, __values) {
let delegate = __values[1];
let argument = __values[3];
 return node("YieldExpression", { argument, delegate: delegate != null })})).setName("OutlineYieldExpression"),

new Action(new Sequence(new Reference("AwaitToken"), new Reference("_"), new Reference("OutlineExpression").setName("argument")), (
function(__context, __values) {
let argument = __values[2];
 return node("AwaitExpression", { argument })})).setName("OutlineAwaitExpression"),

new Action(new Sequence(new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Choice(new Reference("OutlineExpression"), new Reference("Statement")).setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})), 1).setName("args"), new Reference("Outdent")), (
function(__context, __values) {
let args = __values[2];
 return args.flat() })).setName("OutlineArguments"),

new Action(new Sequence(new Reference("InlineExpression").setName("call"), new Reference("OutlineArguments").setName("args"), new CustomPredicate('').setHandler((
function(__context, __values) {
let call = __values[0];
let args = __values[1];
 return ast.CallExpression.is(call) }))), (
function(__context, __values) {
let call = __values[0];
let args = __values[1];
 return node("CallExpression", { ...call, arguments: [...call.arguments, ...args] }) })).setName("OutlineCallExpression"),

new Action(new Sequence(new Reference("NewToken"), new Reference("_"), new Reference("MemberExpressionNoCall").setName("callee"), new Choice(new Action(new Sequence(new Reference("InlineArguments").setName("value"), new Reference("EOL")), (
function(__context, __values) {
let value = __values[0];
return value;})), new Reference("OutlineArguments")).setName("args")), (
function(__context, __values) {
let callee = __values[2];
let args = __values[3];
 return node("CallExpression", { new: true, callee, arguments: args }) })).setName("OutlineNewExpression"),

new Choice(new Reference("InlineSpreadElement"), new Reference("InlineYieldExpression"), new Reference("InlineAwaitExpression"), new Reference("InlineFunction"), new Reference("InlineNewExpression"), new Reference("RangeExpression"), new Reference("ConditionalExpression")).setName("InlineExpression"),

new Action(new Sequence(new Reference("AwaitToken"), new Reference("_"), new Reference("InlineExpression").setName("argument")), (
function(__context, __values) {
let argument = __values[2];
 return node("AwaitExpression", { argument })})).setName("InlineAwaitExpression"),

new Action(new Sequence(new Reference("YieldToken"), new Optional(new Terminal("*")).setName("delegate"), new Reference("_"), new Reference("InlineExpression").setName("argument")), (
function(__context, __values) {
let delegate = __values[1];
let argument = __values[3];
 return node("YieldExpression", { argument, delegate: delegate != null })})).setName("InlineYieldExpression"),

new Action(new Sequence(new Reference("NewToken"), new Reference("_"), new Reference("MemberExpressionNoCall").setName("callee"), new Reference("InlineArguments").setName("args")), (
function(__context, __values) {
let callee = __values[2];
let args = __values[3];
 return node("CallExpression", { new: true, callee, arguments: args }) })).setName("InlineNewExpression"),

new Choice(new Reference("Reference"), new Reference("Literal"), new Reference("ThisExpression"), new Reference("DotExpression"), new Reference("GroupExpression"), new Reference("InlineArrayExpression"), new Reference("InlineObjectExpression"), new Reference("InlineJSXElementExpression")).setName("PrimaryExpression"),

new Action(new Sequence(new Terminal("("), new Reference("_"), new Reference("InlineExpression").setName("value"), new Reference("_"), new Terminal(")")), (
function(__context, __values) {
let value = __values[2];
return value;})).setName("GroupExpression"),

new Action(new Sequence(new Reference("ThisToken")), (
function(__context, __values) {
;
 return node('ThisExpression') })).setName("ThisExpression"),

new Choice(new Action(new Sequence(new Terminal("."), new Reference("Identifier").setName("property")), (
function(__context, __values) {
let property = __values[1];
 return node('MemberExpression',{object:node('DotExpression'),property,computed:false}) })), new Action(new Sequence(new Terminal(".["), new Reference("_"), new Reference("InlineExpression").setName("property"), new Reference("_"), new Terminal("]")), (
function(__context, __values) {
let property = __values[2];
 return node('MemberExpression',{object:node('DotExpression'),property,computed:true}) })), new Action(new Sequence(new Terminal(".")), (
function(__context, __values) {
;
 return node('DotExpression') }))).setName("DotExpression"),

new Action(new Sequence(new Reference("InlineExpression").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("InlineExpression").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return [head, ...tail] })).setName("InlineExpressionList"),

new Choice(new Action(new Sequence(new Terminal("()")), (
function(__context, __values) {
;
 return [] })), new Action(new Sequence(new Terminal("("), new Reference("_"), new Reference("InlineExpressionList").setName("value"), new Reference("_"), new Terminal(")")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("InlineArguments"),

new Action(new Sequence(new Optional(new Terminal("?")).setName("optional"), new Terminal("["), new Reference("_"), new Reference("InlineExpression").setName("property"), new Reference("_"), new Terminal("]")), (
function(__context, __values) {
let optional = __values[0];
let property = __values[3];
 return { property, computed:true, optional: optional != null } })).setName("InlineChainMemberComputed"),

new Action(new Sequence(new Optional(new Terminal("?")).setName("optional"), new Reference("_"), new Terminal("."), new Reference("Identifier").setName("property")), (
function(__context, __values) {
let optional = __values[0];
let property = __values[3];
 return { property, computed:false, optional: optional != null } })).setName("InlineChainMember"),

new Action(new Sequence(new Optional(new Terminal("?")).setName("optional"), new Reference("InlineArguments").setName("args")), (
function(__context, __values) {
let optional = __values[0];
let args = __values[1];
 return { arguments:args, optional: optional != null } })).setName("InlineChainMemberCall"),

new Choice(new Reference("InlineChainMemberComputed"), new Reference("InlineChainMember"), new Reference("InlineChainMemberCall")).setName("InlineChain"),

new Action(new Sequence(new Repeat(new Reference("InlineChain"), 1).setName("head"), new Choice(new Reference("OutlineArguments"), new Action(new Sequence(new Reference("EOL")), (
function(__context, __values) {
;
 return null }))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];

        let last = head[head.length - 1]
        if (tail && last.arguments) {
            // then we can insert our outline arguments if we have any.
            head[head.length - 1] = { ...last, arguments: [...last.arguments, ...tail] }
        }
        return head
    })).setName("OutlineChain"),

new Action(new Sequence(new Reference("PrimaryExpression").setName("head"), new Repeat(new Reference("InlineChain")).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return toChain(head, tail) })).setName("MemberExpression"),

new Action(new Sequence(new Reference("PrimaryExpression").setName("head"), new Repeat(new Choice(new Reference("InlineChainMemberComputed"), new Reference("InlineChainMember"))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];

        return tail.reduce(
            (left, right) => node("MemberExpression", { object:left, ...right })
            ,head
        )
    })).setName("MemberExpressionNoCall"),

new Action(new Sequence(new Terminal("..."), new Reference("InlineExpression").setName("argument")), (
function(__context, __values) {
let argument = __values[1];
 return node("SpreadElement", { argument }) })).setName("InlineSpreadElement"),

new Action(new Sequence(new Terminal("..."), new Reference("OutlineExpression").setName("argument")), (
function(__context, __values) {
let argument = __values[1];
 return node("SpreadElement", { argument }) })).setName("OutlineSpreadElement"),

new Choice(new Reference("InlineSpreadElement"), new Reference("InlineExpression")).setName("ArrayElement"),

new Action(new Sequence(new Reference("ArrayElement").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("ArrayElement").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return [head, ...tail] })).setName("ArrayElements"),

new Choice(new Action(new Sequence(new Terminal("["), new Reference("_"), new Optional(new Reference("ArrayElements")).setName("elements"), new Reference("_"), new Terminal("]")), (
function(__context, __values) {
let elements = __values[2];
 return node("ArrayExpression", { elements:elements || [] }) })), new Action(new Sequence(new Terminal("|"), new Reference("_"), new Optional(new Reference("ArrayElements")).setName("elements"), new Reference("_"), new Terminal("|")), (
function(__context, __values) {
let elements = __values[2];
 return node("ArrayExpression", { elements:elements || [], isSet: true }) }))).setName("InlineArrayExpression"),

new Action(new Sequence(new Reference("Reference").setName("object"), new Optional(new Action(new Sequence(new Terminal("."), new Reference("Identifier").setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;}))).setName("property")), (
function(__context, __values) {
let object = __values[0];
let property = __values[1];
 return property ? node("MemberExpression", { object, property }) : object })).setName("JSXName"),

new Reference("JSXName").setName("JSXAttributeName"),

new Reference("JSXName").setName("JSXElementName"),

new Action(new Sequence(new Reference("JSXAttributeName").setName("key"), new Optional(new Reference("JSXAttributeInitializer")).setName("value")), (
function(__context, __values) {
let key = __values[0];
let value = __values[1];
 return node("Property", { key, value: value || node("Literal", { value: true }) }) })).setName("JSXAttribute"),

new Action(new Sequence(new Terminal("="), new Reference("_"), new Reference("JSXAttributeValue").setName("value")), (
function(__context, __values) {
let value = __values[2];
return value;})).setName("JSXAttributeInitializer"),

new Choice(new Reference("StringLiteral"), new Action(new Sequence(new Terminal("{"), new Reference("_"), new Reference("InlineExpression").setName("value"), new Reference("_"), new Terminal("}")), (
function(__context, __values) {
let value = __values[2];
return value;}))).setName("JSXAttributeValue"),

new Action(new Sequence(new Terminal("{"), new Reference("_"), new Reference("InlineSpreadElement").setName("value"), new Reference("_"), new Terminal("}")), (
function(__context, __values) {
let value = __values[2];
return value;})).setName("JSXSpreadAttribute"),

new Repeat(new Action(new Sequence(new Reference("_"), new Choice(new Reference("JSXAttribute"), new Reference("JSXSpreadAttribute")).setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})), 1).setName("JSXAttributes"),

new Action(new Sequence(new Terminal("<"), new Reference("_"), new Reference("JSXElementName").setName("kind"), new Reference("_"), new Optional(new Reference("JSXAttributes")).setName("properties"), new Reference("_"), new Terminal("/>")), (
function(__context, __values) {
let kind = __values[2];
let properties = __values[4];
 return node("ElementExpression", { kind, properties: properties || [], children: [] }) })).setName("InlineJSXElementSelfClosing"),

new Action(new Sequence(new Terminal("<"), new Reference("_"), new Reference("JSXElementName").setName("kind"), new Reference("_"), new Optional(new Reference("JSXAttributes")).setName("properties"), new Reference("_"), new Terminal(">")), (
function(__context, __values) {
let kind = __values[2];
let properties = __values[4];
 return node("ElementExpression", { kind, properties: properties || [], children: [] }) })).setName("InlineJSXElementOpen"),

new Action(new Sequence(new Terminal("</"), new Reference("_"), new Reference("JSXElementName").setName("value"), new Reference("_"), new Terminal(">")), (
function(__context, __values) {
let value = __values[2];
return value;})).setName("InlineJSXElementClose"),

new Action(new Sequence(new Repeat(new Group(new Sequence(new NotPredicate(new Terminal("<")), new NotPredicate(new Terminal(">")), new NotPredicate(new Terminal("{")), new NotPredicate(new Terminal("}")), new Any())), 1)), (
function(__context, __values) {
;
 return node("Literal", { value: text().replace(/&lt;/g, "<").replace(/&gt;/g, ">") })})).setName("InlineJSXText"),

new Choice(new Action(new Sequence(new Terminal("{"), new Reference("_"), new Choice(new Reference("InlineExpression"), new Reference("InlineSpreadElement")).setName("value"), new Reference("_"), new Terminal("}")), (
function(__context, __values) {
let value = __values[2];
return value;})), new Reference("InlineJSXElementExpression"), new Reference("InlineJSXText")).setName("InlineJSXChild"),

new Choice(new Reference("InlineJSXElementSelfClosing"), new Action(new Sequence(new Reference("InlineJSXElementOpen").setName("open"), new Repeat(new Reference("InlineJSXChild")).setName("children"), new Reference("InlineJSXElementClose").setName("close")), (
function(__context, __values) {
let open = __values[0];
let children = __values[1];
let close = __values[2];
 return node("ElementExpression", { ...open, children, close: close || null }) }))).setName("InlineJSXElementExpression"),

new Action(new Sequence(new Reference("InlineJSXElementSelfClosing").setName("element"), new Reference("OutlineArrayArguments").setName("children")), (
function(__context, __values) {
let element = __values[0];
let children = __values[1];
 return node("ElementExpression", { ...element, children }) })).setName("OutlineJSXElementExpression"),

new Action(new Sequence(new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Choice(new Action(new Sequence(new Choice(new Reference("OutlineExpression"), new Action(new Sequence(new Reference("InlineExpressionList").setName("value"), new Reference("EOL")), (
function(__context, __values) {
let value = __values[0];
return value;}))).setName("value")), (
function(__context, __values) {
let value = __values[0];
return value;})), new Action(new Sequence(new Reference("Statement").setName("value")), (
function(__context, __values) {
let value = __values[0];
return value;}))).setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})), 1).setName("args"), new Reference("Outdent")), (
function(__context, __values) {
let args = __values[2];
 return args.flat() })).setName("OutlineArrayArguments"),

new Choice(new Action(new Sequence(new Terminal("[]"), new Reference("OutlineArrayArguments").setName("elements")), (
function(__context, __values) {
let elements = __values[1];
 return node("ArrayExpression", { elements: elements.flat() }) })), new Action(new Sequence(new Terminal("||"), new Reference("OutlineArrayArguments").setName("elements")), (
function(__context, __values) {
let elements = __values[1];
 return node("ArrayExpression", { elements: elements.flat(), isSet: true }) }))).setName("OutlineArrayExpression"),

new Action(new Sequence(new Reference("InlineObjectExpression").setName("e"), new Reference("OutlinePropertyList").setName("properties")), (
function(__context, __values) {
let e = __values[0];
let properties = __values[1];
 return node("ObjectExpression", { isMap: e.isMap, properties: [...e.properties, ...properties] }) })).setName("OutlineObjectExpression"),

new Action(new Sequence(new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Choice(new Reference("OutlineMapProperty"), new Reference("Statement")).setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})), 1).setName("value"), new Reference("Outdent")), (
function(__context, __values) {
let value = __values[2];
return value;})).setName("OutlineMapPropertyList"),

new Action(new Sequence(new Reference("InlineExpression").setName("key"), new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("OutlineExpression").setName("value")), (
function(__context, __values) {
let key = __values[0];
let value = __values[4];
 return node("Property", { key, value, computed: true })})).setName("OutlineMapProperty"),

new Action(new Sequence(new Reference("EOL"), new Reference("Indent"), new Repeat(new Action(new Sequence(new Reference("Dent"), new Choice(new Reference("OutlineProperty"), new Reference("Statement")).setName("value")), (
function(__context, __values) {
let value = __values[1];
return value;})), 1).setName("value"), new Reference("Outdent")), (
function(__context, __values) {
let value = __values[2];
return value;})).setName("OutlinePropertyList"),

new Choice(new Reference("OutlineProperty"), new Reference("OutlineMapProperty")).setName("PropertyStatement"),

new Choice(new Action(new Sequence(new Reference("InlineSpreadElement").setName("value"), new Reference("EOL")), (
function(__context, __values) {
let value = __values[0];
return value;})), new Action(new Sequence(new Terminal("["), new Reference("_"), new Reference("InlineExpression").setName("key"), new Reference("_"), new Terminal("]"), new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("OutlineExpression").setName("value")), (
function(__context, __values) {
let key = __values[2];
let value = __values[8];
 return node("Property", { key, value, computed: true }) })), new Action(new Sequence(new Action(new Sequence(new Reference("Identifier").setName("value"), new Reference("_"), new Terminal(":")), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("key"), new Reference("_"), new Reference("OutlineExpression").setName("value")), (
function(__context, __values) {
let key = __values[0];
let value = __values[2];
 return node("Property", { key, value }) })), new Action(new Sequence(new Reference("GetToken"), new Reference("_"), new Reference("NamedOutlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[2];
 return node("Property", { key: value.id, value, kind: "get", method: true }) })), new Action(new Sequence(new Reference("SetToken"), new Reference("_"), new Reference("NamedOutlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[2];
 return node("Property", { key: value.id, value, kind: "set", method: true }) })), new Action(new Sequence(new Reference("NamedOutlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[0];
 return node("Property", { key: value.id, value, method: true }) })), new Action(new Sequence(new Reference("Identifier").setName("key"), new Reference("EOL")), (
function(__context, __values) {
let key = __values[0];
 return node("Property", { key, value: node("Reference", key), shorthand: true }) }))).setName("OutlineProperty"),

new Action(new Sequence(new Reference("InlineExpression").setName("key"), new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("InlineExpression").setName("value")), (
function(__context, __values) {
let key = __values[0];
let value = __values[4];
 return node("Property", { key, value, computed: true })})).setName("InlineMapProperty"),

new Action(new Sequence(new Reference("InlineMapProperty").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("InlineMapProperty").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return [head, ...tail] })).setName("InlineMapPropertyList"),

new Choice(new Action(new Sequence(new Terminal("{"), new Reference("_"), new Optional(new Reference("InlinePropertyList")).setName("properties"), new Reference("_"), new Terminal("}")), (
function(__context, __values) {
let properties = __values[2];
 return node("ObjectExpression", {properties: properties || []}) })), new Action(new Sequence(new Terminal("("), new Reference("_"), new Optional(new Reference("InlineMapPropertyList")).setName("properties"), new Reference("_"), new Terminal(")")), (
function(__context, __values) {
let properties = __values[2];
 return node("ObjectExpression", { properties: properties || [], isMap: true }) }))).setName("InlineObjectExpression"),

new Choice(new Reference("InlineSpreadElement"), new Action(new Sequence(new Terminal("["), new Reference("_"), new Reference("InlineExpression").setName("key"), new Reference("_"), new Terminal("]"), new Reference("_"), new Terminal(":"), new Reference("_"), new Reference("InlineExpression").setName("value")), (
function(__context, __values) {
let key = __values[2];
let value = __values[8];
 return node("Property", { key, value, computed: true }) })), new Action(new Sequence(new Action(new Sequence(new Choice(new Reference("Identifier"), new Reference("StringLiteral")).setName("value"), new Reference("_"), new Terminal(":")), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("key"), new Reference("_"), new Reference("InlineExpression").setName("value")), (
function(__context, __values) {
let key = __values[0];
let value = __values[2];
 return node("Property", { key, value }) })), new Action(new Sequence(new Reference("GetToken"), new Reference("_"), new Reference("NamedInlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[2];
 return node("Property", { key: value.id, value, kind: "get", method: true }) })), new Action(new Sequence(new Reference("SetToken"), new Reference("_"), new Reference("NamedInlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[2];
 return node("Property", { key: value.id, value, kind: "set", method: true }) })), new Action(new Sequence(new Reference("NamedInlineFunction").setName("value")), (
function(__context, __values) {
let value = __values[0];
 return node("Property", { key: value.id, value, method: true }) })), new Action(new Sequence(new Reference("Identifier").setName("key")), (
function(__context, __values) {
let key = __values[0];
 return node("Property", { key, value: node("Reference", key), shorthand: true }) }))).setName("InlineProperty"),

new Action(new Sequence(new Reference("InlineProperty").setName("head"), new Repeat(new Action(new Sequence(new Reference("_"), new Terminal(","), new Reference("_"), new Reference("InlineProperty").setName("value")), (
function(__context, __values) {
let value = __values[3];
return value;}))).setName("tail")), (
function(__context, __values) {
let head = __values[0];
let tail = __values[1];
 return [head, ...tail] })).setName("InlinePropertyList"),

new Choice(new Reference("NumericLiteral"), new Reference("BooleanLiteral"), new Reference("StringLiteral"), new Reference("NullLiteral"), new Reference("RegularExpression")).setName("Literal"),

new Choice(new Reference("HexIntegerLiteral"), new Reference("DecimalLiteral"), new Reference("DecimalIntegerLiteral")).setName("NumericLiteral"),

new Action(new Sequence(new Reference("NullToken")), (
function(__context, __values) {
;
 return node('Literal', { value: null }) })).setName("NullLiteral"),

new Action(new Sequence(new Choice(new Reference("TrueToken"), new Reference("FalseToken")).setName("value")), (
function(__context, __values) {
let value = __values[0];
 return node('Literal', { value: JSON.parse(value) ? true : false } ) })).setName("BooleanLiteral"),

new Sequence(new Terminal("e"), new Optional(new Regex(/[\+\-]/y)), new Repeat(new Regex(/[0-9]/y), 1), new NotPredicate(new Reference("IdPart"))).setName("ExponentPart"),

new Action(new Sequence(new Choice(new Sequence(new Optional(new Reference("DecimalInteger")), new Terminal("."), new Repeat(new Regex(/[0-9]/y), 1), new Optional(new Reference("ExponentPart"))), new Sequence(new Reference("DecimalInteger"), new Reference("ExponentPart"))), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
;
 return node('Literal', { value: parseFloat(text()) })})).setName("DecimalLiteral"),

new Regex(/[0-9A-F]/y).setName("HexDigit"),

new Action(new Sequence(new Terminal("0x"), new Repeat(new Reference("HexDigit"), 1), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
;
 return node('Literal', {value: parseInt(text(), 16) }) })).setName("HexIntegerLiteral"),

new Action(new Sequence(new Reference("DecimalInteger")), (
function(__context, __values) {
;
 return node('Literal', { value: parseInt(text()) }) })).setName("DecimalIntegerLiteral"),

new Choice(new Terminal("0"), new Action(new Sequence(new Optional(new Regex(/[\+\-]/y)), new Regex(/[1-9]/y), new Repeat(new Regex(/[0-9]/y)), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
;
 return parseInt(text()) }))).setName("DecimalInteger"),

new Action(new Sequence(new Terminal("\""), new Repeat(new Reference("DoubleStringChar")), new Terminal("\"")), (
function(__context, __values) {
;
 return node('Literal', { value: eval(text()) }); })).setName("StringLiteral"),

new Choice(new Terminal("\\\""), new Sequence(new NotPredicate(new Terminal("\"")), new Any())).setName("DoubleStringChar"),

new Choice(new Action(new Sequence(new Reference("_"), new Reference("LineTerminatorSequence")), (
function(__context, __values) {
;
 return '' })), new Action(new Sequence(new Reference("Dent"), new Repeat(new Regex(/[^\r\n]/y)).setName("line"), new Reference("LineTerminatorSequence")), (
function(__context, __values) {
let line = __values[1];
 return line.join('') }))).setName("OutlineStringLiteralLine"),

new Action(new Sequence(new Terminal("\"\""), new Reference("EOL"), new Reference("Indent"), new Repeat(new Reference("OutlineStringLiteralLine")).setName("lines"), new Reference("Outdent")), (
function(__context, __values) {
let lines = __values[3];
 return node('Literal', { value: lines.join('\n') }) })).setName("OutlineStringLiteral"),

new Action(new Sequence(new Terminal("/"), new StringValue(new Repeat(new Choice(new Group(new Sequence(new Terminal("\\"), new Any())), new Regex(/[^\/]/y)), 1)).setName("pattern"), new Terminal("/"), new StringValue(new Repeat(new Regex(/[a-z]/y))).setName("flags")), (
function(__context, __values) {
let pattern = __values[1];
let flags = __values[3];
 return node("RegularExpression", {pattern, flags }) })).setName("RegularExpression"),

new Regex(/[a-zA-Z\$_]/y).setName("IdStart"),

new Choice(new Reference("IdStart"), new Regex(/[0-9]/y)).setName("IdPart"),

new Choice(new StringValue(new Group(new Sequence(new Reference("IdStart"), new Repeat(new Reference("IdPart"))))), new Action(new Sequence(new Terminal("`"), new StringValue(new Repeat(new Group(new Sequence(new NotPredicate(new Terminal("`")), new Any())))).setName("value"), new Terminal("`")), (
function(__context, __values) {
let value = __values[1];
return value;}))).setName("IdName"),

new Action(new Sequence(new Reference("IdName").setName("name")), (
function(__context, __values) {
let name = __values[0];
 return node('Identifier', { name }) })).setName("Identifier"),

new Action(new Sequence(new NotPredicate(new Reference("ReservedWord")), new Reference("IdName").setName("name")), (
function(__context, __values) {
let name = __values[1];

        return node("Reference", { name })
    })).setName("Reference"),

new Action(new Sequence(new NotPredicate(new Reference("ReservedWord")), new Reference("IdName").setName("name")), (
function(__context, __values) {
let name = __values[1];

        return node("Declarator", { name })
    })).setName("Declarator"),

new Action(new Sequence(new Terminal("this").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ThisToken"),

new Action(new Sequence(new Terminal("null").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("NullToken"),

new Action(new Sequence(new Terminal("false").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("TrueToken"),

new Action(new Sequence(new Terminal("true").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("FalseToken"),

new Action(new Sequence(new Terminal("type").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("TypeToken"),

new Action(new Sequence(new Terminal("is").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("IsToken"),

new Action(new Sequence(new Terminal("by").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ByToken"),

new Action(new Sequence(new Terminal("isnt").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("IsntToken"),

new Action(new Sequence(new Terminal("as").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("AsToken"),

new Action(new Sequence(new Terminal("and").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("AndToken"),

new Action(new Sequence(new Terminal("or").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("OrToken"),

new Action(new Sequence(new Terminal("xor").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("XorToken"),

new Action(new Sequence(new Terminal("not").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("NotToken"),

new Action(new Sequence(new Terminal("typeof").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("TypeofToken"),

new Action(new Sequence(new Terminal("delete").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("DeleteToken"),

new Action(new Sequence(new Terminal("new").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("NewToken"),

new Action(new Sequence(new Terminal("import").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ImportToken"),

new Action(new Sequence(new Terminal("export").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ExportToken"),

new Action(new Sequence(new Terminal("default").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("DefaultToken"),

new Action(new Sequence(new Terminal("class").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ClassToken"),

new Action(new Sequence(new Terminal("struct").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("StructToken"),

new Action(new Sequence(new Terminal("var").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("VarToken"),

new Action(new Sequence(new Terminal("let").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("LetToken"),

new Action(new Sequence(new Terminal("property").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("PropertyToken"),

new Action(new Sequence(new Terminal("meta").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("MetaToken"),

new Action(new Sequence(new Terminal("static").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("StaticToken"),

new Action(new Sequence(new Terminal("data").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("DataToken"),

new Action(new Sequence(new Terminal("extends").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ExtendsToken"),

new Action(new Sequence(new Terminal("for").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ForToken"),

new Action(new Sequence(new Terminal("while").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("WhileToken"),

new Action(new Sequence(new Terminal("in").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("InToken"),

new Action(new Sequence(new Terminal("of").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("OfToken"),

new Action(new Sequence(new Terminal("if").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("IfToken"),

new Action(new Sequence(new Terminal("else").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ElseToken"),

new Action(new Sequence(new Terminal("return").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ReturnToken"),

new Action(new Sequence(new Terminal("break").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("BreakToken"),

new Action(new Sequence(new Terminal("continue").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ContinueToken"),

new Action(new Sequence(new Terminal("asm").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("AsmToken"),

new Action(new Sequence(new Terminal("throw").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("ThrowToken"),

new Action(new Sequence(new Terminal("try").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("TryToken"),

new Action(new Sequence(new Terminal("catch").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("CatchToken"),

new Action(new Sequence(new Terminal("finally").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("FinallyToken"),

new Action(new Sequence(new Terminal("get").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("GetToken"),

new Action(new Sequence(new Terminal("set").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("SetToken"),

new Action(new Sequence(new Terminal("switch").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("SwitchToken"),

new Action(new Sequence(new Terminal("async").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("AsyncToken"),

new Action(new Sequence(new Terminal("await").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("AwaitToken"),

new Action(new Sequence(new Terminal("yield").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("YieldToken"),

new Action(new Sequence(new Terminal("do").setName("value"), new NotPredicate(new Reference("IdPart"))), (
function(__context, __values) {
let value = __values[0];
return value;})).setName("DoToken"),

new Choice(new Reference("ThisToken"), new Reference("NullToken"), new Reference("TrueToken"), new Reference("FalseToken"), new Reference("AndToken"), new Reference("IsToken"), new Reference("IsntToken"), new Reference("AsToken"), new Reference("OrToken"), new Reference("XorToken"), new Reference("NotToken"), new Reference("TypeofToken"), new Reference("NewToken"), new Reference("ClassToken"), new Reference("StructToken"), new Reference("VarToken"), new Reference("LetToken"), new Reference("ForToken"), new Reference("WhileToken"), new Reference("IfToken"), new Reference("ElseToken"), new Reference("ReturnToken"), new Reference("BreakToken"), new Reference("ContinueToken"), new Reference("ExportToken"), new Reference("ImportToken"), new Reference("AsmToken"), new Reference("ThrowToken"), new Reference("TryToken"), new Reference("CatchToken"), new Reference("FinallyToken"), new Reference("SwitchToken")).setName("Keyword"),

new Reference("Keyword").setName("ReservedWord"),

new Increment("indentation", 1).setName("Indent"),

new Increment("indentation", -1).setName("Outdent"),

new Repeat(new Terminal("    "), "indentation", "indentation").setName("Dent"),

new Choice(new Terminal("\n"), new Terminal("\r\n"), new Terminal("\r")).setName("LineTerminatorSequence"),

new Sequence(new Terminal("//"), new Repeat(new Group(new Sequence(new NotPredicate(new Regex(/[\r\n]/y)), new Any())))).setLabel("").setName("Comment"),

new Repeat(new Terminal(" ")).setLabel("").setName("_"),

new Repeat(new Choice(new Terminal(" "), new Reference("LineTerminatorSequence"), new Reference("Comment"))).setLabel("").setName("__"),

new Choice(new Repeat(new Group(new Sequence(new Reference("_"), new Optional(new Reference("Comment")), new Repeat(new Reference("LineTerminatorSequence"), 1))), 1), new Sequence(new Reference("_"), new Optional(new Reference("Comment")), new Reference("EOF"))).setLabel("end of line").setName("EOL"),

new NotPredicate(new Any()).setLabel("").setName("EOF")]))

        return parser
    }
})()
;
exports.default = exports