The list of enum values is now allowed to end in a comma.
authorWouter van Oortmerssen <wvo@google.com>
Thu, 21 Aug 2014 22:17:45 +0000 (15:17 -0700)
committerWouter van Oortmerssen <wvo@google.com>
Fri, 22 Aug 2014 21:02:32 +0000 (14:02 -0700)
Bug: 16490424
Change-Id: Ic3dd5f06efb5cf2dc4aefbd3f2db64c7b59b6b93
Tested: on OS X.

src/idl_parser.cpp
tests/monster_test.fbs

index 8b7f78e..bf550df 100644 (file)
@@ -725,7 +725,7 @@ void Parser::ParseEnum(bool is_union) {
       if (prevsize && enum_def.vals.vec[prevsize - 1]->value >= ev.value)
         Error("enum values must be specified in ascending order");
     }
-  } while (IsNext(','));
+  } while (IsNext(',') && token_ != '}');
   Expect('}');
   if (enum_def.attributes.Lookup("bit_flags")) {
     for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
index 7494144..9f3920d 100755 (executable)
@@ -4,7 +4,7 @@ include "include_test1.fbs";
 
 namespace MyGame.Example;
 
-enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3 }
+enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3, }
 
 union Any { Monster }  // TODO: add more elements