1 #ifndef AWFUL_IDLPARSE_TOKEN_H_
2 #define AWFUL_IDLPARSE_TOKEN_H_
4 #include <boost/wave.hpp>
5 #include <boost/wave/cpplexer/cpp_lex_token.hpp>
7 namespace awful
{ namespace idlparser
44 static TokenType
Translate( const char* pIdentifier_
);
47 static TokenTransTable s_Instance
;
48 std::map
< std::string
, TokenType
> m_TransMap
;
51 // This wraps a wave token. Like the wave token, it can be cast into token_id.
52 // It can also be cast into TokenTypes, which provides enums for custom keywords.
53 // Note that the cutsom keywords are of token_id T_IDENTIFIER, so the grammar shouldn't
54 // use T_IDENTIFIER but rather TT_IDENTIFIER from the TokenType enum above, which will
55 // designate tokens that are actual identifiers and not custom keywords originally recognized
56 // as T_IDENTIFIER by wave's cpplexer.
57 template< typename T
> class Token
64 Token( const T
& InputTok_
)
69 const Token
& operator=( const T
& InputTok_
)
71 m_WrappedToken
= InputTok_
;
74 if( m_WrappedToken
== boost::wave::T_IDENTIFIER
)
75 m_Type
= TokenTransTable::Translate( m_WrappedToken
.get_value().c_str() );
80 operator boost::wave::token_id() const
82 return m_WrappedToken
;
85 operator TokenType() const
90 const typename
T::string_type
& get_value() const
92 return m_WrappedToken
.get_value();
95 const typename
T::position_type
& get_position() const
97 return m_WrappedToken
.get_position();