grammar refactoring: interpreter_tree, parse_token_types fixed

This commit is contained in:
ProgramSnail 2023-04-09 13:43:01 +03:00
parent 0d98183953
commit ff893d3ebd
2 changed files with 221 additions and 250 deletions

View file

@ -36,45 +36,31 @@ struct Namespace;
// Definitions ----------------- // Definitions -----------------
struct ImportStatement; struct ImportStatement;
struct UsageDefinition; struct AliasDefinitionStatement;
struct AliasDefinition; struct VariableDefinitionStatement;
struct VariableDefinition;
struct FunctionDeclaration; struct FunctionDeclaration;
struct FunctionDefinition; struct FunctionDefinitionStatement;
struct AliasTypeDefinition; struct TypeDefinitionStatement;
struct TypeDefinition; struct AbstractTypeDefinitionStatement;
struct TypeclassDefinition; struct TypeclassDefinitionStatement;
using SourceStatement = std::variant< using SourceStatement = std::variant<
std::unique_ptr<ImportStatement>, std::unique_ptr<ImportStatement>,
std::unique_ptr<UsageDefinition>, std::unique_ptr<AliasDefinitionStatement>,
std::unique_ptr<AliasDefinition>,
std::unique_ptr<VariableDefinition>, // ??
std::unique_ptr<FunctionDeclaration>, std::unique_ptr<FunctionDeclaration>,
std::unique_ptr<FunctionDefinition>, std::unique_ptr<FunctionDefinitionStatement>,
std::unique_ptr<AliasTypeDefinition>, std::unique_ptr<TypeDefinitionStatement>,
std::unique_ptr<TypeDefinition>, std::unique_ptr<AbstractTypeDefinitionStatement>,
std::unique_ptr<TypeclassDefinition>, std::unique_ptr<TypeclassDefinitionStatement>,
std::unique_ptr<Namespace>>; std::unique_ptr<Namespace>>;
// Definition parts // Definition parts
struct ParametrizedType; using ImportSymbol = AnyIdentifier;
struct TupleType;
struct VariantType;
struct ParametrizedTypeclass;
using FunctionDeclarationType = std::variant<
std::unique_ptr<ParametrizedType>,
std::unique_ptr<TupleType>,
std::unique_ptr<VariantType>,
std::unique_ptr<ParametrizedTypeclass>>;
struct DefinedName; struct FunctionDefinition;
struct DefinedAnnotatedName; struct TypeDefinition;
struct DefinedType;
struct DefinedTypeclass;
struct DefinitionParameter; struct DefinitionParameter;
struct DefinitionArgument;
// Flow control ----------------- // Flow control -----------------
@ -99,30 +85,34 @@ struct Block;
// //
struct NameSuperExpression; struct NameExpression;
struct ScopedStatement; struct ScopedStatement;
enum class LoopControlExpression {
Break,
Continue,
};
using SubExpressionToken = std::variant< using SubExpressionToken = std::variant<
std::unique_ptr<NameSuperExpression>, std::unique_ptr<NameExpression>,
std::unique_ptr<ScopedStatement>>; std::unique_ptr<ScopedStatement>>;
// //
struct FunctionCallExpression; struct FunctionCallExpression;
struct BinaryOperatorExpression; struct BinaryOperatorExpression;
struct ArrayExpression;
struct ReferenceExpression;
using SubExpression = std::variant< using SubExpression = std::variant<
std::unique_ptr<FunctionCallExpression>, std::unique_ptr<FunctionCallExpression>,
std::unique_ptr<BinaryOperatorExpression>, std::unique_ptr<BinaryOperatorExpression>,
std::unique_ptr<SubExpressionToken>>; std::unique_ptr<SubExpressionToken>,
std::unique_ptr<ArrayExpression>,
std::unique_ptr<ReferenceExpression>>;
// //
enum class LoopControlExpression {
Break,
Continue,
};
struct ReturnExpression; struct ReturnExpression;
using PrefixedExpression = std::variant< using PrefixedExpression = std::variant<
@ -156,73 +146,95 @@ using SuperExpression = std::variant<
// //
struct ScopedStatement; // ?? scoped statement is _superexpression ?? struct ScopedStatement;
// Operators // Operators
struct BinaryOperatorExpression; struct BinaryOperatorExpression;
struct UnaryOperatorExpression; struct UnaryOperatorExpression;
struct ReferenceExpression;
// Simple Expressions // Other Expressions
struct FunctionCallExpression; struct FunctionCallExpression;
struct TypeExpression;
using FunctionArgument = std::variant<
SubExpressionToken,
std::unique_ptr<TypeExpression>>;
struct TupleExpression; struct TupleExpression;
struct VariantExpression; struct VariantExpression;
struct ReturnExpression; struct ReturnExpression;
// Lambda struct TypeConstructor;
struct LambdaFunction; struct LambdaFunction;
struct ArrayExpression;
// Name // Name
struct NameSuperExpression;
struct NameExpression; struct NameExpression;
struct TupleName; struct TupleName;
struct VariantName; struct VariantName;
struct AnnotatedName; struct AnnotatedName;
// // ScopedAnyName <-> AnyName
using AnyName = std::variant< using AnyName = std::variant<
std::unique_ptr<AnnotatedName>, std::unique_ptr<AnnotatedName>,
std::unique_ptr<TupleName>, std::unique_ptr<TupleName>,
std::unique_ptr<VariantName>>; std::unique_ptr<VariantName>>;
using ScopedAnyName = AnyName;
// Type, typeclass, etc. -----------------
// Type // Type
struct TypeConstructor; struct FunctionType;
// // TypeOrAnyType <-> AnyType
struct TupleType; struct TupleType;
struct VariantType; struct VariantType;
struct VariantType;
struct AnnotatedType;
struct ParametrizedType;
struct TypeExpression;
using Constructor = std::string;
// // ScopedAnyType <-> AnyType
using AnyType = std::variant< using AnyType = std::variant<
std::unique_ptr<ParametrizedType>, std::unique_ptr<ParametrizedType>,
std::unique_ptr<TupleType>, std::unique_ptr<TupleType>,
std::unique_ptr<VariantType>>; std::unique_ptr<VariantType>,
std::unique_ptr<FunctionType>>;
// // TypeIdentifierDefinition <-> some '.' + TypeIdentifier using ScopedAnyType = AnyType;
using TypeIdentifierDefinition = std::string;
struct AnnotatedType; struct ExtendedScopedAnyType;
// // TypeAnnotations - inplace ??
struct ParametrizedType; // Typeclass
struct TypeExpression;
struct ParametrizedTypeclass;
struct TypeclassExpression;
using TypeclassUsage = std::variant<
std::unique_ptr<TypeclassExpression>,
std::unique_ptr<ParametrizedTypeclass>>;
// Typeclass & Type
using TypeParameter = std::variant<
std::unique_ptr<TypeExpression>,
std::unique_ptr<ParametrizedType>>;
using TypeSubExpression = std::variant< using TypeSubExpression = std::variant<
std::unique_ptr<AnyTypeIdentifier>, std::unique_ptr<AnyTypeIdentifier>,
std::unique_ptr<ParametrizedType>>; std::unique_ptr<ParametrizedType>>;
// Typeclass
struct AnnotatedTypeclass;
struct ParametrizedTypeclass;
struct TypeclassExpression;
// Comments [IGNORE] ----------------- // Comments [IGNORE] -----------------
// Identifiers, constants, etc. ----------------- // Identifiers, constants, etc. -----------------
using ExtendedName = std::string;
struct FloatNumberLiteral; struct FloatNumberLiteral;
struct NumberLiteral; struct NumberLiteral;
struct StringLiteral; struct StringLiteral;
@ -236,143 +248,115 @@ using Literal = std::variant<
// //
using NameSubSuperExpression = std::variant< using NameSubExpression = std::variant<
std::unique_ptr<NameIdentifier>, std::unique_ptr<NameIdentifier>,
std::unique_ptr<Literal>, std::unique_ptr<Literal>,
std::unique_ptr<SuperExpression>>; std::unique_ptr<SuperExpression>>;
enum class ReferenceType {
Reference,
UniqueReference,
};
////////////////////////////////////////////////////////////////////////////////////////////
// ----------------- Sources ----------------- // ----------------- Sources -----------------
struct SourceFile : public Node { struct SourceFile {
std::vector<std::variant<SourceStatement, Partition>> statements; std::vector<std::variant<SourceStatement, Partition>> statements;
}; };
struct Sources : public Node { struct Sources {
std::vector<SourceStatement> statements; std::vector<SourceStatement> statements;
}; };
// ----------------- Namespaces, partittions ----------------- // ----------------- Namespaces, partittions -----------------
struct Partition : public Node { struct Namespace {
enum PartitionType { bool is_const;
std::optional<ExtendedName> name;
TypeIdentifier type;
std::unique_ptr<Sources> scope;
};
struct Partition {
enum PartitionName {
Test, Test,
Interface, Interface,
Core, Core,
Lib, Lib,
Module, // rename ?? Module,
Exe, Exe,
}; };
PartitionType type; PartitionName name;
std::unique_ptr<Sources> scope;
};
struct Namespace : public Node {
bool is_const;
std::variant<
std::unique_ptr<DefinedAnnotatedName>,
std::unique_ptr<DefinedType>> name;
// TODO add const / var specification
std::unique_ptr<Sources> scope; std::unique_ptr<Sources> scope;
}; };
// ----------------- Definitions ----------------- // ----------------- Definitions -----------------
struct TypeclassExpression; struct ImportStatement {
struct TypeExpression; std::optional<TypeIdentifier> name;
struct NameExpression;
using ImportSymbol = std::variant<
std::unique_ptr<TypeclassExpression>,
std::unique_ptr<TypeExpression>,
std::unique_ptr<NameExpression>>;
//
struct ImportStatement : public Node {
std::string module_name; std::string module_name;
std::vector<ImportSymbol> symbols; std::vector<ImportSymbol> symbols;
}; };
struct UsageDefinition : public Node { struct AliasDefinitionStatement {
TypeIdentifier name; // rename ?? TypeIdentifier type;
std::unique_ptr<ImportStatement> import_statement; std::vector<AbstractTypeIdentifier> parameters;
};
struct AliasDefinition : public Node {
std::unique_ptr<DefinedType> type;
std::unique_ptr<ParametrizedType> value; std::unique_ptr<ParametrizedType> value;
}; };
struct VariableDefinition : public Node { struct VariableDefinitionStatement {
bool is_const; // default value ?? enum { Var, Const } modifier;
NameIdentifier name; AnyName name;
SuperExpression value; SuperExpression value;
}; };
struct FunctionDeclaration : public Node { struct FunctionDeclaration {
NameOrOperatorIdentifier name; NameOrOperatorIdentifier name;
std::vector<std::unique_ptr<DefinitionParameter>> parameters; std::vector<std::unique_ptr<DefinitionParameter>> parameters;
std::vector<FunctionDeclarationType> argument_types; std::unique_ptr<FunctionType> type;
}; };
struct FunctionDefinition : public Node { struct FunctionDefinitionStatement {
std::unique_ptr<DefinedName> name; std::unique_ptr<FunctionDefinition> definition;
SuperExpression value; SuperExpression value;
}; };
struct AliasTypeDefinition : public Node { struct TypeDefinitionStatement {
std::unique_ptr<DefinedType> type; enum { Struct, Class } modifier;
std::unique_ptr<ParametrizedType> value; std::unique_ptr<TypeDefinition> definition;
};
struct TypeDefinition : public Node {
bool is_class; // class vs struct
std::unique_ptr<DefinedType> type;
AnyType value; AnyType value;
}; };
struct TypeclassDefinition : public Node { struct AbstractTypeDefinitionStatement {
std::unique_ptr<DefinedTypeclass> typeclass; enum { Basic, Abstract } modifier;
std::unique_ptr<AnnotatedType> definition;
};
struct TypeclassDefinitionStatement {
std::unique_ptr<TypeDefinition> definition;
std::vector<std::unique_ptr<FunctionDeclaration>> requirements; std::vector<std::unique_ptr<FunctionDeclaration>> requirements;
}; };
// Definition parts ----------------- // Definition parts -----------------
struct DefinedName : public Node { struct FunctionDefinition {
bool is_operator = false; // other format ?? enum { Operator, Function } modifier;
NameOrOperatorIdentifier name; // function name or operator NameOrOperatorIdentifier name;
std::vector<std::unique_ptr<DefinitionParameter>> parameters; std::vector<std::unique_ptr<DefinitionParameter>> parameters;
std::vector<std::unique_ptr<DefinitionArgument>> arguments; std::vector<ExtendedName> arguments;
}; };
struct DefinedAnnotatedName : public Node { struct TypeDefinition {
NameIdentifier name;
std::variant<
std::unique_ptr<DefinedType>,
std::unique_ptr<DefinedTypeclass>> type;
};
struct DefinedType : public Node {
std::unique_ptr<AnnotatedType> type; std::unique_ptr<AnnotatedType> type;
std::vector<std::unique_ptr<DefinitionParameter>> parameters; std::vector<std::unique_ptr<DefinitionParameter>> parameters;
std::vector<std::unique_ptr<DefinitionArgument>> arguments;
}; };
struct DefinedTypeclass : public Node { struct DefinitionParameter {
std::unique_ptr<AnnotatedTypeclass> typeclass;
std::vector<std::unique_ptr<DefinitionParameter>> parameters;
std::vector<std::unique_ptr<DefinitionArgument>> arguments;
};
struct DefinitionParameter : public Node {
AbstractTypeIdentifier type; AbstractTypeIdentifier type;
std::vector<std::unique_ptr<ParametrizedTypeclass>> typeclasses; std::vector<std::unique_ptr<TypeclassUsage>> typeclasses;
};
struct DefinitionArgument : public Node {
NameIdentifier name;
std::vector<std::unique_ptr<ParametrizedType>> types; // TODO: one type
}; };
// ----------------- Flow control ----------------- // ----------------- Flow control -----------------
@ -383,33 +367,33 @@ struct MatchCase {
std::optional<Expression> statement; std::optional<Expression> statement;
}; };
struct Match : public Node { struct Match {
Expression value; Expression value;
std::vector<MatchCase> matches; std::vector<MatchCase> matches;
}; };
struct Condition : public Node { struct Condition {
std::vector<Expression> conditions; // if, elif std::vector<Expression> conditions; // if, elif
std::vector<Expression> statements; // if, elif, else std::vector<Expression> statements; // if, elif, else
}; };
struct DoWhileLoop : public Node { struct DoWhileLoop {
Expression condition; Expression condition;
Expression statement; Expression statement;
}; };
struct WhileLoop : public Node { struct WhileLoop {
Expression condition; Expression condition;
Expression statement; Expression statement;
}; };
struct ForLoop : public Node { struct ForLoop {
AnyName variable; AnyName variable;
Expression interval; Expression interval;
Expression statement; Expression statement;
}; };
struct LoopLoop : public Node { struct LoopLoop {
Expression statement; Expression statement;
}; };
@ -417,140 +401,137 @@ struct LoopLoop : public Node {
using BlockStatement = std::variant< using BlockStatement = std::variant<
std::unique_ptr<Expression>, std::unique_ptr<Expression>,
std::unique_ptr<AliasDefinition>, std::unique_ptr<VariableDefinitionStatement>,
std::unique_ptr<VariableDefinition>,
std::unique_ptr<FlowControl>, std::unique_ptr<FlowControl>,
std::unique_ptr<PrefixedExpression>>; std::unique_ptr<PrefixedExpression>>;
struct Block : public Node { struct Block {
std::vector<BlockStatement> statements; std::vector<BlockStatement> statements;
}; };
struct ScopedStatement : public Node { struct ScopedStatement {
SuperExpression statement; SuperExpression statement;
}; };
// Operators ----------------- // Operators -----------------
struct BinaryOperatorExpression : public Node { struct BinaryOperatorExpression {
OperatorIdentifier operator_name; OperatorIdentifier operator_name;
SubExpression left_expression; SubExpression left_expression;
SubExpression right_expression; SubExpression right_expression;
}; };
struct UnaryOperatorExpression : public Node { // TODO fix prescendence struct UnaryOperatorExpression {
OperatorIdentifier operator_name; OperatorIdentifier operator_name;
Expression expression; Expression expression;
}; };
struct ReferenceExpression {
std::vector<ReferenceType> references;
ScopedStatement expression;
}
// Simple Expressions ----------------- // Simple Expressions -----------------
using FunctionArgument = std::variant< struct FunctionCallExpression {
std::unique_ptr<SubExpressionToken>, std::unique_ptr<NameExpression> name;
std::unique_ptr<TypeSubExpression>>;
struct FunctionCallExpression : public Node {
std::unique_ptr<NameSuperExpression> name;
std::vector<FunctionArgument> arguments; std::vector<FunctionArgument> arguments;
}; };
struct TupleExpression : public Node { struct TupleExpression {
std::vector<SubExpression> expressions; std::vector<SubExpression> expressions;
}; };
struct VariantExpression : public Node { struct VariantExpression {
std::vector<SubExpression> expressions; std::vector<SubExpression> expressions;
}; };
struct ReturnExpression : public Node { struct ReturnExpression {
Expression expression; Expression expression;
}; };
// Lambda ----------------- struct TypeConstructor {
std::unique_ptr<ParametrizedType> type;
std::vector<std::pair<ExtendedName, SubExpression>> parameters;
};
struct LambdaFunction : public Node { struct LambdaFunction {
std::vector<std::unique_ptr<DefinitionParameter>> parameters; std::vector<std::unique_ptr<DefinitionParameter>> parameters;
std::vector<std::unique_ptr<DefinitionArgument>> arguments; std::vector<ExtendedName> arguments;
Expression expression; Expression expression;
}; };
struct ArrayExpression {
std::vector<Expression> elements;
};
// Name ----------------- // Name -----------------
struct NameSuperExpression : public Node { struct NameExpression {
std::vector<TypeSubExpression> namespaces; std::vector<TypeSubExpression> namespaces;
std::vector<NameSubSuperExpression> expressions; std::vector<NameSubExpression> expressions;
}; };
struct NameExpression : public Node { struct TupleName {
std::vector<TypeSubExpression> namespaces; std::vector<std::unique_ptr<ScopedAnyName>> names;
std::vector<NameIdentifier> names;
}; };
struct TupleName : public Node { struct VariantName {
std::vector<std::unique_ptr<AnnotatedName>> names; std::vector<std::unique_ptr<ScopedAnyName>> names;
}; };
struct VariantName : public Node { struct AnnotatedName {
std::vector<std::unique_ptr<AnnotatedName>> names;
};
struct AnnotatedName : public Node {
NameIdentifier name; NameIdentifier name;
std::optional<std::unique_ptr<ParametrizedType>> type; // optional std::optional<std::unique_ptr<ScopedAnyType>> type;
}; };
// TODO ?? mark all optional fields ?? // TODO ?? mark all optional fields ??
// Type ----------------- // Type -----------------
struct TypeConstructor : public Node { struct FunctionType {
std::unique_ptr<ParametrizedType> type; std::vector<ScopedAnyType> types;
std::vector<std::pair<NameIdentifier, SubExpression>> parameters;
}; };
struct TupleType : public Node { struct TupleType {
std::optional<TypeIdentifierDefinition> type; std::optional<Constructor> type;
std::vector<std::pair<std::optional<NameIdentifier>, AnyType>> entities; std::vector<std::pair<std::optional<ExtendedName>, ExtendedScopedAnyType>> entities;
}; };
struct VariantType : public Node { struct VariantType {
std::optional<TypeIdentifierDefinition> type; std::optional<Constructor> type;
std::vector<std::variant<TypeIdentifierDefinition, std::unique_ptr<TupleType>>> constructors; std::vector<std::variant<Constructor, std::unique_ptr<TupleType>>> constructors;
}; };
struct AnnotatedType : public Node { struct AnnotatedType {
std::unique_ptr<TypeExpression> type_expression; std::unique_ptr<TypeExpression> type_expression;
std::vector<std::unique_ptr<ParametrizedTypeclass>> annotations; std::vector<std::unique_ptr<TypeclassUsage>> annotations;
}; };
using TypeParameter = std::variant< struct ParametrizedType {
std::unique_ptr<TypeExpression>,
std::unique_ptr<ParametrizedType>,
std::unique_ptr<Expression>>;
struct ParametrizedType : public Node {
std::unique_ptr<TypeExpression> type_expression; std::unique_ptr<TypeExpression> type_expression;
std::vector<TypeParameter> parameters; std::vector<TypeParameter> parameters;
}; };
struct TypeExpression : public Node { struct TypeExpression {
std::vector<TypeSubExpression> namespaces; std::vector<TypeSubExpression> namespaces;
AnyTypeIdentifier type; AnyTypeIdentifier type;
std::optional<size_t> ArraySize; // if array; 0 - dynamic size
}; };
struct ExtendedScopedAnyType {
std::vector<ReferenceType> references;
AnyType type;
}
// Typeclass ----------------- // Typeclass -----------------
struct AnnotatedTypeclass : public Node { struct ParametrizedTypeclass {
std::unique_ptr<TypeclassExpression> typeclass_expression;
std::vector<std::unique_ptr<ParametrizedTypeclass>> annotations;
};
struct ParametrizedTypeclass : public Node {
std::unique_ptr<TypeclassExpression> typeclass_expression; std::unique_ptr<TypeclassExpression> typeclass_expression;
std::vector<TypeParameter> parameters; std::vector<TypeParameter> parameters;
}; };
struct TypeclassExpression : public Node { struct TypeclassExpression {
std::vector<TypeSubExpression> namespaces; std::vector<TypeSubExpression> namespaces;
TypeclassIdentifier typeclass; TypeclassIdentifier typeclass;
}; };
@ -558,19 +539,19 @@ struct TypeclassExpression : public Node {
// ----------------- Comments [IGNORE] ----------------- // ----------------- Comments [IGNORE] -----------------
// ----------------- Identifiers, constants, etc. ----------------- // ----------------- Identifiers, constants, etc. -----------------
struct FloatNumberLiteral : public Node { struct FloatNumberLiteral {
double value; double value;
}; };
struct NumberLiteral : public Node { struct NumberLiteral {
int64_t value; int64_t value;
}; };
struct StringLiteral : public Node { struct StringLiteral {
std::string value; std::string value;
}; };
struct CharLiteral : public Node { struct CharLiteral {
char value; char value;
}; };

View file

@ -8,124 +8,116 @@ namespace parser::tokens {
const std::string SourceFile = "source_file"; const std::string SourceFile = "source_file";
const std::string Sources = "sources"; const std::string Sources = "sources";
const std::string SourceStatement = "source_statement";
// Namespaces, partitions ----------------- // Namespaces, partitions -----------------
const std::string Partition = "partition";
const std::string Namespace = "namespace"; const std::string Namespace = "namespace";
const std::string Partition = "partition";
const std::string PartitionName = "partition_name";
// Definitions ----------------- // Definitions -----------------
const std::string ImportStatement = "import_statement"; const std::string ImportStatement = "import_statement";
const std::string UsageDefinition = "usage_definition"; const std::string AliasDefinitionStatement = "alias_definition_statement";
const std::string AliasDefinition = "alias_definition"; const std::string VariableDefinitionStatement = "variable_definition_statement";
const std::string VariableDefinition = "variable_definition";
const std::string FunctionDeclaration = "function_declaration"; const std::string FunctionDeclaration = "function_declaration";
const std::string FunctionDefinition = "function_definition"; const std::string FunctionDefinitionStatement = "function_definition_statement";
const std::string AliasTypeDefinition = "alias_type_definition"; const std::string TypeDefinitionStatement = "type_definition_statement";
const std::string TypeDefinition = "type_definition"; const std::string AbstractTypeDefinitionStatement = "abstract_type_definition_statement";
const std::string TypeclassDefinition = "typeclass_definition"; const std::string TypeclassDefinitionStatement = "typeclass_definition_statement";
const std::string SourceStatement = "source_statement";
const std::string ImportSymbol = "import_symbol";
// Definition parts // Definition parts
const std::string DefinedName = "defined_name"; const std::string ImportSymbol = "import_symbol";
const std::string DefinedAnnotatedName = "defined_annotated_name"; const std::string FunctionDefinition = "function_definition";
const std::string DefinedType = "defined_type"; const std::string TypeDefinition = "type_definition";
const std::string DefinedTypeclass = "defined_typeclass";
const std::string DefinitionParameter = "definition_parameter"; const std::string DefinitionParameter = "definition_parameter";
const std::string DefinitionArgument = "definition_argument";
const std::string FunctionDeclarationType = "function_declaration_type";
// Flow control ----------------- // Flow control -----------------
const std::string MatchCase = "match_case";
const std::string Match = "match"; const std::string Match = "match";
const std::string Condition = "condition"; const std::string Condition = "condition";
const std::string DoWhileLoop = "do_while_loop"; const std::string DoWhileLoop = "do_while_loop";
const std::string WhileLoop = "while_loop"; const std::string WhileLoop = "while_loop";
const std::string ForLoop = "for_loop"; const std::string ForLoop = "for_loop";
const std::string LoopLoop = "loop_loop"; const std::string LoopLoop = "loop_loop";
const std::string FlowControl = "flow_control"; const std::string FlowControl = "flow_control";
// Statements, expressions, blocks, etc. ----------------- // Statements, expressions, blocks, etc. -----------------
const std::string BlockStatement = "block_statement";
const std::string Block = "block"; const std::string Block = "block";
const std::string ScopedStatement = "scoped_statement";
const std::string LoopControlExpression = "loop_control_expression";
const std::string SubExpressionToken = "subexpression_token"; const std::string SubExpressionToken = "subexpression_token";
const std::string SubExpression = "subexpression"; const std::string SubExpression = "subexpression";
const std::string PrefixedExpression = "prefixed_expression"; const std::string PrefixedExpression = "prefixed_expression";
const std::string Expression = "expression"; const std::string Expression = "expression";
const std::string SuperExpression = "superexpression"; const std::string SuperExpression = "superexpression";
const std::string ScopedStatement = "scoped_statement";
const std::string BlockStatement = "block_statement";
// Operators // Operators
const std::string BinaryOperatorExpression = "binary_operator_expression"; const std::string BinaryOperatorExpression = "binary_operator_expression";
const std::string UnaryOperatorExpression = "unary_operator_expression"; const std::string UnaryOperatorExpression = "unary_operator_expression";
const std::string ReferenceExpression = "reference_expression";
// Simple Expressions // Other expressions
const std::string FunctionArgument = "function_argument";
const std::string FunctionCallExpression = "function_call_expression"; const std::string FunctionCallExpression = "function_call_expression";
const std::string TupleExpression = "tuple_expression"; const std::string TupleExpression = "tuple_expression";
const std::string VariantExpression = "variant_expression"; const std::string VariantExpression = "variant_expression";
const std::string ReturnExpression = "return_expression"; const std::string ReturnExpression = "return_expression";
const std::string TypeConstructor = "type_constructor";
const std::string FunctionArgument = "function_argument";
// Lambda
const std::string LambdaFunction = "lambda_function"; const std::string LambdaFunction = "lambda_function";
const std::string ArrayExpression = "array_expression";
const std::string LoopControlExpression = "loop_control_expression";
// Name // Name
const std::string NameSuperExpression = "name_superexpression";
const std::string NameExpression = "name_expression"; const std::string NameExpression = "name_expression";
const std::string TupleName = "tuple_name"; const std::string TupleName = "tuple_name";
const std::string VariantName = "variant_name"; const std::string VariantName = "variant_name";
const std::string AnnotatedName = "annotated_name"; const std::string AnnotatedName = "annotated_name";
const std::string NameSubExpression = "name_subexpression";
const std::string AnyName = "any_name"; const std::string AnyName = "any_name";
const std::string ScopedAnyName = "scoped_any_name";
// Type, typeclass, etc. -----------------
// Type // Type
const std::string TypeConstructor = "type_constructor"; const std::string FunctionType = "function_type";
const std::string TupleType = "tuple_type"; const std::string TupleType = "tuple_type";
const std::string VariantType = "variant_type"; const std::string VariantType = "variant_type";
const std::string AnnotatedType = "annotated_type"; const std::string AnnotatedType = "annotated_type";
const std::string ParametrizedType = "parametrized_type"; const std::string ParametrizedType = "parametrized_type";
const std::string TypeExpression = "type_expression"; const std::string TypeExpression = "type_expression";
const std::string Constructor = "constructor";
const std::string AnyType = "any_type"; const std::string AnyType = "any_type";
const std::string TypeSubExpression = "type_subexpression"; const std::string ScopedAnyType = "scoped_any_type";
const std::string ExtendedScopedAnyType = "extended_scoped_any_type";
const std::string TypeParameter = "type_parameter";
// Typeclass // Typeclass
const std::string AnnotatedTypeclass = "annotated_typeclass"; const std::string TypeclassUsage = "typeclass_usage";
const std::string ParametrizedTypeclass = "parametrized_typeclass"; const std::string ParametrizedTypeclass = "parametrized_typeclass";
const std::string TypeclassExpression = "typeclass_expression"; const std::string TypeclassExpression = "typeclass_expression";
// Typeclass & Type
const std::string TypeParameter = "type_parameter";
const std::string TypeSubExpression = "type_subexpression";
// Identifiers, constants, etc. ----------------- // Identifiers, constants, etc. -----------------
const std::string TypeIdentifierDefinition = "type_identifier_definition"; const std::string ExtendedName = "extended_name";
const std::string TypeclassIdentifier = "typeclass_identifier"; const std::string TypeclassIdentifier = "typeclass_identifier";
const std::string NameIdentifier = "name_identifier"; const std::string NameIdentifier = "name_identifier";
const std::string TypeIdentifier = "type_identifier"; const std::string TypeIdentifier = "type_identifier";
const std::string AbstractTypeIdentifier = "abstract_type_identifier"; const std::string AbstractTypeIdentifier = "abstract_type_identifier";
const std::string OperatorIdentifier = "operator";
const std::string OperatorIdentifier = "operator_identifier";
//
const std::string FloatNumberLiteral = "float_number_literal"; const std::string FloatNumberLiteral = "float_number_literal";
const std::string NumberLiteral = "number_literal"; const std::string NumberLiteral = "number_literal";
@ -134,6 +126,4 @@ const std::string CharLiteral = "char_literal";
const std::string Literal = "literal"; const std::string Literal = "literal";
const std::string NameSubSuperExpression = "name_subsuperexpression";
} // namespace parser::tokens } // namespace parser::tokens