This repository was archived by the owner on Mar 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +70
-1
lines changed
Expand file tree Collapse file tree 2 files changed +70
-1
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,9 @@ module.exports = class JDLParser extends CstParser {
334334 this . RULE ( 'enumPropList' , ( ) => {
335335 this . SUBRULE ( this . enumProp ) ;
336336 this . MANY ( ( ) => {
337- this . CONSUME ( LexerTokens . COMMA ) ;
337+ this . OPTION ( ( ) => {
338+ this . CONSUME ( LexerTokens . COMMA ) ;
339+ } ) ;
338340 this . SUBRULE1 ( this . enumProp ) ;
339341 } ) ;
340342 } ) ;
Original file line number Diff line number Diff line change @@ -938,6 +938,73 @@ entity A {
938938 } ) ;
939939 } ) ;
940940 context ( 'when parsing enums' , ( ) => {
941+ context ( 'with values separated by commas' , ( ) => {
942+ let parsedEnum ;
943+
944+ before ( ( ) => {
945+ const content = parseFromContent (
946+ `enum MyEnum {
947+ FRANCE,
948+ ENGLAND,
949+ ICELAND
950+ }
951+ `
952+ ) ;
953+ parsedEnum = content . enums [ 0 ] ;
954+ } ) ;
955+
956+ it ( 'should parse them' , ( ) => {
957+ expect ( parsedEnum ) . to . deep . equal ( {
958+ name : 'MyEnum' ,
959+ values : [
960+ {
961+ key : 'FRANCE'
962+ } ,
963+ {
964+ key : 'ENGLAND'
965+ } ,
966+ {
967+ key : 'ICELAND'
968+ }
969+ ]
970+ } ) ;
971+ } ) ;
972+ } ) ;
973+ context ( 'with values separated by whitespaces' , ( ) => {
974+ let parsedEnum ;
975+
976+ before ( ( ) => {
977+ const content = parseFromContent (
978+ `enum MyEnum {
979+ FRANCE ENGLAND("aaa bbb ccc") ICELAND
980+ GERMANY
981+ }
982+ `
983+ ) ;
984+ parsedEnum = content . enums [ 0 ] ;
985+ } ) ;
986+
987+ it ( 'should parse them' , ( ) => {
988+ expect ( parsedEnum ) . to . deep . equal ( {
989+ name : 'MyEnum' ,
990+ values : [
991+ {
992+ key : 'FRANCE'
993+ } ,
994+ {
995+ key : 'ENGLAND' ,
996+ value : 'aaa bbb ccc'
997+ } ,
998+ {
999+ key : 'ICELAND'
1000+ } ,
1001+ {
1002+ key : 'GERMANY'
1003+ }
1004+ ]
1005+ } ) ;
1006+ } ) ;
1007+ } ) ;
9411008 context ( 'without custom values' , ( ) => {
9421009 let parsedEnum ;
9431010
You can’t perform that action at this time.
0 commit comments