class rule_pat : int -> int -> int -> int array -> bool -> object end
A rule pattern will be stored in a list pertaining to a particular
category (the "trigger" category). The rule pattern says that if you
have a chart item (p1,q1)...(pn,qn):C, you either have automatically
an item pat#out_states((p1,q1)...(pn,qn)):pat#OC, (in the case of a
chain rule, if pat#states((p1,q1)...(pn,qn)) is satisfied; or you
will have such an item if you find an item that matches
pat#other_states((p1,q1)... (pn,qn)) and pat#check_states (on its
own states). The arities array we pass here is of the form [|
<head-cat arity>; <1st rhs arity>; [<2nd rhs arity>] |]
.
oc
: Output category (LHS cat)
rn
: Rule number in grammar
num_rhs
: Number of RHS elements (1 or 2)
arities
: Arity array, see above
reversed
: true iff binary rule and the trigger is the 1st element
method set_state : int -> int -> unit
Sets state number i to value v. Here a state
number is a specifier for what the item that triggers this pattern
should look like, so set_state i v
indicates that state i of the
trigger should match state v of the trigger.
Returns nothing
i
: Index of state to set.
v
: Value to set.
method set_other_state : int -> int -> unit
Sets "other state" number i to value v.
This signifies that the ith state of the category that we're going
to look for in the chart as a result of triggering this pattern should
match the vth state of the trigger item.
Returns nothing
i
: Index of state to set.
v
: Value to set the state to.
method set_check_state : int -> int -> unit
Sets "check state" number i to value v.
This means that the ith state of the item we looked for in the
chart (the so-called "other" item) must match the vth state of
that same item.
Returns nothing
i
: Index of check state to set
v
: Value to set the ith check state to.
method set_other_cat : int -> unit
Says that the presence of the trigger item for
this pattern indicates that we should look for an item in the chart
of category cat. This defaults to 0, indicating that the pattern
is for a chain rule.
Returns nothing
cat
: Non-trigger category number.
method set_out_state : int -> int * int -> unit
Indicates that if the pattern
matches, the ith state of the item to be produced will come from
the st-idxth state of the el-idxth right-hand-side element.
Returns nothing
i
: Out-state number to specify.
v
: Value to set out-state i to (a tuple: (el-idx, st-idx))
method get_rule_num : int
Returns the rule number this pattern is for
method get_other_cat : int
Returns category to look up in the chart
method get_out_cat : int
Returns category of item to be produced
method multi_cat_pat : unit -> bool
Returns whether |RHS| > 1
method get_other_state : int -> int
Returns the trigger item state that must be matched by the item
to be searched for in the chart. This value can be -1 to
indicate that there is no match requirement.
i
: index of non-trigger-item state specification to look at
method get_state : int -> int
Returns State number of trigger item, other than i, that
state number i of trigger item must be equal to, or
-1 if there is no requirement.
i
: index of trigger state to check.
method search_item : Chart.subitem -> Chart.subitem
Returns the search key needed to look in the chart
and see if the rule indicated by this pattern can
apply.
item
: Item that triggered the use of this pattern.
method check_item : Chart.subitem -> bool
Returns whether the states in item meet the self-identity
requirements of the pattern (requirements that certain
states in the item be identical to other states in the
item).
item
: Item that triggered the use of this pattern.
method check_other_item : Chart.subitem -> bool
Returns whether the states in item meet the requirements imposed
by the pattern (the requirement that certain states in the
item be identical to other states in that same item).
item
: An item found in the chart using the key produced by
search_item
method out_item : Chart.subitem -> Chart.subitem -> Chart.subitem
Returns the item that is produced by application of the rule.
item
: Item that triggered the use of this pattern.
other_item
: Other item involved in the rule, or [||]
if the
rule is a chain rule
method unify_check_items : Chart.subitem -> Chart.subitem -> Chart.subitem * Chart.subitem
Checks whether other_states is satisfied between the trigger item
trigger
and the other item other
, and performs indicated
unifications.
Raises Ununifiable
if the items do not unify or other_states is not
satisfied.
Returns unified items as a tuple (trigger
, other
).
trigger
: Item that triggered the use of this pattern
other
: Other item in the RHS of the rule this pattern represents
method output_self : int -> unit
Shows the pattern in human-readable form.
Returns nothing
cat
: Category of the trigger item for this pattern.