import { Comment, Constant } from ".."; import { TokenRange } from "../token"; export declare enum NodeKind { ArithmeticExpression = "ArithmeticExpression", ArrayWrapper = "ArrayWrapper", AsExpression = "AsExpression", AsNullablePrimitiveType = "AsNullablePrimitiveType", AsType = "AsType", CatchExpression = "CatchExpression", Constant = "Constant", Csv = "Csv", EachExpression = "EachExpression", EqualityExpression = "EqualityExpression", ErrorHandlingExpression = "ErrorHandlingExpression", ErrorRaisingExpression = "ErrorRaisingExpression", FieldProjection = "FieldProjection", FieldSelector = "FieldSelector", FieldSpecification = "FieldSpecification", FieldSpecificationList = "FieldSpecificationList", FieldTypeSpecification = "FieldTypeSpecification", FunctionExpression = "FunctionExpression", FunctionType = "FunctionType", GeneralizedIdentifier = "GeneralizedIdentifier", GeneralizedIdentifierPairedAnyLiteral = "GeneralizedIdentifierPairedAnyLiteral", GeneralizedIdentifierPairedExpression = "GeneralizedIdentifierPairedExpression", Identifier = "Identifier", IdentifierExpression = "IdentifierExpression", IdentifierPairedExpression = "IdentifierPairedExpression", IfExpression = "IfExpression", InvokeExpression = "InvokeExpression", IsExpression = "IsExpression", IsNullablePrimitiveType = "IsNullablePrimitiveType", ItemAccessExpression = "ItemAccessExpression", LetExpression = "LetExpression", ListExpression = "ListExpression", ListLiteral = "ListLiteral", ListType = "ListType", LiteralExpression = "LiteralExpression", LogicalExpression = "LogicalExpression", MetadataExpression = "MetadataExpression", NotImplementedExpression = "NotImplementedExpression", NullablePrimitiveType = "NullablePrimitiveType", NullableType = "NullableType", NullCoalescingExpression = "NullCoalescingExpression", OtherwiseExpression = "OtherwiseExpression", Parameter = "Parameter", ParameterList = "ParameterList", ParenthesizedExpression = "ParenthesizedExpression", PrimitiveType = "PrimitiveType", RangeExpression = "RangeExpression", RecordExpression = "RecordExpression", RecordLiteral = "RecordLiteral", RecordType = "RecordType", RecursivePrimaryExpression = "RecursivePrimaryExpression", RelationalExpression = "RelationalExpression", Section = "Section", SectionMember = "SectionMember", TableType = "TableType", TypePrimaryType = "TypePrimaryType", UnaryExpression = "UnaryExpression" } export interface INode { readonly kind: NodeKind; readonly id: number; readonly attributeIndex: number | undefined; readonly tokenRange: TokenRange; readonly isLeaf: boolean; } export type TNode = TDocument | TAuxiliaryNodes; export type TLeaf = GeneralizedIdentifier | Identifier | LiteralExpression | PrimitiveType | TConstant; export type TAuxiliaryNodes = TConstant | FieldSpecification | FieldSpecificationList | FieldTypeSpecification | GeneralizedIdentifier | Identifier | SectionMember | TAnyLiteral | TArrayWrapper | TBinOpExpression | TCsv | TKeyValuePair | TListItem | TNullablePrimitiveType | TPairedConstant | TParameter | TParameterList | TType | TWrapped; export type TArrayWrapper = IArrayWrapper | IArrayWrapper> | IArrayWrapper | IArrayWrapper | IArrayWrapper | TCsvArray; export type TCsvArray = ICsvArray; export type TCsv = ICsv; export type TCsvType = FieldSelector | FieldSpecification | GeneralizedIdentifierPairedAnyLiteral | GeneralizedIdentifierPairedExpression | IdentifierPairedExpression | TParameter | TAnyLiteral | TExpression | TListItem; export type TParameter = IParameter; export type TParameterList = IParameterList; export type TRecursivePrimaryExpression = RecursivePrimaryExpression | InvokeExpression | ItemAccessExpression | TFieldAccessExpression; export type TBinOpExpressionNodeKind = NodeKind.ArithmeticExpression | NodeKind.AsExpression | NodeKind.EqualityExpression | NodeKind.IsExpression | NodeKind.LogicalExpression | NodeKind.NullCoalescingExpression | NodeKind.MetadataExpression | NodeKind.RelationalExpression; export type TKeyValuePair = GeneralizedIdentifierPairedAnyLiteral | GeneralizedIdentifierPairedExpression | IdentifierPairedExpression; export type TKeyValuePairNodeKind = NodeKind.GeneralizedIdentifierPairedAnyLiteral | NodeKind.GeneralizedIdentifierPairedExpression | NodeKind.IdentifierPairedExpression; export type TPairedConstant = AsNullablePrimitiveType | AsType | CatchExpression | EachExpression | ErrorRaisingExpression | IsNullablePrimitiveType | NullablePrimitiveType | NullableType | OtherwiseExpression | TypePrimaryType; export type TPairedConstantNodeKind = NodeKind.AsNullablePrimitiveType | NodeKind.AsType | NodeKind.CatchExpression | NodeKind.EachExpression | NodeKind.ErrorRaisingExpression | NodeKind.IsNullablePrimitiveType | NodeKind.NullablePrimitiveType | NodeKind.NullableType | NodeKind.OtherwiseExpression | NodeKind.TypePrimaryType; export type TWrapped = InvokeExpression | ListExpression | ListLiteral | RecordExpression | RecordLiteral | TParameterList | FieldProjection | FieldSelector | FieldSpecificationList | ItemAccessExpression | ListType | ParenthesizedExpression; export type TWrappedNodeKind = NodeKind.FieldProjection | NodeKind.FieldSelector | NodeKind.FieldSpecificationList | NodeKind.InvokeExpression | NodeKind.ItemAccessExpression | NodeKind.ListExpression | NodeKind.ListLiteral | NodeKind.ListType | NodeKind.ParameterList | NodeKind.ParenthesizedExpression | NodeKind.RecordExpression | NodeKind.RecordLiteral; export type TDocument = Section | TExpression; export interface Section extends INode { readonly kind: NodeKind.Section; readonly isLeaf: false; readonly literalAttributes: RecordLiteral | undefined; readonly sectionConstant: IConstant; readonly name: Identifier | undefined; readonly semicolonConstant: IConstant; readonly sectionMembers: IArrayWrapper; } export interface SectionMember extends INode { readonly kind: NodeKind.SectionMember; readonly isLeaf: false; readonly precedingDirectives: ReadonlyArray | undefined; readonly literalAttributes: RecordLiteral | undefined; readonly sharedConstant: IConstant | undefined; readonly namePairedExpression: IdentifierPairedExpression; readonly semicolonConstant: IConstant; } export type TExpression = TNullCoalescingExpression | EachExpression | FunctionExpression | LetExpression | IfExpression | ErrorRaisingExpression | TErrorHandlingExpression; export type TLogicalExpression = LogicalExpression | TIsExpression; export type TIsExpression = IsExpression | TAsExpression; export type TNullablePrimitiveType = NullablePrimitiveType | PrimitiveType; export type NullablePrimitiveType = IPairedConstant; export type IsNullablePrimitiveType = IPairedConstant; export interface PrimitiveType extends INode { readonly kind: NodeKind.PrimitiveType; readonly isLeaf: true; readonly primitiveTypeKind: Constant.PrimitiveTypeConstant; } export type TAsExpression = AsExpression | TEqualityExpression; export type TEqualityExpression = EqualityExpression | TRelationalExpression; export type TRelationalExpression = RelationalExpression | TArithmeticExpression; export type TArithmeticExpression = ArithmeticExpression | TMetadataExpression; export type TMetadataExpression = MetadataExpression | TUnaryExpression; export type MetadataExpression = IBinOpExpression; export type TUnaryExpression = UnaryExpression | TTypeExpression; export interface UnaryExpression extends INode { readonly kind: NodeKind.UnaryExpression; readonly isLeaf: false; readonly operators: IArrayWrapper>; readonly typeExpression: TTypeExpression; } export type TPrimaryExpression = LiteralExpression | ListExpression | RecordExpression | IdentifierExpression | ParenthesizedExpression | TFieldAccessExpression | TRecursivePrimaryExpression | NotImplementedExpression; export declare enum LiteralKind { List = "List", Logical = "Logical", Null = "Null", Numeric = "Numeric", Record = "Record", Text = "Text" } export interface LiteralExpression extends INode { readonly kind: NodeKind.LiteralExpression; readonly isLeaf: true; readonly literal: string; readonly literalKind: Exclude; } export interface IdentifierExpression extends INode { readonly kind: NodeKind.IdentifierExpression; readonly isLeaf: false; readonly inclusiveConstant: IConstant | undefined; readonly identifier: Identifier; } export interface ParenthesizedExpression extends IParenthesisWrapped { } export interface NotImplementedExpression extends INode { readonly kind: NodeKind.NotImplementedExpression; readonly isLeaf: false; readonly ellipsisConstant: IConstant; } export interface InvokeExpression extends IParenthesisWrapped> { } export type TListItem = TExpression | RangeExpression; export interface ListExpression extends IBraceWrapped> { } export interface RangeExpression extends INode { readonly kind: NodeKind.RangeExpression; readonly isLeaf: false; readonly left: TExpression; readonly rangeConstant: IConstant; readonly right: TExpression; } export type RecordExpression = IBracketWrapped>; export interface ItemAccessExpression extends IBraceWrapped { readonly optionalConstant: IConstant | undefined; } export type TFieldAccessExpression = FieldSelector | FieldProjection; export interface FieldSelector extends IBracketWrapped { readonly optionalConstant: IConstant | undefined; } export interface FieldProjection extends IBracketWrapped> { readonly optionalConstant: IConstant | undefined; } export interface FunctionExpression extends INode { readonly kind: NodeKind.FunctionExpression; readonly isLeaf: false; readonly parameters: IParameterList; readonly functionReturnType: AsNullablePrimitiveType | undefined; readonly fatArrowConstant: IConstant; readonly expression: TExpression; } export type EachExpression = IPairedConstant; export interface LetExpression extends INode { readonly kind: NodeKind.LetExpression; readonly letConstant: IConstant; readonly variableList: ICsvArray; readonly inConstant: IConstant; readonly expression: TExpression; } export interface IfExpression extends INode { readonly kind: NodeKind.IfExpression; readonly isLeaf: false; readonly ifConstant: IConstant; readonly condition: TExpression; readonly thenConstant: IConstant; readonly trueExpression: TExpression; readonly elseConstant: IConstant; readonly falseExpression: TExpression; } export type TTypeExpression = TPrimaryExpression | TypePrimaryType; export type TType = TExpression | TPrimaryType; export type TPrimaryType = PrimitiveType | FunctionType | ListType | NullableType | RecordType | TableType; export interface FunctionType extends INode { readonly kind: NodeKind.FunctionType; readonly isLeaf: false; readonly functionConstant: IConstant; readonly parameters: IParameterList; readonly functionReturnType: AsType; } export interface ListType extends IBraceWrapped { } export type NullableType = IPairedConstant; export interface RecordType extends INode { readonly kind: NodeKind.RecordType; readonly isLeaf: false; readonly fields: FieldSpecificationList; } export interface TableType extends INode { readonly kind: NodeKind.TableType; readonly isLeaf: false; readonly tableConstant: IConstant; readonly rowType: FieldSpecificationList | TPrimaryExpression; } export type ErrorRaisingExpression = IPairedConstant; export declare enum ErrorHandlerKind { Catch = "Catch", Otherwise = "Otherwise" } export interface IErrorHandlingExpression extends INode { readonly kind: NodeKind.ErrorHandlingExpression; readonly handlerKind: K; readonly isLeaf: false; readonly tryConstant: IConstant; readonly protectedExpression: TExpression; readonly handler: H | undefined; } export type ErrorHandlingCatchExpression = IErrorHandlingExpression; export type ErrorHandlingOtherwiseExpression = IErrorHandlingExpression; export type TErrorHandlingExpression = ErrorHandlingCatchExpression | ErrorHandlingOtherwiseExpression; export type CatchExpression = IPairedConstant; export type OtherwiseExpression = IPairedConstant; export interface RecursivePrimaryExpression extends INode { readonly kind: NodeKind.RecursivePrimaryExpression; readonly isLeaf: false; readonly head: TPrimaryExpression; readonly recursiveExpressions: IArrayWrapper; } export type TypePrimaryType = IPairedConstant; export type TAnyLiteral = ListLiteral | LiteralExpression | RecordLiteral; export interface ListLiteral extends IBraceWrapped> { readonly literalKind: LiteralKind.List; } export interface RecordLiteral extends IBracketWrapped> { readonly literalKind: LiteralKind.Record; } export interface IArrayWrapper extends INode { readonly kind: NodeKind.ArrayWrapper; readonly elements: ReadonlyArray; } export type ICsvArray = IArrayWrapper>; export interface ICsv extends INode { readonly kind: NodeKind.Csv; readonly node: T; readonly commaConstant: IConstant | undefined; } export interface IKeyValuePair extends INode { readonly kind: Kind; readonly precedingDirectives: ReadonlyArray | undefined; readonly key: Key; readonly equalConstant: IConstant; readonly value: Value; } export interface IPairedConstant extends INode { readonly kind: Kind; readonly constant: IConstant; readonly paired: Paired; } export interface IWrapped extends INode { readonly kind: Kind; readonly openWrapperConstant: IConstant; readonly content: Content; readonly closeWrapperConstant: IConstant; } export type IBraceWrapped = IWrapped; export type IBracketWrapped = IWrapped; export type IParenthesisWrapped = IWrapped; export type TBinOpExpression = ArithmeticExpression | AsExpression | EqualityExpression | IsExpression | LogicalExpression | MetadataExpression | NullCoalescingExpression | RelationalExpression | TBinOpExpressionSubtype; export type TBinOpExpressionSubtype = IBinOpExpression | IBinOpExpression; export interface IBinOpExpression extends INode { readonly kind: Kind; readonly left: Left; readonly operatorConstant: IConstant; readonly right: Left | Right | IBinOpExpression | IBinOpExpression; } export type ArithmeticExpression = IBinOpExpression; export type AsExpression = IBinOpExpression; export type EqualityExpression = IBinOpExpression; export type IsExpression = IBinOpExpression; export type LogicalExpression = IBinOpExpression; export type RelationalExpression = IBinOpExpression; export type GeneralizedIdentifierPairedAnyLiteral = IKeyValuePair; export interface GeneralizedIdentifierPairedExpression extends IKeyValuePair { } export type IdentifierPairedExpression = IKeyValuePair; export type TParameterType = AsType | AsNullablePrimitiveType | undefined; export type IParameterList = IParenthesisWrapped>>; export interface IParameter extends INode { readonly kind: NodeKind.Parameter; readonly isLeaf: false; readonly optionalConstant: IConstant | undefined; readonly name: Identifier; readonly parameterType: T; } export type AsNullablePrimitiveType = IPairedConstant; export type AsType = IPairedConstant; export interface IConstant extends INode { readonly kind: NodeKind.Constant; readonly isLeaf: true; readonly constantKind: ConstantKind; } export type TConstant = IConstant; export type TBinOpExpressionConstant = IConstant; export type TNullCoalescingExpression = NullCoalescingExpression | TLogicalExpression; export type NullCoalescingExpression = IBinOpExpression; export interface FieldSpecification extends INode { readonly kind: NodeKind.FieldSpecification; readonly isLeaf: false; readonly optionalConstant: IConstant | undefined; readonly name: GeneralizedIdentifier; readonly fieldTypeSpecification: FieldTypeSpecification | undefined; } export interface FieldSpecificationList extends IBracketWrapped> { readonly openRecordMarkerConstant: IConstant | undefined; } export interface FieldTypeSpecification extends INode { readonly kind: NodeKind.FieldTypeSpecification; readonly equalConstant: IConstant; readonly fieldType: TType; } export interface GeneralizedIdentifier extends INode { readonly kind: NodeKind.GeneralizedIdentifier; readonly isLeaf: true; readonly literal: string; } export interface Identifier extends INode { readonly kind: NodeKind.Identifier; readonly isLeaf: true; readonly literal: string; readonly identifierContextKind: IdentifierContextKind; } export declare enum IdentifierContextKind { Key = "Key", Keyword = "Keyword", Parameter = "Parameter", Value = "Value" } export declare const NodeKindsForTFieldAccessExpression: Set; export declare const NodeKindsForTRecursivePrimaryExpression: Set; export declare const NodeKindsForTPrimaryExpression: Set; export declare const NodeKindsForTTypeExpression: Set; export declare const NodeKindsForTUnaryExpression: Set; export declare const NodeKindsForTMetadataExpression: Set; export declare const NodeKindsForTArithmeticExpression: Set; export declare const NodeKindsForTRelationalExpression: Set; export declare const NodeKindsForTEqualityExpression: Set; export declare const NodeKindsForTAsExpression: Set; export declare const NodeKindsForTIsExpression: Set; export declare const NodeKindsForTLogicalExpression: Set; export declare const NodeKindsForTNullablePrimitiveType: Set; export declare const NodeKindsForTNullCoalescingExpression: Set; export declare const NodeKindsForTExpression: Set; export declare const NodeKindsForTListItem: Set; export declare const NodeKindsForTPrimaryType: Set; export declare const NodeKindsForTType: Set; export declare const NodeKindsForTAnyLiteral: Set; export declare const NodeKindsForTLeaf: Set;