]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/DataBoardRepository.cpp
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / DataBoard / DataBoardRepository.cpp
1 #include "DataBoardRepository.h"
2
3 #include "RecordType.h"
4 #include "ArrayType.h"
5 #include "Constants.h"
6 #include "Component.h"
7 #include "IntegerType.h"
8 #include "DataType.h"
9 #include "StringType.h"
10 #include "DoubleType.h"
11 #include "LongType.h"
12 #include "ByteType.h"
13 #include "BooleanType.h"
14 #include "MapType.h"
15 #include "OptionalType.h"
16 #include "UnionType.h"
17 #include "VariantType.h"
18 #include "Range.h"
19 #include "Limit.h"
20
21 #include <iostream>
22 #include <sstream>
23
24 namespace Databoard {
25         namespace Type {
26
27                 std::string strTypeDefinition::writeOut()
28                 {
29                         std::string r;
30                         
31                         r += "type " + name + " = ";
32
33                         r += dataBoard->writeOut();
34
35                         return r;
36                 }
37
38                 DataBoardRepository::DataBoardRepository()
39                 {
40                 }
41
42                 DataBoardRepository::~DataBoardRepository()
43                 {
44                         for(int i = 0; i < (int)dataBoards.size(); ++i)
45                         {
46                                 delete dataBoards.at(i).dataBoard;
47                         }
48
49                         dataBoards.clear();
50                 }
51
52                 void DataBoardRepository::addDataBoard(char* name, DataType* dataBoard)
53                 {
54                         strTypeDefinition dataBoard_;
55
56                         dataBoard_.name = std::string(name);
57                         dataBoard_.dataBoard = dataBoard;
58
59                         dataBoards.push_back(dataBoard_);
60                 }
61
62                 int DataBoardRepository::count()
63                 {
64                         return (int)dataBoards.size();
65                 }
66
67                 strTypeDefinition DataBoardRepository::getDataBoard(int i)
68                 {
69                         return dataBoards.at(i);
70                 }
71
72                 DataType* DataBoardRepository::getDataBoard(std::string name)
73                 {
74                         for(int i = 0; i < (int)dataBoards.size(); ++i)
75                         {
76                                 if(dataBoards.at(i).name == name)
77                                 {
78                                         return dataBoards.at(i).dataBoard;
79                                 }
80                         }
81
82                         return NULL;
83                 }
84
85                 bool DataBoardRepository::open(std::string fileName)
86                 {
87                         pANTLR3_INPUT_STREAM input = antlr3AsciiFileStreamNew((pANTLR3_UINT8)fileName.c_str());
88
89                         if ( input == NULL )
90                         {
91                                 ANTLR3_FPRINTF(stderr, "string: %s\n", fileName.c_str());
92
93                                 return false;
94                         }
95
96                         pSimanticsDataLexer lexer = SimanticsDataLexerNew(input);
97
98                         if ( lexer == NULL )
99                         {
100                                 ANTLR3_FPRINTF(stderr, "Unable to create the lexer due to malloc() failure1\n");
101                                 //exit(ANTLR3_ERR_NOMEM);
102
103                                 return false;
104                         }
105
106                         pANTLR3_COMMON_TOKEN_STREAM tstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lexer));//->pLexer->tokSource);
107
108                         if (tstream == NULL)
109                         {
110                                 ANTLR3_FPRINTF(stderr, "Out of memory trying to allocate token stream\n");
111                                 //exit(ANTLR3_ERR_NOMEM);
112
113                                 return false;
114                         }
115
116                         pSimanticsDataParser parser = SimanticsDataParserNew(tstream); // CParserNew is generated by ANTLR3
117
118                         if (parser == NULL)
119                         {
120                                 ANTLR3_FPRINTF(stderr, "Out of memory trying to allocate parser\n");
121                                 //exit(ANTLR3_ERR_NOMEM);
122
123                                 return false;
124                         }
125
126                         SimanticsDataParser_typeDefinitions_return astType = parser->typeDefinitions(parser);
127
128                         bool retValue = true;
129
130                         if(lexer->pLexer->rec->state->errorCount == 0)
131                         {
132                                 temporaryname t(this);
133
134                                 t.parse(astType.tree);
135                         
136                                 //print(astType.tree);
137                         }
138                         else
139                         {
140                                 retValue = false;
141                         }
142
143
144                         parser->free(parser);
145                         tstream->free(tstream);
146                         lexer->free(lexer);
147                         input->free(input);
148
149                         return retValue;
150                 }
151
152                 void DataBoardRepository::print(pANTLR3_BASE_TREE tree, int indent)
153                 {
154                         for(int i=0;i<indent;++i)
155                                 std::cout << "  ";
156
157                         std::cout << tree->getText(tree)->chars << " " << 
158                                 tree->getType(tree) << std::endl;
159
160                         for(int i=0;i<(int)tree->getChildCount(tree);++i)
161                         {
162                                 print((pANTLR3_BASE_TREE)tree->getChild(tree, i), indent + 1);
163                         }
164                 }
165
166                 const strTypeDefinition* DataBoardRepository::get(std::string name)
167                 {
168                         for(int i = 0; i < (int)dataBoards.size(); ++i)
169                         {
170                                 const strTypeDefinition& dataBoard = dataBoards.at(i); // for debug purposes
171
172                                 if(dataBoard.name == name)
173                                 {
174                                         return &dataBoard;
175                                 }
176                         }
177
178                         return NULL;
179                 }
180
181                 ///////////////////////////////////////////////
182
183                 temporaryname::temporaryname(DataBoardRepository* dataBoardRepository)
184                 {
185                         this->dataBoardRepository = dataBoardRepository;
186                 }
187
188                 temporaryname::~temporaryname()
189                 {
190                 }
191
192                 DataType* temporaryname::parse(pANTLR3_BASE_TREE tree, DataType* parent, int indent)
193                 //DataType* DataBoardRepository::parse(pANTLR3_BASE_TREE tree, DataType* parent, int indent)
194                 //DataType* parse(pANTLR3_BASE_TREE tree, DataType* parent, int indent)
195                 {
196                         switch(tree->getType(tree)) {
197                                 case TYPE_DEFINITIONS:
198                                         {
199                                                 for(int i=0;i<(int)tree->getChildCount(tree);++i)
200                                                 {
201                                                         parse((pANTLR3_BASE_TREE)tree->getChild(tree, i), parent, indent + 1);
202                                                 }
203                                         }
204                                         break;
205                                 case TYPE_DEFINITION:
206                                         {
207                                                 if(tree->getChildCount(tree) == 2)
208                                                 {
209                                                         pANTLR3_BASE_TREE id = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
210                                                         pANTLR3_BASE_TREE type = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
211
212                                                         DataType* dataBoard = parse(type, parent, indent+1);
213
214                                                         if(dataBoard != NULL)
215                                                         {
216                                                                 dataBoard->setNotBuiltIn();
217
218                                                                 if(dataBoardRepository != NULL)
219                                                                 {
220                                                                         dataBoardRepository->addDataBoard((char*)id->getText(id)->chars, dataBoard);
221                                                                 }
222                                                         }
223                                                 }
224                                         }
225                                         break;
226                                 case TUPLE_TYPE:
227                                         {
228                                                 RecordType* record = new RecordType();
229
230                                                 for(int i=0;i<(int)tree->getChildCount(tree);++i)
231                                                 {
232                                                         DataType* childType = parse((pANTLR3_BASE_TREE)tree->getChild(tree, i), record, indent + 1);
233
234                                                         if(childType != NULL)
235                                                         {
236                                                                 std::stringstream ss;
237
238                                                                 ss << i;
239
240                                                                 std::string tupleId;
241
242                                                                 ss >> tupleId;
243
244                                                                 addToChildren(record, (char*)tupleId.c_str(), childType);
245                                                         }
246                                                 }
247
248                                                 return record;
249                                         }
250
251                                         break;
252
253                                 case RECORD_TYPE:
254                                         {
255                                                 RecordType* record = new RecordType();
256
257                                                 for(int i=0;i<(int)tree->getChildCount(tree);++i)
258                                                 {
259                                                         DataType* childType = parse((pANTLR3_BASE_TREE)tree->getChild(tree, i), record, indent + 1);
260                                                 }
261
262                                                 return record;
263                                         }
264
265                                         break;
266                                 case ARRAY_TYPE:
267                                         {
268                                                 ArrayType* arrayType = new ArrayType();
269
270                                                 int childCount = tree->getChildCount(tree);
271
272                                                 if(childCount >= 1)
273                                                 {
274                                                         DataType* dataType = parse((pANTLR3_BASE_TREE)tree->getChild(tree, 0), parent);
275
276                                                         arrayType->setComponentType(dataType);
277                                                         
278                                                         if(childCount >= 2)
279                                                         {
280                                                                 Range* range = parseRange(tree, 1, childCount);
281
282                                                                 arrayType->setLength(range);
283                                                         }
284                                                 }
285
286                                                 return arrayType;
287                                         }
288
289                                         break;
290
291                                 case UNION_TYPE:
292                                         {
293                                                 UnionType* unionType = new UnionType();
294
295                                                 int childCount = tree->getChildCount(tree);
296
297                                                 for(int i=0;i<(int)tree->getChildCount(tree);++i)
298                                                 {
299                                                         pANTLR3_BASE_TREE p = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
300
301                                                         if(p->getChildCount(p) == 1)
302                                                         {
303                                                                 pANTLR3_BASE_TREE t = (pANTLR3_BASE_TREE)p->getChild(p, 0);
304                                                                 
305                                                                 std::string dataTypeName((char*)t->getText(t)->chars);
306
307                                                                 DataType* dataType = NULL;
308
309                                                                 if(dataBoardRepository != NULL)
310                                                                 {
311                                                                         dataType = dataBoardRepository->getDataBoard(dataTypeName);
312                                                                 }
313
314                                                                 unionType->addComponent(dataTypeName, dataType);
315                                                         }
316                                                 }
317
318                                                 return unionType;
319                                         }
320                                         break;
321
322                                 case TYPE_COMPONENT:
323                                         {
324                                                 pANTLR3_BASE_TREE parameter = NULL;
325                                                 pANTLR3_BASE_TREE type = NULL;
326                                                 
327                                                 if(tree->getChildCount(tree) == 2)
328                                                 {
329                                                         parameter = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
330                                                         type = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
331                                                 }
332
333                                                 DataType* returnType = NULL;
334
335                                                 if(type != NULL)
336                                                 {
337                                                         if(type->getType(type) == TYPE_REFERENCE)
338                                                         {
339                                                                 returnType = parse(type, parent, indent + 1);
340                                                         }
341                                                         else if(type->getType(type) == RECORD_TYPE)
342                                                         {
343                                                                 returnType = parse(type, parent, indent + 1);
344                                                         }
345                                                         else if(type->getType(type) == TUPLE_TYPE)
346                                                         {
347                                                                 returnType = parse(type, parent, indent + 1);
348                                                         }
349                                                         else if(type->getType(type) == ARRAY_TYPE)
350                                                         {
351                                                                 returnType = parse(type, parent, indent + 1);
352                                                         }
353                                                         else
354                                                         {
355                                                                 //std::cout << "!!" << std::endl;
356                                                                 //std::cout << parameter->getText(parameter)->chars << std::endl;
357                                                                 //std::cout << parameter->getType(parameter) << std::endl;
358
359                                                                 //std::cout << type->getText(type)->chars << std::endl;
360                                                                 //std::cout << type->getType(type) << std::endl;
361                                                         }
362                                                 }
363
364                                                 if(parameter != NULL && returnType != NULL)
365                                                 {
366                                                         addToChildren(parent, (char*)parameter->getText(parameter)->chars, returnType);
367                                                 }
368
369                                                 return returnType;
370
371                                                 break;
372                                         }
373                                 case TYPE_REFERENCE:
374                                         if(tree->getChildCount(tree) >= 1)
375                                         {
376                                                 pANTLR3_BASE_TREE id = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
377
378                                                 const char* typeName = (char*)id->getText(id)->chars;
379
380                                                 bool errFound = false;
381
382                                                 DataType* returnType = NULL;
383
384                                                 if(id->getType(id) == ID)
385                                                 {
386                                                         if(strEquals(typeName, STR_BOOLEAN) == true)
387                                                         {
388                                                                 returnType = new BooleanType();
389                                                         }
390                                                         else if(strEquals(typeName, STR_INTEGER) == true)
391                                                         {
392                                                                 returnType = new IntegerType();
393                                                         }
394                                                         else if(strEquals(typeName, STR_DOUBLE) == true)
395                                                         {
396                                                                 returnType = new DoubleType();
397                                                         }
398                                                         else if(strEquals(typeName, STR_BYTE) == true)
399                                                         {
400                                                                 returnType = new ByteType();
401                                                         }
402                                                         else if(strEquals(typeName, STR_LONG) == true)
403                                                         {
404                                                                 returnType = new LongType();
405                                                         }
406                                                         else if(strEquals(typeName, STR_FLOAT) == true)
407                                                         {
408                                                                 // double=>float contradiction on purpose
409                                                                 returnType = new DoubleType();
410                                                         }
411                                                         else if(strEquals(typeName, STR_STRING) == true)
412                                                         {
413                                                                 returnType = new StringType();
414                                                         }
415                                                         else if(strEquals(typeName, STR_MAP) == true)
416                                                         {
417                                                                 returnType = new MapType();
418                                                         }
419                                                         else if(strEquals(typeName, STR_OPTIONAL) == true)
420                                                         {
421                                                                 returnType = new OptionalType();
422                                                         }
423                                                         else if(strEquals(typeName, STR_VARIANT) == true)
424                                                         {
425                                                                 returnType = new VariantType();
426                                                         }
427                                                         else
428                                                         {
429                                                                 if(dataBoardRepository != NULL)
430                                                                 {
431                                                                         returnType = dataBoardRepository->getDataBoard(typeName);
432                                                                 }
433                                                         }
434                                                 }
435
436                                                 parseParameters(tree, returnType);
437
438                                                 //if(errFound == true)
439                                                 //{
440                                                 //      std::cout << "!-" << std::endl;
441                                                 //      std::cout << "unknown: " << typeName << std::endl << std::endl;
442
443                                                 //      std::cout << parameter->getText(parameter)->chars << std::endl;
444                                                 //      std::cout << parameter->getType(parameter) << std::endl;
445
446                                                 //      std::cout << "-!" << std::endl;
447                                                 //}
448
449                                                 return returnType;
450                                         }
451                                         break;
452                                 case TYPE_ANNOTATION:
453                                         if(tree->getChildCount(tree) == 2)
454                                         {
455                                                 pANTLR3_BASE_TREE id = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
456                                                 pANTLR3_BASE_TREE parameterValue = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
457
458                                                 const char* idName = (char*)id->getText(id)->chars;
459
460                                                 if(strEquals(idName, STR_UNIT) == true)
461                                                 {
462                                                         std::string strValue((char*)parameterValue->getText(parameterValue)->chars);
463
464                                                         NumberType* numberType = dynamic_cast<NumberType*>(parent);
465
466                                                         if(numberType != NULL)
467                                                         {
468                                                                 numberType->setUnit(strValue);
469                                                         }
470                                                 }
471                                                 //else if(strEquals(typeName, STR_RANGE) == true)
472                                                 //{
473                                                 //}
474                                                 else if(strEquals(idName, STR_PATTERN) == true)
475                                                 {
476                                                         std::string strValue((char*)parameterValue->getText(parameterValue)->chars);
477
478                                                         StringType* stringType = dynamic_cast<StringType*>(parent);
479
480                                                         if(stringType != NULL)
481                                                         {
482                                                                 stringType->setPattern(strValue);
483                                                         }
484                                                 }
485                                                 else if(strEquals(idName, STR_MIMETYPE) == true)
486                                                 {
487                                                         std::string strValue((char*)parameterValue->getText(parameterValue)->chars);
488
489                                                         StringType* stringType = dynamic_cast<StringType*>(parent);
490
491                                                         if(stringType != NULL)
492                                                         {
493                                                                 stringType->setMimeType(strValue);
494                                                         }
495                                                 }
496                                                 //else if(strEquals(idName, STR_LENGTH) == true) // range
497                                                 //{
498                                                 //      std::string strValue((char*)parameterValue->getText(parameterValue)->chars);
499
500                                                 //      StringType* stringType = dynamic_cast<StringType*>(parent);
501
502                                                 //      if(stringType != NULL)
503                                                 //      {
504                                                 //              stringType->setLength(strValue);
505                                                 //      }
506                                                 //}
507                                         }
508
509                                         break;
510                                 case ID:
511                                         parent = parent;
512                                         break;
513
514                                 default:
515                                         break;
516                         }
517
518                         return NULL;
519                 }
520
521                 Range* temporaryname::parseRange(pANTLR3_BASE_TREE tree, int minPos, int maxPos)
522                 //Range* DataBoardRepository::parseRange(pANTLR3_BASE_TREE tree, int minPos, int maxPos)
523                 //Range* parseRange(pANTLR3_BASE_TREE tree, int minPos, int maxPos)
524                 {
525                         Range* range = new Range();
526
527                         bool rangeLower = true;
528
529                         bool inclusiveLower = true;
530                         bool inclusiveUpper = true;
531
532                         for(int i = minPos;i < maxPos; ++i)
533                         {
534                                 pANTLR3_BASE_TREE rangechild = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
535
536                                 std::string rangeString((char*)rangechild->getText(rangechild)->chars);
537
538                                 if(i == minPos && rangeString == STR_BRACEOPEN)
539                                 {
540                                         inclusiveLower = false;
541                                 }
542                                 else if(i == minPos && rangeString == STR_BRACKETOPEN)
543                                 {
544                                         inclusiveLower = true;
545                                 }
546                                 else if(i == (maxPos-1) && rangeString == STR_BRACECLOSE)
547                                 {
548                                         inclusiveUpper = false;
549                                 }
550                                 else if(i == (maxPos-1) && rangeString == STR_BRACKETCLOSE)
551                                 {
552                                         inclusiveUpper = true;
553                                 }
554                                 else if(rangeString == STR_RANGESPLIT)
555                                 {
556                                         rangeLower = false;
557                                 }
558                                 else
559                                 {
560                                         if(rangeLower == true)
561                                         {
562                                                 range->setLower(rangeString);
563                                         }
564                                         else
565                                         {
566                                                 range->setUpper(rangeString);
567                                         }
568                                 }
569                         }
570
571                         if(inclusiveLower == true)
572                         {
573                                 range->getLower()->setInclusive();
574                         }
575                         if(inclusiveUpper == true)
576                         {
577                                 range->getUpper()->setInclusive();
578                         }
579
580                         // split not received => upper = lower
581                         if(rangeLower == true)
582                         {
583                                 range->setUpper(range->getLower()->getValue());
584                         }
585
586                         return range;
587                 }
588
589                 bool temporaryname::addToChildren(DataType* parent, char* name, DataType* children)
590                 //bool DataBoardRepository::addToChildren(DataType* parent, char* name, DataType* children)
591                 //bool addToChildren(DataType* parent, char* name, DataType* children)
592                 {
593                         //TypeRoot* typeRoot = dynamic_cast<TypeRoot*>(parent);
594
595                         //if(typeRoot != NULL)
596                         //{
597                         //      typeRoot->addDataBoard(name, children);
598
599                         //      return true;
600                         //}
601
602                         RecordType* recordType = dynamic_cast<RecordType*>(parent);
603
604                         if(recordType != NULL)
605                         {
606                                 recordType->addComponent(name, children);
607
608                                 return true;
609                         }
610
611                         return false;
612                 }
613
614                 void temporaryname::parseParameters(pANTLR3_BASE_TREE tree, DataType* type)
615                 //void DataBoardRepository::parseParameters(pANTLR3_BASE_TREE tree, DataType* type)
616                 //void parseParameters(pANTLR3_BASE_TREE tree, DataType* type)
617                 {
618                         if((int)tree->getChildCount(tree) >= 2)
619                         {
620                                 if(dynamic_cast<NumberType*>(type) != NULL)
621                                 {
622                                         NumberType* numberType = (NumberType*)type;
623
624                                         int annotationCount = (int)tree->getChildCount(tree);
625
626                                         if(annotationCount >= 1)
627                                         {
628                                                 for(int i = 1; i < annotationCount; ++i)
629                                                 {
630                                                         pANTLR3_BASE_TREE annotation = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
631
632                                                         pANTLR3_BASE_TREE unit = (pANTLR3_BASE_TREE)annotation->getChild(annotation, 0);
633
634                                                         const char* unitName = (char*)unit->getText(unit)->chars;
635
636                                                         if(strEquals(unitName, STR_UNIT) == true)
637                                                         {
638                                                                 if((int)annotation->getChildCount(annotation) == 2)
639                                                                 {
640                                                                         pANTLR3_BASE_TREE value = (pANTLR3_BASE_TREE)annotation->getChild(annotation, 1);
641
642                                                                         std::string strValue((char*)value->getText(value)->chars);
643
644                                                                         strValue = removeQuotes(strValue);
645
646                                                                         NumberType* numberType = dynamic_cast<NumberType*>(type);
647
648                                                                         if(numberType != NULL)
649                                                                         {
650                                                                                 numberType->setUnit(strValue);
651                                                                         }
652                                                                 }
653                                                         }
654                                                         else if(strEquals(unitName, STR_RANGE) == true)
655                                                         {
656                                                                 int c = (int)annotation->getChildCount(annotation);
657                                                                 // possibilities:
658                                                                 // 5: range;[;n;..;]
659                                                                 // 5: range;[;..;m;]
660                                                                 // 6: range;[;n;..;m;]
661                                                                 if(c >= 5)
662                                                                 {
663                                                                         //pANTLR3_BASE_TREE openBracket = (pANTLR3_BASE_TREE)annotation->getChild(annotation, 0);
664                                                                         //pANTLR3_BASE_TREE closeBracket = (pANTLR3_BASE_TREE)annotation->getChild(annotation, c-1);
665
666                                                                         //if((char)(openBracket->getText(openBracket)->chars) != '[' &&
667                                                                         //      (char)(closeBracket->getText(closeBracket)->chars) != ']')
668                                                                         //{
669                                                                                 Range* range = parseRange(annotation, 1, c);
670
671                                                                                 numberType->setRange(range);
672                                                                         //}
673                                                                 }
674                                                         }
675                                                 }
676                                         }
677                                 }
678                                 else if(dynamic_cast<StringType*>(type) != NULL)
679                                 {
680                                         StringType* stringType = (StringType*)type;
681
682                                         for(int i = 1; i < (int)tree->getChildCount(tree); ++i)
683                                         {
684                                                 pANTLR3_BASE_TREE annotation = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
685
686                                                 pANTLR3_BASE_TREE unit = (pANTLR3_BASE_TREE)annotation->getChild(annotation, 0);
687                                                 pANTLR3_BASE_TREE value = (pANTLR3_BASE_TREE)annotation->getChild(annotation, 1);
688
689                                                 const char* unitName = (char*)unit->getText(unit)->chars;
690
691                                                 if(strEquals(unitName, STR_PATTERN) == true)
692                                                 {
693                                                         std::string strValue((char*)value->getText(value)->chars);
694
695                                                         strValue = removeQuotes(strValue);
696
697                                                         StringType* stringType = dynamic_cast<StringType*>(type);
698
699                                                         if(stringType != NULL)
700                                                         {
701                                                                 stringType->setPattern(strValue);
702                                                         }
703                                                 }
704                                                 else if(strEquals(unitName, STR_MIMETYPE) == true)
705                                                 {
706                                                         std::string strValue((char*)value->getText(value)->chars);
707
708                                                         strValue = removeQuotes(strValue);
709
710                                                         StringType* stringType = dynamic_cast<StringType*>(type);
711
712                                                         if(stringType != NULL)
713                                                         {
714                                                                 stringType->setMimeType(strValue);
715                                                         }
716                                                 }
717                                                 //else if(strEquals(idName, STR_LENGTH) == true) // range
718                                                 //{
719                                                 //      std::string strValue((char*)parameterValue->getText(parameterValue)->chars);
720
721                                                 //      StringType* stringType = dynamic_cast<StringType*>(parent);
722
723                                                 //      if(stringType != NULL)
724                                                 //      {
725                                                 //              stringType->setLength(strValue);
726                                                 //      }
727                                                 //}
728                                         }
729                                 }
730                                 else if(dynamic_cast<MapType*>(type) != NULL)
731                                 {
732                                         MapType* mapType = (MapType*)type;
733
734                                         if((int)tree->getChildCount(tree) == 3)
735                                         {
736                                                 pANTLR3_BASE_TREE key = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
737                                                 pANTLR3_BASE_TREE value = (pANTLR3_BASE_TREE)tree->getChild(tree, 2);
738
739                                                 DataType* typeKey = parse(key, mapType);
740                                                 DataType* typeValue = parse(value, mapType);
741
742                                                 mapType->setKeyType(typeKey);
743                                                 mapType->setValueType(typeValue);
744                                         }
745                                 }
746                                 else if(dynamic_cast<OptionalType*>(type) != NULL)
747                                 {
748                                         OptionalType* optionalType = (OptionalType*)type;
749
750                                         if((int)tree->getChildCount(tree) == 2)
751                                         {
752                                                 pANTLR3_BASE_TREE typeRef = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
753
754                                                 DataType* dataType = parse(typeRef, optionalType);
755
756                                                 if(dataType != NULL)
757                                                 {
758                                                         optionalType->setComponentType(dataType);
759                                                 }
760                                         }
761                                 }
762                         }
763
764                         //for(int i = 1; i < (int)tree->getChildCount(tree); ++i)
765                         //{
766                         //      pANTLR3_BASE_TREE parameter = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
767
768                         //      parse(parameter, returnType, indent + 1);
769                         //}
770                 }
771         }
772 }