OpenPLX Syntax Reference
OpenPLX was inspired by YAML but has been extended with object oriented constructs, expressions as well as making the syntax simpler and more like natural language. OpenPLX is indentation sensitive.
is (Assignments and inheritance)
Inheritance and assigning values to variables is done with the is keyword.
MyPart is SomeOtherPart:
value is Real: 1.0
Here MyPart inherits from SomeOtherPart and value is assigned to be of type Real with a value of 1.0.
with (Traits)
Assigning traits to models can be done with the with keyword.
trait BoxGeometry
geometry is Physics3D.Geometries.Box:
size: Math.Vec3.from_xyz(1, 1, 1)
Scene is Physics3D.System:
box is Physics3D.Bodies.RigidBody with BoxGeometry
becomes (Specialization)
Using the becomes keyword specializes a model.
MyRigidBody is Physics3D.Bodies.RigidBody:
geometry is Physics3D.Geometries.Box:
size: {1, 1, 1}
MySpecializedRigidBody is MyRigidBody:
color is Math.Vec3
ParentModel:
body is MyRigidBody
MyModel is ParentModel:
body becomes MySpecializedRigidBody
Here body in the model MyModel can be of type MyRigidBody that it inherited from the model ParentModel.
However we can also specialize body to become the model MySpecializedRigidBody. The type must be compatible with the previous type,
in this example MySpecializedRigidBody must extend MyRigidBody or we can not make body becomes MySpecializedRigidBody.
OpenPLX supports the following features:
or (Union types)
Union types can be declared with the or keyword.
Truck is Vehicle
Car is Vehicle
ModelWithUnionType:
truck_or_car is Truck or Car
ModelSpecializingUnionType is ModelWithUnionType:
truck_or_car becomes Car
Here truck_or_car can take on two different models, Truck or Car. The or keyword can be used more than once to include more models.