diff --git a/nyan/ast.cpp b/nyan/ast.cpp index d9d0aff..db9e296 100644 --- a/nyan/ast.cpp +++ b/nyan/ast.cpp @@ -538,7 +538,7 @@ bool ASTMemberType::exists() const { } -ASTMemberArgument::ASTMemberArgument(TokenStream &tokens) +ASTMemberTypeArgument::ASTMemberTypeArgument(TokenStream &tokens) : has_key{false} { auto token = tokens.next(); @@ -756,7 +756,7 @@ void ASTMemberType::strb(std::ostringstream &builder, int /*indentlevel*/) const } -void ASTMemberArgument::strb(std::ostringstream &builder, int /*indentlevel*/) const { +void ASTMemberTypeArgument::strb(std::ostringstream &builder, int /*indentlevel*/) const { if (this->has_key) { builder << this->key.str() << "="; } diff --git a/nyan/ast.h b/nyan/ast.h index cbde529..ed66916 100644 --- a/nyan/ast.h +++ b/nyan/ast.h @@ -50,13 +50,13 @@ class ASTBase { /** * AST representation of a member type argument declaration. */ -class ASTMemberArgument : public ASTBase { +class ASTMemberTypeArgument : public ASTBase { friend class ASTMemberType; friend class Database; friend class Type; public: - ASTMemberArgument(TokenStream &tokens); + ASTMemberTypeArgument(TokenStream &tokens); void strb(std::ostringstream &builder, int indentlevel=0) const override; @@ -86,7 +86,7 @@ class ASTMemberType : ASTBase { IDToken name; bool has_args; - std::vector args; + std::vector args; }; diff --git a/nyan/member_info.h b/nyan/member_info.h index 61db751..a565648 100644 --- a/nyan/member_info.h +++ b/nyan/member_info.h @@ -13,7 +13,6 @@ class Type; /** * Stores information for a member of an Object. - * Also responsible for validating applied operators. */ class MemberInfo { public: diff --git a/nyan/type.cpp b/nyan/type.cpp index faa34ba..23816fc 100644 --- a/nyan/type.cpp +++ b/nyan/type.cpp @@ -105,7 +105,7 @@ bool Type::is_container(container_t type) const { } -bool Type::is_basic_compatible(const BasicType &type) const { +bool Type::is_basic_type_match(const BasicType &type) const { return (this->basic_type == type); } diff --git a/nyan/type.h b/nyan/type.h index 86da927..e21b35f 100644 --- a/nyan/type.h +++ b/nyan/type.h @@ -72,9 +72,9 @@ class Type { bool is_container(container_t type) const; /** - * Test if the basic type is compatbile, i. e. the same. + * Test if the basic type matches the given type, i. e. it's the same. */ - bool is_basic_compatible(const BasicType &type) const; + bool is_basic_type_match(const BasicType &type) const; /** * Check if this type can be in the given other type. diff --git a/nyan/value/value.cpp b/nyan/value/value.cpp index 6e18b10..bed2a29 100644 --- a/nyan/value/value.cpp +++ b/nyan/value/value.cpp @@ -30,10 +30,18 @@ static ValueHolder value_from_value_token(const Type &target_type, return {std::make_shared(value_token)}; case primitive_t::INT: - return {std::make_shared(value_token)}; - - case primitive_t::FLOAT: - return {std::make_shared(value_token)}; + case primitive_t::FLOAT: { + if (value_token.get_type() == token_type::INT) { + return {std::make_shared(value_token)}; + } + else if (value_token.get_type() == token_type::FLOAT) { + return {std::make_shared(value_token)}; + } + throw LangError{ + value_token, + "invalid value for number, expecting float or int" + }; + } case primitive_t::FILENAME: { // TODO: make relative to current namespace