Boost logo

Boost Users :

Subject: Re: [Boost-users] [Spirit] Qi Symbols mapping to AST enum
From: rmawatson rmawatson (rmawatson_at_[hidden])
Date: 2018-11-28 23:47:34


They do exactly that in the examples,

https://github.com/boostorg/spirit/blob/develop/example/qi/compiler_tutorial/calc8/expression.hpp#L55

________________________________
From: Boost-users <boost-users-bounces_at_[hidden]> on behalf of Michael Powell via Boost-users <boost-users_at_[hidden]>
Sent: 28 November 2018 23:36
To: boost-users_at_[hidden]
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
Boost-users_at_[hidden]
https://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net