@@ -41,6 +41,7 @@ class CndParser extends AbstractParser
4141 private $ PRIMARYITEM = array ('primaryitem ' , '! ' );//, 'variant' => false);
4242
4343 // common for properties and child definitions
44+ private $ PRIMARY = array ('! ' , 'pri ' , 'primary ' ); //, 'variant' => true),
4445 private $ AUTOCREATED = array ('a ' , 'aut ' , 'autocreated ' ); //, 'variant' => true),
4546 private $ MANDATORY = array ('m ' , 'man ' , 'mandatory ' ); //, 'variant' => true),
4647 private $ PROTECTED = array ('p ' , 'pro ' , 'protected ' ); //, 'variant' => true),
@@ -343,7 +344,7 @@ protected function parsePropDef(NodeTypeTemplateInterface $nodeType)
343344 $ this ->parseDefaultValue ($ property );
344345 }
345346
346- $ this ->parsePropertyAttributes ($ property );
347+ $ this ->parsePropertyAttributes ($ nodeType , $ property );
347348
348349 // Check if there is a constraint (and not another namespace def)
349350 // Next token is '<' and two token later it's not '=', i.e. not '<ident='
@@ -370,7 +371,7 @@ protected function parsePropertyType(PropertyDefinitionTemplateInterface $proper
370371 $ types = array ("STRING " , "BINARY " , "LONG " , "DOUBLE " , "BOOLEAN " , "DATE " , "NAME " , "PATH " ,
371372 "REFERENCE " , "WEAKREFERENCE " , "DECIMAL " , "URI " , "UNDEFINED " , "* " , "? " );
372373
373- if (! $ this ->checkTokenIn (Token::TK_IDENTIFIER , $ types )) {
374+ if (! $ this ->checkTokenIn (Token::TK_IDENTIFIER , $ types, true )) {
374375 throw new ParserException ($ this ->tokenQueue , sprintf ("Invalid property type: %s " , $ this ->tokenQueue ->get ()->getData ()));
375376 }
376377
@@ -474,11 +475,13 @@ protected function parseValueConstraints(PropertyDefinitionTemplateInterface $pr
474475 * NoFullText ::= ('nofulltext' | 'nof') ['?']
475476 * NoQueryOrder ::= ('noqueryorder' | 'nqord') ['?']
476477 */
477- protected function parsePropertyAttributes (PropertyDefinitionTemplateInterface $ property )
478+ protected function parsePropertyAttributes (NodeTypeTemplateInterface $ parentType , PropertyDefinitionTemplateInterface $ property )
478479 {
479480 $ opvSeen = false ;
480481 while (true ) {
481- if ($ this ->checkTokenIn (Token::TK_IDENTIFIER , $ this ->AUTOCREATED )) {
482+ if ($ this ->checkTokenIn (Token::TK_IDENTIFIER , $ this ->PRIMARY )) {
483+ $ parentType ->setPrimaryItemName ($ property ->getName ());
484+ } else if ($ this ->checkTokenIn (Token::TK_IDENTIFIER , $ this ->AUTOCREATED )) {
482485 $ property ->setAutoCreated (true );
483486 } else if ($ this ->checkTokenIn (Token::TK_IDENTIFIER , $ this ->MANDATORY )) {
484487 $ property ->setMandatory (true );
@@ -597,7 +600,7 @@ protected function parseChildNodeAttributes(
597600 NodeDefinitionTemplateInterface $ childType
598601 ) {
599602 while (true ) {
600- if ($ this ->checkTokenIn (Token::TK_IDENTIFIER , $ this ->PRIMARYITEM )) {
603+ if ($ this ->checkTokenIn (Token::TK_IDENTIFIER , $ this ->PRIMARY )) {
601604 $ parentType ->setPrimaryItemName ($ childType ->getName ());
602605 } else if ($ this ->checkTokenIn (Token::TK_IDENTIFIER , $ this ->AUTOCREATED )) {
603606 $ childType ->setAutoCreated (true );
0 commit comments