Object Scoping

Place the DSL script so that bare references will resolve to a single object.

Nested Function and (to an extent) Function Sequence may provide a nice DSL syntax, but in their basic forms they come with a serious cost: global functions and (worse) global state.

Object Scoping alleviates these problems by resolving all bare calls to a single object and this avoids cluttering the global namespace with global functions, allowing you to store any parsing data within this host object. The most common way to do this is to write the DSL script inside a subclass of a builder that defines the functions—this allows the parsing data to be captured in that one object.

For more details see chapter 36 of the DSL book

DSL Catalog