mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-09 16:38:45 +00:00
changes for new grammar, fixes
This commit is contained in:
parent
91f9affadc
commit
3106a64949
35 changed files with 605 additions and 550 deletions
|
|
@ -105,23 +105,23 @@ inline std::optional<InternalType> ToInternalType(const std::string& type) {
|
|||
}
|
||||
|
||||
switch (type[0]) {
|
||||
case 'F':
|
||||
if (type == "Float") { return InternalType::Float; }
|
||||
case 'f':
|
||||
if (type == "float") { return InternalType::Float; }
|
||||
break;
|
||||
case 'I':
|
||||
if (type == "Int") { return InternalType::Int; }
|
||||
case 'i':
|
||||
if (type == "int") { return InternalType::Int; }
|
||||
break;
|
||||
case 'S':
|
||||
if (type == "String") { return InternalType::String; }
|
||||
case 's':
|
||||
if (type == "string") { return InternalType::String; }
|
||||
break;
|
||||
case 'C':
|
||||
if (type == "Char") { return InternalType::Char; }
|
||||
case 'c':
|
||||
if (type == "char") { return InternalType::Char; }
|
||||
break;
|
||||
case 'B':
|
||||
if (type == "Bool") { return InternalType::Bool; }
|
||||
case 'b':
|
||||
if (type == "bool") { return InternalType::Bool; }
|
||||
break;
|
||||
case 'U':
|
||||
if (type == "Unit") { return InternalType::Unit; }
|
||||
case 'u':
|
||||
if (type == "unit") { return InternalType::Unit; }
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -135,22 +135,22 @@ inline std::string ToString(InternalType type) {
|
|||
|
||||
switch (type) {
|
||||
case InternalType::Float:
|
||||
result = "Float";
|
||||
result = "float";
|
||||
break;
|
||||
case InternalType::Int:
|
||||
result = "Int";
|
||||
result = "int";
|
||||
break;
|
||||
case InternalType::String:
|
||||
result = "String";
|
||||
result = "string";
|
||||
break;
|
||||
case InternalType::Char:
|
||||
result = "Char";
|
||||
result = "char";
|
||||
break;
|
||||
case InternalType::Bool:
|
||||
result = "Bool";
|
||||
result = "bool";
|
||||
break;
|
||||
case InternalType::Unit:
|
||||
result = "Unit";
|
||||
result = "unit";
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
|
@ -187,7 +187,7 @@ class VariantType {
|
|||
public:
|
||||
VariantType() = default;
|
||||
VariantType(const std::optional<std::string>& name,
|
||||
const std::vector<TupleType>& constructors,
|
||||
const std::vector<std::pair<std::string, std::optional<TupleType>>>& constructors,
|
||||
std::optional<size_t> current_constructor)
|
||||
: name_(name), constructors_(constructors), current_constructor_(current_constructor) {}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ public:
|
|||
std::optional<utils::IdType> GetFieldType(const std::string& name,
|
||||
const std::unordered_set<utils::IdType>& type_namespaces) const;
|
||||
|
||||
const std::vector<TupleType>& GetConstructors() const {
|
||||
const std::vector<std::pair<std::string, std::optional<TupleType>>>& GetConstructors() const {
|
||||
return constructors_;
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ public:
|
|||
std::string ToString() const;
|
||||
private:
|
||||
std::optional<std::string> name_;
|
||||
std::vector<TupleType> constructors_;
|
||||
std::vector<std::pair<std::string, std::optional<TupleType>>> constructors_;
|
||||
std::optional<size_t> current_constructor_;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue