parser.md 1.5 KB

parser api

The provided PEGjs parser accepts a text blob of modellang as input and returns an object of the following structure:

systems: Map <String, System>
behaviors: Map <String, Behavior>
interactions: Array <Interaction>
triggers: Array <Trigger>
init: Array <Init>
errors: Array <SyntaxError>

types you might want to know about

System:
  type: "System"
  id: String
  body: Array <Sequence & Alternation>
  refs: Array <String>
  properties: Object
  scope: Scope
Behavior:
  type: "Behavior"
  id: String
  body: Array <Sequence & Alternation>
  refs: Array <String>
  properties: Object
  scope: Scope
Interaction:
  type: "Order" | "Join"
  body: Array <Expression & Selector>
Trigger:
  type: "Trigger"
  on: Selector | Expression
  do: String
Init:
  type: "Init"
  system: Identifier
  do: String
Sequence:
  type: "Sequence"
  body: Array <Group & Identifier>
  scope: Scope
Alternation:
  type: "Alternation"
  body: Array <Group & Identifier>
  scope: Scope
Group:
  type: "Group"
  async: Boolean
  body: Array <Group & Identifier>
  scope: Scope
Expression:
  type: "Expression"
  operator: String
  lhs: Integer & String
  rhs: Integer & String
Selector:
  type: "Selector"
  system: String
  pattern: Alternation & Sequence
Identifier:
  id: String
  scope: Scope
Scope:
  min: Integer
  max: Integer
SyntaxError:
  offset: String
  line: String
  column: String
  expected: String
  found: String
  message: String