dsl - when to use cross-reference and when use containment reference? -


i need implement domain specific language. have panel , shapes on it.

 'panel' name = id '('  title = string',' bgcolor = color',' width = int',' height = int ')''{'((rects += rect)| (ellipse += ellipse)|(arcs += arc)|)*'}' 

and each shape has unique rule other features. example:

roundrect: 'roundrectangle' name = id '{' (fill ?= 'filled' (fillpattern?='fillpattern' fillpaint=paint)?)? (stroke?='stroke' str=stroke)? 'paint' paint=paint 'coordination' x=int ',' y=int 'dimention' height=int ',' width=int 'arc' archeight=int ',' arcwidth=int '}'  

as obvious in dsl, used references. don't know rules correct or should use cross-reference in those? rule works fine , receive correct output expected. know when feature not of basic type (string, integer, , on), reference (an instance of ereference),this containment reference, although non-containment references, referenced object stored somewhere else, example, in object of same resource or in different resource. , point cross-reference implemented non-containment reference. need know when should use cross-reference , when use containment reference?

as far know difference following:
containment-reference if want reference content of rule it's lazy redefining rule's content everytime use containment-reference.
cross-reference behaves bit different: if use cross-reference parser need user having typed in content of rule cross-reference refers beforeallowing him refer typed in content.

an example real programming language: method call cross-reference method of name should declared somewhere in code because otherwise doesn't exist. in contrary normal code implemented containment-reference can used (for example) within class, field or method , code typing in needs fullfill existance of few keywords , structures these defined in parser , needn't defined user himself before beeing able use them.

i hope have illustrated enough know difference , meaning of these reference types.

greeting krzmbrzl


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -