Skip to content

Occurrences

dwightguth edited this page Dec 6, 2018 · 1 revision

A brief note on how we structure occurrences in the llvm backend: unlike the original pattern matching paper by Maranget, we use a list of strings to represent an occurrence rather than a list of ints, merely for simplicity since some possible occurrences we wish to represent are not easily represented solely using integers.

The occurrences essentially work as follows:

  • occurrences which come from regular constructors are unchanged except that their integer components are pretty-printed to a decimal string representation
  • map/set occurrences which are dependent on a particular key use an unspecified but unique string representation of the key in question, as well as the suffixes "_rem", "_val" to refer to the map/set minus the key and the value/presence of the key.
  • occurrences representing the truth of a side condition are represented as ["side_condition_N"] for some rule ordinal N
  • occurrences representing literals are represented as ["lit", text, hook] for some text and hook corresponding to the text and sort of the literal.
  • occurrences representing equality of two terms are represented as ["eq"] ++ o1 ++ ["and"] ++ o2 for the occurrences o1 and o2 of the terms.
  • occurrences representing the size of a collection are represented as "size" : o for some occurrence o of the collection
Clone this wiki locally