[Spirit] Qi Symbols mapping to AST enum

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Spirit] Qi Symbols mapping to AST enum

Boost - Users mailing list
Hello,

I've got a qi::symbols capturing some built-in types. At the moment, I
gather, they are mapped to std::string. However, I would rather map
them to an AST level enum.

For instance,

struct builtin_type_t : qi::symbols<char, std::string> {
    builtin_type_t() {
        this->add("double", "double")
            ("float", "float")
            // ...
            ;
    }
} builtin_type;

Instead,

namespace ast {
    enum type_t { type_double, type_float /* , ... */ };
}

struct builtin_type_t : qi::symbols<char, ast::type_t> {
    builtin_type_t() {
        this->add("double", ast::type_double)
            ("float", ast::type_float)
            // ...
            ;
    }
} builtin_type;

I assume this is possible? Am I missing something about that?

Thanks!

Michael Powell
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit] Qi Symbols mapping to AST enum

Boost - Users mailing list
They do exactly that in the examples,



From: Boost-users <[hidden email]> on behalf of Michael Powell via Boost-users <[hidden email]>
Sent: 28 November 2018 23:36
To: [hidden email]
Cc: Michael Powell
Subject: [Boost-users] [Spirit] Qi Symbols mapping to AST enum
 
Hello,

I've got a qi::symbols capturing some built-in types. At the moment, I
gather, they are mapped to std::string. However, I would rather map
them to an AST level enum.

For instance,

struct builtin_type_t : qi::symbols<char, std::string> {
    builtin_type_t() {
        this->add("double", "double")
            ("float", "float")
            // ...
            ;
    }
} builtin_type;

Instead,

namespace ast {
    enum type_t { type_double, type_float /* , ... */ };
}

struct builtin_type_t : qi::symbols<char, ast::type_t> {
    builtin_type_t() {
        this->add("double", ast::type_double)
            ("float", ast::type_float)
            // ...
            ;
    }
} builtin_type;

I assume this is possible? Am I missing something about that?

Thanks!

Michael Powell
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users