|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73330 - in trunk/libs/spirit/example/qi/compiler_tutorial: conjure2 conjure3
From: joel_at_[hidden]
Date: 2011-07-24 12:08:47
Author: djowel
Date: 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
New Revision: 73330
URL: http://svn.boost.org/trac/boost/changeset/73330
Log:
improved enumerations and constants
Added:
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ids.hpp (contents, props changed)
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ids.hpp (contents, props changed)
Removed:
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/token_ids.hpp
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/token_ids.hpp
Text files modified:
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ast.hpp | 88 ++---------------------------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp | 43 +++++++---------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.hpp | 2
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_lexer.hpp | 98 ++++++++++++++++++++--------------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_switch_lexer.hpp | 98 ++++++++++++++++++++--------------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/expression_def.hpp | 8 +-
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/function_def.hpp | 1
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer.hpp | 33 +++++++-----
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer_def.hpp | 50 ++++++++++----------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/statement_def.hpp | 11 ++--
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp | 88 ++---------------------------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp | 43 +++++++---------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp | 2
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_lexer.hpp | 98 ++++++++++++++++++++--------------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_switch_lexer.hpp | 98 ++++++++++++++++++++--------------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/expression_def.hpp | 8 +-
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/function_def.hpp | 3
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.cpp | 2
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.hpp | 60 +++++++++++++++++++++--
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer_def.hpp | 74 +++++++++++++++++------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/statement_def.hpp | 11 ++--
21 files changed, 407 insertions(+), 512 deletions(-)
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ast.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ast.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ast.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -15,7 +15,7 @@
#include <boost/optional.hpp>
#include <list>
-#include "token_ids.hpp"
+#include "ids.hpp"
namespace client { namespace ast
{
@@ -51,93 +51,15 @@
>
operand;
- #define OP(id) (id + op_operator)
- #define OP_EX(id, mask) (id + (mask | op_operator))
-
- enum optoken
- {
- // pseudo tags
- op_operator = lexer::ID_OP_OPERATOR,
- op_binary = lexer::ID_OP_BINARY,
- op_unary = lexer::ID_OP_UNARY,
- op_mask = (op_operator | op_unary | op_binary),
-
- // precedence 1
- op_comma = OP(0),
-
- // precedence 2
- op_assign = OP(1),
- op_plus_assign = OP(2),
- op_minus_assign = OP(3),
- op_times_assign = OP(4),
- op_divide_assign = OP(5),
- op_mod_assign = OP(6),
- op_bit_and_assign = OP(7),
- op_bit_xor_assign = OP(8),
- op_bitor_assign = OP(9),
- op_shift_left_assign = OP(10),
- op_shift_right_assign = OP(11),
-
- // precedence 3
- op_logical_or = OP_EX(12, op_binary),
-
- // precedence 4
- op_logical_and = OP_EX(13, op_binary),
-
- // precedence 5
- op_bit_or = OP_EX(14, op_binary),
-
- // precedence 6
- op_bit_xor = OP_EX(15, op_binary),
-
- // precedence 7
- op_bit_and = OP_EX(16, op_binary),
-
- // precedence 8
- op_equal = OP_EX(17, op_binary),
- op_not_equal = OP_EX(18, op_binary),
-
- // precedence 9
- op_less = OP_EX(19, op_binary),
- op_less_equal = OP_EX(20, op_binary),
- op_greater = OP_EX(21, op_binary),
- op_greater_equal = OP_EX(22, op_binary),
-
- // precedence 10
- op_shift_left = OP_EX(23, op_binary),
- op_shift_right = OP_EX(24, op_binary),
-
- // precedence 11
- op_plus = OP_EX(25, op_binary|op_unary),
- op_minus = OP_EX(26, op_binary|op_unary),
-
- // precedence 12
- op_times = OP_EX(27, op_binary),
- op_divide = OP_EX(28, op_binary),
- op_mod = OP_EX(29, op_binary),
-
- // precedence 13
- op_positive = OP_EX(30, op_unary),
- op_negative = OP_EX(31, op_unary),
- op_pre_incr = OP_EX(32, op_unary),
- op_pre_decr = OP_EX(33, op_unary),
- op_compl = OP_EX(34, op_unary),
- op_not = OP_EX(35, op_unary),
-
- // precedence 14
- op_post_incr = OP(36),
- op_post_decr = OP(37)
- };
-
struct unary
{
- optoken operator_;
+ token::type operator_;
operand operand_;
};
struct operation
{
- optoken operator_;
+ token::type operator_;
operand operand_;
};
@@ -224,13 +146,13 @@
BOOST_FUSION_ADAPT_STRUCT(
client::ast::unary,
- (client::ast::optoken, operator_)
+ (client::token::type, operator_)
(client::ast::operand, operand_)
)
BOOST_FUSION_ADAPT_STRUCT(
client::ast::operation,
- (client::ast::optoken, operator_)
+ (client::token::type, operator_)
(client::ast::operand, operand_)
)
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -245,25 +245,25 @@
return true;
}
- bool compiler::operator()(ast::optoken const& x)
+ bool compiler::operator()(token::type const& x)
{
BOOST_ASSERT(current != 0);
switch (x)
{
- case ast::op_plus: current->op(op_add); break;
- case ast::op_minus: current->op(op_sub); break;
- case ast::op_times: current->op(op_mul); break;
- case ast::op_divide: current->op(op_div); break;
-
- case ast::op_equal: current->op(op_eq); break;
- case ast::op_not_equal: current->op(op_neq); break;
- case ast::op_less: current->op(op_lt); break;
- case ast::op_less_equal: current->op(op_lte); break;
- case ast::op_greater: current->op(op_gt); break;
- case ast::op_greater_equal: current->op(op_gte); break;
+ case token::plus: current->op(op_add); break;
+ case token::minus: current->op(op_sub); break;
+ case token::times: current->op(op_mul); break;
+ case token::divide: current->op(op_div); break;
+
+ case token::equal: current->op(op_eq); break;
+ case token::not_equal: current->op(op_neq); break;
+ case token::less: current->op(op_lt); break;
+ case token::less_equal: current->op(op_lte); break;
+ case token::greater: current->op(op_gt); break;
+ case token::greater_equal: current->op(op_gte); break;
- case ast::op_logical_or: current->op(op_or); break;
- case ast::op_logical_and: current->op(op_and); break;
+ case token::logical_or: current->op(op_or); break;
+ case token::logical_and: current->op(op_and); break;
default: BOOST_ASSERT(0); return false;
}
return true;
@@ -276,9 +276,9 @@
return false;
switch (x.operator_)
{
- case ast::op_minus: current->op(op_neg); break;
- case ast::op_not: current->op(op_not); break;
- case ast::op_plus: break;
+ case token::minus: current->op(op_neg); break;
+ case token::not_: current->op(op_not); break;
+ case token::plus: break;
default: BOOST_ASSERT(0); return false;
}
return true;
@@ -388,11 +388,6 @@
};
}
- inline int precedence_of(ast::optoken op)
- {
- return precedence[op & ~ast::op_mask];
- }
-
// The Shunting-yard algorithm
bool compiler::compile_expression(
int min_precedence,
@@ -401,14 +396,14 @@
{
while ((rbegin != rend) && (precedence_of(rbegin->operator_) >= min_precedence))
{
- ast::optoken op = rbegin->operator_;
+ token::type op = rbegin->operator_;
if (!boost::apply_visitor(*this, rbegin->operand_))
return false;
++rbegin;
while ((rbegin != rend) && (precedence_of(rbegin->operator_) > precedence_of(op)))
{
- ast::optoken next_op = rbegin->operator_;
+ token::type next_op = rbegin->operator_;
compile_expression(precedence_of(next_op), rbegin, rend);
}
(*this)(op);
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -77,7 +77,7 @@
bool operator()(unsigned int x);
bool operator()(bool x);
bool operator()(ast::identifier const& x);
- bool operator()(ast::optoken const& x);
+ bool operator()(token::type const& x);
bool operator()(ast::unary const& x);
bool operator()(ast::function_call const& x);
bool operator()(ast::expression const& x);
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_lexer.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_lexer.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_lexer.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -6,8 +6,8 @@
// Auto-generated by boost::lexer, do not edit
-#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUN__4_2011_19_46_16)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUN__4_2011_19_46_16
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_24_2011_23_44_34)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_24_2011_23_44_34
#include <boost/detail/iterator.hpp>
#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
@@ -83,44 +83,44 @@
24, 17, 19, 2, 26, 25, 14, 12,
15, 26, 26, 7, 4, 26, 6, 26,
26, 26, 9, 26, 3, 26, 5, 8,
- 22, 10, 23, 0, 1, 65645, 0, 0,
+ 22, 10, 23, 0, 1, 41, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 2, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 1, 65636,
+ 0, 0, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 26, 26, 26, 28, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65636, 28, 0, 0, 0, 0, 0,
+ 1, 38, 28, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 29,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
26, 30, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 32, 26,
26, 26, 31, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 33, 26, 26, 26, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65636, 28,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0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 44,
26, 26, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
45, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
46, 26, 26, 26, 0, 0, 0, 0,
- 1, 65641, 4, 0, 0, 0, 0, 0,
+ 1, 65538, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 47, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
48, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
49, 26, 26, 26, 0, 0, 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, 1, 65636,
+ 42, 42, 42, 42, 42, 42, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 51,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65636, 28, 0, 0, 0, 0, 0,
+ 1, 38, 28, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 43, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 52, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65640, 3, 0,
+ 0, 0, 0, 0, 1, 65537, 3, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 53,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65636, 28, 0, 0, 0, 0, 0,
+ 1, 38, 28, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 54, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
@@ -340,28 +340,28 @@
50, 56, 56, 56, 57, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 1, 65646,
+ 56, 56, 56, 56, 56, 56, 1, 42,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65639, 2, 0, 0, 0, 0, 0,
+ 1, 65536, 2, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65642, 5, 0, 0, 0,
+ 0, 0, 1, 65539, 5, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 58, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -372,17 +372,17 @@
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 1, 65637, 29, 0, 0, 0,
+ 56, 56, 1, 39, 29, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 65643, 6, 0,
+ 0, 0, 0, 0, 1, 65540, 6, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -393,7 +393,7 @@
57, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 1, 65644, 7, 0, 0, 0,
+ 56, 56, 1, 65541, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_switch_lexer.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_switch_lexer.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_switch_lexer.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -6,8 +6,8 @@
// Auto-generated by boost::lexer, do not edit
-#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUN__4_2011_19_46_16)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUN__4_2011_19_46_16
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_24_2011_23_44_34)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_24_2011_23_44_34
#include <boost/detail/iterator.hpp>
#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
@@ -109,7 +109,7 @@
state0_1:
end_state_ = true;
- id_ = 65645;
+ id_ = 41;
uid_ = 0;
end_token_ = curr_;
@@ -122,7 +122,7 @@
state0_2:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -137,7 +137,7 @@
state0_3:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -152,7 +152,7 @@
state0_4:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -167,7 +167,7 @@
state0_5:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -184,7 +184,7 @@
state0_6:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -199,7 +199,7 @@
state0_7:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -214,7 +214,7 @@
state0_8:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -258,7 +258,7 @@
state0_12:
end_state_ = true;
- id_ = 327715;
+ id_ = 7077923;
uid_ = 20;
end_token_ = curr_;
@@ -271,7 +271,7 @@
state0_13:
end_state_ = true;
- id_ = 196627;
+ id_ = 4849683;
uid_ = 12;
end_token_ = curr_;
@@ -284,7 +284,7 @@
state0_14:
end_state_ = true;
- id_ = 196629;
+ id_ = 4849685;
uid_ = 14;
end_token_ = curr_;
@@ -297,28 +297,28 @@
state0_15:
end_state_ = true;
- id_ = 458777;
+ id_ = 5898265;
uid_ = 16;
end_token_ = curr_;
goto end;
state0_16:
end_state_ = true;
- id_ = 458778;
+ id_ = 5898266;
uid_ = 17;
end_token_ = curr_;
goto end;
state0_17:
end_state_ = true;
- id_ = 196635;
+ id_ = 6422555;
uid_ = 18;
end_token_ = curr_;
goto end;
state0_18:
end_state_ = true;
- id_ = 196636;
+ id_ = 6422556;
uid_ = 19;
end_token_ = curr_;
@@ -373,7 +373,7 @@
state0_25:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -386,7 +386,7 @@
state0_26:
end_state_ = true;
- id_ = 65638;
+ id_ = 40;
uid_ = 30;
end_token_ = curr_;
@@ -399,7 +399,7 @@
state0_27:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -414,7 +414,7 @@
state0_28:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -429,7 +429,7 @@
state0_29:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -444,7 +444,7 @@
state0_30:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -459,7 +459,7 @@
state0_31:
end_state_ = true;
- id_ = 65641;
+ id_ = 65538;
uid_ = 4;
end_token_ = curr_;
@@ -472,7 +472,7 @@
state0_32:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -487,7 +487,7 @@
state0_33:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -502,7 +502,7 @@
state0_34:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -517,42 +517,42 @@
state0_35:
end_state_ = true;
- id_ = 196620;
+ id_ = 1703948;
uid_ = 8;
end_token_ = curr_;
goto end;
state0_36:
end_state_ = true;
- id_ = 196621;
+ id_ = 2228237;
uid_ = 9;
end_token_ = curr_;
goto end;
state0_37:
end_state_ = true;
- id_ = 196625;
+ id_ = 4325393;
uid_ = 10;
end_token_ = curr_;
goto end;
state0_38:
end_state_ = true;
- id_ = 196626;
+ id_ = 4325394;
uid_ = 11;
end_token_ = curr_;
goto end;
state0_39:
end_state_ = true;
- id_ = 196628;
+ id_ = 4849684;
uid_ = 13;
end_token_ = curr_;
goto end;
state0_40:
end_state_ = true;
- id_ = 196630;
+ id_ = 4849686;
uid_ = 15;
end_token_ = curr_;
goto end;
@@ -569,7 +569,7 @@
state0_42:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -584,7 +584,7 @@
state0_43:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -599,7 +599,7 @@
state0_44:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -614,7 +614,7 @@
state0_45:
end_state_ = true;
- id_ = 65640;
+ id_ = 65537;
uid_ = 3;
end_token_ = curr_;
@@ -627,7 +627,7 @@
state0_46:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -642,7 +642,7 @@
state0_47:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -657,7 +657,7 @@
state0_48:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -684,7 +684,7 @@
state0_50:
end_state_ = true;
- id_ = 65646;
+ id_ = 42;
uid_ = 1;
end_token_ = curr_;
@@ -697,7 +697,7 @@
state0_51:
end_state_ = true;
- id_ = 65639;
+ id_ = 65536;
uid_ = 2;
end_token_ = curr_;
@@ -710,7 +710,7 @@
state0_52:
end_state_ = true;
- id_ = 65642;
+ id_ = 65539;
uid_ = 5;
end_token_ = curr_;
@@ -723,7 +723,7 @@
state0_53:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -738,7 +738,7 @@
state0_54:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -763,14 +763,14 @@
state0_56:
end_state_ = true;
- id_ = 65637;
+ id_ = 39;
uid_ = 29;
end_token_ = curr_;
goto end;
state0_57:
end_state_ = true;
- id_ = 65643;
+ id_ = 65540;
uid_ = 6;
end_token_ = curr_;
@@ -783,7 +783,7 @@
state0_58:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -810,7 +810,7 @@
state0_60:
end_state_ = true;
- id_ = 65644;
+ id_ = 65541;
uid_ = 7;
end_token_ = curr_;
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/expression_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/expression_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/expression_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -41,19 +41,19 @@
// Main expression grammar
expr =
unary_expr
- >> *(tokenid_mask(ast::op_binary) > unary_expr)
+ >> *(tokenid_mask(token::binary) > unary_expr)
;
unary_expr =
primary_expr
- | (tokenid_mask(ast::op_unary) > primary_expr)
+ | (tokenid_mask(token::unary) > primary_expr)
;
primary_expr =
- lexer.uint_
+ lexer.lit_uint
| function_call
| identifier
- | lexer.bool_
+ | lexer.true_or_false
| '(' > expr > ')'
;
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/function_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/function_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/function_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -5,7 +5,6 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include "token_ids.hpp"
#include "function.hpp"
#include "error_handler.hpp"
#include "annotation.hpp"
Added: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ids.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ids.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -0,0 +1,179 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+#if !defined(BOOST_SPIRIT_CONJURE_IDS_HPP)
+#define BOOST_SPIRIT_CONJURE_IDS_HPP
+
+namespace client
+{
+ struct op_type
+ {
+ enum type
+ {
+ binary = 0x20000,
+ unary = 0x40000,
+ assign = 0x80000
+ };
+ };
+
+ struct op
+ {
+ enum type
+ {
+ comma,
+ assign,
+ plus_assign,
+ minus_assign,
+ times_assign,
+ divide_assign,
+ mod_assign,
+ bit_and_assign,
+ bit_xor_assign,
+ bit_or_assign,
+ shift_left_assign,
+ shift_right_assign,
+ logical_or,
+ logical_and,
+ bit_or,
+ bit_xor,
+ bit_and,
+ equal,
+ not_equal,
+ less,
+ less_equal,
+ greater,
+ greater_equal,
+ shift_left,
+ shift_right,
+ plus,
+ minus,
+ times,
+ divide,
+ mod,
+ positive,
+ negative,
+ pre_incr,
+ pre_decr,
+ compl_,
+ not_,
+ post_incr,
+ post_decr
+ };
+ };
+
+ template <int type, int op, int precedence>
+ struct make_op
+ {
+ static int const value =
+ (precedence << 19)
+ + type
+ + op
+ ;
+ };
+
+ template <int op, int precedence>
+ struct unary_op : make_op<op_type::unary, op, precedence> {};
+
+ template <int op, int precedence>
+ struct binary_op
+ : make_op<op_type::binary, op, precedence> {};
+
+ template <int op, int precedence>
+ struct assign_op
+ : make_op<op_type::binary | op_type::assign, op, precedence> {};
+
+ struct token
+ {
+ enum type
+ {
+ // pseudo tags
+ invalid = -1,
+ binary = op_type::binary,
+ unary = op_type::unary,
+
+ // binary operators precedence 1
+ comma = binary_op<op::comma, 1>::value,
+
+ // binary operators precedence 2
+ assign = assign_op<op::assign, 2>::value,
+ plus_assign = assign_op<op::plus_assign, 2>::value,
+ minus_assign = assign_op<op::minus_assign, 2>::value,
+ times_assign = assign_op<op::times_assign, 2>::value,
+ divide_assign = assign_op<op::divide_assign, 2>::value,
+ mod_assign = assign_op<op::mod_assign, 2>::value,
+ bit_and_assign = assign_op<op::bit_and_assign, 2>::value,
+ bit_xor_assign = assign_op<op::bit_xor_assign, 2>::value,
+ bit_or_assign = assign_op<op::bit_or_assign, 2>::value,
+ shift_left_assign = assign_op<op::shift_left_assign, 2>::value,
+ shift_right_assign = assign_op<op::shift_right_assign, 2>::value,
+
+ // binary operators precedence 3
+ logical_or = binary_op<op::logical_or, 3>::value,
+
+ // binary operators precedence 4
+ logical_and = binary_op<op::logical_and, 4>::value,
+
+ // binary operators precedence 5
+ bit_or = binary_op<op::bit_or, 5>::value,
+
+ // binary operators precedence 6
+ bit_xor = binary_op<op::bit_xor, 6>::value,
+
+ // binary operators precedence 7
+ bit_and = binary_op<op::bit_and, 7>::value,
+
+ // binary operators precedence 8
+ equal = binary_op<op::equal, 8>::value,
+ not_equal = binary_op<op::not_equal, 8>::value,
+
+ // binary operators precedence 9
+ less = binary_op<op::less, 9>::value,
+ less_equal = binary_op<op::less_equal, 9>::value,
+ greater = binary_op<op::greater, 9>::value,
+ greater_equal = binary_op<op::greater_equal, 9>::value,
+
+ // binary operators precedence 10
+ shift_left = binary_op<op::shift_left, 10>::value,
+ shift_right = binary_op<op::shift_right, 10>::value,
+
+ // binary operators precedence 11
+ plus = binary_op<op::plus, 11>::value,
+ minus = binary_op<op::minus, 11>::value,
+
+ // binary operators precedence 12
+ times = binary_op<op::times, 12>::value,
+ divide = binary_op<op::divide, 12>::value,
+ mod = binary_op<op::mod, 12>::value,
+
+ // unary operators precedence 13
+ positive = unary_op<op::positive, 13>::value,
+ negative = unary_op<op::negative, 13>::value,
+ pre_incr = unary_op<op::pre_incr, 13>::value,
+ pre_decr = unary_op<op::pre_decr, 13>::value,
+ compl_ = unary_op<op::compl_, 13>::value,
+ not_ = unary_op<op::not_, 13>::value,
+
+ // unary operators precedence 14
+ post_incr = unary_op<op::post_incr, 14>::value,
+ post_decr = unary_op<op::post_decr, 14>::value,
+
+ // misc tags
+ identifier = op::post_decr + 1,
+ comment,
+ whitespace,
+ lit_uint,
+ true_or_false
+ };
+ };
+
+ inline int precedence_of(token::type op)
+ {
+ return (op >> 19) & 0xF;
+ }
+}
+
+#endif
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -7,8 +7,11 @@
#if !defined(BOOST_SPIRIT_CONJURE_LEXER_HPP)
#define BOOST_SPIRIT_CONJURE_LEXER_HPP
+#include <boost/spirit/include/lex_lexertl.hpp>
+#include <boost/spirit/include/lex_lexertl_position_token.hpp>
+
#include "config.hpp"
-#include "token_ids.hpp"
+#include "ids.hpp"
#if CONJURE_LEXER_STATIC_TABLES != 0
#include <boost/spirit/include/lex_static_lexertl.hpp>
@@ -19,8 +22,10 @@
#endif
#include <boost/assert.hpp>
-namespace client { namespace lexer
+namespace client { namespace lexer
{
+ namespace lex = boost::spirit::lex;
+
///////////////////////////////////////////////////////////////////////////
namespace detail
{
@@ -29,9 +34,9 @@
template <typename BaseIterator>
struct get_lexer_type
{
- // Our token needs to be able to carry several token values:
+ // Our token needs to be able to carry several token values:
// std::string, unsigned int, and bool
- typedef boost::mpl::vector<std::string, unsigned int, bool>
+ typedef boost::mpl::vector<std::string, unsigned int, bool>
token_value_types;
// Using the position_token class as the token type to be returned
@@ -65,20 +70,20 @@
///////////////////////////////////////////////////////////////////////////
template <typename BaseIterator>
- struct conjure_tokens
+ struct conjure_tokens
: lex::lexer<typename detail::get_lexer_type<BaseIterator>::type>
{
private:
// get the type of any qi::raw_token(...) and qi::token(...) constructs
typedef typename boost::spirit::result_of::terminal<
- boost::spirit::tag::raw_token(tokenids)
+ boost::spirit::tag::raw_token(token::type)
>::type raw_token_spec;
typedef typename boost::spirit::result_of::terminal<
- boost::spirit::tag::token(tokenids)
+ boost::spirit::tag::token(token::type)
>::type token_spec;
- typedef std::map<std::string, tokenids> keyword_map_type;
+ typedef std::map<std::string, token::type> keyword_map_type;
protected:
// add a keyword to the mapping table
@@ -90,30 +95,30 @@
conjure_tokens();
// extract a raw_token(id) for the given registered keyword
- raw_token_spec raw_token (std::string const& kwd) const
+ raw_token_spec operator()(std::string const& kwd) const
{
namespace qi = boost::spirit::qi;
qi::raw_token_type raw_token;
typename keyword_map_type::const_iterator it = keywords_.find(kwd);
BOOST_ASSERT(it != keywords_.end());
- return qi::raw_token((it != keywords_.end()) ? (*it).second : ID_INVALID);
+ return qi::raw_token((it != keywords_.end()) ? (*it).second : token::invalid);
}
// extract a token(id) for the given registered keyword
- token_spec token (std::string const& kwd) const
+ token_spec token(std::string const& kwd) const
{
namespace qi = boost::spirit::qi;
qi::token_type token;
typename keyword_map_type::const_iterator it = keywords_.find(kwd);
BOOST_ASSERT(it != keywords_.end());
- return qi::token((it != keywords_.end()) ? (*it).second : ID_INVALID);
+ return qi::token((it != keywords_.end()) ? (*it).second : token::invalid);
}
lex::token_def<std::string> identifier;
- lex::token_def<unsigned int> uint_;
- lex::token_def<bool> bool_;
+ lex::token_def<unsigned int> lit_uint;
+ lex::token_def<bool> true_or_false;
keyword_map_type keywords_;
};
}}
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/lexer_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -11,13 +11,13 @@
{
template <typename BaseIterator>
conjure_tokens<BaseIterator>::conjure_tokens()
- : identifier("[a-zA-Z_][a-zA-Z_0-9]*", ID_IDENTIFIER)
- , uint_("[0-9]+", ID_UINT)
- , bool_("true|false", ID_BOOL)
+ : identifier("[a-zA-Z_][a-zA-Z_0-9]*", token::identifier)
+ , lit_uint("[0-9]+", token::lit_uint)
+ , true_or_false("true|false", token::true_or_false)
{
lex::_pass_type _pass;
- this->self = uint_ | bool_;
+ this->self = lit_uint | true_or_false;
add_keyword("void");
add_keyword("int");
@@ -26,31 +26,31 @@
add_keyword("while");
add_keyword("return");
- this->self.add
- ("\\|\\|", ID_OP_LOGICAL_OR)
- ("&&", ID_OP_LOGICAL_AND)
- ("==", ID_OP_EQUAL)
- ("!=", ID_OP_NOT_EQUAL)
- ("<", ID_OP_LESS)
- ("<=", ID_OP_LESS_EQUAL)
- (">", ID_OP_GREATER)
- (">=", ID_OP_GREATER_EQUAL)
- ("\\+", ID_OP_PLUS)
- ("\\-", ID_OP_MINUS)
- ("\\*", ID_OP_TIMES)
- ("\\/", ID_OP_DIVIDE)
- ("!", ID_OP_NOT)
+ this->self.add
+ ("\\|\\|", token::logical_or)
+ ("&&", token::logical_and)
+ ("==", token::equal)
+ ("!=", token::not_equal)
+ ("<", token::less)
+ ("<=", token::less_equal)
+ (">", token::greater)
+ (">=", token::greater_equal)
+ ("\\+", token::plus)
+ ("\\-", token::minus)
+ ("\\*", token::times)
+ ("\\/", token::divide)
+ ("!", token::not_)
;
this->self += lex::char_('(') | ')' | '{' | '}' | ',' | '=' | ';';
- this->self +=
+ this->self +=
identifier
- | lex::string("\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/", ID_COMMENT)
+ | lex::string("\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/", token::comment)
[
lex::_pass = lex::pass_flags::pass_ignore
- ]
- | lex::string("[ \t\n\r]+", ID_WHITESPACE)
+ ]
+ | lex::string("[ \t\n\r]+", token::whitespace)
[
lex::_pass = lex::pass_flags::pass_ignore
]
@@ -61,11 +61,11 @@
bool conjure_tokens<BaseIterator>::add_keyword(std::string const& keyword)
{
// add the token to the lexer
- tokenids id = tokenids(this->get_next_id());
+ token::type id = token::type(this->get_next_id());
this->self.add(keyword, id);
- // store the mapping for later retrieval
- std::pair<typename keyword_map_type::iterator, bool> p =
+ // store the mapping for later retrieval
+ std::pair<typename keyword_map_type::iterator, bool> p =
keywords_.insert(typename keyword_map_type::value_type(keyword, id));
return p.second;
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/statement_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/statement_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/statement_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -5,7 +5,6 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include "token_ids.hpp"
#include "statement.hpp"
#include "error_handler.hpp"
#include "annotation.hpp"
@@ -50,7 +49,7 @@
;
variable_declaration =
- l.raw_token("int")
+ l("int")
> expr.identifier
> -('=' > expr)
> ';'
@@ -64,20 +63,20 @@
;
if_statement =
- l.raw_token("if")
+ l("if")
> '('
> expr
> ')'
> statement_
>
-(
- l.raw_token("else")
+ l("else")
> statement_
)
;
while_statement =
- l.raw_token("while")
+ l("while")
> '('
> expr
> ')'
@@ -89,7 +88,7 @@
;
return_statement =
- l.raw_token("return")
+ l("return")
> -expr
> ';'
;
Deleted: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/token_ids.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/token_ids.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
+++ (empty file)
@@ -1,51 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2011 Hartmut Kaiser
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_CONJURE_TOKEN_IDS_HPP)
-#define BOOST_SPIRIT_CONJURE_TOKEN_IDS_HPP
-
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <boost/spirit/include/lex_lexertl_position_token.hpp>
-
-namespace client { namespace lexer
-{
- namespace lex = boost::spirit::lex;
-
- enum tokenids
- {
- ID_INVALID = - 1,
-
- ID_OP_OPERATOR = 0x10000,
- ID_OP_BINARY = 0x20000,
- ID_OP_UNARY = 0x40000,
-
- // the token ids (added values below) have to correspond to the
- // sequence numbers used in the ast::optoken enumeration
- ID_OP_LOGICAL_OR = (ID_OP_OPERATOR | ID_OP_BINARY) + 12,
- ID_OP_LOGICAL_AND = (ID_OP_OPERATOR | ID_OP_BINARY) + 13,
- ID_OP_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 17,
- ID_OP_NOT_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 18,
- ID_OP_LESS = (ID_OP_OPERATOR | ID_OP_BINARY) + 19,
- ID_OP_LESS_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 20,
- ID_OP_GREATER = (ID_OP_OPERATOR | ID_OP_BINARY) + 21,
- ID_OP_GREATER_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 22,
- ID_OP_PLUS = (ID_OP_OPERATOR | ID_OP_UNARY | ID_OP_BINARY) + 25,
- ID_OP_MINUS = (ID_OP_OPERATOR | ID_OP_UNARY | ID_OP_BINARY) + 26,
- ID_OP_TIMES = (ID_OP_OPERATOR | ID_OP_BINARY) + 27,
- ID_OP_DIVIDE = (ID_OP_OPERATOR | ID_OP_BINARY) + 28,
- ID_OP_NOT = (ID_OP_OPERATOR | ID_OP_UNARY) + 35,
-
- ID_IDENTIFIER = ID_OP_OPERATOR + 100,
- ID_COMMENT,
- ID_WHITESPACE,
- ID_UINT,
- ID_BOOL
- };
-}}
-
-#endif
-
-
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ast.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -15,7 +15,7 @@
#include <boost/optional.hpp>
#include <list>
-#include "token_ids.hpp"
+#include "ids.hpp"
namespace client { namespace ast
{
@@ -51,93 +51,15 @@
>
operand;
- #define OP(id) (id + op_operator)
- #define OP_EX(id, mask) (id + (mask | op_operator))
-
- enum optoken
- {
- // pseudo tags
- op_operator = lexer::ID_OP_OPERATOR,
- op_binary = lexer::ID_OP_BINARY,
- op_unary = lexer::ID_OP_UNARY,
- op_mask = (op_operator | op_unary | op_binary),
-
- // precedence 1
- op_comma = OP(0),
-
- // precedence 2
- op_assign = OP(1),
- op_plus_assign = OP(2),
- op_minus_assign = OP(3),
- op_times_assign = OP(4),
- op_divide_assign = OP(5),
- op_mod_assign = OP(6),
- op_bit_and_assign = OP(7),
- op_bit_xor_assign = OP(8),
- op_bitor_assign = OP(9),
- op_shift_left_assign = OP(10),
- op_shift_right_assign = OP(11),
-
- // precedence 3
- op_logical_or = OP_EX(12, op_binary),
-
- // precedence 4
- op_logical_and = OP_EX(13, op_binary),
-
- // precedence 5
- op_bit_or = OP_EX(14, op_binary),
-
- // precedence 6
- op_bit_xor = OP_EX(15, op_binary),
-
- // precedence 7
- op_bit_and = OP_EX(16, op_binary),
-
- // precedence 8
- op_equal = OP_EX(17, op_binary),
- op_not_equal = OP_EX(18, op_binary),
-
- // precedence 9
- op_less = OP_EX(19, op_binary),
- op_less_equal = OP_EX(20, op_binary),
- op_greater = OP_EX(21, op_binary),
- op_greater_equal = OP_EX(22, op_binary),
-
- // precedence 10
- op_shift_left = OP_EX(23, op_binary),
- op_shift_right = OP_EX(24, op_binary),
-
- // precedence 11
- op_plus = OP_EX(25, op_binary|op_unary),
- op_minus = OP_EX(26, op_binary|op_unary),
-
- // precedence 12
- op_times = OP_EX(27, op_binary),
- op_divide = OP_EX(28, op_binary),
- op_mod = OP_EX(29, op_binary),
-
- // precedence 13
- op_positive = OP_EX(30, op_unary),
- op_negative = OP_EX(31, op_unary),
- op_pre_incr = OP_EX(32, op_unary),
- op_pre_decr = OP_EX(33, op_unary),
- op_compl = OP_EX(34, op_unary),
- op_not = OP_EX(35, op_unary),
-
- // precedence 14
- op_post_incr = OP(36),
- op_post_decr = OP(37)
- };
-
struct unary
{
- optoken operator_;
+ token::type operator_;
operand operand_;
};
struct operation
{
- optoken operator_;
+ token::type operator_;
operand operand_;
};
@@ -224,13 +146,13 @@
BOOST_FUSION_ADAPT_STRUCT(
client::ast::unary,
- (client::ast::optoken, operator_)
+ (client::token::type, operator_)
(client::ast::operand, operand_)
)
BOOST_FUSION_ADAPT_STRUCT(
client::ast::operation,
- (client::ast::optoken, operator_)
+ (client::token::type, operator_)
(client::ast::operand, operand_)
)
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -69,9 +69,9 @@
switch (x.operator_)
{
- case ast::op_minus: return builder.CreateNeg(operand, "negtmp");
- case ast::op_not: return builder.CreateNot(operand, "nottmp");
- case ast::op_plus: return operand;
+ case token::minus: return builder.CreateNeg(operand, "negtmp");
+ case token::not_: return builder.CreateNot(operand, "nottmp");
+ case token::plus: return operand;
default: BOOST_ASSERT(0); return 0;
}
}
@@ -174,33 +174,28 @@
}
llvm::Value* compiler::compile_binary_expression(
- llvm::Value* lhs, llvm::Value* rhs, ast::optoken op)
+ llvm::Value* lhs, llvm::Value* rhs, token::type op)
{
switch (op)
{
- case ast::op_plus: return builder.CreateAdd(lhs, rhs, "addtmp");
- case ast::op_minus: return builder.CreateSub(lhs, rhs, "subtmp");
- case ast::op_times: return builder.CreateMul(lhs, rhs, "multmp");
- case ast::op_divide: return builder.CreateSDiv(lhs, rhs, "divtmp");
-
- case ast::op_equal: return builder.CreateICmpEQ(lhs, rhs, "eqtmp");
- case ast::op_not_equal: return builder.CreateICmpNE(lhs, rhs, "netmp");
- case ast::op_less: return builder.CreateICmpSLT(lhs, rhs, "slttmp");
- case ast::op_less_equal: return builder.CreateICmpSLE(lhs, rhs, "sletmp");
- case ast::op_greater: return builder.CreateICmpSGT(lhs, rhs, "sgttmp");
- case ast::op_greater_equal: return builder.CreateICmpSGE(lhs, rhs, "sgetmp");
+ case token::plus: return builder.CreateAdd(lhs, rhs, "addtmp");
+ case token::minus: return builder.CreateSub(lhs, rhs, "subtmp");
+ case token::times: return builder.CreateMul(lhs, rhs, "multmp");
+ case token::divide: return builder.CreateSDiv(lhs, rhs, "divtmp");
+
+ case token::equal: return builder.CreateICmpEQ(lhs, rhs, "eqtmp");
+ case token::not_equal: return builder.CreateICmpNE(lhs, rhs, "netmp");
+ case token::less: return builder.CreateICmpSLT(lhs, rhs, "slttmp");
+ case token::less_equal: return builder.CreateICmpSLE(lhs, rhs, "sletmp");
+ case token::greater: return builder.CreateICmpSGT(lhs, rhs, "sgttmp");
+ case token::greater_equal: return builder.CreateICmpSGE(lhs, rhs, "sgetmp");
- case ast::op_logical_or: return builder.CreateOr(lhs, rhs, "ortmp");
- case ast::op_logical_and: return builder.CreateAnd(lhs, rhs, "andtmp");
+ case token::logical_or: return builder.CreateOr(lhs, rhs, "ortmp");
+ case token::logical_and: return builder.CreateAnd(lhs, rhs, "andtmp");
default: BOOST_ASSERT(0); return 0;
}
}
- inline int precedence_of(ast::optoken op)
- {
- return precedence[op & ~ast::op_mask];
- }
-
// The Shunting-yard algorithm
llvm::Value* compiler::compile_expression(
int min_precedence,
@@ -211,7 +206,7 @@
while ((rest_begin != rest_end) &&
(precedence_of(rest_begin->operator_) >= min_precedence))
{
- ast::optoken op = rest_begin->operator_;
+ token::type op = rest_begin->operator_;
llvm::Value* rhs = boost::apply_visitor(*this, rest_begin->operand_);
if (rhs == 0)
return 0;
@@ -220,7 +215,7 @@
while ((rest_begin != rest_end) &&
(precedence_of(rest_begin->operator_) > precedence_of(op)))
{
- ast::optoken next_op = rest_begin->operator_;
+ token::type next_op = rest_begin->operator_;
rhs = compile_expression(
precedence_of(next_op), rhs, rest_begin, rest_end);
}
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -96,7 +96,7 @@
void init_fpm();
llvm::Value* compile_binary_expression(
- llvm::Value* lhs, llvm::Value* rhs, ast::optoken op);
+ llvm::Value* lhs, llvm::Value* rhs, token::type op);
llvm::Value* compile_expression(
int min_precedence,
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_lexer.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_lexer.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_lexer.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -6,8 +6,8 @@
// Auto-generated by boost::lexer, do not edit
-#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUN__4_2011_19_46_16)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUN__4_2011_19_46_16
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_24_2011_23_59_45)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_24_2011_23_59_45
#include <boost/detail/iterator.hpp>
#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
@@ -83,44 +83,44 @@
24, 17, 19, 2, 26, 25, 14, 12,
15, 26, 26, 7, 4, 26, 6, 26,
26, 26, 9, 26, 3, 26, 5, 8,
- 22, 10, 23, 0, 1, 65645, 0, 0,
+ 22, 10, 23, 0, 1, 41, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 2, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 1, 65636,
+ 0, 0, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 26, 26, 26, 28, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65636, 28, 0, 0, 0, 0, 0,
+ 1, 38, 28, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 29,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
26, 30, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 32, 26,
26, 26, 31, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 33, 26, 26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
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 44,
26, 26, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
45, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
46, 26, 26, 26, 0, 0, 0, 0,
- 1, 65641, 4, 0, 0, 0, 0, 0,
+ 1, 65538, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 47, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
48, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,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
42, 42, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 1, 65636,
+ 42, 42, 42, 42, 42, 42, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 51,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65636, 28, 0, 0, 0, 0, 0,
+ 1, 38, 28, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 43, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 52, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65640, 3, 0,
+ 0, 0, 0, 0, 1, 65537, 3, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 53,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65636, 28, 0, 0, 0, 0, 0,
+ 1, 38, 28, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 54, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65636, 28, 0, 0, 0,
+ 0, 0, 1, 38, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
@@ -340,28 +340,28 @@
50, 56, 56, 56, 57, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 1, 65646,
+ 56, 56, 56, 56, 56, 56, 1, 42,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 0, 0, 0, 0,
- 1, 65639, 2, 0, 0, 0, 0, 0,
+ 1, 65536, 2, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 26, 0, 0, 0, 0, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 65642, 5, 0, 0, 0,
+ 0, 0, 1, 65539, 5, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 0, 0, 0, 0, 1, 65636, 28, 0,
+ 0, 0, 0, 0, 1, 38, 28, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 58, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -372,17 +372,17 @@
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 1, 65637, 29, 0, 0, 0,
+ 56, 56, 1, 39, 29, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 65643, 6, 0,
+ 0, 0, 0, 0, 1, 65540, 6, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 26, 26, 0,
0, 0, 0, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 65636,
+ 26, 26, 0, 0, 0, 0, 1, 38,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -393,7 +393,7 @@
57, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 1, 65644, 7, 0, 0, 0,
+ 56, 56, 1, 65541, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 26, 26, 26, 26, 26,
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_switch_lexer.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_switch_lexer.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_switch_lexer.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -6,8 +6,8 @@
// Auto-generated by boost::lexer, do not edit
-#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUN__4_2011_19_46_16)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUN__4_2011_19_46_16
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_24_2011_23_59_45)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_24_2011_23_59_45
#include <boost/detail/iterator.hpp>
#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
@@ -109,7 +109,7 @@
state0_1:
end_state_ = true;
- id_ = 65645;
+ id_ = 41;
uid_ = 0;
end_token_ = curr_;
@@ -122,7 +122,7 @@
state0_2:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -137,7 +137,7 @@
state0_3:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -152,7 +152,7 @@
state0_4:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -167,7 +167,7 @@
state0_5:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -184,7 +184,7 @@
state0_6:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -199,7 +199,7 @@
state0_7:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -214,7 +214,7 @@
state0_8:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -258,7 +258,7 @@
state0_12:
end_state_ = true;
- id_ = 327715;
+ id_ = 7077923;
uid_ = 20;
end_token_ = curr_;
@@ -271,7 +271,7 @@
state0_13:
end_state_ = true;
- id_ = 196627;
+ id_ = 4849683;
uid_ = 12;
end_token_ = curr_;
@@ -284,7 +284,7 @@
state0_14:
end_state_ = true;
- id_ = 196629;
+ id_ = 4849685;
uid_ = 14;
end_token_ = curr_;
@@ -297,28 +297,28 @@
state0_15:
end_state_ = true;
- id_ = 458777;
+ id_ = 5898265;
uid_ = 16;
end_token_ = curr_;
goto end;
state0_16:
end_state_ = true;
- id_ = 458778;
+ id_ = 5898266;
uid_ = 17;
end_token_ = curr_;
goto end;
state0_17:
end_state_ = true;
- id_ = 196635;
+ id_ = 6422555;
uid_ = 18;
end_token_ = curr_;
goto end;
state0_18:
end_state_ = true;
- id_ = 196636;
+ id_ = 6422556;
uid_ = 19;
end_token_ = curr_;
@@ -373,7 +373,7 @@
state0_25:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -386,7 +386,7 @@
state0_26:
end_state_ = true;
- id_ = 65638;
+ id_ = 40;
uid_ = 30;
end_token_ = curr_;
@@ -399,7 +399,7 @@
state0_27:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -414,7 +414,7 @@
state0_28:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -429,7 +429,7 @@
state0_29:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -444,7 +444,7 @@
state0_30:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -459,7 +459,7 @@
state0_31:
end_state_ = true;
- id_ = 65641;
+ id_ = 65538;
uid_ = 4;
end_token_ = curr_;
@@ -472,7 +472,7 @@
state0_32:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -487,7 +487,7 @@
state0_33:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -502,7 +502,7 @@
state0_34:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -517,42 +517,42 @@
state0_35:
end_state_ = true;
- id_ = 196620;
+ id_ = 1703948;
uid_ = 8;
end_token_ = curr_;
goto end;
state0_36:
end_state_ = true;
- id_ = 196621;
+ id_ = 2228237;
uid_ = 9;
end_token_ = curr_;
goto end;
state0_37:
end_state_ = true;
- id_ = 196625;
+ id_ = 4325393;
uid_ = 10;
end_token_ = curr_;
goto end;
state0_38:
end_state_ = true;
- id_ = 196626;
+ id_ = 4325394;
uid_ = 11;
end_token_ = curr_;
goto end;
state0_39:
end_state_ = true;
- id_ = 196628;
+ id_ = 4849684;
uid_ = 13;
end_token_ = curr_;
goto end;
state0_40:
end_state_ = true;
- id_ = 196630;
+ id_ = 4849686;
uid_ = 15;
end_token_ = curr_;
goto end;
@@ -569,7 +569,7 @@
state0_42:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -584,7 +584,7 @@
state0_43:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -599,7 +599,7 @@
state0_44:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -614,7 +614,7 @@
state0_45:
end_state_ = true;
- id_ = 65640;
+ id_ = 65537;
uid_ = 3;
end_token_ = curr_;
@@ -627,7 +627,7 @@
state0_46:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -642,7 +642,7 @@
state0_47:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -657,7 +657,7 @@
state0_48:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -684,7 +684,7 @@
state0_50:
end_state_ = true;
- id_ = 65646;
+ id_ = 42;
uid_ = 1;
end_token_ = curr_;
@@ -697,7 +697,7 @@
state0_51:
end_state_ = true;
- id_ = 65639;
+ id_ = 65536;
uid_ = 2;
end_token_ = curr_;
@@ -710,7 +710,7 @@
state0_52:
end_state_ = true;
- id_ = 65642;
+ id_ = 65539;
uid_ = 5;
end_token_ = curr_;
@@ -723,7 +723,7 @@
state0_53:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -738,7 +738,7 @@
state0_54:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -763,14 +763,14 @@
state0_56:
end_state_ = true;
- id_ = 65637;
+ id_ = 39;
uid_ = 29;
end_token_ = curr_;
goto end;
state0_57:
end_state_ = true;
- id_ = 65643;
+ id_ = 65540;
uid_ = 6;
end_token_ = curr_;
@@ -783,7 +783,7 @@
state0_58:
end_state_ = true;
- id_ = 65636;
+ id_ = 38;
uid_ = 28;
end_token_ = curr_;
@@ -810,7 +810,7 @@
state0_60:
end_state_ = true;
- id_ = 65644;
+ id_ = 65541;
uid_ = 7;
end_token_ = curr_;
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/expression_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/expression_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/expression_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -41,19 +41,19 @@
// Main expression grammar
expr =
unary_expr
- >> *(tokenid_mask(ast::op_binary) > unary_expr)
+ >> *(tokenid_mask(token::binary) > unary_expr)
;
unary_expr =
primary_expr
- | (tokenid_mask(ast::op_unary) > primary_expr)
+ | (tokenid_mask(token::unary) > primary_expr)
;
primary_expr =
- lexer.uint_
+ lexer.lit_uint
| function_call
| identifier
- | lexer.bool_
+ | lexer.true_or_false
| '(' > expr > ')'
;
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/function_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/function_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/function_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -5,7 +5,6 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include "token_ids.hpp"
#include "function.hpp"
#include "error_handler.hpp"
#include "annotation.hpp"
@@ -39,7 +38,7 @@
identifier = body.expr.identifier;
argument_list = -(identifier % ',');
- start = (token(lexer::ID_VOID_KWD) | token(lexer::ID_INT_KWD))
+ start = (l.token("void") | l.token("int"))
> identifier
> '(' > argument_list > ')'
> (';' | '{' > body > '}')
Added: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ids.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ids.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -0,0 +1,179 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+#if !defined(BOOST_SPIRIT_CONJURE_IDS_HPP)
+#define BOOST_SPIRIT_CONJURE_IDS_HPP
+
+namespace client
+{
+ struct op_type
+ {
+ enum type
+ {
+ binary = 0x20000,
+ unary = 0x40000,
+ assign = 0x80000
+ };
+ };
+
+ struct op
+ {
+ enum type
+ {
+ comma,
+ assign,
+ plus_assign,
+ minus_assign,
+ times_assign,
+ divide_assign,
+ mod_assign,
+ bit_and_assign,
+ bit_xor_assign,
+ bit_or_assign,
+ shift_left_assign,
+ shift_right_assign,
+ logical_or,
+ logical_and,
+ bit_or,
+ bit_xor,
+ bit_and,
+ equal,
+ not_equal,
+ less,
+ less_equal,
+ greater,
+ greater_equal,
+ shift_left,
+ shift_right,
+ plus,
+ minus,
+ times,
+ divide,
+ mod,
+ positive,
+ negative,
+ pre_incr,
+ pre_decr,
+ compl_,
+ not_,
+ post_incr,
+ post_decr
+ };
+ };
+
+ template <int type, int op, int precedence>
+ struct make_op
+ {
+ static int const value =
+ (precedence << 19)
+ + type
+ + op
+ ;
+ };
+
+ template <int op, int precedence>
+ struct unary_op : make_op<op_type::unary, op, precedence> {};
+
+ template <int op, int precedence>
+ struct binary_op
+ : make_op<op_type::binary, op, precedence> {};
+
+ template <int op, int precedence>
+ struct assign_op
+ : make_op<op_type::binary | op_type::assign, op, precedence> {};
+
+ struct token
+ {
+ enum type
+ {
+ // pseudo tags
+ invalid = -1,
+ binary = op_type::binary,
+ unary = op_type::unary,
+
+ // binary operators precedence 1
+ comma = binary_op<op::comma, 1>::value,
+
+ // binary operators precedence 2
+ assign = assign_op<op::assign, 2>::value,
+ plus_assign = assign_op<op::plus_assign, 2>::value,
+ minus_assign = assign_op<op::minus_assign, 2>::value,
+ times_assign = assign_op<op::times_assign, 2>::value,
+ divide_assign = assign_op<op::divide_assign, 2>::value,
+ mod_assign = assign_op<op::mod_assign, 2>::value,
+ bit_and_assign = assign_op<op::bit_and_assign, 2>::value,
+ bit_xor_assign = assign_op<op::bit_xor_assign, 2>::value,
+ bit_or_assign = assign_op<op::bit_or_assign, 2>::value,
+ shift_left_assign = assign_op<op::shift_left_assign, 2>::value,
+ shift_right_assign = assign_op<op::shift_right_assign, 2>::value,
+
+ // binary operators precedence 3
+ logical_or = binary_op<op::logical_or, 3>::value,
+
+ // binary operators precedence 4
+ logical_and = binary_op<op::logical_and, 4>::value,
+
+ // binary operators precedence 5
+ bit_or = binary_op<op::bit_or, 5>::value,
+
+ // binary operators precedence 6
+ bit_xor = binary_op<op::bit_xor, 6>::value,
+
+ // binary operators precedence 7
+ bit_and = binary_op<op::bit_and, 7>::value,
+
+ // binary operators precedence 8
+ equal = binary_op<op::equal, 8>::value,
+ not_equal = binary_op<op::not_equal, 8>::value,
+
+ // binary operators precedence 9
+ less = binary_op<op::less, 9>::value,
+ less_equal = binary_op<op::less_equal, 9>::value,
+ greater = binary_op<op::greater, 9>::value,
+ greater_equal = binary_op<op::greater_equal, 9>::value,
+
+ // binary operators precedence 10
+ shift_left = binary_op<op::shift_left, 10>::value,
+ shift_right = binary_op<op::shift_right, 10>::value,
+
+ // binary operators precedence 11
+ plus = binary_op<op::plus, 11>::value,
+ minus = binary_op<op::minus, 11>::value,
+
+ // binary operators precedence 12
+ times = binary_op<op::times, 12>::value,
+ divide = binary_op<op::divide, 12>::value,
+ mod = binary_op<op::mod, 12>::value,
+
+ // unary operators precedence 13
+ positive = unary_op<op::positive, 13>::value,
+ negative = unary_op<op::negative, 13>::value,
+ pre_incr = unary_op<op::pre_incr, 13>::value,
+ pre_decr = unary_op<op::pre_decr, 13>::value,
+ compl_ = unary_op<op::compl_, 13>::value,
+ not_ = unary_op<op::not_, 13>::value,
+
+ // unary operators precedence 14
+ post_incr = unary_op<op::post_incr, 14>::value,
+ post_decr = unary_op<op::post_decr, 14>::value,
+
+ // misc tags
+ identifier = op::post_decr + 1,
+ comment,
+ whitespace,
+ lit_uint,
+ true_or_false
+ };
+ };
+
+ inline int precedence_of(token::type op)
+ {
+ return (op >> 19) & 0xF;
+ }
+}
+
+#endif
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.cpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -13,3 +13,5 @@
typedef std::string::const_iterator base_iterator_type;
template client::lexer::conjure_tokens<base_iterator_type>::conjure_tokens();
+template bool client::lexer::conjure_tokens<base_iterator_type>::add_keyword(
+ std::string const&);
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -7,8 +7,11 @@
#if !defined(BOOST_SPIRIT_CONJURE_LEXER_HPP)
#define BOOST_SPIRIT_CONJURE_LEXER_HPP
+#include <boost/spirit/include/lex_lexertl.hpp>
+#include <boost/spirit/include/lex_lexertl_position_token.hpp>
+
#include "config.hpp"
-#include "token_ids.hpp"
+#include "ids.hpp"
#if CONJURE_LEXER_STATIC_TABLES != 0
#include <boost/spirit/include/lex_static_lexertl.hpp>
@@ -17,9 +20,12 @@
#include <boost/spirit/include/lex_static_lexertl.hpp>
#include "conjure_static_switch_lexer.hpp"
#endif
+#include <boost/assert.hpp>
-namespace client { namespace lexer
+namespace client { namespace lexer
{
+ namespace lex = boost::spirit::lex;
+
///////////////////////////////////////////////////////////////////////////
namespace detail
{
@@ -28,9 +34,9 @@
template <typename BaseIterator>
struct get_lexer_type
{
- // Our token needs to be able to carry several token values:
+ // Our token needs to be able to carry several token values:
// std::string, unsigned int, and bool
- typedef boost::mpl::vector<std::string, unsigned int, bool>
+ typedef boost::mpl::vector<std::string, unsigned int, bool>
token_value_types;
// Using the position_token class as the token type to be returned
@@ -64,16 +70,56 @@
///////////////////////////////////////////////////////////////////////////
template <typename BaseIterator>
- struct conjure_tokens
+ struct conjure_tokens
: lex::lexer<typename detail::get_lexer_type<BaseIterator>::type>
{
+ private:
+ // get the type of any qi::raw_token(...) and qi::token(...) constructs
+ typedef typename boost::spirit::result_of::terminal<
+ boost::spirit::tag::raw_token(token::type)
+ >::type raw_token_spec;
+
+ typedef typename boost::spirit::result_of::terminal<
+ boost::spirit::tag::token(token::type)
+ >::type token_spec;
+
+ typedef std::map<std::string, token::type> keyword_map_type;
+
+ protected:
+ // add a keyword to the mapping table
+ bool add_keyword(std::string const& keyword);
+
+ public:
typedef BaseIterator base_iterator_type;
conjure_tokens();
+ // extract a raw_token(id) for the given registered keyword
+ raw_token_spec operator()(std::string const& kwd) const
+ {
+ namespace qi = boost::spirit::qi;
+ qi::raw_token_type raw_token;
+
+ typename keyword_map_type::const_iterator it = keywords_.find(kwd);
+ BOOST_ASSERT(it != keywords_.end());
+ return qi::raw_token((it != keywords_.end()) ? (*it).second : token::invalid);
+ }
+
+ // extract a token(id) for the given registered keyword
+ token_spec token(std::string const& kwd) const
+ {
+ namespace qi = boost::spirit::qi;
+ qi::token_type token;
+
+ typename keyword_map_type::const_iterator it = keywords_.find(kwd);
+ BOOST_ASSERT(it != keywords_.end());
+ return qi::token((it != keywords_.end()) ? (*it).second : token::invalid);
+ }
+
lex::token_def<std::string> identifier;
- lex::token_def<unsigned int> uint_;
- lex::token_def<bool> bool_;
+ lex::token_def<unsigned int> lit_uint;
+ lex::token_def<bool> true_or_false;
+ keyword_map_type keywords_;
};
}}
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/lexer_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -11,52 +11,64 @@
{
template <typename BaseIterator>
conjure_tokens<BaseIterator>::conjure_tokens()
- : identifier("[a-zA-Z_][a-zA-Z_0-9]*", ID_IDENTIFIER)
- , uint_("[0-9]+", ID_UINT)
- , bool_("true|false", ID_BOOL)
+ : identifier("[a-zA-Z_][a-zA-Z_0-9]*", token::identifier)
+ , lit_uint("[0-9]+", token::lit_uint)
+ , true_or_false("true|false", token::true_or_false)
{
lex::_pass_type _pass;
- this->self = uint_ | bool_;
+ this->self = lit_uint | true_or_false;
- this->self.add
- ("void", ID_VOID_KWD)
- ("int", ID_INT_KWD)
- ("if", ID_IF_KWD)
- ("else", ID_ELSE_KWD)
- ("while", ID_WHILE_KWD)
- ("return", ID_RETURN_KWD)
- ;
-
- this->self.add
- ("\\|\\|", ID_OP_LOGICAL_OR)
- ("&&", ID_OP_LOGICAL_AND)
- ("==", ID_OP_EQUAL)
- ("!=", ID_OP_NOT_EQUAL)
- ("<", ID_OP_LESS)
- ("<=", ID_OP_LESS_EQUAL)
- (">", ID_OP_GREATER)
- (">=", ID_OP_GREATER_EQUAL)
- ("\\+", ID_OP_PLUS)
- ("\\-", ID_OP_MINUS)
- ("\\*", ID_OP_TIMES)
- ("\\/", ID_OP_DIVIDE)
- ("!", ID_OP_NOT)
+ add_keyword("void");
+ add_keyword("int");
+ add_keyword("if");
+ add_keyword("else");
+ add_keyword("while");
+ add_keyword("return");
+
+ this->self.add
+ ("\\|\\|", token::logical_or)
+ ("&&", token::logical_and)
+ ("==", token::equal)
+ ("!=", token::not_equal)
+ ("<", token::less)
+ ("<=", token::less_equal)
+ (">", token::greater)
+ (">=", token::greater_equal)
+ ("\\+", token::plus)
+ ("\\-", token::minus)
+ ("\\*", token::times)
+ ("\\/", token::divide)
+ ("!", token::not_)
;
this->self += lex::char_('(') | ')' | '{' | '}' | ',' | '=' | ';';
- this->self +=
+ this->self +=
identifier
- | lex::string("\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/", ID_COMMENT)
+ | lex::string("\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/", token::comment)
[
lex::_pass = lex::pass_flags::pass_ignore
- ]
- | lex::string("[ \t\n\r]+", ID_WHITESPACE)
+ ]
+ | lex::string("[ \t\n\r]+", token::whitespace)
[
lex::_pass = lex::pass_flags::pass_ignore
]
;
}
+
+ template <typename BaseIterator>
+ bool conjure_tokens<BaseIterator>::add_keyword(std::string const& keyword)
+ {
+ // add the token to the lexer
+ token::type id = token::type(this->get_next_id());
+ this->self.add(keyword, id);
+
+ // store the mapping for later retrieval
+ std::pair<typename keyword_map_type::iterator, bool> p =
+ keywords_.insert(typename keyword_map_type::value_type(keyword, id));
+
+ return p.second;
+ }
}}
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/statement_def.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/statement_def.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/statement_def.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
@@ -5,7 +5,6 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include "token_ids.hpp"
#include "statement.hpp"
#include "error_handler.hpp"
#include "annotation.hpp"
@@ -50,7 +49,7 @@
;
variable_declaration =
- raw_token(lexer::ID_INT_KWD)
+ l("int")
> expr.identifier
> -('=' > expr)
> ';'
@@ -64,20 +63,20 @@
;
if_statement =
- raw_token(lexer::ID_IF_KWD)
+ l("if")
> '('
> expr
> ')'
> statement_
>
-(
- raw_token(lexer::ID_ELSE_KWD)
+ l("else")
> statement_
)
;
while_statement =
- raw_token(lexer::ID_WHILE_KWD)
+ l("while")
> '('
> expr
> ')'
@@ -89,7 +88,7 @@
;
return_statement =
- raw_token(lexer::ID_RETURN_KWD)
+ l("return")
> -expr
> ';'
;
Deleted: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/token_ids.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/token_ids.hpp 2011-07-24 12:08:45 EDT (Sun, 24 Jul 2011)
+++ (empty file)
@@ -1,55 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2011 Hartmut Kaiser
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_CONJURE_TOKEN_IDS_HPP)
-#define BOOST_SPIRIT_CONJURE_TOKEN_IDS_HPP
-
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <boost/spirit/include/lex_lexertl_position_token.hpp>
-
-namespace client { namespace lexer
-{
- namespace lex = boost::spirit::lex;
-
- enum tokenids
- {
- ID_OP_OPERATOR = 0x10000,
- ID_OP_BINARY = 0x20000,
- ID_OP_UNARY = 0x40000,
-
- // the token ids (added values below) have to correspond to the
- // sequence numbers used in the ast::optoken enumeration
- ID_OP_LOGICAL_OR = (ID_OP_OPERATOR | ID_OP_BINARY) + 12,
- ID_OP_LOGICAL_AND = (ID_OP_OPERATOR | ID_OP_BINARY) + 13,
- ID_OP_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 17,
- ID_OP_NOT_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 18,
- ID_OP_LESS = (ID_OP_OPERATOR | ID_OP_BINARY) + 19,
- ID_OP_LESS_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 20,
- ID_OP_GREATER = (ID_OP_OPERATOR | ID_OP_BINARY) + 21,
- ID_OP_GREATER_EQUAL = (ID_OP_OPERATOR | ID_OP_BINARY) + 22,
- ID_OP_PLUS = (ID_OP_OPERATOR | ID_OP_UNARY | ID_OP_BINARY) + 25,
- ID_OP_MINUS = (ID_OP_OPERATOR | ID_OP_UNARY | ID_OP_BINARY) + 26,
- ID_OP_TIMES = (ID_OP_OPERATOR | ID_OP_BINARY) + 27,
- ID_OP_DIVIDE = (ID_OP_OPERATOR | ID_OP_BINARY) + 28,
- ID_OP_NOT = (ID_OP_OPERATOR | ID_OP_UNARY) + 35,
-
- ID_IDENTIFIER = ID_OP_OPERATOR + 100,
- ID_COMMENT,
- ID_WHITESPACE,
- ID_VOID_KWD,
- ID_INT_KWD,
- ID_IF_KWD,
- ID_ELSE_KWD,
- ID_WHILE_KWD,
- ID_RETURN_KWD,
- ID_UINT,
- ID_BOOL
- };
-}}
-
-#endif
-
-
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk