GG: ExpressionParser.h Source File

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

ExpressionParser.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3 Copyright (C) 2003-2008 T. Zachary Laine
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License
7 as published by the Free Software Foundation; either version 2.1
8 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA
19
20 If you do not wish to comply with the terms of the LGPL please
21 contact the author as other terms are available for a fee.
22
23 Zach Laine
24 whatwasthataddress@gmail.com */
25
28 #ifndef _GG_ExpressionParser_h_
29 #define _GG_ExpressionParser_h_
30
31 #include <GG/Lexer.h>
32 #include <GG/adobe/array.hpp>
33 #include <GG/adobe/dictionary.hpp>
34 #include <GG/adobe/implementation/token.hpp>
35
36 #include <boost/spirit/include/qi.hpp>
37 #include <boost/spirit/include/phoenix.hpp>
38
39
40 namespace GG {
41
42 struct GG_API expression_parser_rules
43 {
44 typedef boost::spirit::qi::rule<
45 token_iterator,
46 adobe::name_t(),
47 skipper_type
48 > keyword_rule;
49
50 expression_parser_rules(const lexer& tok, const keyword_rule& keyword_);
51
52 typedef boost::spirit::qi::rule<
53 token_iterator,
54 void(adobe::array_t&),
55 boost::spirit::qi::locals<adobe::array_t, adobe::array_t>,
56 skipper_type
57 > expression_rule;
58 typedef boost::spirit::qi::rule<
59 token_iterator,
60 void(adobe::array_t&),
61 boost::spirit::qi::locals<adobe::name_t>,
62 skipper_type
63 > local_name_rule;
64 typedef boost::spirit::qi::rule<
65 token_iterator,
66 void(adobe::array_t&),
67 boost::spirit::qi::locals<std::size_t>,
68 skipper_type
69 > local_size_rule;
70 typedef boost::spirit::qi::rule<
71 token_iterator,
72 void(adobe::array_t&),
73 boost::spirit::qi::locals<adobe::array_t>,
74 skipper_type
75 > local_array_rule;
76 typedef boost::spirit::qi::rule<
77 token_iterator,
78 void(adobe::array_t&),
79 skipper_type
80 > no_locals_rule;
81
82 // expression grammar
83 expression_rule expression;
84
85 local_array_rule or_expression;
86 local_array_rule and_expression;
87 local_name_rule equality_expression;
88 local_name_rule relational_expression;
89 local_name_rule additive_expression;
90 local_name_rule multiplicative_expression;
91 local_name_rule unary_expression;
92 no_locals_rule postfix_expression;
93 no_locals_rule primary_expression;
94 local_name_rule variable_or_function;
95 no_locals_rule array;
96 no_locals_rule dictionary;
97 no_locals_rule argument_expression_list;
98 local_size_rule argument_list;
99 local_size_rule named_argument_list;
100 local_name_rule named_argument;
101 no_locals_rule name;
102 no_locals_rule boolean;
103
104 // lexical grammar
105 boost::spirit::qi::rule<
106 token_iterator,
107 void(adobe::array_t&),
108 boost::spirit::qi::locals<std::string>,
109 skipper_type
110 > string;
111 keyword_rule keyword;
112 };
113
114 }
115
116 #endif