1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "parser_rules.h"
24 PARSE_START_NO_DESCRIPTION(Main
, CParseNode
)
26 while (!tokenizer
.end())
39 PARSE_START(Db
, CDbNode
)
43 PARSE_IDENTIFIER(Name
)
46 PARSE_OPT_KEYWORD_IN(String
, MainFile
);
52 PARSE_ALTERNATIVE(File
)
53 PARSE_ALTERNATIVE(UsePch
)
68 PARSE_START(File
, CFileNode
)
70 PARSE_OPT_BEFORE(File
)
71 PARSE_OPT_IN(Separated
, SeparatedFlag
);
72 PARSE_END_OPT_BEFORE()
79 main
->IncludeAs
= main
->Name
;
81 PARSE_OPT_KEYWORD_IN(String
, IncludeAs
);
87 PARSE_ALTERNATIVE(Include
)
88 PARSE_ALTERNATIVE(Type
)
89 PARSE_ALTERNATIVE(Class
)
90 PARSE_ALTERNATIVE(Enum
)
91 PARSE_ALTERNATIVE(Dimension
)
92 //PARSE_ALTERNATIVE(CppCode)
93 PARSE_ALTERNATIVE(LogMsg
)
94 PARSE_ALTERNATIVE(LogContext
)
109 PARSE_START(Include
, CIncludeNode
)
111 PARSE_KEYWORD(Include
)
121 PARSE_START(UsePch
, CUsePchNode
)
123 PARSE_KEYWORD(UsePch
)
134 PARSE_START(CppCode
, CCppCodeNode
)
136 PARSE_OPT_KEYWORD_IN(Identifier
, Name
)
137 PARSE_KEYWORD_IN(CppCode
, RawCode
)
146 PARSE_START(Type
, CTypeNode
)
148 PARSE_OPT_BEFORE(Type
)
149 PARSE_OPT_IN(Extern
, ExternFlag
);
150 PARSE_END_OPT_BEFORE()
154 if (main
->ExternFlag
)
156 PARSE_SCOPE_IDF(Name
)
160 PARSE_IDENTIFIER(Name
)
163 main
->DisplayName
= main
->Name
;
166 if (tokenizer
.current() == TokenOpenParenthesis
)
170 PARSE_IDENTIFIER(CppType
)
174 PARSE_IDENTIFIER(StorageType
)
176 PARSE_KEYWORD(CloseParenthesis
)
179 if (tokenizer
.current() == TokenOpenBrace
)
184 PARSE_IDENTIFIER(Temp
)
185 if (main
->Temp
== main
->CppType
)
188 PARSE_KEYWORD(OpenParenthesis
)
190 PARSE_IDENTIFIER(Temp
)
191 if (main
->Temp
!= main
->StorageType
)
194 PARSE_KEYWORD(CloseParenthesis
)
196 PARSE_NODE(CppCode
, ToCppType
)
199 else if (main
->Temp
== main
->StorageType
)
202 PARSE_KEYWORD(OpenParenthesis
)
204 PARSE_IDENTIFIER(Temp
)
205 if (main
->Temp
!= main
->CppType
)
208 PARSE_KEYWORD(CloseParenthesis
)
210 PARSE_NODE(CppCode
, ToStorageType
)
216 if (tokenizer
.current() != TokenCloseBrace
)
218 PARSE_IDENTIFIER(Temp
)
220 if (main
->Temp
== main
->CppType
&& main
->ToCppType
== NULL
)
223 PARSE_KEYWORD(OpenParenthesis
)
225 PARSE_IDENTIFIER(Temp
)
226 if (main
->Temp
!= main
->StorageType
)
229 PARSE_KEYWORD(CloseParenthesis
)
231 PARSE_NODE(CppCode
, ToCppType
)
234 else if (main
->Temp
== main
->StorageType
&& main
->ToStorageType
== NULL
)
237 PARSE_KEYWORD(OpenParenthesis
)
239 PARSE_IDENTIFIER(Temp
)
240 if (main
->Temp
!= main
->CppType
)
243 PARSE_KEYWORD(CloseParenthesis
)
245 PARSE_NODE(CppCode
, ToStorageType
)
252 PARSE_KEYWORD(CloseBrace
)
256 PARSE_KEYWORD(SemiColon
)
261 PARSE_IDENTIFIER(CppType
)
262 main
->StorageType
= main
->CppType
;
264 PARSE_KEYWORD(SemiColon
)
275 PARSE_START(Class
, CClassNode
)
277 PARSE_OPT_BEFORE(Class
)
278 PARSE_OPT_IN(Mapped
, MappedFlag
);
279 PARSE_OPT_IN(Derived
, DerivatedFlag
);
280 PARSE_END_OPT_BEFORE()
284 PARSE_IDENTIFIER(Name
)
289 PARSE_IDENTIFIER(Inherited
)
295 PARSE_KEYWORD(OpenParenthesis
)
297 PARSE_IDENTIFIER(ClassKey
)
299 PARSE_KEYWORD(CloseParenthesis
)
303 PARSE_OPT(Implements
)
305 PARSE_IDENTIFIER(Implements
)
311 PARSE_KEYWORD(OpenParenthesis
)
313 PARSE_IDENTIFIER(Reserve
)
315 PARSE_KEYWORD(CloseParenthesis
)
323 PARSE_ALTERNATIVE(CppCode
)
324 PARSE_ALTERNATIVE(Declaration
)
339 PARSE_START(Declaration
, CDeclarationNode
)
341 PARSE_OPT_BEFORE_2(Identifier
, ScopedIdentifier
)
342 PARSE_OPT_IN(WriteTrigger
, WriteTriggerFlag
);
343 PARSE_OPT_IN(InitFill
, InitFillFlag
);
344 PARSE_OPT_IN(Parent
, ParentFlag
);
345 PARSE_OPT_IN(Hidden
, HiddenFlag
);
346 PARSE_OPT_IN(Mirrored
, MirroredFlag
);
347 PARSE_END_OPT_BEFORE()
349 if (main
->ParentFlag
)
351 PARSE_IDENTIFIER(ParentClass
);
355 PARSE_IDENTIFIER(ParentField
);
357 PARSE_IDENTIFIER(Name
);
362 PARSE_SCOPE_IDF(Type
);
367 PARSE_IDENTIFIER(ForwardRefAttribute
);
371 PARSE_OPT(OpenBracket
)
373 PARSE_IDENTIFIER(ArrayIndex
);
375 main
->ArrayFlag
= true;
376 PARSE_KEYWORD(CloseBracket
)
379 PARSE_IDENTIFIER(Name
);
382 PARSE_NEXT_OPT(LessThan
)
383 main
->SetFlag
= true;
385 PARSE_KEYWORD(GreaterThan
)
388 PARSE_IDENTIFIER(Name
);
393 PARSE_IDENTIFIER(Name
);
397 //PARSE_VALUE(DefaultValue)
398 PARSE_KEYWORD_IN(CppCode
, DefaultValue
)
404 if (tokenizer
.current() == TokenOpenBrace
)
409 CDeclarationNode::CUserCode UCode
;
411 PARSE_KEYWORD_IN_TEMP(Identifier
, UCode
.Event
)
413 PARSE_OPT_LIST(OpenParenthesis
, CloseParenthesis
)
415 std::string UCodeAtom
;
416 PARSE_KEYWORD_IN_TEMP(Identifier
, UCodeAtom
)
417 if (!UCode
.CodeSpecializer
.empty())
418 UCode
.CodeSpecializer
+= ".";
419 UCode
.CodeSpecializer
+= UCodeAtom
;
421 PARSE_END_OPT_LIST(CloseParenthesis
, Dot
)
423 PARSE_KEYWORD_IN_TEMP(CppCode
, UCode
.UserCode
)
425 main
->UserCodes
.push_back(UCode
);
432 PARSE_KEYWORD(SemiColon
);
443 PARSE_START(Enum
, CEnumNode
)
447 PARSE_IDENTIFIER(Name
)
449 PARSE_START_LIST(OpenBrace
, CloseBrace
)
453 PARSE_ALTERNATIVE(EnumRange
)
454 PARSE_ALTERNATIVE(EnumSimpleValue
)
459 PARSE_END_LIST(CloseBrace
, Comma
)
461 PARSE_OPT_KEYWORD_IN(Identifier
, EndRange
)
468 PARSE_START(EnumSimpleValue
, CEnumSimpleValueNode
)
470 PARSE_LIST_KEYWORDS(Identifier
, Names
, Or
)
475 PARSE_START(EnumRange
, CEnumRangeNode
)
477 PARSE_IDENTIFIER(Name
)
479 PARSE_START_LIST(OpenBrace
, CloseBrace
)
483 PARSE_ALTERNATIVE(EnumRange
)
484 PARSE_ALTERNATIVE(EnumSimpleValue
)
489 PARSE_END_LIST(CloseBrace
, Comma
)
492 PARSE_OPT_KEYWORD_IN(Identifier
, EndRange
)
502 PARSE_START(Dimension
, CDimensionNode
)
504 PARSE_KEYWORD(Dimension
)
506 PARSE_IDENTIFIER(Name
)
510 PARSE_KEYWORD(SemiColon
);
519 PARSE_START(LogMsg
, CLogMsgNode
)
521 PARSE_KEYWORD(LogMsg
)
523 PARSE_IDENTIFIER(Name
)
526 PARSE_KEYWORD(OpenParenthesis
)
528 PARSE_LIST_2_KEYWORDS(Identifier
, Identifier
, Params
, Comma
)
529 PARSE_KEYWORD(CloseParenthesis
)
532 PARSE_KEYWORD(OpenBrace
)
534 PARSE_LIST_KEYWORDS(String
, Logs
, Comma
)
537 PARSE_KEYWORD(CloseBrace
)
542 PARSE_START(LogContext
, CLogMsgNode
)
544 PARSE_KEYWORD(LogContext
)
546 PARSE_IDENTIFIER(Name
)
549 main
->Context
= true;
551 PARSE_KEYWORD(OpenParenthesis
)
553 PARSE_LIST_2_KEYWORDS(Identifier
, Identifier
, Params
, Comma
)
554 PARSE_KEYWORD(CloseParenthesis
)
557 PARSE_KEYWORD(OpenBrace
)
559 PARSE_LIST_KEYWORDS(String
, Logs
, Comma
)
562 PARSE_KEYWORD(CloseBrace
)