@precedence {
  text @right
  p1
  p2
  p3
}

@top Text { textItem* }

@skip { space }

@tokens {
  space { @whitespace+ }

  Offset { $[-]?$[1-9]$[0-9]* }
  Global { $[XCSDATFPR]$[1-9]$[0-9]* }

  word { ![@{|}! \t\n]+ }

  gram { $[-a-zA-Z0-9]+ } 

  @precedence { word, space }
}

textItem { 
  !p1 ref |
  !p2 Error |
  !p3 Filler
}

Filler { word_enum }
Error { "!" word_enum "!" }
word_enum {
  word |
  word !text word_enum
}

ref {
  RefEntity |
  RefSyntactic
}

RefEntity {
  "@{" Global "|" Grams "}"
}
Grams { gram_enum }
gram_enum {
  gram |
  gram "," gram_enum
}

RefSyntactic {
  "@{" Offset "|" Nominal "}"
}
Nominal { word+ }

@detectDelim

@external propSource highlighting from "./highlight"