diff --git a/common/constants.ts b/common/constants.ts index f943092b..8fd7361e 100644 --- a/common/constants.ts +++ b/common/constants.ts @@ -7,7 +7,7 @@ export const BIN = /_?[0-1]+/ // identifiers export const IDENTIFIER = /_?[a-z][a-z0-9_]*(\?|!)?'*/ -export const OPERATOR = /(==|[!@$%^&*|<>~*\\\-+/.])[!@$%^&*|<>~*\\\-+/.=?]*/ +export const OPERATOR = /[!@$%^&*|<>~*\\\-+/.?=]+/ export const TYPE = /[A-Z][a-zA-Z0-9]*/ // declarations diff --git a/common/declarations.ts b/common/declarations.ts index 67472569..b8bb818b 100644 --- a/common/declarations.ts +++ b/common/declarations.ts @@ -14,15 +14,12 @@ export const declaration_member = ( $: GrammarSymbols, ) => seq( - field('as', alias($.identifier, $.identifier_pattern_name)), + field('as', alias($.identifier, $.identifier_pattern)), optional( - seq( - 'from', - field('name', alias($.js_identifier, $.identifier_pattern_name)), - ), + seq('from', field('name', alias($.js_identifier, $.identifier_pattern))), ), - '::', - field('type', $._type), + ':', + field('type', $._term), ) export const js_identifier = () => token(seq(JS_ALPHA, repeat(JS_ALPHANUMERIC))) diff --git a/common/dialects.ts b/common/dialects.ts new file mode 100644 index 00000000..d47d18d3 --- /dev/null +++ b/common/dialects.ts @@ -0,0 +1,4 @@ +export enum Dialect { + DTN, + Tony, +} diff --git a/common/enums.ts b/common/enums.ts deleted file mode 100644 index 3ca00d99..00000000 --- a/common/enums.ts +++ /dev/null @@ -1,41 +0,0 @@ -export enum Prec { - Group = -1, - SubtractionType = -1, - UnionType = 0, - Assignment = 1, - TypeHint = 1, - CurriedType = 1, - NamedInfixApplication = 1, - SectionIdentifier = 1, - Literal = 1, - IntersectionType = 1, - LabeledType = 2, - OperatorInfixApplication = 2, - OptionalType = 3, - Biconditional = 3, - TaggedType = 4, - Implication = 4, - Or = 5, - And = 6, - Equality = 7, - Order = 8, - Mod = 9, - Sum = 10, - Product = 11, - Exponentiation = 12, - Not = 13, - InfixApplication = 14, - Application = 15, - Term = 16, - Pattern = 16, - Access = 17, - Pipeline = 18, - ParametricTypeInstance = 19, - Argument = 20, - Hole = 21, -} - -export enum Dialect { - DTN, - Tony, -} diff --git a/common/imports.ts b/common/imports.ts index 0dfed101..2e7d042d 100644 --- a/common/imports.ts +++ b/common/imports.ts @@ -1,4 +1,4 @@ -import { Dialect, Prec } from './enums' +import { Dialect } from './dialects' import { commaSep1 } from './util' export const import_ = ($: GrammarSymbols) => @@ -8,36 +8,32 @@ export const exported_import = ( $: GrammarSymbols, ) => seq('export', $._import_body) -export const _import_body_constructor = - (dialect: Dialect) => - ($: GrammarSymbols) => { - switch (dialect) { - case Dialect.DTN: - return prec.left( - Prec.Pattern, - seq( - '{', - commaSep1(field('import', $.import_type)), - '}', - 'from', - field('source', $.raw_string), - ), - ) - case Dialect.Tony: - return prec.left( - Prec.Pattern, - seq( - choice( - field('default', alias($.identifier, $.identifier_pattern_name)), - seq( - optional( - seq( - field( - 'default', - alias($.identifier, $.identifier_pattern_name), - ), - ',', - ), +export const _import_body_constructor = (dialect: Dialect) => < + RuleName extends string +>( + $: GrammarSymbols, +) => { + switch (dialect) { + case Dialect.DTN: + return prec.left( + seq( + '{', + commaSep1(field('import', $.import_type)), + '}', + 'from', + field('source', $.raw_string), + ), + ) + case Dialect.Tony: + return prec.left( + seq( + choice( + field('default', alias($.identifier, $.identifier_pattern)), + seq( + optional( + seq( + field('default', alias($.identifier, $.identifier_pattern)), + ',', ), '{', commaSep1( @@ -58,9 +54,9 @@ export const import_identifier = ( ) => seq( optional( - seq(field('name', alias($.identifier, $.identifier_pattern_name)), 'as'), + seq(field('name', alias($.identifier, $.identifier_pattern)), 'as'), ), - field('as', alias($.identifier, $.identifier_pattern_name)), + field('as', alias($.identifier, $.identifier_pattern)), ) export const import_type = ( diff --git a/common/literals.ts b/common/literals.ts index 03d3ea33..62a4d8a6 100644 --- a/common/literals.ts +++ b/common/literals.ts @@ -1,14 +1,13 @@ import { BIN, DIGITS, EXP, HEX, OCT } from './constants' -import { Prec } from './enums' import { buildString } from './util' export const _literal = ( $: GrammarSymbols, -) => prec(Prec.Literal, choice($.boolean, $.number, $.string, $.regex)) +) => choice($.boolean, $.decimal, $.integer, $.string, $.regex) export const boolean = () => choice('false', 'true') -export const _decimal = () => { +export const decimal = () => { const digits = repeat1(DIGITS) const exponent = seq(EXP, digits) @@ -17,7 +16,7 @@ export const _decimal = () => { ) } -export const _integer = () => +export const integer = () => token( choice( seq('0x', repeat1(HEX)), @@ -27,9 +26,6 @@ export const _integer = () => ), ) -export const number = ($: GrammarSymbols) => - choice($._decimal, $._integer) - export const raw_string = ( $: GrammarSymbols, ) => buildString($) diff --git a/common/patterns.ts b/common/patterns.ts index 0be1e5cd..fc9002fc 100644 --- a/common/patterns.ts +++ b/common/patterns.ts @@ -1,20 +1,20 @@ +import { Prec } from './precedences' import { - buildIdentifierPattern, + buildBindingPattern, buildList, buildMember, buildStruct, buildTuple, } from './util' -import { Prec } from './enums' export const _pattern = ( $: GrammarSymbols, ) => prec( - Prec.Pattern, + 'base', choice( $.wildcard_pattern, - $.identifier_pattern, + $.binding_pattern, $._assignable_pattern, $._literal_pattern, ), @@ -23,28 +23,41 @@ export const _pattern = ( export const _assignable_pattern = ( $: GrammarSymbols, ) => - choice( - alias($.root_identifier_pattern, $.identifier_pattern), - $.destructuring_pattern, - $.tagged_pattern, - $.pattern_group, + prec( + 'base', + choice( + alias($.root_binding_pattern, $.binding_pattern), + $.destructuring_pattern, + $.pattern_group, + ), ) export const destructuring_pattern = ( $: GrammarSymbols, ) => prec( - Prec.Pattern, + 'base', seq( optional( seq( - field('alias', alias($.identifier, $.identifier_pattern_name)), + field( + 'alias', + choice( + alias($.identifier, $.identifier_pattern), + alias($.type, $.type_pattern), + ), + ), '@', ), ), field( 'pattern', - choice($.struct_pattern, $.tuple_pattern, $.list_pattern), + choice( + $.struct_pattern, + $.tuple_pattern, + $.list_pattern, + $.tag_pattern, + ), ), ), ) @@ -53,12 +66,13 @@ export const struct_pattern = ( $: GrammarSymbols, ) => prec( - Prec.Pattern, + 'base', buildStruct( $, + 'member', choice( $.member_pattern, - alias($.identifier_pattern, $.shorthand_member_pattern), + alias($.binding_pattern, $.shorthand_member_pattern), ), true, ), @@ -66,38 +80,42 @@ export const struct_pattern = ( export const member_pattern = ( $: GrammarSymbols, -) => buildMember($, $._term, $._pattern) +) => prec('base', buildMember($, $._term, $._pattern)) export const tuple_pattern = ( $: GrammarSymbols, -) => prec(Prec.Pattern, buildTuple($, $._pattern, true)) +) => prec('base', buildTuple($, 'element', $._pattern, true, false)) export const list_pattern = ( $: GrammarSymbols, -) => prec(Prec.Pattern, buildList($, $._pattern, true)) +) => prec('base', buildList($, 'element', $._pattern, true)) -export const identifier_pattern = ( +export const binding_pattern = ( $: GrammarSymbols, -) => buildIdentifierPattern($, true) +) => prec('base', buildBindingPattern($, true)) -export const root_identifier_pattern = ( +export const root_binding_pattern = ( $: GrammarSymbols, -) => buildIdentifierPattern($, false) +) => prec('base', choice(buildBindingPattern($, false))) export const wildcard_pattern = () => '_' -export const tagged_pattern = ( +export const tag_pattern = ( $: GrammarSymbols, ) => - seq( - field('name', alias($._identifier_without_operators, $.identifier)), - field('pattern', $._pattern), + prec( + 'application', + seq( + field('name', alias($._identifier_without_operators, $.identifier)), + field('pattern', $._pattern), + ), ) export const _literal_pattern = ( $: GrammarSymbols, -) => choice($.boolean, $.number, $.raw_string, $.regex) +) => + prec('base', choice($.boolean, $.decimal, $.integer, $.raw_string, $.regex)) export const pattern_group = ( $: GrammarSymbols, -) => prec(Prec.Pattern, seq('(', field('pattern', $._pattern), ')')) +) => prec('base', seq('(', field('pattern', $._pattern), ')')) diff --git a/common/precedences.ts b/common/precedences.ts new file mode 100644 index 00000000..4deecac9 --- /dev/null +++ b/common/precedences.ts @@ -0,0 +1,159 @@ +export enum Operator { + Access = 'Access', + And = 'And', + Biconditional = 'Biconditional', + Difference = 'Difference', + Equality = 'Equality', + Exponentiation = 'Exponentiation', + Extends = 'Extends', + Implication = 'Implication', + Mod = 'Mod', + Named = 'Named', + Not = 'Not', + Other = 'Other', + Or = 'Or', + Order = 'Order', + Pipeline = 'Pipeline', + Product = 'Product', + Sum = 'Sum', +} + +export enum Prec { + Group = -1, + SubtractionType = -1, + UnionType = 0, + Assignment = 1, + TypeHint = 1, + CurriedType = 1, + NamedInfixApplication = 1, + SectionIdentifier = 1, + Literal = 1, + IntersectionType = 1, + LabeledType = 2, + OperatorInfixApplication = 2, + Extends = 3, + OptionalType = 3, + Biconditional = 4, + TaggedType = 4, + Implication = 5, + Difference = 6, + Or = 7, + And = 8, + Equality = 9, + Order = 10, + Mod = 11, + Sum = 12, + Product = 13, + Exponentiation = 14, + Not = 15, + InfixApplication = 16, + Application = 17, + Term = 18, + Pattern = 18, + Access = 19, + Pipeline = 20, + // ParametricTypeInstance = 21, + Argument = 21, + // Hole = 21, +} + +export const precedences = ( + $: GrammarSymbols, +) => [ + [ + $.argument, + Operator.Pipeline, + 'access', + 'patternOrTerm', + 'application', + $.infix_application, + Operator.Not, + Operator.Exponentiation, + Operator.Product, + Operator.Sum, + Operator.Mod, + Operator.Order, + Operator.Equality, + Operator.And, + Operator.Or, + Operator.Difference, + Operator.Implication, + Operator.Biconditional, + Operator.Extends, + Operator.Other, + Operator.Named, + $._section_identifier, + 'base', + $.group, + ], + // [ + // Operator.Access, + // Operator.Pipeline, + // $.application, + // $.infix_application, + // Operator.Not, + // Operator.Exponentiation, + // Operator.Product, + // Operator.Sum, + // Operator.Mod, + // Operator.Order, + // Operator.Equality, + // Operator.And, + // Operator.Or, + // Operator.Difference, + // Operator.Implication, + // Operator.Biconditional, + // Operator.Other, + // Operator.Named, + // ], + + // [$.assignment, $._term, + // Operator.Pipeline, + // Operator.Access, + // $.application, + // Operator.Not, + // Operator.Exponentiation, + // Operator.Product, + // Operator.Sum, + // Operator.Mod, + // Operator.Order, + // Operator.Equality, + // Operator.And, + // Operator.Or, + // Operator.Difference, + // Operator.Implication, + // Operator.Biconditional, + // Operator.Other, + // Operator.Named, + // $.static_application, $.group], + + // _term () :: application + [$.application, $.tuple], + + // ? identifer :: hole + [$.hole, $._term], + // [$.hole, $.destructuring_pattern], + // [$.hole, $.root_binding_pattern], + + // _term [ _term ] :: access + // [$.access, $._element], + + // _term -> identifier :: access + // [$.access, $._term], + + // { [ _term ] ... :: member + [$.member, $._element], + + // _term ( ... binding_pattern ) = :: member + // [$.tuple_pattern, $.application], + + // { identifier , ... :: struct + [$.struct, $.binding_pattern], + + // _term ? _term ... :: conditional + [$.conditional, $.optional_type], + + // type = _term :: binding_pattern + [$.binding_pattern, $.infix_application], + [$.binding_pattern, $.application], +] diff --git a/common/terms.ts b/common/terms.ts index 12c51dff..2f74ffe7 100644 --- a/common/terms.ts +++ b/common/terms.ts @@ -1,44 +1,46 @@ -import { IDENTIFIER, OPERATOR } from './constants' +import { IDENTIFIER, OPERATOR, TYPE } from './constants' import { buildBlock, - buildGenericType, buildList, buildMember, buildStruct, buildTuple, - buildTypeConstraint, - buildTypeDeclaration, commaSep1, + sep1, } from './util' -import { Prec } from './enums' +import { Operator, Prec } from './precedences' + +export const _statement = ( + $: GrammarSymbols, +) => choice($._term, $.assignment, $.export, $.class, $.instance, $.data) export const _term = ($: GrammarSymbols) => - prec.left( - Prec.Term, + prec( + 'base', choice( $.block, - $.abstraction, + $.function, $.application, $.infix_application, $._section, $.access, - $.assignment, - $.export, $.return, - $.ternary, - $.if, + $.conditional, $.case, - $.class, - $.instance, $.struct, $.tuple, $.list, $.list_comprehension, - $.parametric_type_instance, $.pure, - $.type_alias, - $.type_hint, $.hole, + $.static_function, + $.static_application, + $.type_hint, + $.function_type, + $.optional_type, + $.keyof_type, + $.map_type, + $.type, $.identifier, $._literal, $.group, @@ -46,89 +48,104 @@ export const _term = ($: GrammarSymbols) => ) export const block = ($: GrammarSymbols) => - buildBlock($, field('term', $._term)) + prec('base', buildBlock($, field('term', choice($._term, $.assignment)))) + +export const _immediate_block = ( + $: GrammarSymbols, +) => + prec( + 'base', + choice(seq('then', field('body', $._term)), field('body', $.block)), + ) export const export_ = ($: GrammarSymbols) => - seq('export', field('declaration', $.assignment)) + prec('base', seq('export', field('declaration', $.assignment))) export const assignment = ( $: GrammarSymbols, ) => prec.right( - Prec.Assignment, + 'base', seq(field('pattern', $._assignable_pattern), '=', field('value', $._term)), ) export const class_ = ($: GrammarSymbols) => - seq( - 'class', - field('name', $.type), - optional(buildTypeConstraint($)), - buildBlock($, field('member', $.class_member)), + prec.right( + 'base', + seq( + 'class', + field('name', $.type), + optional(seq(':', field('constraint', $._term))), + buildBlock($, field('member', $.class_member)), + ), ) export const class_member = ( $: GrammarSymbols, ) => - seq( - field('name', alias($.identifier, $.identifier_pattern_name)), - '::', - field('type', $._type), + prec( + 'base', + seq( + field('name', alias($.identifier, $.identifier_pattern)), + ':', + field('type', $._term), + ), ) export const instance = ( $: GrammarSymbols, ) => - seq( - 'instance', - buildTypeDeclaration($), - 'of', - field('class', $.type), - buildBlock($, field('assignment', $.assignment)), + prec( + 'base', + seq( + 'instance', + field('type', $._term), + 'of', + field('class', $.type), + buildBlock($, field('assignment', $.assignment)), + ), ) -export const argument = ( +export const _parameters = ( $: GrammarSymbols, -) => - prec.left( - Prec.Argument, - choice(field('placeholder', '?'), field('value', $._element)), - ) +) => prec('base', buildTuple($, 'parameter', $._pattern, true, true)) -export const abstraction = ( +export const function_ = ( $: GrammarSymbols, -) => - prec.left( - seq( - optional(buildGenericType('typeParameter', $.type_variable_declaration)), - buildTuple($, $._pattern, true, true), - '=>', - field('body', $._term), - ), - ) +) => prec.right('base', seq($._parameters, '=>', field('body', $._term))) + +export const _arguments = ( + $: GrammarSymbols, +) => prec('base', buildTuple($, 'argument', $.argument, true, true)) export const application = ( $: GrammarSymbols, ) => prec.left( - Prec.Application, + 'application', + // Prec.Application, seq( field('name', $._term), - choice( - prec(Prec.Argument, buildTuple($, $.argument, false, true)), - field('element', $._term), - ), + choice($._arguments, field('argument', $._term)), ), ) +export const argument = ( + $: GrammarSymbols, +) => + // prec( + // Prec.Argument, + choice(field('placeholder', '?'), field('value', $._element)) +//) + export const infix_application = ( $: GrammarSymbols, ) => prec.left( - Prec.InfixApplication, + // Prec.InfixApplication, choice( prec.left( - Prec.Pipeline, + Operator.Pipeline, seq( field('left', $._term), field('name', alias('&.', $.identifier)), @@ -136,7 +153,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Pipeline, + Operator.Pipeline, seq( field('left', $._term), field('name', alias('.', $.identifier)), @@ -144,7 +161,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Not, + Operator.Not, seq( field('left', $._term), field('name', alias('!', $.identifier)), @@ -152,7 +169,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Exponentiation, + Operator.Exponentiation, seq( field('left', $._term), field('name', alias('^', $.identifier)), @@ -160,7 +177,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Product, + Operator.Product, seq( field('left', $._term), field('name', alias('*', $.identifier)), @@ -168,7 +185,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Product, + Operator.Product, seq( field('left', $._term), field('name', alias('/', $.identifier)), @@ -176,7 +193,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Sum, + Operator.Sum, seq( field('left', $._term), field('name', alias('+', $.identifier)), @@ -184,7 +201,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Sum, + Operator.Sum, seq( field('left', $._term), field('name', alias('-', $.identifier)), @@ -192,7 +209,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Mod, + Operator.Mod, seq( field('left', $._term), field('name', alias('%', $.identifier)), @@ -200,7 +217,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Order, + Operator.Order, seq( field('left', $._term), field('name', alias('<', $.identifier)), @@ -208,7 +225,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Order, + Operator.Order, seq( field('left', $._term), field('name', alias('<=', $.identifier)), @@ -216,7 +233,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Order, + Operator.Order, seq( field('left', $._term), field('name', alias('>', $.identifier)), @@ -224,7 +241,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Order, + Operator.Order, seq( field('left', $._term), field('name', alias('>=', $.identifier)), @@ -232,7 +249,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Equality, + Operator.Equality, seq( field('left', $._term), field('name', alias('==', $.identifier)), @@ -240,7 +257,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Equality, + Operator.Equality, seq( field('left', $._term), field('name', alias('!=', $.identifier)), @@ -248,7 +265,7 @@ export const infix_application = ( ), ), prec.left( - Prec.And, + Operator.And, seq( field('left', $._term), field('name', alias('&&', $.identifier)), @@ -256,7 +273,15 @@ export const infix_application = ( ), ), prec.left( - Prec.Or, + Operator.And, + seq( + field('left', $._term), + field('name', alias('&', $.identifier)), + field('right', $._term), + ), + ), + prec.left( + Operator.Or, seq( field('left', $._term), field('name', alias('||', $.identifier)), @@ -264,7 +289,23 @@ export const infix_application = ( ), ), prec.left( - Prec.Implication, + Operator.Or, + seq( + field('left', $._term), + field('name', alias('|', $.identifier)), + field('right', $._term), + ), + ), + prec.left( + Operator.Difference, + seq( + field('left', $._term), + field('name', alias('\\', $.identifier)), + field('right', $._term), + ), + ), + prec.left( + Operator.Implication, seq( field('left', $._term), field('name', alias('==>', $.identifier)), @@ -272,7 +313,7 @@ export const infix_application = ( ), ), prec.left( - Prec.Biconditional, + Operator.Biconditional, seq( field('left', $._term), field('name', alias('<=>', $.identifier)), @@ -280,7 +321,15 @@ export const infix_application = ( ), ), prec.left( - Prec.OperatorInfixApplication, + Operator.Extends, + seq( + field('left', $._term), + field('name', alias('<:', $.identifier)), + field('right', $._term), + ), + ), + prec.left( + Operator.Other, seq( field('left', $._term), field('name', alias($._operator, $.identifier)), @@ -288,7 +337,7 @@ export const infix_application = ( ), ), prec.left( - Prec.NamedInfixApplication, + Operator.Named, seq( field('left', $._term), '`', @@ -302,80 +351,84 @@ export const infix_application = ( export const _section = ( $: GrammarSymbols, -) => choice($.left_section, $.right_section) +) => prec('base', choice($.left_section, $.right_section)) export const left_section = ( $: GrammarSymbols, -) => seq('(', field('value', $._term), $._section_identifier, ')') +) => prec('base', seq('(', field('value', $._term), $._section_identifier, ')')) export const right_section = ( $: GrammarSymbols, -) => seq('(', $._section_identifier, field('value', $._term), ')') +) => prec('base', seq('(', $._section_identifier, field('value', $._term), ')')) export const _section_identifier = ( $: GrammarSymbols, ) => - prec( - Prec.SectionIdentifier, - choice( - seq('(', field('name', alias($._operator, $.identifier)), ')'), - seq( - '`', - field('name', alias($._identifier_without_operators, $.identifier)), - '`', - ), + // prec( + // Prec.SectionIdentifier, + choice( + seq('(', field('name', alias($._operator, $.identifier)), ')'), + seq( + '`', + field('name', alias($._identifier_without_operators, $.identifier)), + '`', ), ) +// ) export const list_comprehension = ( $: GrammarSymbols, ) => - seq( - '[', - field('body', $._term), - '|', - commaSep1( - choice( - field('generator', $.list_comprehension_generator), - field('condition', $.list_comprehension_condition), + prec( + 'base', + seq( + '[', + field('body', $._term), + '|', + commaSep1( + choice(field('generator', $.generator), field('condition', $._term)), ), + ']', ), - ']', ) -export const list_comprehension_generator = ( +export const generator = ( $: GrammarSymbols, ) => - seq( - field('name', alias($.identifier, $.identifier_pattern_name)), - 'in', - field('value', $._term), + prec( + 'base', + seq( + field('name', alias($.identifier, $.identifier_pattern)), + 'in', + field('value', $._term), + ), ) -export const list_comprehension_condition = ( - $: GrammarSymbols, -) => field('value', $._term) - export const access = ($: GrammarSymbols) => prec.left( - Prec.Access, + 'access', + // Prec.Access, seq( - field('name', $._term), + field('left', $._term), choice( - seq('[', field('value', $._term), ']'), + seq('[', field('right', $._term), ']'), seq( '->', - field('value', alias($.identifier, $.shorthand_access_identifier)), + field('right', alias($.identifier, $.shorthand_access_identifier)), ), ), ), ) export const return_ = ($: GrammarSymbols) => - prec.right(seq('return', field('value', $._term))) + prec.right('base', seq('return', field('value', $._term))) -export const ternary = ($: GrammarSymbols) => +export const conditional = ( + $: GrammarSymbols, +) => prec.right( + 'application', + // Prec.Application, seq( field('condition', $._term), '?', @@ -384,32 +437,12 @@ export const ternary = ($: GrammarSymbols) => ), ) -export const if_ = ($: GrammarSymbols) => - prec.right( - seq( - 'if', - field('condition', $._term), - choice(seq('then', field('body', $._term)), field('body', $.block)), - repeat(field('elseIf', $.else_if)), - optional(seq('else', field('else', $._term))), - ), - ) - -export const else_if = ($: GrammarSymbols) => - prec.right( - seq( - 'else if', - field('condition', $._term), - choice(seq('then', field('body', $._term)), field('body', $.block)), - ), - ) - export const case_ = ($: GrammarSymbols) => prec.right( + 'base', seq( 'case', field('value', $._term), - $._newline, repeat1(field('when', $.when)), 'else', field('else', $._term), @@ -417,77 +450,143 @@ export const case_ = ($: GrammarSymbols) => ) export const when = ($: GrammarSymbols) => - seq( - 'when', - commaSep1(field('pattern', $._pattern)), - choice(seq('then', field('body', $._term)), field('body', $.block)), + prec( + 'base', + seq('when', commaSep1(field('pattern', $._pattern)), $._immediate_block), ) export const struct = ($: GrammarSymbols) => prec( - Prec.Term, + 'patternOrTerm', + // Prec.Term, buildStruct( $, + 'member', choice($.member, alias($.identifier, $.shorthand_member), $.spread), + false, ), ) export const member = ($: GrammarSymbols) => - buildMember($, $._term, $._term) + prec('base', buildMember($, $._term, $._term)) export const tuple = ($: GrammarSymbols) => - prec(Prec.Term, buildTuple($, $._element)) + prec('base', buildTuple($, 'element', $._element, false, false)) export const list = ($: GrammarSymbols) => - prec(Prec.Term, buildList($, $._element)) + prec('base', buildList($, 'element', $._element, false)) export const _element = ( $: GrammarSymbols, -) => choice($._term, $.spread) +) => prec('base', choice($._term, $.spread)) export const spread = ($: GrammarSymbols) => - seq('...', field('value', $._term)) + prec('base', seq('...', field('value', $._term))) + +export const pure = ($: GrammarSymbols) => + prec('base', prec.right(seq('pure', field('value', $._term)))) -export const parametric_type_instance = ( +export const hole = ($: GrammarSymbols) => + prec( + 'base', + seq('?', field('name', alias($.identifier, $.identifier_pattern))), + ) + +export const static_function = ( $: GrammarSymbols, ) => - prec( - Prec.ParametricTypeInstance, + prec.right( + 'base', seq( - field('name', $._term), - buildGenericType('typeArgument', $.parametric_type), + '<', + commaSep1(field('parameter', $._pattern)), + '>', + field('value', $._term), ), ) -export const pure = ($: GrammarSymbols) => - prec.right(seq('pure', field('value', $._term))) - -export const type_alias = ( +export const static_application = ( $: GrammarSymbols, ) => - prec.right(seq('type', buildTypeDeclaration($), '=', field('type', $._type))) + prec.left( + 'patternOrTerm', + // Prec.Term, + seq( + field('value', $._term), + '<', + commaSep1(prec.left(field('argument', $._term))), + '>', + ), + ) export const type_hint = ( $: GrammarSymbols, ) => + prec.right('base', seq(field('value', $._term), 'as', field('type', $._term))) + +export const data = ($: GrammarSymbols) => + prec.right( + Operator.Or, + seq( + 'data', + field('name', $.type), + '=', + optional(seq('(', commaSep1(field('parameter', $._pattern)), ')', '=>')), + sep1('|')(field('constructor', $.tag)), + ), + ) + +export const tag = ($: GrammarSymbols) => prec.left( - Prec.TypeHint, - seq(field('value', $._term), 'as', field('type', $._type)), + Operator.Or, + seq( + field( + 'name', + alias($._identifier_without_operators, $.identifier_pattern), + ), + optional(field('type', $._term)), + ), ) -export const hole = ($: GrammarSymbols) => +export const function_type = ( + $: GrammarSymbols, +) => + prec.right( + 'access', + // Prec.Access, + seq(field('from', $._term), '->', field('to', $._term)), + ) + +export const optional_type = ( + $: GrammarSymbols, +) => prec.right('base', seq('?', field('type', $._term))) + +export const keyof_type = ( + $: GrammarSymbols, +) => prec.right('base', seq('keyof', field('type', $._term))) + +export const map_type = ( + $: GrammarSymbols, +) => prec( - Prec.Hole, - seq('?', field('name', alias($.identifier, $.identifier_pattern_name))), + 'base', + seq( + '{', + optional(seq(field('property', alias($.type, $.type_pattern)), 'in')), + field('key', $._term), + '->', + field('value', $._term), + '}', + ), ) -export const _identifier_without_operators = () => IDENTIFIER +export const type = () => TYPE +export const _identifier_without_operators = () => IDENTIFIER export const _operator = () => OPERATOR - export const identifier = ( $: GrammarSymbols, -) => choice($._operator, $._identifier_without_operators) +) => prec.left('base', choice($._operator, $._identifier_without_operators)) export const group = ($: GrammarSymbols) => - prec(Prec.Group, seq('(', field('term', $._term), ')')) + seq('(', field('term', $._term), ')') diff --git a/common/types.ts b/common/types.ts deleted file mode 100644 index b744ab5b..00000000 --- a/common/types.ts +++ /dev/null @@ -1,239 +0,0 @@ -import { Dialect, Prec } from './enums' -import { - buildGenericType, - buildStruct, - buildTuple, - buildTypeConstraint, - commaSep1, -} from './util' -import { TYPE } from './constants' - -export const type_variable_declaration = ( - $: GrammarSymbols, -) => - prec.left( - seq( - field('name', alias($.type, $.type_variable_declaration_name)), - optional(buildTypeConstraint($)), - ), - ) - -export const _type_constructor = - (dialect: Dialect) => - ($: GrammarSymbols) => { - const choices = [ - $.parametric_type, - $.curried_type, - $.intersection_type, - $.union_type, - $.subtraction_type, - $.conditional_type, - $.struct_type, - $.map_type, - $.tuple_type, - $.list_type, - $.optional_type, - $.tagged_type, - $.labeled_type, - $.keyof, - $.type_group, - ] - - if (dialect === Dialect.Tony) - choices.push( - $.typeof, - $.access_type, - $.refinement_type, - $.refinement_type_declaration, - ) - - return choice(...choices) - } - -export const _term_type = ( - $: GrammarSymbols, -) => choice($.identifier, $._literal) - -export const typeof_ = ($: GrammarSymbols) => - seq('typeof', field('value', $._term_type)) - -export const parametric_type_constructor = - (dialect: Dialect) => - ($: GrammarSymbols) => { - const nodes = [ - field('name', $.type), - optional(buildGenericType('argument', $._type)), - ] - - if (dialect === Dialect.Tony) - nodes.push(optional(buildTuple($, $._term_type, false, true, false))) - - return prec.right(seq(...nodes)) - } - -export const curried_type = ( - $: GrammarSymbols, -) => - prec.right( - Prec.CurriedType, - seq(field('from', $._type), '=>', field('to', $._type)), - ) - -export const intersection_type = ( - $: GrammarSymbols, -) => - prec.right( - Prec.IntersectionType, - seq(field('left', $._type), '&', field('right', $._type)), - ) - -export const union_type = ( - $: GrammarSymbols, -) => - prec.right( - Prec.UnionType, - seq(field('left', $._type), '|', field('right', $._type)), - ) - -export const subtraction_type = ( - $: GrammarSymbols, -) => - prec.right( - Prec.SubtractionType, - seq( - field('left', choice($.parametric_type, $.union_type)), - '\\', - field('right', choice($.parametric_type, $.union_type)), - ), - ) - -export const conditional_type = ( - $: GrammarSymbols, -) => - prec.right( - seq( - field('type', $._type), - buildTypeConstraint($), - '?', - field('consequence', $._type), - ':', - field('alternative', $._type), - ), - ) - -export const struct_type = ( - $: GrammarSymbols, -) => buildStruct($, $.member_type) -export const member_type = ( - $: GrammarSymbols, -) => - seq( - field('key', alias($.identifier, $.shorthand_member_identifier)), - ':', - field('value', $._type), - ) - -export const map_type = ( - $: GrammarSymbols, -) => - seq( - '{', - '[', - optional( - seq( - field('property', alias($.type, $.type_variable_declaration_name)), - 'in', - ), - ), - field('key', $._type), - ']', - ':', - field('value', $._type), - '}', - ) - -export const tuple_type = ( - $: GrammarSymbols, -) => buildTuple($, $._type) - -export const list_type = ( - $: GrammarSymbols, -) => seq('[', field('element', $._type), ']') - -export const access_type = ( - $: GrammarSymbols, -) => - prec( - Prec.Access, - seq( - field('type', $._type), - choice( - seq('[', field('value', $._term_type), ']'), - seq( - '->', - field('value', alias($.identifier, $.shorthand_access_identifier)), - ), - ), - ), - ) - -export const optional_type = ( - $: GrammarSymbols, -) => prec(Prec.OptionalType, seq(field('type', $._type), '?')) - -export const tagged_type = ( - $: GrammarSymbols, -) => - prec( - Prec.TaggedType, - seq( - field( - 'name', - alias($._identifier_without_operators, $.identifier_pattern_name), - ), - field('type', $._type), - ), - ) - -export const labeled_type = ( - $: GrammarSymbols, -) => - prec( - Prec.LabeledType, - seq(field('label', $.identifier), ':', field('type', $._type)), - ) - -export const keyof = ($: GrammarSymbols) => - prec.right(seq('keyof', field('type', $._type))) - -export const refinement_type_declaration = ( - $: GrammarSymbols, -) => - prec.left( - seq( - field('name', alias($.identifier, $.identifier_pattern_name)), - '::', - field('type', $._type), - ), - ) - -export const refinement_type = ( - $: GrammarSymbols, -) => - seq( - '[', - field('generator', $._type), - '|', - commaSep1(field('predicate', $._predicate)), - ']', - ) - -export const _predicate = ( - $: GrammarSymbols, -) => choice($.application, $.infix_application) - -export const type_group = ( - $: GrammarSymbols, -) => seq('(', field('type', $._type), ')') - -export const type = () => TYPE diff --git a/common/util.ts b/common/util.ts index 79a144eb..3f255ae0 100644 --- a/common/util.ts +++ b/common/util.ts @@ -1,6 +1,4 @@ -import { Prec } from './enums' - -const sep1 = (sep: string) => (rule: RuleOrLiteral) => +export const sep1 = (sep: string) => (rule: RuleOrLiteral) => seq(rule, repeat(seq(sep, rule))) const sep2 = (sep: string) => (rule: RuleOrLiteral) => @@ -10,6 +8,10 @@ export const commaSep1 = sep1(',') const commaSep2 = sep2(',') +export const newlineSep1 = ( + $: GrammarSymbols, +) => sep1(($._newline as unknown) as string) + const buildDataStructure = ( $: GrammarSymbols, element: Rule, @@ -19,10 +21,10 @@ const buildDataStructure = ( rest ? optional( choice( - seq('...', field('rest', $.identifier_pattern)), + seq('...', field('rest', $.binding_pattern)), seq( commaSepImpl(element), - optional(seq(',', '...', field('rest', $.identifier_pattern))), + optional(seq(',', '...', field('rest', $.binding_pattern))), ), ), ) @@ -30,40 +32,38 @@ const buildDataStructure = ( export const buildStruct = ( $: GrammarSymbols, + fieldName: string, member: Rule, - rest = false, -) => seq('{', buildDataStructure($, field('member', member), rest), '}') + rest: boolean, +) => seq('{', buildDataStructure($, field(fieldName, member), rest), '}') export const buildTuple = ( $: GrammarSymbols, + fieldName: string, element: Rule, - rest = false, - allowSingle = false, - allowEmpty = true, -) => { - const options: RuleOrLiteral[] = [ + rest: boolean, + allowSingle: boolean, +) => + choice( seq( '(', buildDataStructure( $, - field('element', element), + field(fieldName, element), rest, allowSingle ? commaSep1 : commaSep2, ), ')', ), - ] - - if (allowEmpty) options.push('()') - - return choice(...options) -} + '()', + ) export const buildList = ( $: GrammarSymbols, + fieldName: string, element: Rule, - rest = false, -) => seq('[', buildDataStructure($, field('element', element), rest), ']') + rest: boolean, +) => seq('[', buildDataStructure($, field(fieldName, element), rest), ']') export const buildMember = ( $: GrammarSymbols, @@ -92,49 +92,28 @@ export const buildString = ( export const buildGenericType = (name: string, rule: Rule) => seq('<', commaSep1(field(name, rule)), '>') -export const buildTypeConstraint = ( +export const buildBindingPattern = ( $: GrammarSymbols, + allowDefaults: boolean, ) => seq( - '<:', - choice( - field('constraint', $._type), - seq('(', sep2(';')(field('constraint', $._type)), ')'), + field( + 'name', + choice( + alias($.identifier, $.identifier_pattern), + alias($.type, $.type_pattern), + ), ), + optional(seq(':', field('type', $.type))), + allowDefaults ? optional(seq('=', field('default', $._term))) : seq(), ) -export const buildTypeDeclaration = ( - $: GrammarSymbols, -) => - seq( - field('name', $.type), - optional(buildGenericType('parameter', $.type_variable_declaration)), - optional(buildTuple($, $.identifier_pattern, false, true)), - ) - -export const buildIdentifierPattern = ( +export const buildBlock = ( $: GrammarSymbols, - allowDefaults: boolean, -) => - prec.right( - Prec.Pattern, - seq( - field('name', alias($.identifier, $.identifier_pattern_name)), - optional(seq('::', field('type', $._type))), - allowDefaults ? optional(seq('=', field('default', $._term))) : seq(), - ), - ) + rule: Rule +) => seq('{', newlineSep1($)(rule), '}') -const buildStatements = - ($: GrammarSymbols) => - (rule: Rule) => - seq( - optional($._newline), - sep1($._newline as unknown as string)(rule), - optional($._newline), - ) - -export const buildBlock = ( +export const line = ( $: GrammarSymbols, - ...rules: Rule[] -) => seq('{', seq(...rules.map(buildStatements($))), '}') + rule: Rule, +) => seq(rule, choice($._newline, ';')) diff --git a/dtn/corpus/declarations.txt b/dtn/corpus/declarations.txt index 58a8c143..ed050795 100644 --- a/dtn/corpus/declarations.txt +++ b/dtn/corpus/declarations.txt @@ -13,12 +13,12 @@ declare 'module' { declaration: (declaration name: (raw_string) member: (declaration_member - as: (identifier_pattern_name) + as: (identifier_pattern) type: (parametric_type name: (type))) member: (declaration_member - as: (identifier_pattern_name) - name: (identifier_pattern_name) + as: (identifier_pattern) + name: (identifier_pattern) type: (parametric_type name: (type))))) @@ -49,11 +49,11 @@ declare 'module' { declaration: (declaration name: (raw_string) member: (declaration_member - as: (identifier_pattern_name) + as: (identifier_pattern) type: (parametric_type name: (type))) member: (declaration_member - as: (identifier_pattern_name) - name: (identifier_pattern_name) + as: (identifier_pattern) + name: (identifier_pattern) type: (parametric_type name: (type))))) diff --git a/dtn/grammar.ts b/dtn/grammar.ts index 4d265b16..154f5798 100644 --- a/dtn/grammar.ts +++ b/dtn/grammar.ts @@ -1,119 +1,249 @@ -/// +// /// -import { - _decimal, - _integer, - boolean, - number, - raw_string, - regex, - regex_flags, - regex_pattern, -} from '../common/literals' -import { - _identifier_without_operators, - _operator, - identifier, -} from '../common/terms' -import { - _import_body_constructor, - import_, - import_type, -} from '../common/imports' -import { - _type_constructor, - conditional_type, - curried_type, - intersection_type, - keyof, - labeled_type, - list_type, - map_type, - member_type, - optional_type, - parametric_type_constructor, - struct_type, - subtraction_type, - tagged_type, - tuple_type, - type, - type_group, - type_variable_declaration, - union_type, -} from '../common/types' -import { - declaration, - declaration_member, - js_identifier, -} from '../common/declarations' -import { Dialect } from '../common/enums' -import { comment } from '../common/miscellaneous' +// import { +// _assignable_pattern, +// _literal_pattern, +// _pattern, +// binding_pattern, +// destructuring_pattern, +// list_pattern, +// member_pattern, +// pattern_group, +// root_binding_pattern, +// struct_pattern, +// tagged_pattern, +// tuple_pattern, +// wildcard_pattern, +// } from '../common/patterns' +// import { +// _decimal, +// _integer, +// _literal, +// boolean, +// escape_sequence, +// interpolation, +// number, +// raw_string, +// regex, +// regex_flags, +// regex_pattern, +// string, +// } from '../common/literals' +// import { +// _element, +// _identifier_without_operators, +// _operator, +// _section, +// _section_identifier, +// _term, +// access, +// application, +// argument, +// assignment, +// block, +// case_, +// class_, +// class_member, +// data, +// data_constructor, +// else_if, +// export_, +// function_, +// function_type, +// group, +// hole, +// identifier, +// if_, +// infix_application, +// instance, +// keyof_type, +// left_section, +// list, +// list_comprehension, +// list_comprehension_condition, +// list_comprehension_generator, +// map_type, +// member, +// optional_type, +// parametric_type_instance, +// pure, +// return_, +// right_section, +// spread, +// struct, +// ternary, +// tuple, +// type, +// type_hint, +// type_variable_declaration, +// when, +// } from '../common/terms' +// import { +// _import_body_constructor, +// import_, +// import_type, +// } from '../common/imports' +// import { +// declaration, +// declaration_member, +// js_identifier, +// } from '../common/declarations' +// import { Dialect } from '../common/enums' +// import { comment } from '../common/miscellaneous' -const dialect = Dialect.DTN +// const dialect = Dialect.DTN -export = grammar({ - name: 'dtn', +// export = grammar({ +// name: 'dtn', - externals: ($) => [ - $._newline, - $._string_start, - $._string_content, - $._string_end, - ], - extras: ($) => [$.comment, /\s+/], - word: ($) => $._identifier_without_operators, +// externals: ($) => [ +// $._newline, +// $._string_start, +// $._string_content, +// $._string_end, +// ], +// extras: ($) => [$.comment, /\s+/], +// word: ($) => $._identifier_without_operators, +// conflicts: ($) => [ +// [$._term, $.binding_pattern], +// [$._term, $.binding_pattern, $.root_binding_pattern], +// [$.binding_pattern, $.root_binding_pattern], +// // [ +// // $.binding_pattern, +// // $.root_binding_pattern, +// // $.refinement_type_declaration, +// // ], +// [$._term, $.root_binding_pattern], +// // [$._term, $.binding_pattern, $._type], +// [$._term, $.binding_pattern, $.struct], +// [$.string, $.raw_string], +// [$.struct, $.struct_pattern], +// // [$.struct, $.struct_pattern, $.struct_type], +// [$.tuple, $.tuple_pattern], +// // [$.tuple, $.tuple_pattern, $.tuple_type], +// [$.list, $.list_pattern], +// // [$.function, $.tuple_type], +// [$.member, $.member_pattern, $._element], +// [$.member, $.member_pattern, $._element, $.map_type], +// [$.member, $.map_type], +// [$.parametric_type_instance, $.infix_application], +// [$.parametric_type_instance, $.infix_application, $.application], +// [$.application, $.infix_application], +// [$.application, $.infix_application, $.ternary], +// [$.application, $.infix_application, $.ternary, $.optional_type], +// [ +// $.application, +// $.infix_application, +// $.parametric_type_instance, +// $.type_hint, +// ], +// [$.application, $.assignment, $.ternary], +// // [$.application, $.assignment, $.ternary, $.optional_type], +// [$.tagged_pattern, $.identifier], +// // [$.tagged_pattern, $.tagged_type], +// // [$.type_variable_declaration, $.parametric_type], +// [$._element, $.group], +// [$.data_constructor, $.identifier], +// [$.data_constructor, $.identifier, $.tagged_pattern], +// [$.application, $.access, $.type_hint], +// [$.application, $.access, $.ternary], +// [$.application, $.access, $.ternary, $.type_hint], +// [$.application, $.access, $.assignment], +// ], - precedences: () => [], +// precedences: () => [], - rules: { - program: ($) => - seq( - repeat(seq(field('import', $.import), $._newline)), - field('declaration', $.declaration), - optional($._newline), - ), +// rules: { +// program: ($) => +// seq( +// repeat(seq(field('import', $.import), $._newline)), +// field('declaration', $.declaration), +// optional($._newline), +// ), - comment, +// comment, - declaration, - declaration_member, - js_identifier, +// declaration, +// declaration_member, +// js_identifier, - import: import_, - _import_body: _import_body_constructor(dialect), - import_type, +// import: import_, +// _import_body: _import_body_constructor(dialect), +// import_type, - _identifier_without_operators, - _operator, - identifier, +// _term, +// block, +// export: export_, +// assignment, +// class: class_, +// class_member, +// instance, +// argument, +// function: function_, +// application, +// infix_application, +// _section, +// left_section, +// right_section, +// _section_identifier, +// list_comprehension, +// list_comprehension_generator, +// list_comprehension_condition, +// access, +// return: return_, +// ternary, +// if: if_, +// else_if, +// case: case_, +// when, +// struct, +// member, +// tuple, +// list, +// _element, +// spread, +// parametric_type_instance, +// pure, +// hole, +// type_hint, +// data, +// data_constructor, +// type_variable_declaration, +// function_type, +// optional_type, +// map_type, +// keyof_type, +// type, +// _identifier_without_operators, +// _operator, +// identifier, +// group, - type_variable_declaration, - _type: _type_constructor(dialect), - parametric_type: parametric_type_constructor(dialect), - curried_type, - intersection_type, - union_type, - subtraction_type, - conditional_type, - struct_type, - member_type, - map_type, - tuple_type, - list_type, - optional_type, - tagged_type, - labeled_type, - keyof, - type_group, - type, +// _pattern, +// _assignable_pattern, +// destructuring_pattern, +// struct_pattern, +// tuple_pattern, +// list_pattern, +// member_pattern, +// binding_pattern, +// root_binding_pattern, +// wildcard_pattern, +// tagged_pattern, +// _literal_pattern, +// pattern_group, - boolean, - _decimal, - _integer, - number, - raw_string, - regex, - regex_pattern, - regex_flags, - }, -}) +// _literal, +// boolean, +// _decimal, +// _integer, +// number, +// raw_string, +// string, +// interpolation, +// escape_sequence, +// regex, +// regex_pattern, +// regex_flags, +// }, +// }) diff --git a/dtn/index.d.ts b/dtn/index.d.ts index 24de2479..c62a9533 100644 --- a/dtn/index.d.ts +++ b/dtn/index.d.ts @@ -172,65 +172,122 @@ export interface ErrorNode extends NamedNodeBase { export const enum SyntaxType { ERROR = "ERROR", - ConditionalType = "conditional_type", - CurriedType = "curried_type", + Access = "access", + Application = "application", + Argument = "argument", + Assignment = "assignment", + BindingPattern = "binding_pattern", + Block = "block", + Boolean = "boolean", + Case = "case", + Class = "class", + ClassMember = "class_member", + Data = "data", + DataConstructor = "data_constructor", Declaration = "declaration", DeclarationMember = "declaration_member", + DestructuringPattern = "destructuring_pattern", + ElseIf = "else_if", + Export = "export", + Function = "function", + FunctionType = "function_type", + Group = "group", + Hole = "hole", Identifier = "identifier", - IdentifierPatternName = "identifier_pattern_name", + IdentifierPattern = "identifier_pattern", + If = "if", Import = "import", ImportType = "import_type", - IntersectionType = "intersection_type", - Keyof = "keyof", - LabeledType = "labeled_type", - ListType = "list_type", + InfixApplication = "infix_application", + Instance = "instance", + Interpolation = "interpolation", + KeyofType = "keyof_type", + LeftSection = "left_section", + List = "list", + ListComprehension = "list_comprehension", + ListComprehensionCondition = "list_comprehension_condition", + ListComprehensionGenerator = "list_comprehension_generator", + ListPattern = "list_pattern", MapType = "map_type", - MemberType = "member_type", + Member = "member", + MemberPattern = "member_pattern", + Number = "number", OptionalType = "optional_type", - ParametricType = "parametric_type", + ParametricTypeInstance = "parametric_type_instance", + PatternGroup = "pattern_group", Program = "program", + Pure = "pure", RawString = "raw_string", + Regex = "regex", + Return = "return", + RightSection = "right_section", + ShorthandAccessIdentifier = "shorthand_access_identifier", + ShorthandMember = "shorthand_member", ShorthandMemberIdentifier = "shorthand_member_identifier", - StructType = "struct_type", - SubtractionType = "subtraction_type", - TaggedType = "tagged_type", - TupleType = "tuple_type", - TypeGroup = "type_group", - UnionType = "union_type", + ShorthandMemberPattern = "shorthand_member_pattern", + Spread = "spread", + String = "string", + Struct = "struct", + StructPattern = "struct_pattern", + TaggedPattern = "tagged_pattern", + Ternary = "ternary", + Tuple = "tuple", + TuplePattern = "tuple_pattern", + TypeHint = "type_hint", + TypeVariableDeclaration = "type_variable_declaration", + When = "when", Comment = "comment", + EscapeSequence = "escape_sequence", RegexFlags = "regex_flags", RegexPattern = "regex_pattern", Type = "type", + TypePattern = "type_pattern", TypeVariableDeclarationName = "type_variable_declaration_name", + WildcardPattern = "wildcard_pattern", } export type UnnamedType = - | "&" | "(" | "()" | ")" | "," + | "->" + | "..." | "/" | ":" - | "::" | ";" | "<" | "<:" + | "=" | "=>" | ">" | "?" + | "@" + | "Keyof" | "[" - | "\\" | "]" + | "`" | "as" + | SyntaxType.Case // both named and unnamed + | SyntaxType.Class // both named and unnamed + | SyntaxType.Data // both named and unnamed | "declare" + | "else" + | "else if" + | SyntaxType.Export // both named and unnamed | "false" | "from" + | SyntaxType.If // both named and unnamed | SyntaxType.Import // both named and unnamed | "in" - | SyntaxType.Keyof // both named and unnamed + | SyntaxType.Instance // both named and unnamed + | "of" + | SyntaxType.Pure // both named and unnamed | "r/" + | SyntaxType.Return // both named and unnamed + | "then" | "true" + | SyntaxType.When // both named and unnamed | "{" | "|" | "}" @@ -239,80 +296,196 @@ export type UnnamedType = export type TypeString = SyntaxType | UnnamedType; export type SyntaxNode = - | ConditionalTypeNode - | CurriedTypeNode + | AccessNode + | ApplicationNode + | ArgumentNode + | AssignmentNode + | BindingPatternNode + | BlockNode + | BooleanNode + | CaseNode + | ClassNode + | ClassMemberNode + | DataNode + | DataConstructorNode | DeclarationNode | DeclarationMemberNode + | DestructuringPatternNode + | ElseIfNode + | ExportNode + | FunctionNode + | FunctionTypeNode + | GroupNode + | HoleNode | IdentifierNode - | IdentifierPatternNameNode + | IdentifierPatternNode + | IfNode | ImportNode | ImportTypeNode - | IntersectionTypeNode - | KeyofNode - | LabeledTypeNode - | ListTypeNode + | InfixApplicationNode + | InstanceNode + | InterpolationNode + | KeyofTypeNode + | LeftSectionNode + | ListNode + | ListComprehensionNode + | ListComprehensionConditionNode + | ListComprehensionGeneratorNode + | ListPatternNode | MapTypeNode - | MemberTypeNode + | MemberNode + | MemberPatternNode + | NumberNode | OptionalTypeNode - | ParametricTypeNode + | ParametricTypeInstanceNode + | PatternGroupNode | ProgramNode + | PureNode | RawStringNode + | RegexNode + | ReturnNode + | RightSectionNode + | ShorthandAccessIdentifierNode + | ShorthandMemberNode | ShorthandMemberIdentifierNode - | StructTypeNode - | SubtractionTypeNode - | TaggedTypeNode - | TupleTypeNode - | TypeGroupNode - | UnionTypeNode - | UnnamedNode<"&"> + | ShorthandMemberPatternNode + | SpreadNode + | StringNode + | StructNode + | StructPatternNode + | TaggedPatternNode + | TernaryNode + | TupleNode + | TuplePatternNode + | TypeHintNode + | TypeVariableDeclarationNode + | WhenNode | UnnamedNode<"("> | UnnamedNode<"()"> | UnnamedNode<")"> | UnnamedNode<","> + | UnnamedNode<"->"> + | UnnamedNode<"..."> | UnnamedNode<"/"> | UnnamedNode<":"> - | UnnamedNode<"::"> | UnnamedNode<";"> | UnnamedNode<"<"> | UnnamedNode<"<:"> + | UnnamedNode<"="> | UnnamedNode<"=>"> | UnnamedNode<">"> | UnnamedNode<"?"> + | UnnamedNode<"@"> + | UnnamedNode<"Keyof"> | UnnamedNode<"["> - | UnnamedNode<"\\"> | UnnamedNode<"]"> + | UnnamedNode<"`"> | UnnamedNode<"as"> + | UnnamedNode + | UnnamedNode | CommentNode + | UnnamedNode | UnnamedNode<"declare"> + | UnnamedNode<"else"> + | UnnamedNode<"else if"> + | EscapeSequenceNode + | UnnamedNode | UnnamedNode<"false"> | UnnamedNode<"from"> + | UnnamedNode | UnnamedNode | UnnamedNode<"in"> - | UnnamedNode + | UnnamedNode + | UnnamedNode<"of"> + | UnnamedNode | UnnamedNode<"r/"> | RegexFlagsNode | RegexPatternNode + | UnnamedNode + | UnnamedNode<"then"> | UnnamedNode<"true"> | TypeNode + | TypePatternNode | TypeVariableDeclarationNameNode + | UnnamedNode + | WildcardPatternNode | UnnamedNode<"{"> | UnnamedNode<"|"> | UnnamedNode<"}"> | ErrorNode ; -export interface ConditionalTypeNode extends NamedNodeBase { - type: SyntaxType.ConditionalType; - alternativeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; - consequenceNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; - constraintNodes: (ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode)[]; - typeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface AccessNode extends NamedNodeBase { + type: SyntaxType.Access; + nameNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandAccessIdentifierNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; } -export interface CurriedTypeNode extends NamedNodeBase { - type: SyntaxType.CurriedType; - fromNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; - toNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface ApplicationNode extends NamedNodeBase { + type: SyntaxType.Application; + elementNodes: (AccessNode | ApplicationNode | ArgumentNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode)[]; + nameNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface ArgumentNode extends NamedNodeBase { + type: SyntaxType.Argument; + placeholderNode?: UnnamedNode<"?">; + valueNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface AssignmentNode extends NamedNodeBase { + type: SyntaxType.Assignment; + patternNode: BindingPatternNode | DestructuringPatternNode | PatternGroupNode | TaggedPatternNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface BindingPatternNode extends NamedNodeBase { + type: SyntaxType.BindingPattern; + defaultNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + nameNode: IdentifierPatternNode | TypePatternNode; + typeNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface BlockNode extends NamedNodeBase { + type: SyntaxType.Block; + termNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode)[]; +} + +export interface BooleanNode extends NamedNodeBase { + type: SyntaxType.Boolean; +} + +export interface CaseNode extends NamedNodeBase { + type: SyntaxType.Case; + elseNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + whenNodes: WhenNode[]; +} + +export interface ClassNode extends NamedNodeBase { + type: SyntaxType.Class; + constraintNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode)[]; + memberNodes: ClassMemberNode[]; + nameNode: TypeNode; +} + +export interface ClassMemberNode extends NamedNodeBase { + type: SyntaxType.ClassMember; + nameNode: IdentifierPatternNode; + typeNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface DataNode extends NamedNodeBase { + type: SyntaxType.Data; + constructorNodes: DataConstructorNode[]; + nameNode: TypeNode; + parameterNodes: TypeVariableDeclarationNode[]; +} + +export interface DataConstructorNode extends NamedNodeBase { + type: SyntaxType.DataConstructor; + nameNode: IdentifierPatternNode; + typeNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; } export interface DeclarationNode extends NamedNodeBase { @@ -323,17 +496,66 @@ export interface DeclarationNode extends NamedNodeBase { export interface DeclarationMemberNode extends NamedNodeBase { type: SyntaxType.DeclarationMember; - asNode: IdentifierPatternNameNode; - nameNode?: IdentifierPatternNameNode; - typeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; + asNode: IdentifierPatternNode; + nameNode?: IdentifierPatternNode; + typeNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface DestructuringPatternNode extends NamedNodeBase { + type: SyntaxType.DestructuringPattern; + aliasNode?: IdentifierPatternNode | TypePatternNode; + patternNode: ListPatternNode | StructPatternNode | TuplePatternNode; +} + +export interface ElseIfNode extends NamedNodeBase { + type: SyntaxType.ElseIf; + bodyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + conditionNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface ExportNode extends NamedNodeBase { + type: SyntaxType.Export; + declarationNode: AssignmentNode; +} + +export interface FunctionNode extends NamedNodeBase { + type: SyntaxType.Function; + bodyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + elementNodes: (BindingPatternNode | BooleanNode | DestructuringPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; + restNode?: BindingPatternNode; + typeParameterNodes: TypeVariableDeclarationNode[]; +} + +export interface FunctionTypeNode extends NamedNodeBase { + type: SyntaxType.FunctionType; + fromNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + toNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface GroupNode extends NamedNodeBase { + type: SyntaxType.Group; + termNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface HoleNode extends NamedNodeBase { + type: SyntaxType.Hole; + nameNode: IdentifierPatternNode; } export interface IdentifierNode extends NamedNodeBase { type: SyntaxType.Identifier; } -export interface IdentifierPatternNameNode extends NamedNodeBase { - type: SyntaxType.IdentifierPatternName; +export interface IdentifierPatternNode extends NamedNodeBase { + type: SyntaxType.IdentifierPattern; +} + +export interface IfNode extends NamedNodeBase { + type: SyntaxType.If; + bodyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + conditionNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + elseNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + elseIfNodes: ElseIfNode[]; } export interface ImportNode extends NamedNodeBase { @@ -348,50 +570,103 @@ export interface ImportTypeNode extends NamedNodeBase { nameNode?: TypeNode; } -export interface IntersectionTypeNode extends NamedNodeBase { - type: SyntaxType.IntersectionType; - leftNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; - rightNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface InfixApplicationNode extends NamedNodeBase { + type: SyntaxType.InfixApplication; + leftNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + nameNode: IdentifierNode; + rightNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface InstanceNode extends NamedNodeBase { + type: SyntaxType.Instance; + assignmentNodes: AssignmentNode[]; + classNode: TypeNode; + nameNode: TypeNode; + parameterNodes: TypeVariableDeclarationNode[]; +} + +export interface InterpolationNode extends NamedNodeBase { + type: SyntaxType.Interpolation; + termNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface KeyofTypeNode extends NamedNodeBase { + type: SyntaxType.KeyofType; + typeNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface LeftSectionNode extends NamedNodeBase { + type: SyntaxType.LeftSection; + nameNode: IdentifierNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; } -export interface KeyofNode extends NamedNodeBase { - type: SyntaxType.Keyof; - typeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface ListNode extends NamedNodeBase { + type: SyntaxType.List; + elementNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode)[]; } -export interface LabeledTypeNode extends NamedNodeBase { - type: SyntaxType.LabeledType; - labelNode: IdentifierNode; - typeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface ListComprehensionNode extends NamedNodeBase { + type: SyntaxType.ListComprehension; + bodyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + conditionNodes: ListComprehensionConditionNode[]; + generatorNodes: ListComprehensionGeneratorNode[]; } -export interface ListTypeNode extends NamedNodeBase { - type: SyntaxType.ListType; - elementNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface ListComprehensionConditionNode extends NamedNodeBase { + type: SyntaxType.ListComprehensionCondition; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface ListComprehensionGeneratorNode extends NamedNodeBase { + type: SyntaxType.ListComprehensionGenerator; + nameNode: IdentifierPatternNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface ListPatternNode extends NamedNodeBase { + type: SyntaxType.ListPattern; + elementNodes: (BindingPatternNode | BooleanNode | DestructuringPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; + restNode?: BindingPatternNode; } export interface MapTypeNode extends NamedNodeBase { type: SyntaxType.MapType; - keyNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; + keyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; propertyNode?: TypeVariableDeclarationNameNode; - valueNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface MemberNode extends NamedNodeBase { + type: SyntaxType.Member; + keyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandMemberIdentifierNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface MemberPatternNode extends NamedNodeBase { + type: SyntaxType.MemberPattern; + keyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandMemberIdentifierNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + valueNode: BindingPatternNode | BooleanNode | DestructuringPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode; } -export interface MemberTypeNode extends NamedNodeBase { - type: SyntaxType.MemberType; - keyNode: ShorthandMemberIdentifierNode; - valueNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface NumberNode extends NamedNodeBase { + type: SyntaxType.Number; } export interface OptionalTypeNode extends NamedNodeBase { type: SyntaxType.OptionalType; - typeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; + typeNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; } -export interface ParametricTypeNode extends NamedNodeBase { - type: SyntaxType.ParametricType; - argumentNodes: (ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode)[]; - nameNode: TypeNode; +export interface ParametricTypeInstanceNode extends NamedNodeBase { + type: SyntaxType.ParametricTypeInstance; + nameNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + typeArgumentNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode)[]; +} + +export interface PatternGroupNode extends NamedNodeBase { + type: SyntaxType.PatternGroup; + patternNode: BindingPatternNode | BooleanNode | DestructuringPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode; } export interface ProgramNode extends NamedNodeBase { @@ -400,51 +675,123 @@ export interface ProgramNode extends NamedNodeBase { importNodes: ImportNode[]; } +export interface PureNode extends NamedNodeBase { + type: SyntaxType.Pure; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + export interface RawStringNode extends NamedNodeBase { type: SyntaxType.RawString; } +export interface RegexNode extends NamedNodeBase { + type: SyntaxType.Regex; + flagsNode?: RegexFlagsNode; + patternNode: RegexPatternNode; +} + +export interface ReturnNode extends NamedNodeBase { + type: SyntaxType.Return; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface RightSectionNode extends NamedNodeBase { + type: SyntaxType.RightSection; + nameNode: IdentifierNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface ShorthandAccessIdentifierNode extends NamedNodeBase { + type: SyntaxType.ShorthandAccessIdentifier; +} + +export interface ShorthandMemberNode extends NamedNodeBase { + type: SyntaxType.ShorthandMember; +} + export interface ShorthandMemberIdentifierNode extends NamedNodeBase { type: SyntaxType.ShorthandMemberIdentifier; } -export interface StructTypeNode extends NamedNodeBase { - type: SyntaxType.StructType; - memberNodes: MemberTypeNode[]; +export interface ShorthandMemberPatternNode extends NamedNodeBase { + type: SyntaxType.ShorthandMemberPattern; + defaultNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + nameNode: IdentifierPatternNode | TypePatternNode; + typeNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface SpreadNode extends NamedNodeBase { + type: SyntaxType.Spread; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface StringNode extends NamedNodeBase { + type: SyntaxType.String; + escapeSequenceNodes: EscapeSequenceNode[]; + interpolationNodes: InterpolationNode[]; +} + +export interface StructNode extends NamedNodeBase { + type: SyntaxType.Struct; + memberNodes: (MemberNode | ShorthandMemberNode | SpreadNode)[]; +} + +export interface StructPatternNode extends NamedNodeBase { + type: SyntaxType.StructPattern; + memberNodes: (MemberPatternNode | ShorthandMemberPatternNode)[]; + restNode?: BindingPatternNode; +} + +export interface TaggedPatternNode extends NamedNodeBase { + type: SyntaxType.TaggedPattern; + nameNode: IdentifierNode; + patternNode: BindingPatternNode | BooleanNode | DestructuringPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode; } -export interface SubtractionTypeNode extends NamedNodeBase { - type: SyntaxType.SubtractionType; - leftNode: ParametricTypeNode | UnionTypeNode; - rightNode: ParametricTypeNode | UnionTypeNode; +export interface TernaryNode extends NamedNodeBase { + type: SyntaxType.Ternary; + bodyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + conditionNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + elseNode?: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; } -export interface TaggedTypeNode extends NamedNodeBase { - type: SyntaxType.TaggedType; - nameNode: IdentifierPatternNameNode; - typeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface TupleNode extends NamedNodeBase { + type: SyntaxType.Tuple; + elementNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode)[]; } -export interface TupleTypeNode extends NamedNodeBase { - type: SyntaxType.TupleType; - elementNodes: (ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode)[]; +export interface TuplePatternNode extends NamedNodeBase { + type: SyntaxType.TuplePattern; + elementNodes: (BindingPatternNode | BooleanNode | DestructuringPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; + restNode?: BindingPatternNode; } -export interface TypeGroupNode extends NamedNodeBase { - type: SyntaxType.TypeGroup; - typeNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface TypeHintNode extends NamedNodeBase { + type: SyntaxType.TypeHint; + typeNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; } -export interface UnionTypeNode extends NamedNodeBase { - type: SyntaxType.UnionType; - leftNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; - rightNode: ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | UnionTypeNode; +export interface TypeVariableDeclarationNode extends NamedNodeBase { + type: SyntaxType.TypeVariableDeclaration; + constraintNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode)[]; + nameNode: TypeVariableDeclarationNameNode; +} + +export interface WhenNode extends NamedNodeBase { + type: SyntaxType.When; + bodyNode: AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | DataNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | NumberNode | OptionalTypeNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeNode | TypeHintNode; + patternNodes: (BindingPatternNode | BooleanNode | DestructuringPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; } export interface CommentNode extends NamedNodeBase { type: SyntaxType.Comment; } +export interface EscapeSequenceNode extends NamedNodeBase { + type: SyntaxType.EscapeSequence; +} + export interface RegexFlagsNode extends NamedNodeBase { type: SyntaxType.RegexFlags; } @@ -457,7 +804,15 @@ export interface TypeNode extends NamedNodeBase { type: SyntaxType.Type; } +export interface TypePatternNode extends NamedNodeBase { + type: SyntaxType.TypePattern; +} + export interface TypeVariableDeclarationNameNode extends NamedNodeBase { type: SyntaxType.TypeVariableDeclarationName; } +export interface WildcardPatternNode extends NamedNodeBase { + type: SyntaxType.WildcardPattern; +} + diff --git a/package.json b/package.json index 782b97e9..3260adae 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "types": "yarn types-tony && yarn types-dtn", "types-tony": "cd tony && node ../node_modules/@asgerf/dts-tree-sitter/build/src . > index.d.ts", "types-dtn": "cd dtn && node ../node_modules/@asgerf/dts-tree-sitter/build/src . > index.d.ts", - "build": "yarn tsc && yarn generate && yarn types", + "build": "yarn tsc && yarn generate-tony && yarn types", "prettierlint": "prettier --check **/*.ts", "eslint": "eslint . --ext .ts", "lint": "yarn prettierlint && yarn eslint", diff --git a/tony/corpus/literals.txt b/tony/corpus/literals.txt index 24c02c0c..461651d8 100644 --- a/tony/corpus/literals.txt +++ b/tony/corpus/literals.txt @@ -34,23 +34,23 @@ decimal (program term: (application name: (identifier) - element: (number)) + argument: (decimal)) term: (application name: (identifier) - element: (number)) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) + argument: (decimal)) + term: (decimal) + term: (decimal) + term: (decimal) + term: (decimal) + term: (decimal) + term: (decimal) + term: (decimal) + term: (decimal) + term: (decimal) + term: (decimal) term: (application name: (identifier) - element: (number))) + argument: (decimal))) ================== integer @@ -70,14 +70,14 @@ integer (program term: (application name: (identifier) - element: (number)) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number) - term: (number)) + argument: (integer)) + term: (integer) + term: (integer) + term: (integer) + term: (integer) + term: (integer) + term: (integer) + term: (integer)) ===================================== identifier diff --git a/tony/corpus/patterns.txt b/tony/corpus/patterns.txt index 739e7e1c..8ee56a4a 100644 --- a/tony/corpus/patterns.txt +++ b/tony/corpus/patterns.txt @@ -9,18 +9,18 @@ x@[y] = z (program term: (assignment pattern: (destructuring_pattern - alias: (identifier_pattern_name) + alias: (identifier_pattern) pattern: (list_pattern - element: (identifier_pattern - name: (identifier_pattern_name)))) + element: (binding_pattern + name: (identifier_pattern)))) value: (identifier))) ============================================ struct pattern ============================================ -{ b: c :: Type } = a -{ b: c :: Type, d :: Type, ['e']: e :: Type, ...f :: Type = {} } = a +{ b: c: Type } = a +{ b: c: Type, d: Type, d: d, ['e']: e: Type, ...f: Type = {} } = a --- @@ -30,34 +30,33 @@ struct pattern pattern: (struct_pattern member: (member_pattern key: (shorthand_member_identifier) - value: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)))))) + value: (binding_pattern + name: (identifier_pattern) + type: (type))))) value: (identifier)) term: (assignment pattern: (destructuring_pattern pattern: (struct_pattern member: (member_pattern key: (shorthand_member_identifier) - value: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)))) + value: (binding_pattern + name: (identifier_pattern) + type: (type))) member: (shorthand_member_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) + name: (identifier_pattern) + type: (type)) + member: (member_pattern + key: (shorthand_member_identifier) + value: (binding_pattern + name: (identifier_pattern))) member: (member_pattern key: (string) - value: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)))) - rest: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)) + value: (binding_pattern + name: (identifier_pattern) + type: (type))) + rest: (binding_pattern + name: (identifier_pattern) + type: (type) default: (struct)))) value: (identifier))) @@ -65,57 +64,54 @@ struct pattern tagged struct pattern ============================================ -tag { b: c :: Type } = a -tag { b: c :: Type, d :: Type, ['e']: e :: Type, ...f :: Type = {} } = a +tag { b: c: Type } = a +tag { b: c: Type, d: Type, ['e']: e: Type, ...f: Type = {} } = a --- (program term: (assignment - pattern: (tagged_pattern - name: (identifier) - pattern: (destructuring_pattern - pattern: (struct_pattern - member: (member_pattern - key: (shorthand_member_identifier) - value: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))))))) + pattern: (destructuring_pattern + pattern: (tag_pattern + name: (identifier) + pattern: (destructuring_pattern + pattern: (struct_pattern + member: (member_pattern + key: (shorthand_member_identifier) + value: (binding_pattern + name: (identifier_pattern) + type: (type))))))) value: (identifier)) term: (assignment - pattern: (tagged_pattern - name: (identifier) - pattern: (destructuring_pattern - pattern: (struct_pattern - member: (member_pattern - key: (shorthand_member_identifier) - value: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)))) - member: (shorthand_member_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - member: (member_pattern - key: (string) - value: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)))) - rest: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)) - default: (struct))))) + pattern: (destructuring_pattern + pattern: (tag_pattern + name: (identifier) + pattern: (destructuring_pattern + pattern: (struct_pattern + member: (member_pattern + key: (shorthand_member_identifier) + value: (binding_pattern + name: (identifier_pattern) + type: (type))) + member: (shorthand_member_pattern + name: (identifier_pattern) + type: (type)) + member: (member_pattern + key: (string) + value: (binding_pattern + name: (identifier_pattern) + type: (type))) + rest: (binding_pattern + name: (identifier_pattern) + type: (type) + default: (struct)))))) value: (identifier))) ============================================ tuple pattern ============================================ -(a, b :: Type, ...c) = a +(a, b: Type, ...c) = a --- @@ -123,46 +119,45 @@ tuple pattern term: (assignment pattern: (destructuring_pattern pattern: (tuple_pattern - element: (identifier_pattern - name: (identifier_pattern_name)) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - rest: (identifier_pattern - name: (identifier_pattern_name)))) + element: (binding_pattern + name: (identifier_pattern)) + element: (binding_pattern + name: (identifier_pattern) + type: (type)) + rest: (binding_pattern + name: (identifier_pattern)))) value: (identifier))) ============================================ tagged tuple pattern ============================================ -tag (a, b :: Type, ...c) = a +tag (a, b: Type, ...c) = a --- (program term: (assignment - pattern: (tagged_pattern - name: (identifier) - pattern: (destructuring_pattern - pattern: (tuple_pattern - element: (identifier_pattern - name: (identifier_pattern_name)) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - rest: (identifier_pattern - name: (identifier_pattern_name))))) + pattern: (destructuring_pattern + pattern: (tag_pattern + name: (identifier) + pattern: (destructuring_pattern + pattern: (tuple_pattern + element: (binding_pattern + name: (identifier_pattern)) + element: (binding_pattern + name: (identifier_pattern) + type: (type)) + rest: (binding_pattern + name: (identifier_pattern)))))) value: (identifier))) ============================================ list pattern ============================================ -[b :: Type, c :: Type] = a -[b :: Type, c :: Type, ...d :: Type = [1]] = a +[b: Type = 1, c: Type] = a +[b: Type, c: Type = 1, ...d = [1]] = a --- @@ -170,81 +165,74 @@ list pattern term: (assignment pattern: (destructuring_pattern pattern: (list_pattern - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))))) + element: (binding_pattern + name: (identifier_pattern) + type: (type) + default: (integer)) + element: (binding_pattern + name: (identifier_pattern) + type: (type)))) value: (identifier)) term: (assignment pattern: (destructuring_pattern pattern: (list_pattern - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - rest: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)) + element: (binding_pattern + name: (identifier_pattern) + type: (type)) + element: (binding_pattern + name: (identifier_pattern) + type: (type) + default: (integer)) + rest: (binding_pattern + name: (identifier_pattern) default: (list - element: (number))))) + element: (integer))))) value: (identifier))) ============================================ tagged list pattern ============================================ -tag [b :: Type, c :: Type] = a -tag [b :: Type, c :: Type, ...d :: Type = [1]] = a +tag [b: Type, c: Type] = a +tag [b: Type, c: Type, ...d: Type = [1]] = a --- (program term: (assignment - pattern: (tagged_pattern - name: (identifier) - pattern: (destructuring_pattern - pattern: (list_pattern - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)))))) + pattern: (destructuring_pattern + pattern: (tag_pattern + name: (identifier) + pattern: (destructuring_pattern + pattern: (list_pattern + element: (binding_pattern + name: (identifier_pattern) + type: (type)) + element: (binding_pattern + name: (identifier_pattern) + type: (type)))))) value: (identifier)) term: (assignment - pattern: (tagged_pattern - name: (identifier) - pattern: (destructuring_pattern - pattern: (list_pattern - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - rest: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)) - default: (list - element: (number)))))) + pattern: (destructuring_pattern + pattern: (tag_pattern + name: (identifier) + pattern: (destructuring_pattern + pattern: (list_pattern + element: (binding_pattern + name: (identifier_pattern) + type: (type)) + element: (binding_pattern + name: (identifier_pattern) + type: (type)) + rest: (binding_pattern + name: (identifier_pattern) + type: (type) + default: (list + element: (integer))))))) value: (identifier))) ============================================ -tagged pattern +tag pattern ============================================ (tag b) = a @@ -254,10 +242,11 @@ tagged pattern (program term: (assignment pattern: (pattern_group - pattern: (tagged_pattern - name: (identifier) - pattern: (identifier_pattern - name: (identifier_pattern_name)))) + pattern: (destructuring_pattern + pattern: (tag_pattern + name: (identifier) + pattern: (binding_pattern + name: (identifier_pattern))))) value: (identifier))) ============================================ @@ -273,6 +262,6 @@ wildcard pattern pattern: (destructuring_pattern pattern: (tuple_pattern element: (wildcard_pattern) - element: (identifier_pattern - name: (identifier_pattern_name)))) + element: (binding_pattern + name: (identifier_pattern)))) value: (identifier))) diff --git a/tony/corpus/program.txt b/tony/corpus/program.txt index 3acbbb32..95e542bf 100644 --- a/tony/corpus/program.txt +++ b/tony/corpus/program.txt @@ -17,7 +17,7 @@ hash bang line (program hashBangLine: (hash_bang_line) - term: (number)) + term: (integer)) ================== import @@ -37,10 +37,10 @@ import x from 'source' (program import: (import import: (import_identifier - name: (identifier_pattern_name) - as: (identifier_pattern_name)) + name: (identifier_pattern) + as: (identifier_pattern)) import: (import_identifier - as: (identifier_pattern_name)) + as: (identifier_pattern)) import: (import_type name: (type) as: (type)) @@ -48,14 +48,14 @@ import x from 'source' as: (type)) source: (raw_string)) import: (import - default: (identifier_pattern_name) + default: (identifier_pattern) import: (import_identifier - as: (identifier_pattern_name)) + as: (identifier_pattern)) import: (import_identifier - as: (identifier_pattern_name)) + as: (identifier_pattern)) source: (raw_string)) import: (import - default: (identifier_pattern_name) + default: (identifier_pattern) source: (raw_string))) ================== @@ -68,9 +68,9 @@ export x, { a, b } from 'source' (program import: (exported_import - default: (identifier_pattern_name) + default: (identifier_pattern) import: (import_identifier - as: (identifier_pattern_name)) + as: (identifier_pattern)) import: (import_identifier - as: (identifier_pattern_name)) + as: (identifier_pattern)) source: (raw_string))) diff --git a/tony/corpus/terms.txt b/tony/corpus/terms.txt index 52293255..0be7b739 100644 --- a/tony/corpus/terms.txt +++ b/tony/corpus/terms.txt @@ -1,20 +1,20 @@ ================== -abstraction +function ================== (a) => a (a, b) => a -(a :: Type, b :: Type, 1, { c :: Type = 1 }) => a +(a: Type, b: Type, 1, { c: Type = 1 }) => a fib = (x) => 0 fib = (x) => 1 -fib = (n :: T = 2) => +fib = (n: T = 2) => fib(n - 1) + fib(n - 2) -(...a :: T) => { - b = (c :: Type) => +(...a: T) => { + b = (c: Type) => c b(1) } @@ -22,132 +22,124 @@ fib = (n :: T = 2) => () => 1 / = (a, b) => / -fn :: Number => Number? => Number = (a, b = 5) => a + b +fn: Number -> ?Number -> Number = (a, b = 5) => a + b --- (program - term: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name)) + term: (function + parameter: (binding_pattern + name: (identifier_pattern)) body: (identifier)) - term: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name)) - element: (identifier_pattern - name: (identifier_pattern_name)) + term: (function + parameter: (binding_pattern + name: (identifier_pattern)) + parameter: (binding_pattern + name: (identifier_pattern)) body: (identifier)) - term: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - element: (number) - element: (destructuring_pattern + term: (function + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + parameter: (integer) + parameter: (destructuring_pattern pattern: (struct_pattern member: (shorthand_member_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)) - default: (number)))) + name: (identifier_pattern) + type: (type) + default: (integer)))) body: (identifier)) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name)) - body: (number))) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern)) + body: (integer))) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name)) - body: (number))) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern)) + body: (integer))) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (abstraction - typeParameter: (type_variable_declaration - name: (type_variable_declaration_name)) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type)) - default: (number)) - body: (infix_application - left: (application + pattern: (binding_pattern + name: (identifier_pattern)) + value: (static_function + parameter: (binding_pattern + name: (type_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern) + type: (type) + default: (integer)) + body: (infix_application + left: (application + name: (identifier) + argument: (argument + value: (infix_application + left: (identifier) + name: (identifier) + right: (integer)))) name: (identifier) - element: (argument - value: (infix_application - left: (identifier) - name: (identifier) - right: (number)))) - name: (identifier) - right: (application + right: (application + name: (identifier) + argument: (argument + value: (infix_application + left: (identifier) + name: (identifier) + right: (integer)))))))) + term: (static_function + parameter: (binding_pattern + name: (type_pattern) + type: (type)) + value: (function + rest: (binding_pattern + name: (identifier_pattern) + type: (type)) + body: (block + term: (assignment + pattern: (binding_pattern + name: (identifier_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + body: (identifier))) + term: (application name: (identifier) - element: (argument - value: (infix_application - left: (identifier) - name: (identifier) - right: (number))))))) - term: (abstraction - typeParameter: (type_variable_declaration - name: (type_variable_declaration_name) - constraint: (parametric_type - name: (type))) - rest: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - body: (block - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - body: (identifier))) - term: (application - name: (identifier) - element: (argument - value: (number))))) - term: (abstraction - body: (number)) + argument: (argument + value: (integer)))))) + term: (function + body: (integer)) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name)) - element: (identifier_pattern - name: (identifier_pattern_name)) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern)) + parameter: (binding_pattern + name: (identifier_pattern)) body: (identifier))) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (curried_type - from: (parametric_type - name: (type)) - to: (curried_type + pattern: (binding_pattern + name: (identifier_pattern) + type: (function_type + from: (type) + to: (function_type from: (optional_type - type: (parametric_type - name: (type))) - to: (parametric_type - name: (type))))) - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name)) - element: (identifier_pattern - name: (identifier_pattern_name) - default: (number)) + type: (type)) + to: (type)))) + value: (function + parameter: (binding_pattern + name: (identifier_pattern)) + parameter: (binding_pattern + name: (identifier_pattern) + default: (integer)) body: (infix_application left: (identifier) name: (identifier) @@ -175,16 +167,16 @@ f(()) term: (application name: (application name: (identifier) - element: (argument - value: (number))) - element: (argument - value: (number)) - element: (argument - value: (number))) + argument: (argument + value: (integer))) + argument: (argument + value: (integer)) + argument: (argument + value: (integer))) term: (application name: (identifier) - element: (argument - value: (number))) + argument: (argument + value: (integer))) term: (application name: (parametric_type_instance name: (identifier) @@ -196,44 +188,44 @@ f(()) name: (type))) typeArgument: (parametric_type name: (type))) - element: (argument) - element: (argument - value: (number))) + argument: (argument) + argument: (argument + value: (integer))) term: (application name: (identifier) - element: (number)) + argument: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) right: (application name: (identifier) - element: (identifier))) + argument: (identifier))) term: (infix_application - left: (number) + left: (integer) name: (identifier) right: (application name: (identifier) - element: (argument + argument: (argument value: (application name: (identifier))))) term: (application name: (identifier) - element: (argument + argument: (argument value: (spread value: (tuple element: (identifier) element: (identifier))))) term: (application name: (identifier) - element: (argument + argument: (argument value: (string))) term: (application name: (identifier) - element: (argument - value: (number))) + argument: (argument + value: (integer))) term: (application name: (identifier) - element: (argument + argument: (argument value: (tuple)))) ================== @@ -250,16 +242,16 @@ prefix application (program term: (application name: (identifier) - element: (boolean)) + argument: (boolean)) term: (application name: (identifier) - element: (number)) + argument: (integer)) term: (application name: (identifier) - element: (number)) + argument: (integer)) term: (application name: (identifier) - element: (number))) + argument: (integer))) ================== infix application @@ -278,9 +270,8 @@ infix application 1 >= 1 1 == 1 1 != 1 -a === 1 -1 !== b -a ~ b +Type | Type +Type & Type false && false false || false false ==> true <=> true @@ -299,69 +290,65 @@ a&.b&.c(1) (program term: (infix_application - left: (number) - name: (identifier) - right: (number)) - term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (identifier) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (type) name: (identifier) - right: (identifier)) + right: (type)) term: (infix_application - left: (identifier) + left: (type) name: (identifier) - right: (identifier)) + right: (type)) term: (infix_application left: (boolean) name: (identifier) @@ -393,40 +380,40 @@ a&.b&.c(1) right: (boolean))) term: (infix_application left: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application left: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application - left: (number) + left: (integer) name: (identifier) right: (application name: (identifier) - element: (number))) + argument: (integer))) term: (infix_application left: (infix_application left: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) + right: (integer)) name: (identifier) - right: (number)) + right: (integer)) name: (identifier) - right: (number)) + right: (integer)) term: (infix_application left: (boolean) name: (identifier) right: (application name: (identifier) - element: (boolean))) + argument: (boolean))) term: (infix_application left: (infix_application left: (group @@ -438,7 +425,7 @@ a&.b&.c(1) right: (identifier)) name: (identifier) right: (infix_application - left: (number) + left: (integer) name: (identifier) right: (group term: (infix_application @@ -453,8 +440,8 @@ a&.b&.c(1) right: (identifier)) name: (identifier) right: (identifier)) - element: (argument - value: (number))) + argument: (argument + value: (integer))) term: (application name: (infix_application left: (infix_application @@ -463,8 +450,8 @@ a&.b&.c(1) right: (identifier)) name: (identifier) right: (identifier)) - element: (argument - value: (number)))) + argument: (argument + value: (integer)))) ================== sections @@ -480,15 +467,15 @@ sections (program term: (right_section name: (identifier) - value: (number)) + value: (integer)) term: (left_section - value: (number) + value: (integer) name: (identifier)) term: (right_section name: (identifier) - value: (number)) + value: (integer)) term: (left_section - value: (number) + value: (integer) name: (identifier))) ================== @@ -503,54 +490,52 @@ a.b[c] (program term: (access - name: (identifier) - value: (number)) + left: (identifier) + right: (integer)) term: (application name: (access - name: (identifier) - value: (shorthand_access_identifier)) - element: (argument - value: (number))) + left: (identifier) + right: (shorthand_access_identifier)) + argument: (argument + value: (integer))) term: (access - name: (infix_application + left: (infix_application left: (identifier) name: (identifier) right: (identifier)) - value: (identifier))) + right: (identifier))) ================== assignment ================== -a :: Type = 1 -a = (a :: Type) => +a: Type = 1 +a = (a: Type) => 1 --- (program term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - value: (number)) + pattern: (binding_pattern + name: (identifier_pattern) + type: (type)) + value: (integer)) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - body: (number)))) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + body: (integer)))) ================== export ================== export a = 1 -export a = (x :: T) => +export a = (x: T) => 1 --- @@ -558,56 +543,54 @@ export a = (x :: T) => (program term: (export declaration: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (number))) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (integer))) term: (export declaration: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - body: (number))))) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + body: (integer))))) ================== return ================== return 1 -return (a :: Type) => +return (a: Type) => 1 --- (program term: (return - value: (number)) + value: (integer)) term: (return - value: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - body: (number)))) + value: (function + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + body: (integer)))) ================== -if +conditional ================== -if false then +false ? 1 -if true { +true ? { 1 1 -} else 1 +} : 1 a = - if true { + true ? { 1 - } else if false then 1 else if true { + } : false ? 1 : true ? { 1 } @@ -617,39 +600,39 @@ true ? 1 : 1 --- (program - term: (if + term: (conditional condition: (boolean) - body: (number)) - term: (if + body: (integer)) + term: (conditional condition: (boolean) body: (block - term: (number) - term: (number)) - else: (number)) + term: (integer) + term: (integer)) + else: (integer)) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (if + pattern: (binding_pattern + name: (identifier_pattern)) + value: (conditional condition: (boolean) body: (block - term: (number)) - elseIf: (else_if - condition: (boolean) - body: (number)) - elseIf: (else_if + term: (integer)) + else: (conditional condition: (boolean) - body: (block - term: (number))))) + body: (integer) + else: (conditional + condition: (boolean) + body: (block + term: (integer)))))) term: (application name: (identifier) - element: (argument - value: (ternary + argument: (argument + value: (conditional condition: (boolean) - body: (number)))) - term: (ternary + body: (integer)))) + term: (conditional condition: (boolean) - body: (number) - else: (number))) + body: (integer) + else: (integer))) ================== case @@ -663,7 +646,7 @@ a = else 1 case a -when [1, a :: Type] { +when [1, a: Type] { a } when 1, 1 then 1 @@ -676,45 +659,44 @@ else { (program term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) + pattern: (binding_pattern + name: (identifier_pattern)) value: (case value: (identifier) when: (when - pattern: (number) + pattern: (integer) body: (block - term: (number))) - else: (number))) + term: (integer))) + else: (integer))) term: (case value: (identifier) when: (when pattern: (destructuring_pattern pattern: (list_pattern - element: (number) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))))) + element: (integer) + element: (binding_pattern + name: (identifier_pattern) + type: (type)))) body: (block term: (identifier))) when: (when - pattern: (number) - pattern: (number) - body: (number)) + pattern: (integer) + pattern: (integer) + body: (integer)) else: (block - term: (number) - term: (number)))) + term: (integer) + term: (integer)))) ================== class ================== class Type { - a :: Type => Number - b :: Type => Number + a: Type -> Number + b: Type -> Number } -class Ord <: (Num; Eq; Ord) { - compare :: Ord => Ord => Number +class Ord: Num & Eq { + compare: Ord -> Ord -> Number } --- @@ -723,37 +705,28 @@ class Ord <: (Num; Eq; Ord) { term: (class name: (type) member: (class_member - name: (identifier_pattern_name) - type: (curried_type - from: (parametric_type - name: (type)) - to: (parametric_type - name: (type)))) + name: (identifier_pattern) + type: (function_type + from: (type) + to: (type))) member: (class_member - name: (identifier_pattern_name) - type: (curried_type - from: (parametric_type - name: (type)) - to: (parametric_type - name: (type))))) + name: (identifier_pattern) + type: (function_type + from: (type) + to: (type)))) term: (class name: (type) - constraint: (parametric_type - name: (type)) - constraint: (parametric_type - name: (type)) - constraint: (parametric_type - name: (type)) + constraint: (infix_application + left: (type) + name: (identifier) + right: (type)) member: (class_member - name: (identifier_pattern_name) - type: (curried_type - from: (parametric_type - name: (type)) - to: (curried_type - from: (parametric_type - name: (type)) - to: (parametric_type - name: (type))))))) + name: (identifier_pattern) + type: (function_type + from: (type) + to: (function_type + from: (type) + to: (type)))))) ================== instance @@ -762,7 +735,7 @@ instance instance Number of Ord { compare = 1 } -instance Type of Type { +instance (T: Type, U: Type) => Type(T, U) of Type { f = 1 } @@ -770,27 +743,31 @@ instance Type of Type { (program term: (instance - name: (type) + type: (type) class: (type) assignment: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (number))) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (integer))) term: (instance - name: (type) - parameter: (type_variable_declaration - name: (type_variable_declaration_name) - constraint: (parametric_type - name: (type))) - parameter: (type_variable_declaration - name: (type_variable_declaration_name) - constraint: (parametric_type - name: (type))) + type: (function + parameter: (binding_pattern + name: (type_pattern) + type: (type)) + parameter: (binding_pattern + name: (type_pattern) + type: (type)) + body: (application + name: (type) + argument: (argument + value: (type)) + argument: (argument + value: (type)))) class: (type) assignment: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (number)))) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (integer)))) ================== struct @@ -810,7 +787,7 @@ struct term: (struct member: (member key: (string) - value: (number)) + value: (integer)) member: (spread value: (identifier)) member: (member @@ -833,13 +810,13 @@ tuple term: (tuple) term: (tuple element: (identifier) - element: (number) + element: (integer) element: (string) element: (spread value: (identifier))) term: (tuple - element: (number) - element: (number))) + element: (integer) + element: (integer))) ================== list @@ -855,17 +832,17 @@ list term: (list) term: (list element: (identifier) - element: (number) + element: (integer) element: (spread value: (identifier)) element: (string)) term: (list - element: (number) + element: (integer) element: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)) - element: (number))) + right: (integer)) + element: (integer))) ================== list comprehension @@ -882,91 +859,86 @@ list comprehension body: (infix_application left: (identifier) name: (identifier) - right: (number)) - generator: (list_comprehension_generator - name: (identifier_pattern_name) + right: (integer)) + generator: (generator + name: (identifier_pattern) value: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number)))) + right: (integer)))) term: (list_comprehension body: (infix_application left: (identifier) name: (identifier) - right: (number)) - generator: (list_comprehension_generator - name: (identifier_pattern_name) + right: (integer)) + generator: (generator + name: (identifier_pattern) value: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number))) - condition: (list_comprehension_condition - value: (infix_application - left: (infix_application - left: (identifier) - name: (identifier) - right: (number)) + right: (integer))) + condition: (infix_application + left: (infix_application + left: (identifier) name: (identifier) - right: (number)))) + right: (integer)) + name: (identifier) + right: (integer))) term: (list_comprehension body: (list element: (identifier) element: (identifier)) - generator: (list_comprehension_generator - name: (identifier_pattern_name) + generator: (generator + name: (identifier_pattern) value: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number))) - condition: (list_comprehension_condition - value: (infix_application - left: (infix_application - left: (identifier) - name: (identifier) - right: (number)) + right: (integer))) + condition: (infix_application + left: (infix_application + left: (identifier) name: (identifier) - right: (number))) - generator: (list_comprehension_generator - name: (identifier_pattern_name) + right: (integer)) + name: (identifier) + right: (integer)) + generator: (generator + name: (identifier_pattern) value: (infix_application - left: (number) + left: (integer) name: (identifier) - right: (number))) - condition: (list_comprehension_condition - value: (infix_application - left: (infix_application - left: (identifier) - name: (identifier) - right: (number)) + right: (integer))) + condition: (infix_application + left: (infix_application + left: (identifier) name: (identifier) - right: (number))))) + right: (integer)) + name: (identifier) + right: (integer)))) ================== -parametric type instance +static function / application ================== -value -((a :: T) => a) +value; +((a: T) => a) --- (program - term: (parametric_type_instance - name: (identifier) - typeArgument: (parametric_type - name: (type))) - term: (parametric_type_instance - name: (group - term: (abstraction - typeParameter: (type_variable_declaration - name: (type_variable_declaration_name)) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - body: (identifier))) - typeArgument: (parametric_type - name: (type)))) + term: (static_application + value: (identifier) + argument: (type)) + term: (static_application + value: (group + term: (static_function + parameter: (binding_pattern + name: (type_pattern)) + value: (function + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + body: (identifier)))) + argument: (type))) ================== block @@ -986,12 +958,12 @@ block (program term: (block term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) - value: (number)) + pattern: (binding_pattern + name: (identifier_pattern)) + value: (integer)) term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name)) + pattern: (binding_pattern + name: (identifier_pattern)) value: (pure value: (identifier))) term: (return @@ -1001,18 +973,18 @@ block right: (identifier)))) term: (application name: (infix_application - left: (number) + left: (integer) name: (identifier) right: (identifier)) - element: (abstraction - element: (identifier_pattern - name: (identifier_pattern_name)) + argument: (function + parameter: (binding_pattern + name: (identifier_pattern)) body: (block term: (application name: (access - name: (identifier) - value: (shorthand_access_identifier)) - element: (string + left: (identifier) + right: (shorthand_access_identifier)) + argument: (string interpolation: (interpolation term: (identifier)))))))) @@ -1020,65 +992,62 @@ block type alias ================== -type Type = Type -type Type = tag Type -type Type = tag Type | tag () -type Type = T => U -type GreaterThan(x :: T) = [y :: T | y > x] +Type = Type +Type = (T, U: Num) => T -> U +GreaterThan = (T, x: T) => T --- (program - term: (type_alias - name: (type) - type: (parametric_type - name: (type))) - term: (type_alias - name: (type) - type: (tagged_type - name: (identifier_pattern_name) - type: (parametric_type - name: (type)))) - term: (type_alias - name: (type) - type: (union_type - left: (tagged_type - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - right: (tagged_type - name: (identifier_pattern_name) - type: (tuple_type)))) - term: (type_alias + term: (assignment + pattern: (binding_pattern + name: (type_pattern)) + value: (type)) + term: (assignment + pattern: (binding_pattern + name: (type_pattern)) + value: (function + parameter: (binding_pattern + name: (type_pattern)) + parameter: (binding_pattern + name: (type_pattern) + type: (type)) + body: (function_type + from: (type) + to: (type)))) + term: (assignment + pattern: (binding_pattern + name: (type_pattern)) + value: (function + parameter: (binding_pattern + name: (type_pattern)) + parameter: (binding_pattern + name: (identifier_pattern) + type: (type)) + body: (type)))) + +================== +data +================== + +data Type = tag Type +data Type = tag Type | tag + +--- + +(program + term: (data name: (type) - parameter: (type_variable_declaration - name: (type_variable_declaration_name)) - parameter: (type_variable_declaration - name: (type_variable_declaration_name) - constraint: (parametric_type - name: (type))) - type: (curried_type - from: (parametric_type - name: (type)) - to: (parametric_type - name: (type)))) - term: (type_alias + constructor: (tag + name: (identifier_pattern) + type: (type))) + term: (data name: (type) - parameter: (type_variable_declaration - name: (type_variable_declaration_name)) - element: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - type: (refinement_type - generator: (refinement_type_declaration - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - predicate: (infix_application - left: (identifier) - name: (identifier) - right: (identifier))))) + constructor: (tag + name: (identifier_pattern) + type: (type)) + constructor: (tag + name: (identifier_pattern)))) ================== type hint @@ -1091,8 +1060,7 @@ type hint (program term: (type_hint value: (string) - type: (parametric_type - name: (type)))) + type: (type))) ================== hole @@ -1104,7 +1072,7 @@ hole (program term: (hole - name: (identifier_pattern_name))) + name: (identifier_pattern))) ================== group @@ -1120,17 +1088,17 @@ n / ((n + 1) * (-2)) (program term: (group - term: (number)) + term: (integer)) term: (group term: (identifier)) term: (group term: (application name: (identifier) - element: (number))) + argument: (integer))) term: (group term: (application name: (identifier) - element: (identifier))) + argument: (identifier))) term: (infix_application left: (identifier) name: (identifier) @@ -1140,9 +1108,9 @@ n / ((n + 1) * (-2)) term: (infix_application left: (identifier) name: (identifier) - right: (number))) + right: (integer))) name: (identifier) right: (group term: (application name: (identifier) - element: (number))))))) + argument: (integer))))))) diff --git a/tony/corpus/types.txt b/tony/corpus/types.txt deleted file mode 100644 index 9a1d043c..00000000 --- a/tony/corpus/types.txt +++ /dev/null @@ -1,397 +0,0 @@ -================== -struct type -================== - -a :: { - a: Type, - b: Type -} = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (struct_type - member: (member_type - key: (shorthand_member_identifier) - value: (parametric_type - name: (type))) - member: (member_type - key: (shorthand_member_identifier) - value: (parametric_type - name: (type))))) - value: (number))) - -================== -map type -================== - -a :: { [Type]: Type } = 1 -a :: { [T in Type]: U } = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (map_type - key: (parametric_type - name: (type)) - value: (parametric_type - name: (type)))) - value: (number)) - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (map_type - property: (type_variable_declaration_name) - key: (parametric_type - name: (type)) - value: (parametric_type - name: (type)))) - value: (number))) - -================== -tuple type -================== - -a :: (Type, Type) = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (tuple_type - element: (parametric_type - name: (type)) - element: (parametric_type - name: (type)))) - value: (number))) - -================== -list type -================== - -a :: [Type] = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (list_type - element: (parametric_type - name: (type)))) - value: (number))) - -================== -optional type -================== - -a as Type? - ---- - -(program - term: (type_hint - value: (identifier) - type: (optional_type - type: (parametric_type - name: (type))))) - -================== -access type -================== - -a as Type[b] -a as Type->a -a as T[0] - ---- - -(program - term: (type_hint - value: (identifier) - type: (access_type - type: (parametric_type - name: (type)) - value: (identifier))) - term: (type_hint - value: (identifier) - type: (access_type - type: (parametric_type - name: (type)) - value: (shorthand_access_identifier))) - term: (type_hint - value: (identifier) - type: (access_type - type: (parametric_type - name: (type)) - value: (number)))) - -================== -curried type -================== - -a :: Type => [Type] => Type = 1 -a :: Type => (Type => Type) => T = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (curried_type - from: (parametric_type - name: (type)) - to: (curried_type - from: (list_type - element: (parametric_type - name: (type))) - to: (parametric_type - name: (type))))) - value: (number)) - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (curried_type - from: (parametric_type - name: (type)) - to: (curried_type - from: (type_group - type: (curried_type - from: (parametric_type - name: (type)) - to: (parametric_type - name: (type)))) - to: (parametric_type - name: (type))))) - value: (number))) - -================== -parametric type -================== - -a as Type -a as Type(5) -a as Type -a as Type(5, 'string') -a as Type - ---- - -(program - term: (type_hint - value: (identifier) - type: (parametric_type - name: (type))) - term: (type_hint - value: (identifier) - type: (parametric_type - name: (type) - element: (number))) - term: (type_hint - value: (identifier) - type: (parametric_type - name: (type) - argument: (parametric_type - name: (type)))) - term: (type_hint - value: (identifier) - type: (parametric_type - name: (type) - argument: (parametric_type - name: (type)) - element: (number) - element: (string))) - term: (type_hint - value: (identifier) - type: (parametric_type - name: (type) - argument: (parametric_type - name: (type)) - argument: (parametric_type - name: (type)) - argument: (typeof - value: (identifier)) - argument: (typeof - value: (string)) - argument: (typeof - value: (number))))) - -================== -intersection/union type -================== - -a :: Type | Type & Type | Type = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (union_type - left: (parametric_type - name: (type)) - right: (union_type - left: (intersection_type - left: (parametric_type - name: (type)) - right: (parametric_type - name: (type))) - right: (parametric_type - name: (type))))) - value: (number))) - -================== -subtraction type -================== - -a :: Type | Type \ Type = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (subtraction_type - left: (union_type - left: (parametric_type - name: (type)) - right: (parametric_type - name: (type))) - right: (parametric_type - name: (type)))) - value: (number))) - -================== -conditional type -================== - -a :: Type <: (Type; Type) ? Type <: Type ? Type : Type : Type <: Type ? Type : Type = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (conditional_type - type: (parametric_type - name: (type)) - constraint: (parametric_type - name: (type)) - constraint: (parametric_type - name: (type)) - consequence: (conditional_type - type: (parametric_type - name: (type)) - constraint: (parametric_type - name: (type)) - consequence: (parametric_type - name: (type)) - alternative: (parametric_type - name: (type))) - alternative: (conditional_type - type: (parametric_type - name: (type)) - constraint: (parametric_type - name: (type)) - consequence: (parametric_type - name: (type)) - alternative: (parametric_type - name: (type))))) - value: (number))) - -================== -keyof -================== - -a :: keyof Type = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (keyof - type: (parametric_type - name: (type)))) - value: (number))) - -================== -refinement type -================== - -a :: Type<[(a :: Type, Type) | a > 0, a < 10]> = 1 - ---- - -(program - term: (assignment - pattern: (identifier_pattern - name: (identifier_pattern_name) - type: (parametric_type - name: (type) - argument: (refinement_type - generator: (tuple_type - element: (refinement_type_declaration - name: (identifier_pattern_name) - type: (parametric_type - name: (type))) - element: (parametric_type - name: (type))) - predicate: (infix_application - left: (identifier) - name: (identifier) - right: (number)) - predicate: (infix_application - left: (identifier) - name: (identifier) - right: (number))))) - value: (number))) - -================== -labeled type -================== - -a as label: Type - ---- - -(program - term: (type_hint - value: (identifier) - type: (labeled_type - label: (identifier) - type: (parametric_type - name: (type))))) - -================== -type -================== - -a as Type -a as AaA0Z - ---- - -(program - term: (type_hint - value: (identifier) - type: (parametric_type - name: (type))) - term: (type_hint - value: (identifier) - type: (parametric_type - name: (type)))) diff --git a/tony/grammar.ts b/tony/grammar.ts index bca43d0f..fbc356b8 100644 --- a/tony/grammar.ts +++ b/tony/grammar.ts @@ -4,25 +4,24 @@ import { _assignable_pattern, _literal_pattern, _pattern, + binding_pattern, destructuring_pattern, - identifier_pattern, list_pattern, member_pattern, pattern_group, - root_identifier_pattern, + root_binding_pattern, struct_pattern, - tagged_pattern, + tag_pattern, tuple_pattern, wildcard_pattern, } from '../common/patterns' import { - _decimal, - _integer, _literal, boolean, + decimal, escape_sequence, + integer, interpolation, - number, raw_string, regex, regex_flags, @@ -32,11 +31,12 @@ import { import { _element, _identifier_without_operators, + _immediate_block, _operator, _section, _section_identifier, + _statement, _term, - abstraction, access, application, argument, @@ -45,31 +45,38 @@ import { case_, class_, class_member, - else_if, + conditional, + data, export_, + function_, + function_type, + generator, group, hole, identifier, - if_, infix_application, instance, + keyof_type, left_section, list, list_comprehension, - list_comprehension_condition, - list_comprehension_generator, + map_type, member, - parametric_type_instance, + optional_type, pure, return_, right_section, spread, + static_application, + static_function, struct, - ternary, + tag, tuple, - type_alias, + type, type_hint, when, + _arguments, + _parameters, } from '../common/terms' import { _import_body_constructor, @@ -78,35 +85,10 @@ import { import_identifier, import_type, } from '../common/imports' -import { - _predicate, - _term_type, - _type_constructor, - access_type, - conditional_type, - curried_type, - intersection_type, - keyof, - labeled_type, - list_type, - map_type, - member_type, - optional_type, - parametric_type_constructor, - refinement_type, - refinement_type_declaration, - struct_type, - subtraction_type, - tagged_type, - tuple_type, - type, - type_group, - type_variable_declaration, - typeof_, - union_type, -} from '../common/types' import { comment, hash_bang_line } from '../common/miscellaneous' -import { Dialect } from '../common/enums' +import { Dialect } from '../common/dialects' +import { precedences } from '../common/precedences' +import { line } from '../common/util' const dialect = Dialect.Tony @@ -119,49 +101,74 @@ export = grammar({ $._string_content, $._string_end, ], - extras: ($) => [$.comment, /\s+/], + + extras: ($) => [$.comment, /\s/], + word: ($) => $._identifier_without_operators, + conflicts: ($) => [ - [$._term, $.identifier_pattern], - [$._term, $.identifier_pattern, $.root_identifier_pattern], - [$.identifier_pattern, $.root_identifier_pattern], - [ - $.identifier_pattern, - $.root_identifier_pattern, - $.refinement_type_declaration, - ], - [$._term, $.root_identifier_pattern], - [$._term, $.identifier_pattern, $._type], - [$._term, $.identifier_pattern, $.struct], - [$.string, $.raw_string], + [$._term, $.destructuring_pattern], + + [$.binding_pattern], + [$._term, $.binding_pattern], + [$.root_binding_pattern], + [$._term, $.root_binding_pattern], + [$.binding_pattern, $.root_binding_pattern], + [$._term, $.binding_pattern, $.root_binding_pattern], + + [$.member, $.binding_pattern], + [$.member, $.class_member], + [$.member, $.class_member, $.binding_pattern], + + [$.list, $.list_pattern], [$.struct, $.struct_pattern], - [$.struct, $.struct_pattern, $.struct_type], [$.tuple, $.tuple_pattern], - [$.tuple, $.tuple_pattern, $.tuple_type], - [$.list, $.list_pattern], - [$.abstraction, $.tuple_type], - [$.member, $.member_pattern, $._element], - [$.parametric_type_instance, $.infix_application], - [$.parametric_type_instance, $.infix_application, $.application], - [$.application, $.infix_application], - [$.application, $.infix_application, $.ternary], - [$.application, $.assignment, $.ternary], - [$.tagged_pattern, $.identifier], - [$.tagged_pattern, $.tagged_type], - [$.type_variable_declaration, $.parametric_type], - [$._element, $.group], + [$._literal, $._literal_pattern], + + [$.tuple, $._arguments], + [$.tuple_pattern, $._parameters], + + [$.raw_string, $.string], + + [$.group, $._element], + [$.argument, $.tuple], + + // investigate + [$.static_application, $.infix_application], + [$.static_application, $.infix_application, $.conditional], + [$._term, $.struct], + [$._term, $.struct, $.binding_pattern], + [$.import_type, $.binding_pattern], + [$.import_identifier, $.binding_pattern], + + [$._term, $.hole, $.destructuring_pattern], + [$._term, $.hole, $.root_binding_pattern], + [$.tuple_pattern, $.application], + [$.tuple_pattern, $.tuple, $.application], + + [$.infix_application, $.application], + [$.infix_application, $.application, $.static_application], + [$.infix_application, $.application, $.static_application, $.conditional], + [ + $.infix_application, + $.application, + $.static_application, + $.conditional, + $.optional_type, + ], + + [$.access, $._element], + [$.access, $._term], ], - precedences: () => [], + precedences, rules: { program: ($) => seq( - optional(seq(field('hashBangLine', $.hash_bang_line), $._newline)), - repeat( - seq(field('import', choice($.import, $.exported_import)), $._newline), - ), - repeat(seq(field('term', $._term), $._newline)), + optional(line($, field('hashBangLine', $.hash_bang_line))), + repeat(line($, field('import', choice($.import, $.exported_import)))), + repeat(line($, field('term', $._statement))), ), hash_bang_line, @@ -173,6 +180,7 @@ export = grammar({ import_identifier, import_type, + _statement, _term, block, export: export_, @@ -181,7 +189,9 @@ export = grammar({ class_member, instance, argument, - abstraction, + _parameters, + function: function_, + _arguments, application, infix_application, _section, @@ -189,13 +199,13 @@ export = grammar({ right_section, _section_identifier, list_comprehension, - list_comprehension_generator, - list_comprehension_condition, + generator, access, return: return_, - ternary, - if: if_, - else_if, + static_application, + static_function, + conditional, + _immediate_block, case: case_, when, struct, @@ -204,11 +214,16 @@ export = grammar({ list, _element, spread, - parametric_type_instance, pure, - type_alias, - type_hint, hole, + type_hint, + data, + tag, + function_type, + optional_type, + keyof_type, + map_type, + type, _identifier_without_operators, _operator, identifier, @@ -221,44 +236,17 @@ export = grammar({ tuple_pattern, list_pattern, member_pattern, - identifier_pattern, - root_identifier_pattern, + binding_pattern, + root_binding_pattern, wildcard_pattern, - tagged_pattern, + tag_pattern, _literal_pattern, pattern_group, - type_variable_declaration, - _type: _type_constructor(dialect), - _term_type, - typeof: typeof_, - parametric_type: parametric_type_constructor(dialect), - curried_type, - intersection_type, - union_type, - subtraction_type, - conditional_type, - struct_type, - member_type, - map_type, - tuple_type, - list_type, - optional_type, - access_type, - tagged_type, - labeled_type, - keyof, - refinement_type_declaration, - refinement_type, - _predicate, - type_group, - type, - _literal, boolean, - _decimal, - _integer, - number, + decimal, + integer, raw_string, string, interpolation, diff --git a/tony/index.d.ts b/tony/index.d.ts index f9c7c3ca..5d0228f4 100644 --- a/tony/index.d.ts +++ b/tony/index.d.ts @@ -172,59 +172,47 @@ export interface ErrorNode extends NamedNodeBase { export const enum SyntaxType { ERROR = "ERROR", - Abstraction = "abstraction", Access = "access", - AccessType = "access_type", Application = "application", Argument = "argument", Assignment = "assignment", + BindingPattern = "binding_pattern", Block = "block", Boolean = "boolean", Case = "case", Class = "class", ClassMember = "class_member", - ConditionalType = "conditional_type", - CurriedType = "curried_type", + Conditional = "conditional", + Data = "data", DestructuringPattern = "destructuring_pattern", - ElseIf = "else_if", Export = "export", ExportedImport = "exported_import", + Function = "function", + FunctionType = "function_type", + Generator = "generator", Group = "group", Hole = "hole", Identifier = "identifier", IdentifierPattern = "identifier_pattern", - IdentifierPatternName = "identifier_pattern_name", - If = "if", Import = "import", ImportIdentifier = "import_identifier", ImportType = "import_type", InfixApplication = "infix_application", Instance = "instance", Interpolation = "interpolation", - IntersectionType = "intersection_type", - Keyof = "keyof", - LabeledType = "labeled_type", + KeyofType = "keyof_type", LeftSection = "left_section", List = "list", ListComprehension = "list_comprehension", - ListComprehensionCondition = "list_comprehension_condition", - ListComprehensionGenerator = "list_comprehension_generator", ListPattern = "list_pattern", - ListType = "list_type", MapType = "map_type", Member = "member", MemberPattern = "member_pattern", - MemberType = "member_type", - Number = "number", OptionalType = "optional_type", - ParametricType = "parametric_type", - ParametricTypeInstance = "parametric_type_instance", PatternGroup = "pattern_group", Program = "program", Pure = "pure", RawString = "raw_string", - RefinementType = "refinement_type", - RefinementTypeDeclaration = "refinement_type_declaration", Regex = "regex", Return = "return", RightSection = "right_section", @@ -233,36 +221,30 @@ export const enum SyntaxType { ShorthandMemberIdentifier = "shorthand_member_identifier", ShorthandMemberPattern = "shorthand_member_pattern", Spread = "spread", + StaticApplication = "static_application", + StaticFunction = "static_function", String = "string", Struct = "struct", StructPattern = "struct_pattern", - StructType = "struct_type", - SubtractionType = "subtraction_type", - TaggedPattern = "tagged_pattern", - TaggedType = "tagged_type", - Ternary = "ternary", + Tag = "tag", + TagPattern = "tag_pattern", Tuple = "tuple", TuplePattern = "tuple_pattern", - TupleType = "tuple_type", - TypeAlias = "type_alias", - TypeGroup = "type_group", TypeHint = "type_hint", - TypeVariableDeclaration = "type_variable_declaration", - Typeof = "typeof", - UnionType = "union_type", When = "when", Comment = "comment", + Decimal = "decimal", EscapeSequence = "escape_sequence", HashBangLine = "hash_bang_line", + Integer = "integer", RegexFlags = "regex_flags", RegexPattern = "regex_pattern", Type = "type", - TypeVariableDeclarationName = "type_variable_declaration_name", + TypePattern = "type_pattern", WildcardPattern = "wildcard_pattern", } export type UnnamedType = - | "&" | "(" | "()" | ")" @@ -271,40 +253,34 @@ export type UnnamedType = | "..." | "/" | ":" - | "::" | ";" | "<" - | "<:" | "=" | "=>" | ">" | "?" | "@" | "[" - | "\\" | "]" | "`" | "as" | SyntaxType.Case // both named and unnamed | SyntaxType.Class // both named and unnamed + | SyntaxType.Data // both named and unnamed | "else" - | "else if" | SyntaxType.Export // both named and unnamed | "false" | "from" - | SyntaxType.If // both named and unnamed | SyntaxType.Import // both named and unnamed | "in" | SyntaxType.Instance // both named and unnamed - | SyntaxType.Keyof // both named and unnamed + | "keyof" | "of" | SyntaxType.Pure // both named and unnamed | "r/" | SyntaxType.Return // both named and unnamed | "then" | "true" - | SyntaxType.Type // both named and unnamed - | SyntaxType.Typeof // both named and unnamed | SyntaxType.When // both named and unnamed | "{" | "|" @@ -314,59 +290,47 @@ export type UnnamedType = export type TypeString = SyntaxType | UnnamedType; export type SyntaxNode = - | AbstractionNode | AccessNode - | AccessTypeNode | ApplicationNode | ArgumentNode | AssignmentNode + | BindingPatternNode | BlockNode | BooleanNode | CaseNode | ClassNode | ClassMemberNode - | ConditionalTypeNode - | CurriedTypeNode + | ConditionalNode + | DataNode | DestructuringPatternNode - | ElseIfNode | ExportNode | ExportedImportNode + | FunctionNode + | FunctionTypeNode + | GeneratorNode | GroupNode | HoleNode | IdentifierNode | IdentifierPatternNode - | IdentifierPatternNameNode - | IfNode | ImportNode | ImportIdentifierNode | ImportTypeNode | InfixApplicationNode | InstanceNode | InterpolationNode - | IntersectionTypeNode - | KeyofNode - | LabeledTypeNode + | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode - | ListComprehensionConditionNode - | ListComprehensionGeneratorNode | ListPatternNode - | ListTypeNode | MapTypeNode | MemberNode | MemberPatternNode - | MemberTypeNode - | NumberNode | OptionalTypeNode - | ParametricTypeNode - | ParametricTypeInstanceNode | PatternGroupNode | ProgramNode | PureNode | RawStringNode - | RefinementTypeNode - | RefinementTypeDeclarationNode | RegexNode | ReturnNode | RightSectionNode @@ -375,25 +339,17 @@ export type SyntaxNode = | ShorthandMemberIdentifierNode | ShorthandMemberPatternNode | SpreadNode + | StaticApplicationNode + | StaticFunctionNode | StringNode | StructNode | StructPatternNode - | StructTypeNode - | SubtractionTypeNode - | TaggedPatternNode - | TaggedTypeNode - | TernaryNode + | TagNode + | TagPatternNode | TupleNode | TuplePatternNode - | TupleTypeNode - | TypeAliasNode - | TypeGroupNode | TypeHintNode - | TypeVariableDeclarationNode - | TypeofNode - | UnionTypeNode | WhenNode - | UnnamedNode<"&"> | UnnamedNode<"("> | UnnamedNode<"()"> | UnnamedNode<")"> @@ -402,35 +358,33 @@ export type SyntaxNode = | UnnamedNode<"..."> | UnnamedNode<"/"> | UnnamedNode<":"> - | UnnamedNode<"::"> | UnnamedNode<";"> | UnnamedNode<"<"> - | UnnamedNode<"<:"> | UnnamedNode<"="> | UnnamedNode<"=>"> | UnnamedNode<">"> | UnnamedNode<"?"> | UnnamedNode<"@"> | UnnamedNode<"["> - | UnnamedNode<"\\"> | UnnamedNode<"]"> | UnnamedNode<"`"> | UnnamedNode<"as"> | UnnamedNode | UnnamedNode | CommentNode + | UnnamedNode + | DecimalNode | UnnamedNode<"else"> - | UnnamedNode<"else if"> | EscapeSequenceNode | UnnamedNode | UnnamedNode<"false"> | UnnamedNode<"from"> | HashBangLineNode - | UnnamedNode | UnnamedNode | UnnamedNode<"in"> | UnnamedNode - | UnnamedNode + | IntegerNode + | UnnamedNode<"keyof"> | UnnamedNode<"of"> | UnnamedNode | UnnamedNode<"r/"> @@ -439,10 +393,8 @@ export type SyntaxNode = | UnnamedNode | UnnamedNode<"then"> | UnnamedNode<"true"> - | UnnamedNode | TypeNode - | TypeVariableDeclarationNameNode - | UnnamedNode + | TypePatternNode | UnnamedNode | WildcardPatternNode | UnnamedNode<"{"> @@ -451,47 +403,41 @@ export type SyntaxNode = | ErrorNode ; -export interface AbstractionNode extends NamedNodeBase { - type: SyntaxType.Abstraction; - bodyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - elementNodes: (BooleanNode | DestructuringPatternNode | IdentifierPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; - restNode?: IdentifierPatternNode; - typeParameterNodes: TypeVariableDeclarationNode[]; -} - export interface AccessNode extends NamedNodeBase { type: SyntaxType.Access; - nameNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandAccessIdentifierNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; -} - -export interface AccessTypeNode extends NamedNodeBase { - type: SyntaxType.AccessType; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - valueNode: BooleanNode | IdentifierNode | NumberNode | RegexNode | ShorthandAccessIdentifierNode | StringNode; + leftNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + rightNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandAccessIdentifierNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface ApplicationNode extends NamedNodeBase { type: SyntaxType.Application; - elementNodes: (AbstractionNode | AccessNode | ApplicationNode | ArgumentNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode)[]; - nameNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + argumentNodes: (AccessNode | ApplicationNode | ArgumentNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode)[]; + nameNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + restNode?: BindingPatternNode; } export interface ArgumentNode extends NamedNodeBase { type: SyntaxType.Argument; placeholderNode?: UnnamedNode<"?">; - valueNode?: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + valueNode?: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface AssignmentNode extends NamedNodeBase { type: SyntaxType.Assignment; - patternNode: DestructuringPatternNode | IdentifierPatternNode | PatternGroupNode | TaggedPatternNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + patternNode: BindingPatternNode | DestructuringPatternNode | PatternGroupNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface BindingPatternNode extends NamedNodeBase { + type: SyntaxType.BindingPattern; + defaultNode?: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + nameNode: IdentifierPatternNode | TypePatternNode; + typeNode?: TypeNode; } export interface BlockNode extends NamedNodeBase { type: SyntaxType.Block; - termNodes: (AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode)[]; + termNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode)[]; } export interface BooleanNode extends NamedNodeBase { @@ -500,48 +446,42 @@ export interface BooleanNode extends NamedNodeBase { export interface CaseNode extends NamedNodeBase { type: SyntaxType.Case; - elseNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + elseNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; whenNodes: WhenNode[]; } export interface ClassNode extends NamedNodeBase { type: SyntaxType.Class; - constraintNodes: (AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode)[]; + constraintNode?: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; memberNodes: ClassMemberNode[]; nameNode: TypeNode; } export interface ClassMemberNode extends NamedNodeBase { type: SyntaxType.ClassMember; - nameNode: IdentifierPatternNameNode; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; + nameNode: IdentifierPatternNode; + typeNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } -export interface ConditionalTypeNode extends NamedNodeBase { - type: SyntaxType.ConditionalType; - alternativeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - consequenceNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - constraintNodes: (AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode)[]; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; +export interface ConditionalNode extends NamedNodeBase { + type: SyntaxType.Conditional; + bodyNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + conditionNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + elseNode?: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } -export interface CurriedTypeNode extends NamedNodeBase { - type: SyntaxType.CurriedType; - fromNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - toNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; +export interface DataNode extends NamedNodeBase { + type: SyntaxType.Data; + constructorNodes: TagNode[]; + nameNode: TypeNode; + parameterNodes: (BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode)[]; } export interface DestructuringPatternNode extends NamedNodeBase { type: SyntaxType.DestructuringPattern; - aliasNode?: IdentifierPatternNameNode; - patternNode: ListPatternNode | StructPatternNode | TuplePatternNode; -} - -export interface ElseIfNode extends NamedNodeBase { - type: SyntaxType.ElseIf; - bodyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - conditionNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + aliasNode?: IdentifierPatternNode | TypePatternNode; + patternNode: ListPatternNode | StructPatternNode | TagPatternNode | TuplePatternNode; } export interface ExportNode extends NamedNodeBase { @@ -551,19 +491,38 @@ export interface ExportNode extends NamedNodeBase { export interface ExportedImportNode extends NamedNodeBase { type: SyntaxType.ExportedImport; - defaultNode?: IdentifierPatternNameNode; + defaultNode?: IdentifierPatternNode; importNodes: (ImportIdentifierNode | ImportTypeNode)[]; sourceNode: RawStringNode; } +export interface FunctionNode extends NamedNodeBase { + type: SyntaxType.Function; + bodyNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + parameterNodes: (BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode)[]; + restNode?: BindingPatternNode; +} + +export interface FunctionTypeNode extends NamedNodeBase { + type: SyntaxType.FunctionType; + fromNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + toNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface GeneratorNode extends NamedNodeBase { + type: SyntaxType.Generator; + nameNode: IdentifierPatternNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; +} + export interface GroupNode extends NamedNodeBase { type: SyntaxType.Group; - termNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + termNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface HoleNode extends NamedNodeBase { type: SyntaxType.Hole; - nameNode: IdentifierPatternNameNode; + nameNode: IdentifierPatternNode; } export interface IdentifierNode extends NamedNodeBase { @@ -572,34 +531,19 @@ export interface IdentifierNode extends NamedNodeBase { export interface IdentifierPatternNode extends NamedNodeBase { type: SyntaxType.IdentifierPattern; - defaultNode?: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - nameNode: IdentifierPatternNameNode; - typeNode?: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - -export interface IdentifierPatternNameNode extends NamedNodeBase { - type: SyntaxType.IdentifierPatternName; -} - -export interface IfNode extends NamedNodeBase { - type: SyntaxType.If; - bodyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - conditionNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - elseNode?: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - elseIfNodes: ElseIfNode[]; } export interface ImportNode extends NamedNodeBase { type: SyntaxType.Import; - defaultNode?: IdentifierPatternNameNode; + defaultNode?: IdentifierPatternNode; importNodes: (ImportIdentifierNode | ImportTypeNode)[]; sourceNode: RawStringNode; } export interface ImportIdentifierNode extends NamedNodeBase { type: SyntaxType.ImportIdentifier; - asNode: IdentifierPatternNameNode; - nameNode?: IdentifierPatternNameNode; + asNode: IdentifierPatternNode; + nameNode?: IdentifierPatternNode; } export interface ImportTypeNode extends NamedNodeBase { @@ -610,162 +554,97 @@ export interface ImportTypeNode extends NamedNodeBase { export interface InfixApplicationNode extends NamedNodeBase { type: SyntaxType.InfixApplication; - leftNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + leftNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; nameNode: IdentifierNode; - rightNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + rightNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface InstanceNode extends NamedNodeBase { type: SyntaxType.Instance; assignmentNodes: AssignmentNode[]; classNode: TypeNode; - elementNodes: IdentifierPatternNode[]; - nameNode: TypeNode; - parameterNodes: TypeVariableDeclarationNode[]; + typeNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface InterpolationNode extends NamedNodeBase { type: SyntaxType.Interpolation; - termNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + termNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } -export interface IntersectionTypeNode extends NamedNodeBase { - type: SyntaxType.IntersectionType; - leftNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - rightNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - -export interface KeyofNode extends NamedNodeBase { - type: SyntaxType.Keyof; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - -export interface LabeledTypeNode extends NamedNodeBase { - type: SyntaxType.LabeledType; - labelNode: IdentifierNode; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; +export interface KeyofTypeNode extends NamedNodeBase { + type: SyntaxType.KeyofType; + typeNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface LeftSectionNode extends NamedNodeBase { type: SyntaxType.LeftSection; nameNode: IdentifierNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface ListNode extends NamedNodeBase { type: SyntaxType.List; - elementNodes: (AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode)[]; + elementNodes: (AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode)[]; } export interface ListComprehensionNode extends NamedNodeBase { type: SyntaxType.ListComprehension; - bodyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - conditionNodes: ListComprehensionConditionNode[]; - generatorNodes: ListComprehensionGeneratorNode[]; -} - -export interface ListComprehensionConditionNode extends NamedNodeBase { - type: SyntaxType.ListComprehensionCondition; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; -} - -export interface ListComprehensionGeneratorNode extends NamedNodeBase { - type: SyntaxType.ListComprehensionGenerator; - nameNode: IdentifierPatternNameNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + bodyNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + conditionNodes: (AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode)[]; + generatorNodes: GeneratorNode[]; } export interface ListPatternNode extends NamedNodeBase { type: SyntaxType.ListPattern; - elementNodes: (BooleanNode | DestructuringPatternNode | IdentifierPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; - restNode?: IdentifierPatternNode; -} - -export interface ListTypeNode extends NamedNodeBase { - type: SyntaxType.ListType; - elementNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; + elementNodes: (BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode)[]; + restNode?: BindingPatternNode; } export interface MapTypeNode extends NamedNodeBase { type: SyntaxType.MapType; - keyNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - propertyNode?: TypeVariableDeclarationNameNode; - valueNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; + keyNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + propertyNode?: TypePatternNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface MemberNode extends NamedNodeBase { type: SyntaxType.Member; - keyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandMemberIdentifierNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + keyNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandMemberIdentifierNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface MemberPatternNode extends NamedNodeBase { type: SyntaxType.MemberPattern; - keyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandMemberIdentifierNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - valueNode: BooleanNode | DestructuringPatternNode | IdentifierPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode; -} - -export interface MemberTypeNode extends NamedNodeBase { - type: SyntaxType.MemberType; - keyNode: ShorthandMemberIdentifierNode; - valueNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - -export interface NumberNode extends NamedNodeBase { - type: SyntaxType.Number; + keyNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | ShorthandMemberIdentifierNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + valueNode: BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode; } export interface OptionalTypeNode extends NamedNodeBase { type: SyntaxType.OptionalType; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - -export interface ParametricTypeNode extends NamedNodeBase { - type: SyntaxType.ParametricType; - argumentNodes: (AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode)[]; - elementNodes: (BooleanNode | IdentifierNode | NumberNode | RegexNode | StringNode)[]; - nameNode: TypeNode; -} - -export interface ParametricTypeInstanceNode extends NamedNodeBase { - type: SyntaxType.ParametricTypeInstance; - nameNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - typeArgumentNodes: ParametricTypeNode[]; + typeNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface PatternGroupNode extends NamedNodeBase { type: SyntaxType.PatternGroup; - patternNode: BooleanNode | DestructuringPatternNode | IdentifierPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode; + patternNode: BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode; } export interface ProgramNode extends NamedNodeBase { type: SyntaxType.Program; hashBangLineNode?: HashBangLineNode; importNodes: (ExportedImportNode | ImportNode)[]; - termNodes: (AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode)[]; + termNodes: (AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ConditionalNode | DataNode | DecimalNode | ExportNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | InstanceNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode)[]; } export interface PureNode extends NamedNodeBase { type: SyntaxType.Pure; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface RawStringNode extends NamedNodeBase { type: SyntaxType.RawString; } -export interface RefinementTypeNode extends NamedNodeBase { - type: SyntaxType.RefinementType; - generatorNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - predicateNodes: (ApplicationNode | InfixApplicationNode)[]; -} - -export interface RefinementTypeDeclarationNode extends NamedNodeBase { - type: SyntaxType.RefinementTypeDeclaration; - nameNode: IdentifierPatternNameNode; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - export interface RegexNode extends NamedNodeBase { type: SyntaxType.Regex; flagsNode?: RegexFlagsNode; @@ -774,13 +653,13 @@ export interface RegexNode extends NamedNodeBase { export interface ReturnNode extends NamedNodeBase { type: SyntaxType.Return; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface RightSectionNode extends NamedNodeBase { type: SyntaxType.RightSection; nameNode: IdentifierNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface ShorthandAccessIdentifierNode extends NamedNodeBase { @@ -797,14 +676,26 @@ export interface ShorthandMemberIdentifierNode extends NamedNodeBase { export interface ShorthandMemberPatternNode extends NamedNodeBase { type: SyntaxType.ShorthandMemberPattern; - defaultNode?: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - nameNode: IdentifierPatternNameNode; - typeNode?: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; + defaultNode?: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + nameNode: IdentifierPatternNode | TypePatternNode; + typeNode?: TypeNode; } export interface SpreadNode extends NamedNodeBase { type: SyntaxType.Spread; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface StaticApplicationNode extends NamedNodeBase { + type: SyntaxType.StaticApplication; + argumentNodes: (AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode)[]; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; +} + +export interface StaticFunctionNode extends NamedNodeBase { + type: SyntaxType.StaticFunction; + parameterNodes: (BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode)[]; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface StringNode extends NamedNodeBase { @@ -821,101 +712,52 @@ export interface StructNode extends NamedNodeBase { export interface StructPatternNode extends NamedNodeBase { type: SyntaxType.StructPattern; memberNodes: (MemberPatternNode | ShorthandMemberPatternNode)[]; - restNode?: IdentifierPatternNode; -} - -export interface StructTypeNode extends NamedNodeBase { - type: SyntaxType.StructType; - memberNodes: MemberTypeNode[]; + restNode?: BindingPatternNode; } -export interface SubtractionTypeNode extends NamedNodeBase { - type: SyntaxType.SubtractionType; - leftNode: ParametricTypeNode | UnionTypeNode; - rightNode: ParametricTypeNode | UnionTypeNode; +export interface TagNode extends NamedNodeBase { + type: SyntaxType.Tag; + nameNode: IdentifierPatternNode; + typeNode?: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } -export interface TaggedPatternNode extends NamedNodeBase { - type: SyntaxType.TaggedPattern; +export interface TagPatternNode extends NamedNodeBase { + type: SyntaxType.TagPattern; nameNode: IdentifierNode; - patternNode: BooleanNode | DestructuringPatternNode | IdentifierPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode; -} - -export interface TaggedTypeNode extends NamedNodeBase { - type: SyntaxType.TaggedType; - nameNode: IdentifierPatternNameNode; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - -export interface TernaryNode extends NamedNodeBase { - type: SyntaxType.Ternary; - bodyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - conditionNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - elseNode?: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; + patternNode: BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode; } export interface TupleNode extends NamedNodeBase { type: SyntaxType.Tuple; - elementNodes: (AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode)[]; + elementNodes: (AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | SpreadNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode)[]; } export interface TuplePatternNode extends NamedNodeBase { type: SyntaxType.TuplePattern; - elementNodes: (BooleanNode | DestructuringPatternNode | IdentifierPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; - restNode?: IdentifierPatternNode; -} - -export interface TupleTypeNode extends NamedNodeBase { - type: SyntaxType.TupleType; - elementNodes: (AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode)[]; -} - -export interface TypeAliasNode extends NamedNodeBase { - type: SyntaxType.TypeAlias; - elementNodes: IdentifierPatternNode[]; - nameNode: TypeNode; - parameterNodes: TypeVariableDeclarationNode[]; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; -} - -export interface TypeGroupNode extends NamedNodeBase { - type: SyntaxType.TypeGroup; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; + elementNodes: (BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode)[]; + restNode?: BindingPatternNode; } export interface TypeHintNode extends NamedNodeBase { type: SyntaxType.TypeHint; - typeNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - valueNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; -} - -export interface TypeVariableDeclarationNode extends NamedNodeBase { - type: SyntaxType.TypeVariableDeclaration; - constraintNodes: (AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode)[]; - nameNode: TypeVariableDeclarationNameNode; -} - -export interface TypeofNode extends NamedNodeBase { - type: SyntaxType.Typeof; - valueNode: BooleanNode | IdentifierNode | NumberNode | RegexNode | StringNode; -} - -export interface UnionTypeNode extends NamedNodeBase { - type: SyntaxType.UnionType; - leftNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; - rightNode: AccessTypeNode | ConditionalTypeNode | CurriedTypeNode | IntersectionTypeNode | KeyofNode | LabeledTypeNode | ListTypeNode | MapTypeNode | OptionalTypeNode | ParametricTypeNode | RefinementTypeNode | RefinementTypeDeclarationNode | StructTypeNode | SubtractionTypeNode | TaggedTypeNode | TupleTypeNode | TypeGroupNode | TypeofNode | UnionTypeNode; + typeNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + valueNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; } export interface WhenNode extends NamedNodeBase { type: SyntaxType.When; - bodyNode: AbstractionNode | AccessNode | ApplicationNode | AssignmentNode | BlockNode | BooleanNode | CaseNode | ClassNode | ExportNode | GroupNode | HoleNode | IdentifierNode | IfNode | InfixApplicationNode | InstanceNode | LeftSectionNode | ListNode | ListComprehensionNode | NumberNode | ParametricTypeInstanceNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StringNode | StructNode | TernaryNode | TupleNode | TypeAliasNode | TypeHintNode; - patternNodes: (BooleanNode | DestructuringPatternNode | IdentifierPatternNode | NumberNode | PatternGroupNode | RawStringNode | RegexNode | TaggedPatternNode | WildcardPatternNode)[]; + bodyNode: AccessNode | ApplicationNode | BlockNode | BooleanNode | CaseNode | ConditionalNode | DecimalNode | FunctionNode | FunctionTypeNode | GroupNode | HoleNode | IdentifierNode | InfixApplicationNode | IntegerNode | KeyofTypeNode | LeftSectionNode | ListNode | ListComprehensionNode | MapTypeNode | OptionalTypeNode | PureNode | RegexNode | ReturnNode | RightSectionNode | StaticApplicationNode | StaticFunctionNode | StringNode | StructNode | TupleNode | TypeNode | TypeHintNode; + patternNodes: (BindingPatternNode | BooleanNode | DecimalNode | DestructuringPatternNode | IntegerNode | PatternGroupNode | RawStringNode | RegexNode | WildcardPatternNode)[]; } export interface CommentNode extends NamedNodeBase { type: SyntaxType.Comment; } +export interface DecimalNode extends NamedNodeBase { + type: SyntaxType.Decimal; +} + export interface EscapeSequenceNode extends NamedNodeBase { type: SyntaxType.EscapeSequence; } @@ -924,6 +766,10 @@ export interface HashBangLineNode extends NamedNodeBase { type: SyntaxType.HashBangLine; } +export interface IntegerNode extends NamedNodeBase { + type: SyntaxType.Integer; +} + export interface RegexFlagsNode extends NamedNodeBase { type: SyntaxType.RegexFlags; } @@ -936,8 +782,8 @@ export interface TypeNode extends NamedNodeBase { type: SyntaxType.Type; } -export interface TypeVariableDeclarationNameNode extends NamedNodeBase { - type: SyntaxType.TypeVariableDeclarationName; +export interface TypePatternNode extends NamedNodeBase { + type: SyntaxType.TypePattern; } export interface WildcardPatternNode extends NamedNodeBase {