diff options
Diffstat (limited to 'src/core/parser/stack')
| -rw-r--r-- | src/core/parser/stack/DocumentHandler.cpp | 61 | ||||
| -rw-r--r-- | src/core/parser/stack/DomainHandler.cpp | 16 | ||||
| -rw-r--r-- | src/core/parser/stack/TypesystemHandler.cpp | 6 | 
3 files changed, 58 insertions, 25 deletions
diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp index 35146b1..1df3cb3 100644 --- a/src/core/parser/stack/DocumentHandler.cpp +++ b/src/core/parser/stack/DocumentHandler.cpp @@ -47,7 +47,7 @@ bool DocumentHandler::start(Variant::mapType &args)  	return true;  } -void DocumentHandler::end() { scope().pop(); } +void DocumentHandler::end() { scope().pop(logger()); }  /* DocumentChildHandler */ @@ -98,6 +98,9 @@ void DocumentChildHandler::createPath(const NodeVector<Node> &path,  	    manager(), scope().getLeaf(),  	    parent->getDescriptor()->getFieldDescriptorIndex(), true)};  	scope().push(field); + +	// Generally allow explicit fields in the new field +	scope().setFlag(ParserFlag::POST_EXPLICIT_FIELDS, false);  }  void DocumentChildHandler::createPath(const size_t &firstFieldIdx, @@ -113,6 +116,9 @@ void DocumentChildHandler::createPath(const size_t &firstFieldIdx,  	parent = static_cast<DocumentEntity *>(transparent.get());  	createPath(path, parent, 2); + +	// Generally allow explicit fields in the new field +	scope().setFlag(ParserFlag::POST_EXPLICIT_FIELDS, false);  }  bool DocumentChildHandler::start(Variant::mapType &args) @@ -170,12 +176,25 @@ bool DocumentChildHandler::start(Variant::mapType &args)  				ssize_t newFieldIdx =  				    parent->getDescriptor()->getFieldDescriptorIndex(name());  				if (newFieldIdx != -1) { -					Rooted<DocumentField> field{new DocumentField( -					    manager(), parentNode, newFieldIdx, false)}; -					field->setLocation(location()); -					scope().push(field); -					isExplicitField = true; -					return true; +					// Check whether explicit fields are allowed here, if not +					if (scope().getFlag(ParserFlag::POST_EXPLICIT_FIELDS)) { +						logger().note( +						    std::string( +						        "Data or structure commands have already been " +						        "given, command \"") + +						        name() + std::string( +						                     "\" is not interpreted explicit " +						                     "field. Move explicit field " +						                     "references to the beginning."), +						    location()); +					} else { +						Rooted<DocumentField> field{new DocumentField( +						    manager(), parentNode, newFieldIdx, false)}; +						field->setLocation(location()); +						scope().push(field); +						isExplicitField = true; +						return true; +					}  				}  			} @@ -200,9 +219,9 @@ bool DocumentChildHandler::start(Variant::mapType &args)  					// if we have transparent elements above us in the structure  					// tree we try to unwind them before we give up.  					// pop the implicit field. -					scope().pop(); +					scope().pop(logger());  					// pop the implicit element. -					scope().pop(); +					scope().pop(logger());  					continue;  				}  				throw LoggableException( @@ -218,11 +237,17 @@ bool DocumentChildHandler::start(Variant::mapType &args)  				    parent->getDescriptor()->getFieldDescriptorIndex();  			}  			// create the entity for the new element at last. -			//TODO: REMOVE +			// TODO: REMOVE  			strct_name = strct->getName();  			entity = parent->createChildStructuredEntity(strct, lastFieldIdx,  			                                             args, nameAttr);  		} + +		// We're past the region in which explicit fields can be defined in the +		// parent structure element +		scope().setFlag(ParserFlag::POST_EXPLICIT_FIELDS, true); + +		// Bush the entity onto the stack  		entity->setLocation(location());  		scope().push(entity);  		return true; @@ -237,7 +262,7 @@ void DocumentChildHandler::end()  		return;  	}  	// pop the "main" element. -	scope().pop(); +	scope().pop(logger());  }  bool DocumentChildHandler::fieldStart(bool &isDefault, size_t fieldIdx) @@ -271,6 +296,10 @@ bool DocumentChildHandler::fieldStart(bool &isDefault, size_t fieldIdx)  	    new DocumentField(manager(), parentNode, fieldIdx, false)};  	field->setLocation(location());  	scope().push(field); + +	// Generally allow explicit fields in the new field +	scope().setFlag(ParserFlag::POST_EXPLICIT_FIELDS, false); +  	return true;  } @@ -279,15 +308,15 @@ void DocumentChildHandler::fieldEnd()  	assert(scope().getLeaf()->isa(&RttiTypes::DocumentField));  	// pop the field from the stack. -	scope().pop(); +	scope().pop(logger());  	// pop all remaining transparent elements.  	while (scope().getLeaf()->isa(&RttiTypes::StructuredEntity) &&  	       scope().getLeaf().cast<StructuredEntity>()->isTransparent()) {  		// pop the transparent element. -		scope().pop(); +		scope().pop(logger());  		// pop the transparent field. -		scope().pop(); +		scope().pop(logger());  	}  } @@ -334,6 +363,10 @@ bool DocumentChildHandler::convertData(Handle<FieldDescriptor> field,  bool DocumentChildHandler::data(Variant &data)  { +	// We're past the region in which explicit fields can be defined in the +	// parent structure element +	scope().setFlag(ParserFlag::POST_EXPLICIT_FIELDS, true); +  	Rooted<Node> parentField = scope().getLeaf();  	assert(parentField->isa(&RttiTypes::DocumentField)); diff --git a/src/core/parser/stack/DomainHandler.cpp b/src/core/parser/stack/DomainHandler.cpp index ddec1ee..aa18faa 100644 --- a/src/core/parser/stack/DomainHandler.cpp +++ b/src/core/parser/stack/DomainHandler.cpp @@ -53,7 +53,7 @@ bool DomainHandler::start(Variant::mapType &args)  	return true;  } -void DomainHandler::end() { scope().pop(); } +void DomainHandler::end() { scope().pop(logger()); }  /* DomainStructHandler */ @@ -85,7 +85,7 @@ bool DomainStructHandler::start(Variant::mapType &args)  	return true;  } -void DomainStructHandler::end() { scope().pop(); } +void DomainStructHandler::end() { scope().pop(logger()); }  /* DomainAnnotationHandler */  bool DomainAnnotationHandler::start(Variant::mapType &args) @@ -102,7 +102,7 @@ bool DomainAnnotationHandler::start(Variant::mapType &args)  	return true;  } -void DomainAnnotationHandler::end() { scope().pop(); } +void DomainAnnotationHandler::end() { scope().pop(logger()); }  /* DomainAttributesHandler */ @@ -118,7 +118,7 @@ bool DomainAttributesHandler::start(Variant::mapType &args)  	return true;  } -void DomainAttributesHandler::end() { scope().pop(); } +void DomainAttributesHandler::end() { scope().pop(logger()); }  /* DomainFieldHandler */ @@ -148,7 +148,7 @@ bool DomainFieldHandler::start(Variant::mapType &args)  	return true;  } -void DomainFieldHandler::end() { scope().pop(); } +void DomainFieldHandler::end() { scope().pop(logger()); }  /* DomainFieldRefHandler */ @@ -218,7 +218,7 @@ bool DomainPrimitiveHandler::start(Variant::mapType &args)  	return true;  } -void DomainPrimitiveHandler::end() { scope().pop(); } +void DomainPrimitiveHandler::end() { scope().pop(logger()); }  /* DomainChildHandler */ @@ -251,7 +251,7 @@ bool DomainParentHandler::start(Variant::mapType &args)  	return true;  } -void DomainParentHandler::end() { scope().pop(); } +void DomainParentHandler::end() { scope().pop(logger()); }  /* DomainParentFieldHandler */ @@ -414,4 +414,4 @@ namespace RttiTypes {  const Rtti DomainParent = RttiBuilder<ousia::parser_stack::DomainParent>(                                "DomainParent").parent(&Node);  } -}
\ No newline at end of file +} diff --git a/src/core/parser/stack/TypesystemHandler.cpp b/src/core/parser/stack/TypesystemHandler.cpp index 8fd9525..727c601 100644 --- a/src/core/parser/stack/TypesystemHandler.cpp +++ b/src/core/parser/stack/TypesystemHandler.cpp @@ -51,7 +51,7 @@ bool TypesystemHandler::start(Variant::mapType &args)  	return true;  } -void TypesystemHandler::end() { scope().pop(); } +void TypesystemHandler::end() { scope().pop(logger()); }  /* TypesystemEnumHandler */ @@ -70,7 +70,7 @@ bool TypesystemEnumHandler::start(Variant::mapType &args)  	return true;  } -void TypesystemEnumHandler::end() { scope().pop(); } +void TypesystemEnumHandler::end() { scope().pop(logger()); }  /* TypesystemEnumEntryHandler */ @@ -112,7 +112,7 @@ bool TypesystemStructHandler::start(Variant::mapType &args)  	return true;  } -void TypesystemStructHandler::end() { scope().pop(); } +void TypesystemStructHandler::end() { scope().pop(logger()); }  /* TypesystemStructFieldHandler */  | 
