Repository navigation
Mate Language
The Mate Object Graph (OG) Language is a Domain-Specific Language (DSL) used to define the structure of object graphs and guide fuzzing of object graph instances.
A grammar consists of one or more type declarations. Each declaration follows this pattern:
TypeName -> {
fieldName1: FieldType,
fieldName2: FieldType,
...
}.
Types usually correspond to Pharo classes (e.g., Person, BlElement).
Fields can be defined by simply naming the type:
age: Age
The language supports several primary types out of the box:
-
SmallInteger: Integer numbers. -
Float: Floating-point numbers. -
Boolean:trueorfalse. -
String: Text strings. -
Color: Color objects. -
Point: X/Y coordinate pairs.
Multi-type fields can be defined using the pipe | operator:
geometry: BlRectangleGeometry | BlEllipseGeometry | BlTriangleGeometry
For more control over field values, use a dictionary-like syntax { ... }.
To define a collection of objects, use square brackets []:
children: { type: [ BlElement ], sizeBetween: 0 and: 10 }
-
type: [ Type ]: Specifies it's an array of the given type. -
size: N: Exact size of the array. -
sizeBetween: min and: max: Range of possible sizes.
For built-in types like SmallInteger, you can restrict the range:
level: { type: SmallInteger, between: 0 and: 99 }
experience: { type: SmallInteger, greaterThan: 0 }
Restrict a field to a specific set of symbolic values:
orientation: { oneOf: { #top . #right . #left . #bottom } }
Here an example:
Player -> {
name: String,
characterClass: Warrior | Rogue | Mage,
level: { type: SmallInteger, between: 1 and: 100 },
inventory: { type: [ Item ], sizeBetween: 0 and: 20 },
isOnline: Boolean
}.
Item -> {
name: String,
rarity: { oneOf: { #common . #rare . #epic . #legendary } }
}.