|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73343 - in trunk/libs/spirit/example/qi/compiler_tutorial: conjure2 conjure3
From: joel_at_[hidden]
Date: 2011-07-24 19:47:45
Author: djowel
Date: 2011-07-24 19:47:43 EDT (Sun, 24 Jul 2011)
New Revision: 73343
URL: http://svn.boost.org/trac/boost/changeset/73343
Log:
Tweaks (separated precedence again)
Text files modified:
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp | 19 +---
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_lexer.hpp | 86 +++++++++++-----------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/conjure_static_switch_lexer.hpp | 86 +++++++++++-----------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/expression_def.hpp | 4
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ids.hpp | 154 +++++++++++++++++----------------------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp | 19 +---
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_lexer.hpp | 86 +++++++++++-----------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_switch_lexer.hpp | 86 +++++++++++-----------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/expression_def.hpp | 4
trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ids.hpp | 154 +++++++++++++++++----------------------
10 files changed, 320 insertions(+), 378 deletions(-)
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 19:47:43 EDT (Sun, 24 Jul 2011)
@@ -372,22 +372,15 @@
// precedence 12
12, // op_times
12, // op_divide
- 12, // op_mod
-
- // precedence 13
- 13, // op_positive
- 13, // op_negative
- 13, // op_pre_incr
- 13, // op_pre_decr
- 13, // op_compl
- 13, // op_not
-
- // precedence 14
- 14, // op_post_incr
- 14 // op_post_decr
+ 12 // op_mod
};
}
+ inline int precedence_of(token::type op)
+ {
+ return precedence[op & 0xFF];
+ }
+
// The Shunting-yard algorithm
bool compiler::compile_expression(
int min_precedence,
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 19:47:43 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_JUL_24_2011_23_44_34)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_24_2011_23_44_34
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_25_2011_07_03_08)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_25_2011_07_03_08
#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, 41, 0, 0,
+ 22, 10, 23, 0, 1, 35, 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, 38,
+ 0, 0, 0, 0, 0, 0, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 34, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 28, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 26, 0, 0, 0,
0, 26, 26, 35, 26, 26, 26, 26,
@@ -141,38 +141,38 @@
0, 0, 0, 0, 0, 38, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 7077923, 20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, 0, 0, 0, 0, 0, 0, 0,
@@ -209,33 +209,33 @@
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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 26, 26,
- 26, 26, 0, 0, 0, 0, 1, 40,
+ 26, 26, 0, 0, 0, 0, 1, 34,
30, 0, 0, 0, 0, 27, 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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 26, 43, 26, 26, 0, 0,
- 0, 0, 1, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -246,49 +246,49 @@
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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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, 0, 0,
- 1, 1703948, 8, 0, 0, 0, 0, 0,
+ 1, 131084, 8, 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, 2228237, 9, 0, 0, 0,
+ 0, 0, 1, 131085, 9, 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, 4325393, 10, 0,
+ 0, 0, 0, 0, 1, 131089, 10, 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, 4325394,
+ 0, 0, 0, 0, 0, 0, 1, 131090,
11, 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, 4849684, 13, 0, 0, 0, 0, 0,
+ 1, 131092, 13, 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, 4849686, 15, 0, 0, 0,
+ 0, 0, 1, 131094, 15, 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,
@@ -298,18 +298,18 @@
50, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 1, 38,
+ 42, 42, 42, 42, 42, 42, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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,
@@ -319,18 +319,18 @@
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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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,7 +340,7 @@
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, 42,
+ 56, 56, 56, 56, 56, 56, 1, 36,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -356,12 +356,12 @@
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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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,7 +372,7 @@
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, 39, 29, 0, 0, 0,
+ 56, 56, 1, 33, 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,
@@ -382,7 +382,7 @@
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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 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 19:47:43 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_JUL_24_2011_23_44_34)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_24_2011_23_44_34
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_25_2011_07_03_08)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_25_2011_07_03_08
#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_ = 41;
+ id_ = 35;
uid_ = 0;
end_token_ = curr_;
@@ -122,7 +122,7 @@
state0_2:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -137,7 +137,7 @@
state0_3:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -152,7 +152,7 @@
state0_4:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -167,7 +167,7 @@
state0_5:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -184,7 +184,7 @@
state0_6:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -199,7 +199,7 @@
state0_7:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -214,7 +214,7 @@
state0_8:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -258,7 +258,7 @@
state0_12:
end_state_ = true;
- id_ = 7077923;
+ id_ = 262177;
uid_ = 20;
end_token_ = curr_;
@@ -271,7 +271,7 @@
state0_13:
end_state_ = true;
- id_ = 4849683;
+ id_ = 131091;
uid_ = 12;
end_token_ = curr_;
@@ -284,7 +284,7 @@
state0_14:
end_state_ = true;
- id_ = 4849685;
+ id_ = 131093;
uid_ = 14;
end_token_ = curr_;
@@ -297,28 +297,28 @@
state0_15:
end_state_ = true;
- id_ = 5898265;
+ id_ = 393241;
uid_ = 16;
end_token_ = curr_;
goto end;
state0_16:
end_state_ = true;
- id_ = 5898266;
+ id_ = 393242;
uid_ = 17;
end_token_ = curr_;
goto end;
state0_17:
end_state_ = true;
- id_ = 6422555;
+ id_ = 131099;
uid_ = 18;
end_token_ = curr_;
goto end;
state0_18:
end_state_ = true;
- id_ = 6422556;
+ id_ = 131100;
uid_ = 19;
end_token_ = curr_;
@@ -373,7 +373,7 @@
state0_25:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -386,7 +386,7 @@
state0_26:
end_state_ = true;
- id_ = 40;
+ id_ = 34;
uid_ = 30;
end_token_ = curr_;
@@ -399,7 +399,7 @@
state0_27:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -414,7 +414,7 @@
state0_28:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -429,7 +429,7 @@
state0_29:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -444,7 +444,7 @@
state0_30:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -472,7 +472,7 @@
state0_32:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -487,7 +487,7 @@
state0_33:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -502,7 +502,7 @@
state0_34:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -517,42 +517,42 @@
state0_35:
end_state_ = true;
- id_ = 1703948;
+ id_ = 131084;
uid_ = 8;
end_token_ = curr_;
goto end;
state0_36:
end_state_ = true;
- id_ = 2228237;
+ id_ = 131085;
uid_ = 9;
end_token_ = curr_;
goto end;
state0_37:
end_state_ = true;
- id_ = 4325393;
+ id_ = 131089;
uid_ = 10;
end_token_ = curr_;
goto end;
state0_38:
end_state_ = true;
- id_ = 4325394;
+ id_ = 131090;
uid_ = 11;
end_token_ = curr_;
goto end;
state0_39:
end_state_ = true;
- id_ = 4849684;
+ id_ = 131092;
uid_ = 13;
end_token_ = curr_;
goto end;
state0_40:
end_state_ = true;
- id_ = 4849686;
+ id_ = 131094;
uid_ = 15;
end_token_ = curr_;
goto end;
@@ -569,7 +569,7 @@
state0_42:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -584,7 +584,7 @@
state0_43:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -599,7 +599,7 @@
state0_44:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -627,7 +627,7 @@
state0_46:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -642,7 +642,7 @@
state0_47:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -657,7 +657,7 @@
state0_48:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -684,7 +684,7 @@
state0_50:
end_state_ = true;
- id_ = 42;
+ id_ = 36;
uid_ = 1;
end_token_ = curr_;
@@ -723,7 +723,7 @@
state0_53:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -738,7 +738,7 @@
state0_54:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -763,7 +763,7 @@
state0_56:
end_state_ = true;
- id_ = 39;
+ id_ = 33;
uid_ = 29;
end_token_ = curr_;
goto end;
@@ -783,7 +783,7 @@
state0_58:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
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 19:47:43 EDT (Sun, 24 Jul 2011)
@@ -41,12 +41,12 @@
// Main expression grammar
expr =
unary_expr
- >> *(tokenid_mask(token::binary) > unary_expr)
+ >> *(tokenid_mask(token::op_binary) > unary_expr)
;
unary_expr =
primary_expr
- | (tokenid_mask(token::unary) > primary_expr)
+ | (tokenid_mask(token::op_unary) > primary_expr)
;
primary_expr =
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ids.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ids.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/ids.hpp 2011-07-24 19:47:43 EDT (Sun, 24 Jul 2011)
@@ -24,6 +24,7 @@
{
enum type
{
+ // binary
comma,
assign,
plus_assign,
@@ -54,37 +55,38 @@
times,
divide,
mod,
- positive,
- negative,
- pre_incr,
- pre_decr,
+
+ // unary
+ plus_plus,
+ minus_minus,
compl_,
not_,
- post_incr,
- post_decr
};
};
- template <int type, int op, int precedence>
+ template <int type, int op>
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 <op::type op>
+ struct unary_op : make_op<op_type::unary, op> {};
- template <int op, int precedence>
+ template <op::type op>
struct binary_op
- : make_op<op_type::binary, op, precedence> {};
+ : make_op<op_type::binary, op> {};
- template <int op, int precedence>
+ template <op::type op>
struct assign_op
- : make_op<op_type::binary | op_type::assign, op, precedence> {};
+ : make_op<op_type::binary | op_type::assign, op> {};
+
+ template <op::type op>
+ struct binary_or_unary_op
+ : make_op<op_type::unary | op_type::binary, op> {};
struct token
{
@@ -92,88 +94,64 @@
{
// 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,
+ op_binary = op_type::binary,
+ op_unary = op_type::unary,
+ op_assign = op_type::assign,
+
+ // binary / unary operators with common tokens
+ // '+' and '-' can be binary or unary
+ // (the lexer cannot distinguish which)
+ plus = binary_or_unary_op<op::plus>::value,
+ minus = binary_or_unary_op<op::minus>::value,
+
+ // binary operators
+ comma = binary_op<op::comma>::value,
+ assign = assign_op<op::assign>::value,
+ plus_assign = assign_op<op::plus_assign>::value,
+ minus_assign = assign_op<op::minus_assign>::value,
+ times_assign = assign_op<op::times_assign>::value,
+ divide_assign = assign_op<op::divide_assign>::value,
+ mod_assign = assign_op<op::mod_assign>::value,
+ bit_and_assign = assign_op<op::bit_and_assign>::value,
+ bit_xor_assign = assign_op<op::bit_xor_assign>::value,
+ bit_or_assign = assign_op<op::bit_or_assign>::value,
+ shift_left_assign = assign_op<op::shift_left_assign>::value,
+ shift_right_assign = assign_op<op::shift_right_assign>::value,
+ logical_or = binary_op<op::logical_or>::value,
+ logical_and = binary_op<op::logical_and>::value,
+ bit_or = binary_op<op::bit_or>::value,
+ bit_xor = binary_op<op::bit_xor>::value,
+ bit_and = binary_op<op::bit_and>::value,
+ equal = binary_op<op::equal>::value,
+ not_equal = binary_op<op::not_equal>::value,
+ less = binary_op<op::less>::value,
+ less_equal = binary_op<op::less_equal>::value,
+ greater = binary_op<op::greater>::value,
+ greater_equal = binary_op<op::greater_equal>::value,
+ shift_left = binary_op<op::shift_left>::value,
+ shift_right = binary_op<op::shift_right>::value,
+ times = binary_op<op::times>::value,
+ divide = binary_op<op::divide>::value,
+ mod = binary_op<op::mod>::value,
+
+ // unary operators with overlaps
+ // '++' and '--' can be prefix or postfix
+ // (the lexer cannot distinguish which)
+ plus_plus = unary_op<op::plus_plus>::value,
+ minus_minus = unary_op<op::minus_minus>::value,
+
+ // unary operators
+ compl_ = unary_op<op::compl_>::value,
+ not_ = unary_op<op::not_>::value,
// misc tags
- identifier = op::post_decr + 1,
+ identifier = op::minus_minus + 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/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 19:47:43 EDT (Sun, 24 Jul 2011)
@@ -157,22 +157,15 @@
// precedence 12
12, // op_times
12, // op_divide
- 12, // op_mod
-
- // precedence 13
- 13, // op_positive
- 13, // op_negative
- 13, // op_pre_incr
- 13, // op_pre_decr
- 13, // op_compl
- 13, // op_not
-
- // precedence 14
- 14, // op_post_incr
- 14 // op_post_decr
+ 12 // op_mod
};
}
+ inline int precedence_of(token::type op)
+ {
+ return precedence[op & 0xFF];
+ }
+
llvm::Value* compiler::compile_binary_expression(
llvm::Value* lhs, llvm::Value* rhs, token::type op)
{
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 19:47:43 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_JUL_24_2011_23_59_45)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_24_2011_23_59_45
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_25_2011_07_25_53)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_JUL_25_2011_07_25_53
#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, 41, 0, 0,
+ 22, 10, 23, 0, 1, 35, 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, 38,
+ 0, 0, 0, 0, 0, 0, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 34, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 0, 0,
- 0, 0, 1, 38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,
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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -246,49 +246,49 @@
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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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, 0, 0,
- 1, 1703948, 8, 0, 0, 0, 0, 0,
+ 1, 131084, 8, 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, 2228237, 9, 0, 0, 0,
+ 0, 0, 1, 131085, 9, 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, 4325393, 10, 0,
+ 0, 0, 0, 0, 1, 131089, 10, 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, 4325394,
+ 0, 0, 0, 0, 0, 0, 1, 131090,
11, 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, 4849684, 13, 0, 0, 0, 0, 0,
+ 1, 131092, 13, 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, 4849686, 15, 0, 0, 0,
+ 0, 0, 1, 131094, 15, 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,
@@ -298,18 +298,18 @@
50, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 1, 38,
+ 42, 42, 42, 42, 42, 42, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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,
@@ -319,18 +319,18 @@
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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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, 38, 28, 0, 0, 0, 0, 0,
+ 1, 32, 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, 38, 28, 0, 0, 0,
+ 0, 0, 1, 32, 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,7 +340,7 @@
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, 42,
+ 56, 56, 56, 56, 56, 56, 1, 36,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 26, 26, 26,
@@ -356,12 +356,12 @@
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, 38, 28, 0,
+ 0, 0, 0, 0, 1, 32, 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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
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,7 +372,7 @@
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, 39, 29, 0, 0, 0,
+ 56, 56, 1, 33, 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,
@@ -382,7 +382,7 @@
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, 38,
+ 26, 26, 0, 0, 0, 0, 1, 32,
28, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 26,
26, 0, 0, 0, 0, 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 19:47:43 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_JUL_24_2011_23_59_45)
-#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_24_2011_23_59_45
+#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_25_2011_07_25_53)
+#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_CONJURE_STATIC_SWITCH_JUL_25_2011_07_25_53
#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_ = 41;
+ id_ = 35;
uid_ = 0;
end_token_ = curr_;
@@ -122,7 +122,7 @@
state0_2:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -137,7 +137,7 @@
state0_3:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -152,7 +152,7 @@
state0_4:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -167,7 +167,7 @@
state0_5:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -184,7 +184,7 @@
state0_6:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -199,7 +199,7 @@
state0_7:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -214,7 +214,7 @@
state0_8:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -258,7 +258,7 @@
state0_12:
end_state_ = true;
- id_ = 7077923;
+ id_ = 262177;
uid_ = 20;
end_token_ = curr_;
@@ -271,7 +271,7 @@
state0_13:
end_state_ = true;
- id_ = 4849683;
+ id_ = 131091;
uid_ = 12;
end_token_ = curr_;
@@ -284,7 +284,7 @@
state0_14:
end_state_ = true;
- id_ = 4849685;
+ id_ = 131093;
uid_ = 14;
end_token_ = curr_;
@@ -297,28 +297,28 @@
state0_15:
end_state_ = true;
- id_ = 5898265;
+ id_ = 393241;
uid_ = 16;
end_token_ = curr_;
goto end;
state0_16:
end_state_ = true;
- id_ = 5898266;
+ id_ = 393242;
uid_ = 17;
end_token_ = curr_;
goto end;
state0_17:
end_state_ = true;
- id_ = 6422555;
+ id_ = 131099;
uid_ = 18;
end_token_ = curr_;
goto end;
state0_18:
end_state_ = true;
- id_ = 6422556;
+ id_ = 131100;
uid_ = 19;
end_token_ = curr_;
@@ -373,7 +373,7 @@
state0_25:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -386,7 +386,7 @@
state0_26:
end_state_ = true;
- id_ = 40;
+ id_ = 34;
uid_ = 30;
end_token_ = curr_;
@@ -399,7 +399,7 @@
state0_27:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -414,7 +414,7 @@
state0_28:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -429,7 +429,7 @@
state0_29:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -444,7 +444,7 @@
state0_30:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -472,7 +472,7 @@
state0_32:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -487,7 +487,7 @@
state0_33:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -502,7 +502,7 @@
state0_34:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -517,42 +517,42 @@
state0_35:
end_state_ = true;
- id_ = 1703948;
+ id_ = 131084;
uid_ = 8;
end_token_ = curr_;
goto end;
state0_36:
end_state_ = true;
- id_ = 2228237;
+ id_ = 131085;
uid_ = 9;
end_token_ = curr_;
goto end;
state0_37:
end_state_ = true;
- id_ = 4325393;
+ id_ = 131089;
uid_ = 10;
end_token_ = curr_;
goto end;
state0_38:
end_state_ = true;
- id_ = 4325394;
+ id_ = 131090;
uid_ = 11;
end_token_ = curr_;
goto end;
state0_39:
end_state_ = true;
- id_ = 4849684;
+ id_ = 131092;
uid_ = 13;
end_token_ = curr_;
goto end;
state0_40:
end_state_ = true;
- id_ = 4849686;
+ id_ = 131094;
uid_ = 15;
end_token_ = curr_;
goto end;
@@ -569,7 +569,7 @@
state0_42:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -584,7 +584,7 @@
state0_43:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -599,7 +599,7 @@
state0_44:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -627,7 +627,7 @@
state0_46:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -642,7 +642,7 @@
state0_47:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -657,7 +657,7 @@
state0_48:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -684,7 +684,7 @@
state0_50:
end_state_ = true;
- id_ = 42;
+ id_ = 36;
uid_ = 1;
end_token_ = curr_;
@@ -723,7 +723,7 @@
state0_53:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -738,7 +738,7 @@
state0_54:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
end_token_ = curr_;
@@ -763,7 +763,7 @@
state0_56:
end_state_ = true;
- id_ = 39;
+ id_ = 33;
uid_ = 29;
end_token_ = curr_;
goto end;
@@ -783,7 +783,7 @@
state0_58:
end_state_ = true;
- id_ = 38;
+ id_ = 32;
uid_ = 28;
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 19:47:43 EDT (Sun, 24 Jul 2011)
@@ -41,12 +41,12 @@
// Main expression grammar
expr =
unary_expr
- >> *(tokenid_mask(token::binary) > unary_expr)
+ >> *(tokenid_mask(token::op_binary) > unary_expr)
;
unary_expr =
primary_expr
- | (tokenid_mask(token::unary) > primary_expr)
+ | (tokenid_mask(token::op_unary) > primary_expr)
;
primary_expr =
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ids.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ids.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/ids.hpp 2011-07-24 19:47:43 EDT (Sun, 24 Jul 2011)
@@ -24,6 +24,7 @@
{
enum type
{
+ // binary
comma,
assign,
plus_assign,
@@ -54,37 +55,38 @@
times,
divide,
mod,
- positive,
- negative,
- pre_incr,
- pre_decr,
+
+ // unary
+ plus_plus,
+ minus_minus,
compl_,
not_,
- post_incr,
- post_decr
};
};
- template <int type, int op, int precedence>
+ template <int type, int op>
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 <op::type op>
+ struct unary_op : make_op<op_type::unary, op> {};
- template <int op, int precedence>
+ template <op::type op>
struct binary_op
- : make_op<op_type::binary, op, precedence> {};
+ : make_op<op_type::binary, op> {};
- template <int op, int precedence>
+ template <op::type op>
struct assign_op
- : make_op<op_type::binary | op_type::assign, op, precedence> {};
+ : make_op<op_type::binary | op_type::assign, op> {};
+
+ template <op::type op>
+ struct binary_or_unary_op
+ : make_op<op_type::unary | op_type::binary, op> {};
struct token
{
@@ -92,88 +94,64 @@
{
// 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,
+ op_binary = op_type::binary,
+ op_unary = op_type::unary,
+ op_assign = op_type::assign,
+
+ // binary / unary operators with common tokens
+ // '+' and '-' can be binary or unary
+ // (the lexer cannot distinguish which)
+ plus = binary_or_unary_op<op::plus>::value,
+ minus = binary_or_unary_op<op::minus>::value,
+
+ // binary operators
+ comma = binary_op<op::comma>::value,
+ assign = assign_op<op::assign>::value,
+ plus_assign = assign_op<op::plus_assign>::value,
+ minus_assign = assign_op<op::minus_assign>::value,
+ times_assign = assign_op<op::times_assign>::value,
+ divide_assign = assign_op<op::divide_assign>::value,
+ mod_assign = assign_op<op::mod_assign>::value,
+ bit_and_assign = assign_op<op::bit_and_assign>::value,
+ bit_xor_assign = assign_op<op::bit_xor_assign>::value,
+ bit_or_assign = assign_op<op::bit_or_assign>::value,
+ shift_left_assign = assign_op<op::shift_left_assign>::value,
+ shift_right_assign = assign_op<op::shift_right_assign>::value,
+ logical_or = binary_op<op::logical_or>::value,
+ logical_and = binary_op<op::logical_and>::value,
+ bit_or = binary_op<op::bit_or>::value,
+ bit_xor = binary_op<op::bit_xor>::value,
+ bit_and = binary_op<op::bit_and>::value,
+ equal = binary_op<op::equal>::value,
+ not_equal = binary_op<op::not_equal>::value,
+ less = binary_op<op::less>::value,
+ less_equal = binary_op<op::less_equal>::value,
+ greater = binary_op<op::greater>::value,
+ greater_equal = binary_op<op::greater_equal>::value,
+ shift_left = binary_op<op::shift_left>::value,
+ shift_right = binary_op<op::shift_right>::value,
+ times = binary_op<op::times>::value,
+ divide = binary_op<op::divide>::value,
+ mod = binary_op<op::mod>::value,
+
+ // unary operators with overlaps
+ // '++' and '--' can be prefix or postfix
+ // (the lexer cannot distinguish which)
+ plus_plus = unary_op<op::plus_plus>::value,
+ minus_minus = unary_op<op::minus_minus>::value,
+
+ // unary operators
+ compl_ = unary_op<op::compl_>::value,
+ not_ = unary_op<op::not_>::value,
// misc tags
- identifier = op::post_decr + 1,
+ identifier = op::minus_minus + 1,
comment,
whitespace,
lit_uint,
true_or_false
};
};
-
- inline int precedence_of(token::type op)
- {
- return (op >> 19) & 0xF;
- }
}
#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