diff --git a/docs/core-module/1-cp.html b/docs/core-module/1-cp.html
index 1de15fc13..8aa30d8e6 100644
--- a/docs/core-module/1-cp.html
+++ b/docs/core-module/1-cp.html
@@ -338,7 +338,7 @@ We begin with core itself.
enum anl_entry_CLASS
enum action_pattern_CLASS
enum action_name_list_CLASS
-enum ap_optional_clause_CLASS
+enum ap_clause_CLASS
enum scene_connector_CLASS
enum understanding_item_CLASS
enum understanding_reference_CLASS
@@ -372,7 +372,7 @@ We begin with core itself.
DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( anl_entry , 1000 )
DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( action_pattern , 100 )
DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( action_name_list , 1000 )
-DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( ap_optional_clause , 400 )
+DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( ap_clause , 400 )
DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( scene_connector , 1000 )
DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( understanding_item , 100 )
DECLARE_CLASS_ALLOCATED_IN_ARRAYS ( understanding_reference , 100 )
diff --git a/docs/if-module/1-im.html b/docs/if-module/1-im.html
index aa604ec2c..d825d8931 100644
--- a/docs/if-module/1-im.html
+++ b/docs/if-module/1-im.html
@@ -83,7 +83,7 @@ function togglePopup(material_id) {
-COMPILE_WRITER ( action_pattern *, ActionPatterns::log )
+COMPILE_WRITER ( action_pattern *, ActionPatterns::log )
COMPILE_WRITER ( grammar_verb *, PL::Parsing::Verbs::log )
COMPILE_WRITER ( grammar_line *, PL::Parsing::Lines::log )
COMPILE_WRITER ( action_name_list *, ActionNameLists::log )
@@ -130,7 +130,7 @@ function togglePopup(material_id) {
- REGISTER_WRITER ( 'A' , ActionPatterns::log );
+ REGISTER_WRITER ( 'A' , ActionPatterns::log );
REGISTER_WRITER ( 'G' , PL::Parsing::Verbs::log );
REGISTER_WRITER ( 'g' , PL::Parsing::Lines::log );
REGISTER_WRITER ( 'L' , ActionNameLists::log );
diff --git a/docs/if-module/3-scn.html b/docs/if-module/3-scn.html
index 124f54b5b..ec697d2b5 100644
--- a/docs/if-module/3-scn.html
+++ b/docs/if-module/3-scn.html
@@ -227,7 +227,7 @@ scenes — to express which, the
return Instances::get_name ( sc -> as_instance , FALSE );
}
- The structure scene is private to this section. The structure scene_end is private to this section. The structure scene_connector is accessed in 2/ri, 3/tm, 3/ts, 4/ap, 4/av, 4/ap2, 5/tfg, 5/gl and here.
+The structure scene is private to this section. The structure scene_end is private to this section. The structure scene_connector is accessed in 2/ri, 3/tm, 3/ts, 4/ap, 4/av, 4/apc, 5/tfg, 5/gl and here.
int Map::check_going ( parse_node * from , parse_node * to ,
parse_node * by , parse_node * through , parse_node * pushing ) {
- if ( ActionPatterns::check_going ( from , "from" ,
+ if ( ActionPatterns::check_going ( from , "from" ,
K_room , K_region ) == FALSE ) return FALSE ;
- if ( ActionPatterns::check_going ( to , "to" ,
+ if ( ActionPatterns::check_going ( to , "to" ,
K_room , K_region ) == FALSE ) return FALSE ;
- if ( ActionPatterns::check_going ( by , "by" ,
+ if ( ActionPatterns::check_going ( by , "by" ,
K_thing , NULL ) == FALSE ) return FALSE ;
- if ( ActionPatterns::check_going ( through , "through" ,
+ if ( ActionPatterns::check_going ( through , "through" ,
K_door , NULL ) == FALSE ) return FALSE ;
- if ( ActionPatterns::check_going ( pushing , "with" ,
+ if ( ActionPatterns::check_going ( pushing , "with" ,
K_thing , NULL ) == FALSE ) return FALSE ;
return TRUE ;
}
diff --git a/docs/if-module/4-act.html b/docs/if-module/4-act.html
index 82d3960ae..e7e823583 100644
--- a/docs/if-module/4-act.html
+++ b/docs/if-module/4-act.html
@@ -214,7 +214,7 @@ have to correspond to names referenced in }
+
diff --git a/docs/if-module/4-anaa.html b/docs/if-module/4-anaa.html
index ac0123eec..1bdd17674 100644
--- a/docs/if-module/4-anaa.html
+++ b/docs/if-module/4-anaa.html
@@ -122,7 +122,7 @@ function togglePopup(material_id) {
void ActionsNodes::write_action_meaning_ANNOT ( text_stream * OUT , parse_node * p ) {
if ( Node::get_action_meaning ( p )) {
WRITE ( " {action meaning: " );
- ActionPatterns::write ( OUT , Node::get_action_meaning ( p ));
+ ActionPatterns::write ( OUT , Node::get_action_meaning ( p ));
WRITE ( "}" );
}
}
@@ -133,7 +133,7 @@ function togglePopup(material_id) {
void ActionsNodes::write_constant_action_pattern_ANNOT ( text_stream * OUT , parse_node * p ) {
if ( Node::get_constant_action_pattern ( p )) {
WRITE ( " {action pattern: " );
- ActionPatterns::write ( OUT , Node::get_constant_action_pattern ( p ));
+ ActionPatterns::write ( OUT , Node::get_constant_action_pattern ( p ));
WRITE ( "}" );
}
}
@@ -147,7 +147,7 @@ function togglePopup(material_id) {
}
+
diff --git a/docs/if-module/4-anl.html b/docs/if-module/4-anl.html
index f55879222..3830db015 100644
--- a/docs/if-module/4-anl.html
+++ b/docs/if-module/4-anl.html
@@ -142,7 +142,7 @@ list can be marked accordingly:
-void ActionNameLists::suppress_action_testing ( action_name_list * list ) {
+void ActionNameLists::suppress_action_testing ( action_name_list * list ) {
list -> test_this_in_ap_match = FALSE ;
}
@@ -296,7 +296,7 @@ are in the list.
return C ;
}
-int ActionNameLists::nonempty ( action_name_list * list ) {
+int ActionNameLists::nonempty ( action_name_list * list ) {
if (( list ) && ( list -> entries )) return TRUE ;
return FALSE ;
}
@@ -325,7 +325,7 @@ anything" — a completely unrestricted action.
entry -> item . nap_listed = NULL ;
}
-anl_item * ActionNameLists::first_item ( action_name_list * list ) {
+anl_item * ActionNameLists::first_item ( action_name_list * list ) {
if (( list ) && ( list -> entries )) return &( list -> entries -> item );
return NULL ;
}
@@ -339,7 +339,7 @@ used in sorting algorithms.
-int ActionNameLists::compare_specificity ( action_name_list * anl1 , action_name_list * anl2 ) {
+int ActionNameLists::compare_specificity ( action_name_list * anl1 , action_name_list * anl2 ) {
int count1 , count2 ;
count1 = ActionNameLists::count_actions_covered ( anl1 );
count2 = ActionNameLists::count_actions_covered ( anl2 );
@@ -379,7 +379,7 @@ negation) but not "doing something other than looking".
-int ActionNameLists::covers_action ( action_name_list * list , action_name * an ) {
+int ActionNameLists::covers_action ( action_name_list * list , action_name * an ) {
LOOP_THROUGH_ANL ( entry , list ) {
anl_item * item = &( entry -> item );
int within = FALSE ;
@@ -474,7 +474,7 @@ the text leading to a list:
-action_name * ActionNameLists::single_positive_action ( action_name_list * list ) {
+action_name * ActionNameLists::single_positive_action ( action_name_list * list ) {
if (( ActionNameLists::length ( list ) == 1 ) &&
( ActionNameLists::positive ( list )))
return ActionNameLists::first_item ( list )-> action_listed ;
@@ -553,7 +553,7 @@ is no best action. (For example, in "throwing or removing something".)
}
}
-void ActionNameLists::log_briefly ( action_name_list * list ) {
+void ActionNameLists::log_briefly ( action_name_list * list ) {
if ( list == NULL ) {
LOG ( "<null-anl>" );
} else {
@@ -905,7 +905,7 @@ the trial entry for future trials.
This code is used in §24.1.3 (three times).
+
diff --git a/docs/if-module/4-ann.html b/docs/if-module/4-ann.html
index 8ce464012..eedc63c23 100644
--- a/docs/if-module/4-ann.html
+++ b/docs/if-module/4-ann.html
@@ -318,7 +318,7 @@ number of words.
}
+
diff --git a/docs/if-module/4-ap.html b/docs/if-module/4-ap.html
index 7cc9256de..d17269468 100644
--- a/docs/if-module/4-ap.html
+++ b/docs/if-module/4-ap.html
@@ -523,7 +523,7 @@ to nothing".
}
+
diff --git a/docs/if-module/4-ap2.html b/docs/if-module/4-ap2.html
index 89af05619..c6739f171 100644
--- a/docs/if-module/4-ap2.html
+++ b/docs/if-module/4-ap2.html
@@ -86,7 +86,7 @@ MathJax = {
An action pattern is a description which may match many actions or none. The text "doing something" matches every action, while "throwing something at a door in a dark room" is seldom matched. Here we parse such text into a data structure called an |action_pattern|.
-
+
-enum ACTOR_AP_CLAUSE from 1
-enum NOUN_AP_CLAUSE
-enum SECOND_AP_CLAUSE
-enum IN_AP_CLAUSE
-enum IN_THE_PRESENCE_OF_AP_CLAUSE
-enum WHEN_AP_CLAUSE
-enum GOING_FROM_AP_CLAUSE
-enum GOING_TO_AP_CLAUSE
-enum GOING_BY_AP_CLAUSE
-enum GOING_THROUGH_AP_CLAUSE
-enum PUSHING_AP_CLAUSE
-enum STV_AP_CLAUSE
-
typedef struct action_pattern {
struct wording text_of_pattern ;
@@ -126,21 +113,14 @@ not-really-action APs are used in no other context, and employ the
int applies_to_any_actor ;
int request ;
- struct parse_node * actor_spec ;
- struct parse_node * noun_spec ;
- int noun_any ;
- struct parse_node * second_spec ;
- int second_any ;
- struct parse_node * room_spec ;
- int room_any ;
- struct parse_node * when ;
+
struct parse_node * from_spec ;
struct parse_node * to_spec ;
struct parse_node * by_spec ;
struct parse_node * through_spec ;
struct parse_node * pushing_spec ;
int nowhere_flag ;
- struct ap_optional_clause * ap_clauses ;
+ struct ap_clause * ap_clauses ;
int chief_action_owner_id ;
struct time_period * duration ;
@@ -150,36 +130,8 @@ not-really-action APs are used in no other context, and employ the
int valid ;
} action_pattern ;
-The structure action_pattern is accessed in 4/pap and here.
-
-
-define ALLOW_REGION_AS_ROOM_APCOPT 1
-
-
-typedef struct ap_optional_clause {
- int clause_ID ;
- struct stacked_variable * stv_to_match ;
- struct parse_node * clause_spec ;
- int clause_options ;
- struct ap_optional_clause * next ;
- CLASS_DEFINITION
-} ap_optional_clause ;
-
-The structure ap_optional_clause is accessed in 2/ri, 3/tm, 3/scn, 3/ts, 4/ap, 4/av, 5/tfg, 5/gl and here.
-
-
-
-parse_node * ActionPatterns::get_presence ( action_pattern * ap ) {
- ap_optional_clause * apoc = ActionPatterns::find_clause ( ap , IN_THE_PRESENCE_OF_AP_CLAUSE , FALSE );
- return ( apoc )?( apoc -> clause_spec ): NULL ;
-}
-
-void ActionPatterns::set_presence ( action_pattern * ap , parse_node * val ) {
- ap_optional_clause * apoc = ActionPatterns::find_clause ( ap , IN_THE_PRESENCE_OF_AP_CLAUSE , TRUE );
- apoc -> clause_spec = val ;
-}
-
-The structure action_pattern is accessed in 4/apc, 4/pap and here.
+
@@ -209,20 +161,16 @@ STV clauses; (2) get this right:
say "Where did you want to go?"
-
+
-action_pattern ActionPatterns::new ( void ) {
+action_pattern ActionPatterns::new ( void ) {
action_pattern ap ;
ap . text_of_pattern = EMPTY_WORDING ;
ap . action_list = NULL ;
- ap . actor_spec = NULL ;
- ap . noun_spec = NULL ; ap . second_spec = NULL ; ap . room_spec = NULL ;
- ap . noun_any = FALSE ; ap . second_any = FALSE ; ap . room_any = FALSE ;
ap . parameter_spec = NULL ;
ap . parameter_kind = K_object ;
ap . valid = FALSE ;
- ap . when = NULL ;
ap . from_spec = NULL ;
ap . to_spec = NULL ;
ap . by_spec = NULL ;
@@ -237,143 +185,7 @@ STV clauses; (2) get this right:
return ap ;
}
-ap_optional_clause * ActionPatterns::find_clause ( action_pattern * ap , int clause , int make ) {
- if ( ap ) {
- ap_optional_clause * last = NULL ;
- for ( ap_optional_clause * apoc = ap -> ap_clauses ; apoc ; apoc = apoc -> next ) {
- if ( apoc -> clause_ID == clause )
- return apoc ;
- last = apoc ;
- }
- if ( make ) {
- ap_optional_clause * new_apoc = ActionPatterns::apoc_new ( clause , NULL , NULL );
- if ( last == NULL ) ap -> ap_clauses = new_apoc ;
- else last -> next = new_apoc ;
- return new_apoc ;
- }
- } else {
- if ( make ) internal_error ( "cannot make clause in null AP" );
- }
- return NULL ;
-}
-
-ap_optional_clause * ActionPatterns::find_stv ( action_pattern * ap , stacked_variable * stv ) {
- if ( ap )
- for ( ap_optional_clause * apoc = ap -> ap_clauses ; apoc ; apoc = apoc -> next )
- if ( apoc -> stv_to_match == stv )
- return apoc ;
- return NULL ;
-}
-
-ap_optional_clause * ActionPatterns::apoc_new ( int clause , stacked_variable * stv , parse_node * spec ) {
- ap_optional_clause * apoc = CREATE ( ap_optional_clause );
- apoc -> clause_ID = clause ;
- apoc -> stv_to_match = stv ;
- apoc -> clause_spec = spec ;
- apoc -> next = NULL ;
- apoc -> clause_options = FALSE ;
- return apoc ;
-}
-
-void ActionPatterns::ap_add_optional_clause ( action_pattern * ap , stacked_variable * stv ,
- wording W ) {
- if ( stv == NULL ) internal_error ( "no stacked variable for apoc" );
- ap_optional_clause * apoc = ActionPatterns::apoc_new ( STV_AP_CLAUSE , stv ,
- ParseActionPatterns::verified_action_parameter ( W ));
- int oid = StackedVariables::get_owner_id ( apoc -> stv_to_match );
- int off = StackedVariables::get_offset ( apoc -> stv_to_match );
- if ( ap -> ap_clauses == NULL ) {
- ap -> ap_clauses = apoc ;
- apoc -> next = NULL ;
- } else {
- ap_optional_clause * oapoc = ap -> ap_clauses , * papoc = NULL ;
- while ( oapoc ) {
- if ( oapoc -> stv_to_match ) {
- int ooff = StackedVariables::get_offset ( oapoc -> stv_to_match );
- if ( off < ooff ) {
- if ( oapoc == ap -> ap_clauses ) {
- apoc -> next = ap -> ap_clauses ;
- ap -> ap_clauses = apoc ;
- papoc = NULL ;
- } else {
- apoc -> next = papoc -> next ;
- papoc -> next = apoc ;
- papoc = NULL ;
- }
- break ;
- }
- }
- papoc = oapoc ;
- oapoc = oapoc -> next ;
- }
- if ( papoc ) {
- apoc -> next = NULL ;
- papoc -> next = apoc ;
- }
- }
-
- if ( oid == 20007 /* i . e ., going */ ) {
- switch ( off ) {
- case 0 : ap -> from_spec = apoc -> clause_spec ;
- apoc -> clause_options |= ALLOW_REGION_AS_ROOM_APCOPT ; break ;
- case 1 : ap -> to_spec = apoc -> clause_spec ;
- apoc -> clause_options |= ALLOW_REGION_AS_ROOM_APCOPT ; break ;
- case 2 : ap -> through_spec = apoc -> clause_spec ; break ;
- case 3 : ap -> by_spec = apoc -> clause_spec ; break ;
- case 4 : ap -> pushing_spec = apoc -> clause_spec ; break ;
- }
- }
- ap -> chief_action_owner_id = oid ;
-}
-
-int ActionPatterns::ap_count_optional_clauses ( action_pattern * ap ) {
- int n = 0 ;
- if ( ap )
- for ( ap_optional_clause * apoc = ap -> ap_clauses ; apoc ; apoc = apoc -> next )
- if ( apoc -> stv_to_match )
- if (( ap -> chief_action_owner_id != 20007 ) ||
- ( StackedVariables::get_offset ( apoc -> stv_to_match ) >= 5 ))
- n ++;
- return n ;
-}
-
-int ActionPatterns::has_stv_clauses ( action_pattern * ap ) {
- if (( ap ) && ( ActionPatterns::nudge_to_stv_apoc ( ap -> ap_clauses ))) return TRUE ;
- return FALSE ;
-}
-
-int ActionPatterns::compare_specificity_of_apoc_list ( action_pattern * ap1 , action_pattern * ap2 ) {
- int rct1 = ActionPatterns::ap_count_optional_clauses ( ap1 );
- int rct2 = ActionPatterns::ap_count_optional_clauses ( ap2 );
-
- if ( rct1 > rct2 ) return 1 ;
- if ( rct1 < rct2 ) return -1;
- if ( rct1 == 0 ) return 0 ;
- if ( ap1 -> chief_action_owner_id != ap2 -> chief_action_owner_id ) return 0 ;
-
- ap_optional_clause * apoc1 = ActionPatterns::nudge_to_stv_apoc ( ap1 -> ap_clauses ),
- * apoc2 = ActionPatterns::nudge_to_stv_apoc ( ap2 -> ap_clauses );
- while (( apoc1 ) && ( apoc2 )) {
- int off1 = StackedVariables::get_offset ( apoc1 -> stv_to_match );
- int off2 = StackedVariables::get_offset ( apoc2 -> stv_to_match );
- if ( off1 == off2 ) {
- int rv = Specifications::compare_specificity ( apoc1 -> clause_spec , apoc2 -> clause_spec , NULL );
- if ( rv != 0 ) return rv ;
- apoc1 = ActionPatterns::nudge_to_stv_apoc ( apoc1 -> next );
- apoc2 = ActionPatterns::nudge_to_stv_apoc ( apoc2 -> next );
- }
- if ( off1 < off2 ) apoc1 = ActionPatterns::nudge_to_stv_apoc ( apoc1 -> next );
- if ( off1 > off2 ) apoc2 = ActionPatterns::nudge_to_stv_apoc ( apoc2 -> next );
- }
- return 0 ;
-}
-
-ap_optional_clause * ActionPatterns::nudge_to_stv_apoc ( ap_optional_clause * apoc ) {
- while (( apoc ) && ( apoc -> stv_to_match == NULL )) apoc = apoc -> next ;
- return apoc ;
-}
-
-void ActionPatterns::log ( action_pattern * ap ) {
+void ActionPatterns::log ( action_pattern * ap ) {
if ( ap == NULL ) LOG ( " [Null]" );
else {
if ( ap -> valid != TRUE ) LOG ( " [Invalid]" );
@@ -381,54 +193,54 @@ STV clauses; (2) get this right:
LOG ( " Action: " );
if ( ap -> action_list == NULL ) LOG ( "unspecified" );
else ActionNameLists::log_briefly ( ap -> action_list );
- if ( ap -> noun_spec ) LOG ( " Noun: $P" , ap -> noun_spec );
- if ( ap -> second_spec ) LOG ( " Second: $P" , ap -> second_spec );
+ if ( APClauses::get_noun ( ap )) LOG ( " Noun: $P" , APClauses::get_noun ( ap ));
+ if ( APClauses::get_second ( ap )) LOG ( " Second: $P" , APClauses::get_second ( ap ));
if ( ap -> from_spec ) LOG ( " From: $P" , ap -> from_spec );
if ( ap -> to_spec ) LOG ( " To: $P" , ap -> to_spec );
if ( ap -> by_spec ) LOG ( " By: $P" , ap -> by_spec );
if ( ap -> through_spec ) LOG ( " Through: $P" , ap -> through_spec );
if ( ap -> pushing_spec ) LOG ( " Pushing: $P" , ap -> pushing_spec );
- if ( ap -> room_spec ) LOG ( " Room: $P" , ap -> room_spec );
+ if ( APClauses::get_room ( ap )) LOG ( " Room: $P" , APClauses::get_room ( ap ));
if ( ap -> parameter_spec ) LOG ( " Parameter: $P" , ap -> parameter_spec );
- if ( ActionPatterns::get_presence ( ap )) LOG ( " Presence: $P" , ActionPatterns::get_presence ( ap ));
+ if ( APClauses::get_presence ( ap )) LOG ( " Presence: $P" , APClauses::get_presence ( ap ));
if ( ap -> nowhere_flag ) LOG ( " Nowhere " );
- if ( ap -> when ) LOG ( " When: $P " , ap -> when );
+ if ( APClauses::get_val ( ap , WHEN_AP_CLAUSE )) LOG ( " When: $P " , APClauses::get_val ( ap , WHEN_AP_CLAUSE ));
if ( ap -> duration ) LOG ( " Duration: $t " , ap -> duration );
}
LOG ( "\n" );
}
-void ActionPatterns::write ( OUTPUT_STREAM , action_pattern * ap ) {
+void ActionPatterns::write ( OUTPUT_STREAM , action_pattern * ap ) {
if ( ap == NULL ) WRITE ( "<null-ap>" );
else if ( ap -> valid != TRUE ) WRITE ( "<invalid>" );
else {
WRITE ( "<action: " );
if ( ap -> action_list == NULL ) WRITE ( "unspecified" );
else ActionNameLists::log_briefly ( ap -> action_list );
- if ( ap -> noun_spec ) WRITE ( " noun: %P" , ap -> noun_spec );
- if ( ap -> second_spec ) WRITE ( " second: %P" , ap -> second_spec );
+ if ( APClauses::get_noun ( ap )) WRITE ( " noun: %P" , APClauses::get_noun ( ap ));
+ if ( APClauses::get_second ( ap )) WRITE ( " second: %P" , APClauses::get_second ( ap ));
if ( ap -> from_spec ) WRITE ( " from: %P" , ap -> from_spec );
if ( ap -> to_spec ) WRITE ( " to: %P" , ap -> to_spec );
if ( ap -> by_spec ) WRITE ( " by: %P" , ap -> by_spec );
if ( ap -> through_spec ) WRITE ( " through: %P" , ap -> through_spec );
if ( ap -> pushing_spec ) WRITE ( " pushing: %P" , ap -> pushing_spec );
- if ( ap -> room_spec ) WRITE ( " room: %P" , ap -> room_spec );
+ if ( APClauses::get_room ( ap )) WRITE ( " room: %P" , APClauses::get_room ( ap ));
if ( ap -> parameter_spec ) WRITE ( " parameter: %P" , ap -> parameter_spec );
- if ( ActionPatterns::get_presence ( ap )) WRITE ( " presence: %P" , ActionPatterns::get_presence ( ap ));
+ if ( APClauses::get_presence ( ap )) WRITE ( " presence: %P" , APClauses::get_presence ( ap ));
if ( ap -> nowhere_flag ) WRITE ( " nowhere" );
- if ( ap -> when ) WRITE ( " when: %P" , ap -> when );
+ if ( APClauses::get_val ( ap , WHEN_AP_CLAUSE )) WRITE ( " when: %P" , APClauses::get_val ( ap , WHEN_AP_CLAUSE ));
if ( ap -> duration ) { WRITE ( " duration: " ); Occurrence::log ( OUT , ap -> duration ); }
WRITE ( ">" );
}
}
-action_pattern * ActionPatterns::ap_store ( action_pattern ap ) {
+action_pattern * ActionPatterns::ap_store ( action_pattern ap ) {
action_pattern * sap = CREATE ( action_pattern );
* sap = ap ;
return sap ;
}
-int ActionPatterns::is_named ( action_pattern * ap ) {
+int ActionPatterns::is_named ( action_pattern * ap ) {
if ( ap ) {
anl_item * item = ActionNameLists::first_item ( ap -> action_list );
if (( item ) && ( item -> nap_listed )) return TRUE ;
@@ -436,7 +248,7 @@ STV clauses; (2) get this right:
return FALSE ;
}
-int ActionPatterns::is_valid ( action_pattern * ap ) {
+int ActionPatterns::is_valid ( action_pattern * ap ) {
if ( ap == NULL ) return FALSE ;
return ap -> valid ;
}
@@ -446,12 +258,12 @@ STV clauses; (2) get this right:
return ap -> request ;
}
-int ActionPatterns::within_action_context ( action_pattern * ap , action_name * an ) {
+int ActionPatterns::within_action_context ( action_pattern * ap , action_name * an ) {
if ( ap == NULL ) return TRUE ;
return ActionNameLists::covers_action ( ap -> action_list , an );
}
-action_name_list * ActionPatterns::list ( action_pattern * ap ) {
+action_name_list * ActionPatterns::list ( action_pattern * ap ) {
if ( ap == NULL ) return NULL ;
return ap -> action_list ;
}
@@ -467,15 +279,15 @@ STV clauses; (2) get this right:
}
int ActionPatterns::is_unspecific ( action_pattern * ap ) {
- action_name * an = ActionPatterns::required_action ( ap );
+ action_name * an = ActionPatterns::required_action ( ap );
if ( an == NULL ) return TRUE ;
- if (( ActionSemantics::must_have_noun ( an )) && ( ap -> noun_spec == NULL )) return TRUE ;
- if (( ActionSemantics::must_have_second ( an )) && ( ap -> second_spec == NULL )) return TRUE ;
+ if (( ActionSemantics::must_have_noun ( an )) && ( APClauses::get_noun ( ap ) == NULL )) return TRUE ;
+ if (( ActionSemantics::must_have_second ( an )) && ( APClauses::get_second ( ap ) == NULL )) return TRUE ;
if (( ActionSemantics::can_have_noun ( an )) &&
- ( ActionPatterns::ap_clause_is_unspecific ( ap -> noun_spec ))) return TRUE ;
+ ( ActionPatterns::ap_clause_is_unspecific ( APClauses::get_noun ( ap )))) return TRUE ;
if (( ActionSemantics::can_have_second ( an )) &&
- ( ActionPatterns::ap_clause_is_unspecific ( ap -> second_spec ))) return TRUE ;
- if ( ActionPatterns::ap_clause_is_unspecific ( ap -> actor_spec )) return TRUE ;
+ ( ActionPatterns::ap_clause_is_unspecific ( APClauses::get_second ( ap )))) return TRUE ;
+ if ( ActionPatterns::ap_clause_is_unspecific ( APClauses::get_actor ( ap ))) return TRUE ;
return FALSE ;
}
@@ -486,10 +298,10 @@ STV clauses; (2) get this right:
}
int ActionPatterns::is_overspecific ( action_pattern * ap ) {
- if ( ap -> when != NULL ) return TRUE ;
- if ( ap -> room_spec != NULL ) return TRUE ;
- if ( ActionPatterns::get_presence ( ap ) != NULL ) return TRUE ;
- if ( ActionPatterns::has_stv_clauses ( ap )) return TRUE ;
+ if ( APClauses::get_val ( ap , WHEN_AP_CLAUSE ) != NULL ) return TRUE ;
+ if ( APClauses::get_room ( ap ) != NULL ) return TRUE ;
+ if ( APClauses::get_presence ( ap ) != NULL ) return TRUE ;
+ if ( APClauses::has_stv_clauses ( ap )) return TRUE ;
if ( ap -> nowhere_flag ) return TRUE ;
if ( ap -> applies_to_any_actor ) return TRUE ;
if ( ap -> duration ) return TRUE ;
@@ -501,7 +313,7 @@ STV clauses; (2) get this right:
ActionNameLists::suppress_action_testing ( ap -> action_list );
}
-
@@ -516,7 +328,7 @@ an action.
return ;
}
- if ( ap -> actor_spec ) {
+ if ( APClauses::get_actor ( ap )) {
StandardProblems::sentence_problem ( Task::syntax_tree (), _p_ ( PM_NamedAPWithActor ),
"behaviour characterised by named action patterns can only specify the action" ,
"not the actor: as a result, it cannot include requests to other people to "
@@ -527,13 +339,13 @@ an action.
NamedActionPatterns::add ( ap , W );
}
-parse_node * ActionPatterns::nullify_nonspecific_references ( parse_node * spec ) {
+parse_node * ActionPatterns::nullify_nonspecific_references ( parse_node * spec ) {
if ( spec == NULL ) return spec ;
if ( Node::is ( spec , UNKNOWN_NT )) return NULL ;
return spec ;
}
-int ActionPatterns::check_going ( parse_node * spec , char * keyword ,
+int ActionPatterns::check_going ( parse_node * spec , char * keyword ,
kind * ka , kind * kb ) {
if ( spec == NULL ) return TRUE ;
if ( Specifications::is_description_like ( spec )) {
@@ -570,7 +382,7 @@ an action.
return FALSE ;
}
-
int ActionPatterns::ap_count_rooms ( action_pattern * ap ) {
int c = 0 ;
- if ( ap -> room_spec ) c += 2 ;
+ if ( APClauses::get_room ( ap )) c += 2 ;
if ( ap -> from_spec ) c += 2 ;
if ( ap -> to_spec ) c += 2 ;
return c ;
@@ -601,17 +413,17 @@ used in sorting algorithms.
( ap -> by_spec ) ||
( ap -> through_spec ))
c ++;
- if (( ap -> room_spec ) ||
+ if (( APClauses::get_room ( ap )) ||
( ap -> from_spec ) ||
( ap -> to_spec ))
c ++;
if (( ap -> nowhere_flag ) ||
- ( ap -> noun_spec ) ||
- ( ap -> second_spec ) ||
- ( ap -> actor_spec ))
+ ( APClauses::get_noun ( ap )) ||
+ ( APClauses::get_second ( ap )) ||
+ ( APClauses::get_actor ( ap )))
c ++;
- if ( ActionPatterns::get_presence ( ap )) c ++;
- if (( ap -> duration ) || ( ap -> when )) c ++;
+ if ( APClauses::get_presence ( ap )) c ++;
+ if (( ap -> duration ) || ( APClauses::get_val ( ap , WHEN_AP_CLAUSE ))) c ++;
if ( ap -> parameter_spec ) c ++;
return c ;
}
@@ -636,7 +448,7 @@ used in sorting algorithms.
c_s_stage_law = I "III.2.1 - Action/Where/Going In Exotic Ways" ;
- rct1 = ActionPatterns::ap_count_going ( ap1 ); rct2 = ActionPatterns::ap_count_going ( ap2 );
+ rct1 = ActionPatterns::ap_count_going ( ap1 ); rct2 = ActionPatterns::ap_count_going ( ap2 );
if ( rct1 > rct2 ) return 1 ;
if ( rct1 < rct2 ) return -1;
@@ -651,20 +463,20 @@ used in sorting algorithms.
c_s_stage_law = I "III.2.2 - Action/Where/Room Where Action Takes Place" ;
- rct1 = ActionPatterns::ap_count_rooms ( ap1 ); rct2 = ActionPatterns::ap_count_rooms ( ap2 );
+ rct1 = ActionPatterns::ap_count_rooms ( ap1 ); rct2 = ActionPatterns::ap_count_rooms ( ap2 );
if ( rct1 > rct2 ) return 1 ;
if ( rct1 < rct2 ) return -1;
- if (( ap1 -> from_spec ) && ( ap1 -> room_spec == NULL )
- && ( ap2 -> room_spec ) && ( ap2 -> from_spec == NULL )) {
- rv = Specifications::compare_specificity ( ap1 -> from_spec , ap2 -> room_spec , NULL );
+ if (( ap1 -> from_spec ) && ( APClauses::get_room ( ap1 ) == NULL )
+ && ( APClauses::get_room ( ap2 )) && ( ap2 -> from_spec == NULL )) {
+ rv = Specifications::compare_specificity ( ap1 -> from_spec , APClauses::get_room ( ap2 ), NULL );
if ( rv != 0 ) return rv ;
suspend_usual_from_and_room = TRUE ;
}
- if (( ap2 -> from_spec ) && ( ap2 -> room_spec == NULL )
- && ( ap1 -> room_spec ) && ( ap1 -> from_spec == NULL )) {
- rv = Specifications::compare_specificity ( ap1 -> room_spec , ap2 -> from_spec , NULL );
+ if (( ap2 -> from_spec ) && ( APClauses::get_room ( ap2 ) == NULL )
+ && ( APClauses::get_room ( ap1 )) && ( ap1 -> from_spec == NULL )) {
+ rv = Specifications::compare_specificity ( APClauses::get_room ( ap1 ), ap2 -> from_spec , NULL );
if ( rv != 0 ) return rv ;
suspend_usual_from_and_room = TRUE ;
}
@@ -675,7 +487,7 @@ used in sorting algorithms.
}
if ( suspend_usual_from_and_room == FALSE ) {
- rv = Specifications::compare_specificity ( ap1 -> room_spec , ap2 -> room_spec , NULL );
+ rv = Specifications::compare_specificity ( APClauses::get_room ( ap1 ), APClauses::get_room ( ap2 ), NULL );
if ( rv != 0 ) return rv ;
}
@@ -684,22 +496,22 @@ used in sorting algorithms.
c_s_stage_law = I "III.2.3 - Action/Where/In The Presence Of" ;
- rv = Specifications::compare_specificity ( ActionPatterns::get_presence ( ap1 ), ActionPatterns::get_presence ( ap2 ), NULL );
+ rv = Specifications::compare_specificity ( APClauses::get_presence ( ap1 ), APClauses::get_presence ( ap2 ), NULL );
if ( rv != 0 ) return rv ;
c_s_stage_law = I "III.2.4 - Action/Where/Other Optional Clauses" ;
- rv = ActionPatterns::compare_specificity_of_apoc_list ( ap1 , ap2 );
+ rv = APClauses::compare_specificity_of_apoc_list ( ap1 , ap2 );
if ( rv != 0 ) return rv ;
c_s_stage_law = I "III.3.1 - Action/What/Second Thing Acted On" ;
- rv = Specifications::compare_specificity ( ap1 -> second_spec , ap2 -> second_spec , NULL );
+ rv = Specifications::compare_specificity ( APClauses::get_second ( ap1 ), APClauses::get_second ( ap2 ), NULL );
if ( rv != 0 ) return rv ;
c_s_stage_law = I "III.3.2 - Action/What/Thing Acted On" ;
- rv = Specifications::compare_specificity ( ap1 -> noun_spec , ap2 -> noun_spec , NULL );
+ rv = Specifications::compare_specificity ( APClauses::get_noun ( ap1 ), APClauses::get_noun ( ap2 ), NULL );
if ( rv != 0 ) return rv ;
if (( ap1 -> nowhere_flag ) && ( ap2 -> nowhere_flag == FALSE )) return -1;
@@ -707,7 +519,7 @@ used in sorting algorithms.
c_s_stage_law = I "III.3.3 - Action/What/Actor Performing Action" ;
- rv = Specifications::compare_specificity ( ap1 -> actor_spec , ap2 -> actor_spec , NULL );
+ rv = Specifications::compare_specificity ( APClauses::get_actor ( ap1 ), APClauses::get_actor ( ap2 ), NULL );
if ( rv != 0 ) return rv ;
c_s_stage_law = I "III.4.1 - Action/How/What Happens" ;
@@ -722,24 +534,24 @@ used in sorting algorithms.
c_s_stage_law = I "III.5.2 - Action/When/Circumstances" ;
- rv = Conditions::compare_specificity_of_CONDITIONs ( ap1 -> when , ap2 -> when );
+ rv = Conditions::compare_specificity_of_CONDITIONs ( APClauses::get_val ( ap1 , WHEN_AP_CLAUSE ), APClauses::get_val ( ap2 , WHEN_AP_CLAUSE ));
if ( rv != 0 ) return rv ;
c_s_stage_law = I "III.6.1 - Action/Name/Is This Named" ;
- if (( ActionPatterns::is_named ( ap1 )) && ( ActionPatterns::is_named ( ap2 ) == FALSE ))
+ if (( ActionPatterns::is_named ( ap1 )) && ( ActionPatterns::is_named ( ap2 ) == FALSE ))
return 1 ;
- if (( ActionPatterns::is_named ( ap1 ) == FALSE ) && ( ActionPatterns::is_named ( ap2 )))
+ if (( ActionPatterns::is_named ( ap1 ) == FALSE ) && ( ActionPatterns::is_named ( ap2 )))
return -1;
return 0 ;
}
-
-void ActionPatterns::put_action_object_into_ap ( action_pattern * ap , int pos , wording W ) {
+void ActionPatterns::put_action_object_into_ap ( action_pattern * ap , int pos , wording W ) {
parse_node * spec = NULL ;
int any_flag = FALSE ;
if ( <action-operand> ( W )) {
@@ -752,13 +564,22 @@ into action patterns in the noun or second noun position.
Node::set_text ( spec , W );
LOGIF ( ACTION_PATTERN_PARSING , "PAOIA (position %d) %W = $P\n" , pos , W , spec );
switch ( pos ) {
- case 1 : ap -> noun_spec = spec ; ap -> noun_any = any_flag ; break ;
- case 2 : ap -> second_spec = spec ; ap -> second_any = any_flag ; break ;
- case 3 : ap -> room_spec = spec ; ap -> room_any = any_flag ; break ;
+ case 1 : APClauses::set_val ( ap , NOUN_AP_CLAUSE , spec );
+ if ( any_flag ) APClauses::set_opt ( APClauses::clause ( ap , NOUN_AP_CLAUSE ), DO_NOT_VALIDATE_APCOPT );
+ else APClauses::clear_opt ( APClauses::clause ( ap , NOUN_AP_CLAUSE ), DO_NOT_VALIDATE_APCOPT );
+ break ;
+ case 2 : APClauses::set_val ( ap , SECOND_AP_CLAUSE , spec );
+ if ( any_flag ) APClauses::set_opt ( APClauses::clause ( ap , SECOND_AP_CLAUSE ), DO_NOT_VALIDATE_APCOPT );
+ else APClauses::clear_opt ( APClauses::clause ( ap , SECOND_AP_CLAUSE ), DO_NOT_VALIDATE_APCOPT );
+ break ;
+ case 3 : APClauses::set_val ( ap , IN_AP_CLAUSE , spec );
+ if ( any_flag ) APClauses::set_opt ( APClauses::clause ( ap , IN_AP_CLAUSE ), DO_NOT_VALIDATE_APCOPT );
+ else APClauses::clear_opt ( APClauses::clause ( ap , IN_AP_CLAUSE ), DO_NOT_VALIDATE_APCOPT );
+ break ;
}
}
-
+
int ActionPatterns::refers_to_past ( action_pattern * ap ) {
@@ -780,16 +601,16 @@ into action patterns in the noun or second noun position.
}
int ActionPatterns::makes_callings ( action_pattern * ap ) {
- if ( Descriptions::makes_callings ( ap -> noun_spec )) return TRUE ;
- if ( Descriptions::makes_callings ( ap -> second_spec )) return TRUE ;
- if ( Descriptions::makes_callings ( ap -> actor_spec )) return TRUE ;
- if ( Descriptions::makes_callings ( ap -> room_spec )) return TRUE ;
+ if ( Descriptions::makes_callings ( APClauses::get_noun ( ap ))) return TRUE ;
+ if ( Descriptions::makes_callings ( APClauses::get_second ( ap ))) return TRUE ;
+ if ( Descriptions::makes_callings ( APClauses::get_actor ( ap ))) return TRUE ;
+ if ( Descriptions::makes_callings ( APClauses::get_room ( ap ))) return TRUE ;
if ( Descriptions::makes_callings ( ap -> parameter_spec )) return TRUE ;
- if ( Descriptions::makes_callings ( ActionPatterns::get_presence ( ap ))) return TRUE ;
+ if ( Descriptions::makes_callings ( APClauses::get_presence ( ap ))) return TRUE ;
return FALSE ;
}
-
+
int ActionPatterns::is_an_action_variable ( parse_node * spec ) {
@@ -804,7 +625,7 @@ into action patterns in the noun or second noun position.
}
+
diff --git a/docs/if-module/4-apc.html b/docs/if-module/4-apc.html
new file mode 100644
index 000000000..b344125dd
--- /dev/null
+++ b/docs/if-module/4-apc.html
@@ -0,0 +1,344 @@
+
+
+
+ Action Pattern Clauses
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Compiler Webs Inbuild Modules Inform7 Modules Inter Modules Services
+
+
+
+
+Pattern-matches on individual nouns in an action are called clauses.
+
+
+
+enum ACTOR_AP_CLAUSE from 1
+enum NOUN_AP_CLAUSE
+enum SECOND_AP_CLAUSE
+enum IN_AP_CLAUSE
+enum IN_THE_PRESENCE_OF_AP_CLAUSE
+enum WHEN_AP_CLAUSE
+enum GOING_FROM_AP_CLAUSE
+enum GOING_TO_AP_CLAUSE
+enum GOING_BY_AP_CLAUSE
+enum GOING_THROUGH_AP_CLAUSE
+enum PUSHING_AP_CLAUSE
+enum STV_AP_CLAUSE
+
+
+typedef struct ap_clause {
+ int clause_ID ;
+ struct stacked_variable * stv_to_match ;
+ struct parse_node * clause_spec ;
+ int clause_options ;
+ struct ap_clause * next ;
+ CLASS_DEFINITION
+} ap_clause ;
+
+The structure ap_clause is accessed in 2/ri, 3/tm, 3/scn, 3/ts, 4/ap, 4/av, 5/tfg, 5/gl and here.
+
+
+define ALLOW_REGION_AS_ROOM_APCOPT 1
+define DO_NOT_VALIDATE_APCOPT 2
+
+
+
+
+int APClauses::opt ( ap_clause * apoc , int opt ) {
+ return ((( apoc ) && ( apoc -> clause_options )) & opt )? TRUE:FALSE ;
+}
+
+void APClauses::set_opt ( ap_clause * apoc , int opt ) {
+ if ( apoc == NULL ) internal_error ( "no such apoc" );
+ apoc -> clause_options |= opt ;
+}
+
+void APClauses::clear_opt ( ap_clause * apoc , int opt ) {
+ if ( apoc == NULL ) internal_error ( "no such apoc" );
+ if ( apoc -> clause_options & opt ) apoc -> clause_options -= opt ;
+}
+
+parse_node * APClauses::get_actor ( action_pattern * ap ) {
+ return APClauses::get_val ( ap , ACTOR_AP_CLAUSE );
+}
+
+void APClauses::set_actor ( action_pattern * ap , parse_node * val ) {
+ APClauses::set_val ( ap , ACTOR_AP_CLAUSE , val );
+}
+
+parse_node * APClauses::get_noun ( action_pattern * ap ) {
+ return APClauses::get_val ( ap , NOUN_AP_CLAUSE );
+}
+
+void APClauses::set_noun ( action_pattern * ap , parse_node * val ) {
+ APClauses::set_val ( ap , NOUN_AP_CLAUSE , val );
+}
+
+parse_node * APClauses::get_second ( action_pattern * ap ) {
+ return APClauses::get_val ( ap , SECOND_AP_CLAUSE );
+}
+
+void APClauses::set_second ( action_pattern * ap , parse_node * val ) {
+ APClauses::set_val ( ap , SECOND_AP_CLAUSE , val );
+}
+
+parse_node * APClauses::get_presence ( action_pattern * ap ) {
+ return APClauses::get_val ( ap , IN_THE_PRESENCE_OF_AP_CLAUSE );
+}
+
+void APClauses::set_presence ( action_pattern * ap , parse_node * val ) {
+ APClauses::set_val ( ap , IN_THE_PRESENCE_OF_AP_CLAUSE , val );
+}
+
+parse_node * APClauses::get_room ( action_pattern * ap ) {
+ return APClauses::get_val ( ap , IN_AP_CLAUSE );
+}
+
+void APClauses::set_room ( action_pattern * ap , parse_node * val ) {
+ APClauses::set_val ( ap , IN_AP_CLAUSE , val );
+}
+
+parse_node * APClauses::get_val ( action_pattern * ap , int C ) {
+ ap_clause * apoc = APClauses::clause ( ap , C );
+ return ( apoc )?( apoc -> clause_spec ): NULL ;
+}
+
+void APClauses::set_val ( action_pattern * ap , int C , parse_node * val ) {
+ if ( val == NULL ) {
+ ap_clause * apoc = APClauses::clause ( ap , C );
+ if ( apoc ) apoc -> clause_spec = val ;
+ } else {
+ ap_clause * apoc = APClauses::ensure_clause ( ap , C );
+ apoc -> clause_spec = val ;
+ }
+}
+
+void APClauses::nullify_nonspecific ( action_pattern * ap , int C ) {
+ ap_clause * apoc = APClauses::clause ( ap , C );
+ if ( apoc ) apoc -> clause_spec = ActionPatterns::nullify_nonspecific_references ( apoc -> clause_spec );
+}
+
+ap_clause * APClauses::clause ( action_pattern * ap , int C ) {
+ return APClauses::find_clause ( ap , C , FALSE );
+}
+
+ap_clause * APClauses::ensure_clause ( action_pattern * ap , int C ) {
+ return APClauses::find_clause ( ap , C , TRUE );
+}
+
+ap_clause * APClauses::find_clause ( action_pattern * ap , int clause , int make ) {
+ if ( ap ) {
+ ap_clause * last = NULL ;
+ for ( ap_clause * apoc = ap -> ap_clauses ; apoc ; apoc = apoc -> next ) {
+ if ( apoc -> clause_ID == clause )
+ return apoc ;
+ last = apoc ;
+ }
+ if ( make ) {
+ ap_clause * new_apoc = APClauses::apoc_new ( clause , NULL , NULL );
+ if ( last == NULL ) ap -> ap_clauses = new_apoc ;
+ else last -> next = new_apoc ;
+ return new_apoc ;
+ }
+ } else {
+ if ( make ) internal_error ( "cannot make clause in null AP" );
+ }
+ return NULL ;
+}
+
+ap_clause * APClauses::find_stv ( action_pattern * ap , stacked_variable * stv ) {
+ if ( ap )
+ for ( ap_clause * apoc = ap -> ap_clauses ; apoc ; apoc = apoc -> next )
+ if ( apoc -> stv_to_match == stv )
+ return apoc ;
+ return NULL ;
+}
+
+ap_clause * APClauses::apoc_new ( int clause , stacked_variable * stv , parse_node * spec ) {
+ ap_clause * apoc = CREATE ( ap_clause );
+ apoc -> clause_ID = clause ;
+ apoc -> stv_to_match = stv ;
+ apoc -> clause_spec = spec ;
+ apoc -> next = NULL ;
+ apoc -> clause_options = FALSE ;
+ return apoc ;
+}
+
+void APClauses::ap_add_optional_clause ( action_pattern * ap , stacked_variable * stv ,
+ wording W ) {
+ if ( stv == NULL ) internal_error ( "no stacked variable for apoc" );
+ ap_clause * apoc = APClauses::apoc_new ( STV_AP_CLAUSE , stv ,
+ ParseActionPatterns::verified_action_parameter ( W ));
+ int oid = StackedVariables::get_owner_id ( apoc -> stv_to_match );
+ int off = StackedVariables::get_offset ( apoc -> stv_to_match );
+ if ( ap -> ap_clauses == NULL ) {
+ ap -> ap_clauses = apoc ;
+ apoc -> next = NULL ;
+ } else {
+ ap_clause * oapoc = ap -> ap_clauses , * papoc = NULL ;
+ while ( oapoc ) {
+ if ( oapoc -> stv_to_match ) {
+ int ooff = StackedVariables::get_offset ( oapoc -> stv_to_match );
+ if ( off < ooff ) {
+ if ( oapoc == ap -> ap_clauses ) {
+ apoc -> next = ap -> ap_clauses ;
+ ap -> ap_clauses = apoc ;
+ papoc = NULL ;
+ } else {
+ apoc -> next = papoc -> next ;
+ papoc -> next = apoc ;
+ papoc = NULL ;
+ }
+ break ;
+ }
+ }
+ papoc = oapoc ;
+ oapoc = oapoc -> next ;
+ }
+ if ( papoc ) {
+ apoc -> next = NULL ;
+ papoc -> next = apoc ;
+ }
+ }
+
+ if ( oid == 20007 /* i . e ., going */ ) {
+ switch ( off ) {
+ case 0 : ap -> from_spec = apoc -> clause_spec ;
+ APClauses::set_opt ( apoc , ALLOW_REGION_AS_ROOM_APCOPT ); break ;
+ case 1 : ap -> to_spec = apoc -> clause_spec ;
+ APClauses::set_opt ( apoc , ALLOW_REGION_AS_ROOM_APCOPT ); break ;
+ case 2 : ap -> through_spec = apoc -> clause_spec ; break ;
+ case 3 : ap -> by_spec = apoc -> clause_spec ; break ;
+ case 4 : ap -> pushing_spec = apoc -> clause_spec ; break ;
+ }
+ }
+ ap -> chief_action_owner_id = oid ;
+}
+
+int APClauses::ap_count_optional_clauses ( action_pattern * ap ) {
+ int n = 0 ;
+ if ( ap )
+ for ( ap_clause * apoc = ap -> ap_clauses ; apoc ; apoc = apoc -> next )
+ if ( apoc -> stv_to_match )
+ if (( ap -> chief_action_owner_id != 20007 ) ||
+ ( StackedVariables::get_offset ( apoc -> stv_to_match ) >= 5 ))
+ n ++;
+ return n ;
+}
+
+int APClauses::has_stv_clauses ( action_pattern * ap ) {
+ if (( ap ) && ( APClauses::nudge_to_stv_apoc ( ap -> ap_clauses ))) return TRUE ;
+ return FALSE ;
+}
+
+int APClauses::compare_specificity_of_apoc_list ( action_pattern * ap1 , action_pattern * ap2 ) {
+ int rct1 = APClauses::ap_count_optional_clauses ( ap1 );
+ int rct2 = APClauses::ap_count_optional_clauses ( ap2 );
+
+ if ( rct1 > rct2 ) return 1 ;
+ if ( rct1 < rct2 ) return -1;
+ if ( rct1 == 0 ) return 0 ;
+ if ( ap1 -> chief_action_owner_id != ap2 -> chief_action_owner_id ) return 0 ;
+
+ ap_clause * apoc1 = APClauses::nudge_to_stv_apoc ( ap1 -> ap_clauses ),
+ * apoc2 = APClauses::nudge_to_stv_apoc ( ap2 -> ap_clauses );
+ while (( apoc1 ) && ( apoc2 )) {
+ int off1 = StackedVariables::get_offset ( apoc1 -> stv_to_match );
+ int off2 = StackedVariables::get_offset ( apoc2 -> stv_to_match );
+ if ( off1 == off2 ) {
+ int rv = Specifications::compare_specificity ( apoc1 -> clause_spec , apoc2 -> clause_spec , NULL );
+ if ( rv != 0 ) return rv ;
+ apoc1 = APClauses::nudge_to_stv_apoc ( apoc1 -> next );
+ apoc2 = APClauses::nudge_to_stv_apoc ( apoc2 -> next );
+ }
+ if ( off1 < off2 ) apoc1 = APClauses::nudge_to_stv_apoc ( apoc1 -> next );
+ if ( off1 > off2 ) apoc2 = APClauses::nudge_to_stv_apoc ( apoc2 -> next );
+ }
+ return 0 ;
+}
+
+ap_clause * APClauses::nudge_to_stv_apoc ( ap_clause * apoc ) {
+ while (( apoc ) && ( apoc -> stv_to_match == NULL )) apoc = apoc -> next ;
+ return apoc ;
+}
+
+int APClauses::validate ( ap_clause * apoc , kind * K ) {
+ if (( apoc ) &&
+ ( APClauses::opt ( apoc , DO_NOT_VALIDATE_APCOPT ) == FALSE ) &&
+ ( Dash::validate_parameter ( apoc -> clause_spec , K ) == FALSE ))
+ return FALSE ;
+ return TRUE ;
+}
+
+
+
+
+
+
+
+
diff --git a/docs/if-module/4-as.html b/docs/if-module/4-as.html
index 0434284d6..47d35282c 100644
--- a/docs/if-module/4-as.html
+++ b/docs/if-module/4-as.html
@@ -185,22 +185,22 @@ preferred way to do that is to use activities for selecting missing parameters.
-int ActionSemantics::can_have_noun ( action_name * an ) {
+int ActionSemantics::can_have_noun ( action_name * an ) {
if ( an -> semantics . max_parameters >= 1 ) return TRUE ;
return FALSE ;
}
-int ActionSemantics::can_have_second ( action_name * an ) {
+int ActionSemantics::can_have_second ( action_name * an ) {
if ( an -> semantics . max_parameters >= 2 ) return TRUE ;
return FALSE ;
}
-int ActionSemantics::must_have_noun ( action_name * an ) {
+int ActionSemantics::must_have_noun ( action_name * an ) {
if ( an -> semantics . min_parameters >= 1 ) return TRUE ;
return FALSE ;
}
-int ActionSemantics::must_have_second ( action_name * an ) {
+int ActionSemantics::must_have_second ( action_name * an ) {
if ( an -> semantics . min_parameters >= 2 ) return TRUE ;
return FALSE ;
}
@@ -356,7 +356,7 @@ clear from the implementation in }
+
diff --git a/docs/if-module/4-av.html b/docs/if-module/4-av.html
index 7d0bf2daf..f1a254eff 100644
--- a/docs/if-module/4-av.html
+++ b/docs/if-module/4-av.html
@@ -302,7 +302,7 @@ action patterns. For example, the Standard Rules define:
}
+
diff --git a/docs/if-module/4-nap.html b/docs/if-module/4-nap.html
index b3b1eddf6..5ae18cb62 100644
--- a/docs/if-module/4-nap.html
+++ b/docs/if-module/4-nap.html
@@ -98,7 +98,7 @@ this category if it matches one of the patterns.
-void NamedActionPatterns::add ( action_pattern * ap , wording W ) {
+void NamedActionPatterns::add ( action_pattern * ap , wording W ) {
named_action_pattern * nap = NamedActionPatterns::by_name ( W );
if ( nap == NULL ) nap = NamedActionPatterns::new ( W );
named_action_pattern_entry * nape = CREATE ( named_action_pattern_entry );
@@ -145,13 +145,13 @@ if and only if it appears in one of the patterns in the list:
named_action_pattern_entry * nape ;
if ( nap )
LOOP_OVER_LINKED_LIST ( nape , named_action_pattern_entry , nap -> patterns )
- if ( ActionPatterns::within_action_context ( nape -> behaviour , an ))
+ if ( ActionPatterns::within_action_context ( nape -> behaviour , an ))
return TRUE ;
return FALSE ;
}
+
diff --git a/docs/if-module/4-pap.html b/docs/if-module/4-pap.html
index de2b79879..9756524ce 100644
--- a/docs/if-module/4-pap.html
+++ b/docs/if-module/4-pap.html
@@ -79,7 +79,7 @@ form the usage conditions for rules in object-based rulebooks.
action_pattern ParseActionPatterns::parametric ( wording W , kind * K ) {
- action_pattern ap = ActionPatterns::new ();
+ action_pattern ap = ActionPatterns::new ();
ap . parameter_spec = ParseActionPatterns::parameter ( W );
ap . parameter_kind = K ;
ap . valid = Dash::validate_parameter ( ap . parameter_spec , K );
@@ -95,7 +95,7 @@ form the usage conditions for rules in object-based rulebooks.
return Specifications::new_UNKNOWN ( W );
}
-parse_node * ParseActionPatterns::verified_action_parameter ( wording W ) {
+parse_node * ParseActionPatterns::verified_action_parameter ( wording W ) {
parse_node * spec = ParseActionPatterns::parameter ( W );
if ( Node::is ( spec , UNKNOWN_NT )) {
Problems::quote_source (1, current_sentence );
@@ -122,7 +122,7 @@ form the usage conditions for rules in object-based rulebooks.
int s2 = permit_trying_omission ;
permit_trying_omission = TRUE ;
if ( <action-pattern> ( W )) {
- anl = ActionPatterns::list ( <<rp>> );
+ anl = ActionPatterns::list ( <<rp>> );
if (( anl ) && ( anl -> entries )) {
if ( <<r>> == ACTOR_EXPLICITLY_UNIVERSAL )
* anyone = TRUE ;
@@ -195,8 +195,8 @@ These are always present tense, and can't be negated.
<action-pattern> ::=
- asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; ap->actor_spec = RP[1];
- <action-parameter> trying <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; ap->actor_spec = RP[1];
+ asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; APClauses::set_actor(ap, RP[1]);
+ <action-parameter> trying <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; APClauses::set_actor(ap, RP[1]);
an actor trying <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
an actor <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
trying <action-pattern-core> | ==> { ACTOR_EXPLICITLY_PLAYER, RP[1] };
@@ -211,9 +211,9 @@ four combinations:
<we-are-action-pattern> ::=
- we are asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; ap->actor_spec = RP[1];
- asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; ap = *XP; ap->request = TRUE; ap->actor_spec = RP[1];
- <action-parameter> trying <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; ap->actor_spec = RP[1];
+ we are asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; APClauses::set_actor(ap, RP[1]);
+ asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; ap = *XP; ap->request = TRUE; APClauses::set_actor(ap, RP[1]);
+ <action-parameter> trying <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; APClauses::set_actor(ap, RP[1]);
an actor trying <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
an actor <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
we are trying <action-pattern-core> | ==> { ACTOR_EXPLICITLY_PLAYER, RP[1] };
@@ -222,9 +222,9 @@ four combinations:
<action-pattern-core-actor> ==> { ACTOR_IMPLICITLY_PLAYER, RP[1] };
<action-pattern-negated> ::=
- we are not asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; ap->actor_spec = RP[1];
- not asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; ap = *XP; ap->request = TRUE; ap->actor_spec = RP[1];
- <action-parameter> not trying <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; ap->actor_spec = RP[1];
+ we are not asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; APClauses::set_actor(ap, RP[1]);
+ not asking <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; ap = *XP; ap->request = TRUE; APClauses::set_actor(ap, RP[1]);
+ <action-parameter> not trying <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; APClauses::set_actor(ap, RP[1]);
an actor not trying <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
an actor not <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
we are not trying <action-pattern-core> | ==> { ACTOR_EXPLICITLY_PLAYER, RP[1] };
@@ -233,16 +233,16 @@ four combinations:
not <action-pattern-core-actor> ==> { ACTOR_IMPLICITLY_PLAYER, RP[1] };
<action-pattern-past> ::=
- we have asked <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; ap->actor_spec = RP[1];
- <action-parameter> has tried <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; ap->actor_spec = RP[1];
+ we have asked <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; APClauses::set_actor(ap, RP[1]);
+ <action-parameter> has tried <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; APClauses::set_actor(ap, RP[1]);
an actor has tried <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
an actor has <action-pattern-past-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
we have tried <action-pattern-core> | ==> { ACTOR_EXPLICITLY_PLAYER, RP[1] };
we have <action-pattern-past-core> ==> { ACTOR_EXPLICITLY_PLAYER, RP[1] };
<action-pattern-past-negated> ::=
- we have not asked <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; ap->actor_spec = RP[1];
- <action-parameter> has not tried <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; ap->actor_spec = RP[1];
+ we have not asked <action-parameter> to try <action-pattern-core> | ==> { ACTOR_REQUESTED, RP[2] }; action_pattern *ap = *XP; ap->request = TRUE; APClauses::set_actor(ap, RP[1]);
+ <action-parameter> has not tried <action-pattern-core> | ==> { ACTOR_NAMED, RP[2] }; ap = *XP; ap->request = FALSE; APClauses::set_actor(ap, RP[1]);
an actor has not tried <action-pattern-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
an actor has not <action-pattern-past-core> | ==> { ACTOR_EXPLICITLY_UNIVERSAL, RP[1] }; ap = *XP; ap->applies_to_any_actor = TRUE;
we have not tried <action-pattern-core> | ==> { ACTOR_EXPLICITLY_PLAYER, RP[1] };
@@ -268,7 +268,7 @@ actorless possibility can always be written.
<action-pattern-core-actor> ::=
<action-pattern-core> | ==> { ACTOR_IMPLICITLY_PLAYER, RP[1] };
- <actor-description> <action-pattern-core> ==> { ACTOR_NAMED, RP[2] }; action_pattern *ap = *XP; ap->request = FALSE; ap->actor_spec = RP[1];
+ <actor-description> <action-pattern-core> ==> { ACTOR_NAMED, RP[2] }; action_pattern *ap = *XP; ap->request = FALSE; APClauses::set_actor(ap, RP[1]);
This is Preform grammar , not regular C code.
<ap-common-core> ::=
- <ap-common-core-inner> when/while <condition-in-ap> | ==> { 0, RP[1] }; action_pattern *ap = *XP; ap->when = RP[2]; if (pap_failure_reason == MISC_PAPF) pap_failure_reason = WHENOKAY_PAPF;
+ <ap-common-core-inner> when/while <condition-in-ap> | ==> { 0, RP[1] }; action_pattern *ap = *XP; APClauses::set_val(ap, WHEN_AP_CLAUSE, RP[2]); if (pap_failure_reason == MISC_PAPF) pap_failure_reason = WHENOKAY_PAPF;
<ap-common-core-inner> | ==> { 0, RP[1] };
... when/while <condition-in-ap> | ==> { 0, NULL }; pap_failure_reason = WHENOKAY_PAPF; return FALSE;
... when/while ... ==> { 0, NULL }; if (pap_failure_reason != WHENOKAY_PAPF) pap_failure_reason = WHEN_PAPF; return FALSE;
@@ -489,7 +489,7 @@ to enable Inform to set up a stack frame if there isn't one already, and so on.
<ap-common-core-inner> ::=
- <ap-common-core-inner-inner> in the presence of <action-parameter> | ==> { 0, RP[1] }; ActionPatterns::set_presence(RP[1], RP[2]);
+ <ap-common-core-inner-inner> in the presence of <action-parameter> | ==> { 0, RP[1] }; APClauses::set_presence(RP[1], RP[2]);
<ap-common-core-inner-inner> ==> { 0, RP[1] };
This is Preform grammar , not regular C code.
@@ -513,10 +513,10 @@ is valid as an AP, but this enables many natural-looking rules to be written
if ( Dash::validate_parameter ( RP [1], K_object ) == FALSE ) {
==> { fail production };
}
- action_pattern ap = ActionPatterns::new ();
+ action_pattern ap = ActionPatterns::new ();
ap . valid = TRUE ; ap . text_of_pattern = W ;
- ap . room_spec = RP [1];
- ==> { 0 , ActionPatterns::ap_store ( ap ) };
+ APClauses::set_room (& ap , RP [1]);
+ ==> { 0 , ActionPatterns::ap_store ( ap ) };
This code is used in §17 .
- trial_ap . noun_spec = NULL ; trial_ap . second_spec = NULL ; trial_ap . room_spec = NULL ; trial_ap . nowhere_flag = FALSE ;
+ trial_ap . ap_clauses = NULL ;
+ APClauses::set_room (& trial_ap , NULL ); trial_ap . nowhere_flag = FALSE ;
if ( Wordings::nonempty ( ActionNameLists::par ( entry , 0 ))) {
if (( ActionNameLists::action ( entry ) == going_action ) && ( <going-action-irregular-operand> ( ActionNameLists::par ( entry , 0 )))) {
if ( <<r>> == FALSE ) trial_ap . nowhere_flag = TRUE ;
else trial_ap . nowhere_flag = 2 ;
- } else ActionPatterns::put_action_object_into_ap (& trial_ap , 1 , ActionNameLists::par ( entry , 0 ));
+ } else ActionPatterns::put_action_object_into_ap (& trial_ap , 1 , ActionNameLists::par ( entry , 0 ));
}
if ( Wordings::nonempty ( ActionNameLists::par ( entry , 1 ))) {
@@ -844,15 +847,16 @@ description.
&& ( K_understanding )
&& ( Kinds::eq ( ActionSemantics::kind_of_second ( ActionNameLists::action ( entry )), K_understanding ))
&& ( <understanding-action-irregular-operand> ( ActionNameLists::par ( entry , 1 )))) {
- trial_ap . second_spec = Rvalues::from_grammar_verb ( NULL );
- Node::set_text ( trial_ap . second_spec , ActionNameLists::par ( entry , 1 ));
+ parse_node * val = Rvalues::from_grammar_verb ( NULL );
+ Node::set_text ( val , ActionNameLists::par ( entry , 1 ));
+ APClauses::set_second (& trial_ap , val );
} else {
- ActionPatterns::put_action_object_into_ap (& trial_ap , 2 , ActionNameLists::par ( entry , 1 ));
+ ActionPatterns::put_action_object_into_ap (& trial_ap , 2 , ActionNameLists::par ( entry , 1 ));
}
}
if ( Wordings::nonempty ( ActionNameLists::in_clause ( entry )))
- ActionPatterns::put_action_object_into_ap (& trial_ap , 3 ,
+ ActionPatterns::put_action_object_into_ap (& trial_ap , 3 ,
ActionNameLists::in_clause ( entry ));
This code is used in §21.5 .
@@ -867,14 +871,11 @@ description.
check_s = ActionSemantics::kind_of_second ( ActionNameLists::action ( entry ));
}
trial_ap . valid = TRUE ;
- if (( trial_ap . noun_any == FALSE ) &&
- ( Dash::validate_parameter ( trial_ap . noun_spec , check_n ) == FALSE ))
+ if ( APClauses::validate ( APClauses::clause (& trial_ap , NOUN_AP_CLAUSE ), check_n ) == FALSE )
trial_ap . valid = FALSE ;
- if (( trial_ap . second_any == FALSE ) &&
- ( Dash::validate_parameter ( trial_ap . second_spec , check_s ) == FALSE ))
+ if ( APClauses::validate ( APClauses::clause (& trial_ap , SECOND_AP_CLAUSE ), check_s ) == FALSE )
trial_ap . valid = FALSE ;
- if (( trial_ap . room_any == FALSE ) &&
- ( Dash::validate_parameter ( trial_ap . room_spec , K_object ) == FALSE ))
+ if ( APClauses::validate ( APClauses::clause (& trial_ap , IN_AP_CLAUSE ), K_object ) == FALSE )
trial_ap . valid = FALSE ;
This code is used in §21.5 .
@@ -989,7 +990,7 @@ the case when the first action name in the list is -
+ Pattern-matches on individual nouns in an action are called clauses.
+
Parse Action Patterns -
diff --git a/docs/runtime-module/5-ap.html b/docs/runtime-module/5-ap.html
index 2fe6bc2f2..7afc04718 100644
--- a/docs/runtime-module/5-ap.html
+++ b/docs/runtime-module/5-ap.html
@@ -78,9 +78,9 @@ function togglePopup(material_id) {
void RTActionPatterns::emit_try ( action_pattern * ap , int store_instead ) {
- parse_node * spec0 = ap -> noun_spec ;
- parse_node * spec1 = ap -> second_spec ;
- parse_node * spec2 = ap -> actor_spec ;
+ parse_node * spec0 = APClauses::get_noun ( ap );
+ parse_node * spec1 = APClauses::get_second ( ap );
+ parse_node * spec2 = APClauses::get_actor ( ap );
if (( K_understanding ) && ( Rvalues::is_CONSTANT_of_kind ( spec0 , K_understanding )) &&
( <subject-pronoun> ( Node::get_text ( spec0 )) == FALSE ))
@@ -352,28 +352,28 @@ and in this case we therefore ignore
@@ -931,10 +931,10 @@ and in this case we therefore ignore