Parser: build methods and constructors.
[fail.git] / src / idl / parser / grammar_class.h
blobf7fe6b6c0bc34c9f43ad8671b98fb0f0b8bfbfc1
1 /*
2 Fail game engine
3 Copyright 2007-2009 Antoine Chavasse <a.chavasse@gmail.com>
5 This file is part of Fail.
7 Fail is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3
9 as published by the Free Software Foundation.
11 Fail is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef FAIL_IDL_PARSER_GRAMMAR_CLASS_H
20 #define FAIL_IDL_PARSER_GRAMMAR_CLASS_H
22 #include "actions_class.h"
24 namespace fail { namespace idlparser
26 struct InheritanceList;
27 struct ClassContent;
28 struct Signal;
29 struct Attribute;
30 struct Function;
31 struct Method;
32 struct StaticMethod;
33 struct Ctor;
34 struct ParamList;
36 struct Class :
37 ifmust<
38 KWclass,
39 seq<
40 Spacing,
41 ifapply<
42 ifapply< identifier, capture< cap_ClassName > >,
43 NewClass >,
44 opt< InheritanceList >,
45 enclose< LeftBrace, ClassContent, RightBrace >,
46 SemiColon,
47 apply< EndClass >
49 > {};
51 struct Struct :
52 ifmust<
53 KWstruct,
54 seq<
55 Spacing,
56 ifapply<
57 ifapply< identifier, capture< cap_ClassName > >,
58 NewStruct >,
59 opt< InheritanceList >,
60 enclose< LeftBrace, ClassContent, RightBrace >,
61 SemiColon
63 > {};
65 struct ClassRef :
66 seq<
67 apply< NewClassRef >,
68 FailList< identifier, ColonColon, AddClassRefComponent >
69 > {};
71 struct InheritanceList :
72 ifmust<
73 Colon,
74 FailList< ClassRef, Comma, AddSuperClass >
75 > {};
77 struct ClassContent :
78 sor<
79 pegtl::plus< sor< FlagList, Signal, Function, Attribute, Enum > >,
80 Spacing
81 > {};
83 struct Attribute :
84 seq<
85 Type,
86 ifapply< identifier, capture< cap_MemberName > >,
87 SemiColon,
88 apply< NewAttribute >
89 > {};
91 struct Signal :
92 seq<
93 Padded< KWSignal >,
94 Less,
95 opt< FailList< Type, Comma > >,
96 Greater,
97 identifier,
98 SemiColon
99 > {};
101 struct Function :
102 sor<
103 ifapply< StaticMethod, NewStaticMethod >,
104 ifapply< Ctor, NewCtor >,
105 ifapply< Method, NewMethod >
106 > {};
108 struct Method :
109 seq<
110 opt< Padded< ifapply< KWvirtual, SetVirtual > > >,
111 sor< Padded< KWvoid >, Type >,
112 not_at< capture< cap_ClassName > >,
113 ifapply< identifier, capture< cap_MemberName > >,
114 ParamList,
115 opt< KWconst >,
116 SemiColon
117 > {};
119 struct StaticMethod :
120 seq<
121 Padded< KWstatic >,
122 sor< Padded< KWvoid >, Type >,
123 not_at< capture< cap_ClassName > >,
124 ifapply< identifier, capture< cap_MemberName > >,
125 ParamList,
126 SemiColon
127 > {};
129 struct Ctor :
130 seq<
131 Padded< capture< cap_ClassName > >,
132 ParamList,
133 SemiColon
134 > {};
136 struct Param :
137 seq<
138 Type,
139 ifapply< identifier, AddParam >
140 > {};
142 struct ParamList :
143 seq<
144 LeftParen,
145 apply< NewParamList >,
146 opt< FailList< Param, Comma > >,
147 RightParen
148 > {};
151 #endif