#pragma once #include namespace tokens { enum class Type { // --- sources SOURCE_FILE, IMPORT, CONSTRAINT, // --- definitions FUNCTION_DEFINITION, TYPE_DEFINITION, // datatype or typeclass // --- flow control CASE, MATCH, CONDITION, LOOP, // --- operators COMMA_EXPRESSION, OPERATOR_EXPRESSION, // --- continers BLOCK, ARRAY, // --- modifiers RETURN, NAME_DEFINITION, ARRAY_ACCESS, TUPLE_ACCESS, LOOP_CONTROL, REFERENCE_EXPRESSION, SUFFIX_EXPRESSION, // --- other NAME_EXPRESSION, CONSTRUCTOR, LAMBDA, // --- type VARIANT_TYPE, TUPLE_TYPE, FUNCTION_TYPE, ARRAY_TYPE, REFERENCE_TYPE, MODIFIED_TYPE, SIMPLE_TYPE, // --- comments DEFINITION_INFO, ANNOTATION_INFO, EXTRA, EMPTY_LINES, // --- tokens PLACEHOLDER, SIMPLE_NAME_IDENTIFIER, SIMPLE_TYPE_IDENTIFIER, TYPECLASS_IDENTIFIER, ARGUMENT_NAME_IDENTIFIER, ARGUMENT_TYPE_IDENTIFIER, ANNOTATION_IDENTIFIER, OPERATOR, OPERATOR_TAIL1, OPERATOR_TAIL2, OPERATOR_TAIL3, FLOAT_LITERAL, DOUBLE_LITERAL, INT_LITERAL, LONG_LITERAL, INDEX_LITERAL, STRING_LITERAL, UNICODE_STRING_LITERAL, CHAR_LITERAL, UNICODE_LITERAL, BOOL_LITERAL, UNIT_LITERAL, NULL_LITERAL, // --- UNDEFINED, }; // --- sources const static std::string SOURCE_FILE = "source_file"; const static std::string IMPORT = "import"; const static std::string CONSTRAINT = "constraint"; // --- definitions const static std::string FUNCTION_DEFINITION = "function_definition"; const static std::string TYPE_DEFINITION = "type_definition"; // --- flow control const static std::string CASE = "case"; const static std::string MATCH = "match"; const static std::string CONDITION = "condition"; const static std::string LOOP = "loop"; // --- operators const static std::string COMMA_EXPRESSION = "comma_expression"; const static std::string OPERATOR_EXPRESSION = "operator_expression"; // --- continers const static std::string BLOCK = "block"; const static std::string ARRAY = "array"; // --- modifiers const static std::string RETURN = "return"; const static std::string NAME_DEFINITION = "name_definition"; const static std::string ARRAY_ACCESS = "array_access"; const static std::string TUPLE_ACCESS = "tuple_access"; const static std::string LOOP_CONTROL = "loop_control"; const static std::string REFERENCE_EXPRESSION = "reference_expression"; const static std::string SUFFIX_EXPRESSION = "suffix_expression"; // --- other const static std::string NAME_EXPRESSION = "name_expression"; const static std::string CONSTRUCTOR = "constructor"; const static std::string LAMBDA = "lambda"; // --- type const static std::string VARIANT_TYPE = "variant_type"; const static std::string TUPLE_TYPE = "tuple_type"; const static std::string FUNCTION_TYPE = "function_type"; const static std::string ARRAY_TYPE = "array_type"; const static std::string REFERENCE_TYPE = "reference_type"; const static std::string MODIFIED_TYPE = "modified_type"; const static std::string SIMPLE_TYPE = "simple_type"; // --- comments const static std::string DEFINITION_INFO = "definition_info"; const static std::string ANNOTATION_INFO = "annotation_info"; const static std::string EXTRA = "extra"; const static std::string EMPTY_LINES = "empty_lines"; // --- tokens const static std::string PLACEHOLDER = "placeholder"; const static std::string SIMPLE_NAME_IDENTIFIER = "simple_name_identifier"; const static std::string SIMPLE_TYPE_IDENTIFIER = "simple_type_identifier"; const static std::string TYPECLASS_IDENTIFIER = "typeclass_identifier"; const static std::string ARGUMENT_NAME_IDENTIFIER = "argument_name_identifier"; const static std::string ARGUMENT_TYPE_IDENTIFIER = "argument_type_identifier"; const static std::string ANNOTATION_IDENTIFIER = "annotation_identifier"; const static std::string OPERATOR = "operator"; const static std::string OPERATOR_TAIL1 = "operator_tail1"; const static std::string OPERATOR_TAIL2 = "operator_tail2"; const static std::string OPERATOR_TAIL3 = "operator_tail3"; const static std::string FLOAT_LITERAL = "float_literal"; const static std::string DOUBLE_LITERAL = "double_literal"; const static std::string INT_LITERAL = "int_literal"; const static std::string LONG_LITERAL = "long_literal"; const static std::string INDEX_LITERAL = "index_literal"; const static std::string STRING_LITERAL = "string_literal"; const static std::string UNICODE_STRING_LITERAL = "unicode_string_literal"; const static std::string CHAR_LITERAL = "char_literal"; const static std::string UNICODE_LITERAL = "unicode_literal"; const static std::string BOOL_LITERAL = "bool_literal"; const static std::string UNIT_LITERAL = "unit_literal"; const static std::string NULL_LITERAL = "null_literal"; inline Type string_to_type(const std::string &str) { if (str == SOURCE_FILE) { return Type::SOURCE_FILE; } else if (str == IMPORT) { return Type::IMPORT; } else if (str == CONSTRAINT) { return Type::CONSTRAINT; } else if (str == FUNCTION_DEFINITION) { return Type::FUNCTION_DEFINITION; } else if (str == TYPE_DEFINITION) { return Type::TYPE_DEFINITION; } else if (str == CASE) { return Type::CASE; } else if (str == MATCH) { return Type::MATCH; } else if (str == CONDITION) { return Type::CONDITION; } else if (str == LOOP) { return Type::LOOP; } else if (str == COMMA_EXPRESSION) { return Type::COMMA_EXPRESSION; } else if (str == OPERATOR_EXPRESSION) { return Type::OPERATOR_EXPRESSION; } else if (str == BLOCK) { return Type::BLOCK; } else if (str == ARRAY) { return Type::ARRAY; } else if (str == RETURN) { return Type::RETURN; } else if (str == NAME_DEFINITION) { return Type::NAME_DEFINITION; } else if (str == ARRAY_ACCESS) { return Type::ARRAY_ACCESS; } else if (str == TUPLE_ACCESS) { return Type::TUPLE_ACCESS; } else if (str == LOOP_CONTROL) { return Type::LOOP_CONTROL; } else if (str == REFERENCE_EXPRESSION) { return Type::REFERENCE_EXPRESSION; } else if (str == SUFFIX_EXPRESSION) { return Type::SUFFIX_EXPRESSION; } else if (str == NAME_EXPRESSION) { return Type::NAME_EXPRESSION; } else if (str == CONSTRUCTOR) { return Type::CONSTRUCTOR; } else if (str == LAMBDA) { return Type::LAMBDA; } else if (str == VARIANT_TYPE) { return Type::VARIANT_TYPE; } else if (str == TUPLE_TYPE) { return Type::TUPLE_TYPE; } else if (str == FUNCTION_TYPE) { return Type::FUNCTION_TYPE; } else if (str == ARRAY_TYPE) { return Type::ARRAY_TYPE; } else if (str == REFERENCE_TYPE) { return Type::REFERENCE_TYPE; } else if (str == MODIFIED_TYPE) { return Type::MODIFIED_TYPE; } else if (str == SIMPLE_TYPE) { return Type::SIMPLE_TYPE; } else if (str == DEFINITION_INFO) { return Type::DEFINITION_INFO; } else if (str == ANNOTATION_INFO) { return Type::ANNOTATION_INFO; } else if (str == EXTRA) { return Type::EXTRA; } else if (str == EMPTY_LINES) { return Type::EMPTY_LINES; } else if (str == PLACEHOLDER) { return Type::PLACEHOLDER; } else if (str == SIMPLE_NAME_IDENTIFIER) { return Type::SIMPLE_NAME_IDENTIFIER; } else if (str == SIMPLE_TYPE_IDENTIFIER) { return Type::SIMPLE_TYPE_IDENTIFIER; } else if (str == TYPECLASS_IDENTIFIER) { return Type::TYPECLASS_IDENTIFIER; } else if (str == ARGUMENT_NAME_IDENTIFIER) { return Type::ARGUMENT_NAME_IDENTIFIER; } else if (str == ARGUMENT_TYPE_IDENTIFIER) { return Type::ARGUMENT_TYPE_IDENTIFIER; } else if (str == ANNOTATION_IDENTIFIER) { return Type::ANNOTATION_IDENTIFIER; } else if (str == OPERATOR) { return Type::OPERATOR; } else if (str == OPERATOR_TAIL1) { return Type::OPERATOR_TAIL1; } else if (str == OPERATOR_TAIL2) { return Type::OPERATOR_TAIL2; } else if (str == OPERATOR_TAIL3) { return Type::OPERATOR_TAIL3; } else if (str == FLOAT_LITERAL) { return Type::FLOAT_LITERAL; } else if (str == DOUBLE_LITERAL) { return Type::DOUBLE_LITERAL; } else if (str == INT_LITERAL) { return Type::INT_LITERAL; } else if (str == LONG_LITERAL) { return Type::LONG_LITERAL; } else if (str == INDEX_LITERAL) { return Type::INDEX_LITERAL; } else if (str == STRING_LITERAL) { return Type::STRING_LITERAL; } else if (str == UNICODE_STRING_LITERAL) { return Type::UNICODE_STRING_LITERAL; } else if (str == CHAR_LITERAL) { return Type::CHAR_LITERAL; } else if (str == UNICODE_LITERAL) { return Type::UNICODE_LITERAL; } else if (str == BOOL_LITERAL) { return Type::BOOL_LITERAL; } else if (str == UNIT_LITERAL) { return Type::UNIT_LITERAL; } else if (str == NULL_LITERAL) { return Type::NULL_LITERAL; } return Type::UNDEFINED; } } // namespace tokens