Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update the documentation on "supercedes attributed"

...

Literals or expressions usually have associated type inference rules that get triggered when the typechecker requires type of the node in question. The rules have a mechanism allowing subconcepts to extend or override the predefined rule. 

rule typeof_IntLiteral {   applicable for concept = IntLiteral as nodeToCheck
applicable always
overrides false
overrides true
do {
typeof(nodeToCheck) :==: <integer>;
}
}

Inference rules for node attributes

...

lookup-inference-rules(node) :
  let skipAttributed = false
  foreach a in attributesOf(node) do
    if hasInferenceRuleFor(a) then
      let rule = getInferenceRuleFor(a)
      yield rule
      if isOverriding(rule) then
        return
      end if
      if isSuperceding(rule) then
let skipAttributed = true
end if
    end if
  end do

  if skipAttributed then
    return
  end if

  /* proceed as usual */
end

An example of using an inference rule applicable to a node attribute shows how the presence condition can alter the type of a literal. Note that in this example the type of the annotated literal is affected by by both this inference rule and any other inference rule applicable to the node.

rule typeof_Literal {   applicable for concept = PresenceConditionAnnotation as pca
applicable always
overrides truefalse 
supercedes attributed false
 do {
typeof(pca.parent) :<==: pca.alternativeNode
}
}
 

Conditionally overriding type inference

...

rule typeof_Literal {
  applicable for concept = PresenceConditionAnnotation as pea
applicable always
overridessupercedes attributed { 
    isConditionSatisfied(pca);
}
do {
typeof(attributedNode) :==: pca.replacementType
}
}

...