Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ by having to capitalise the first letter. We do this by writing to the
buffer and then altering the first character.

=
Constant SHORT_NAME_BUFFER_LEN = 160;

#Iftrue CHARSIZE == 1;
! Allow a generous overrun
Array StorageForShortName buffer SHORT_NAME_BUFFER_LEN+90;
Constant SHORT_NAME_BUFFER_LEN = 250;
Array StorageForShortName buffer SHORT_NAME_BUFFER_LEN;
#Ifnot;
Constant SHORT_NAME_BUFFER_LEN = 1000;
Array StorageForShortName --> SHORT_NAME_BUFFER_LEN;
#Endif;

Expand All @@ -44,10 +44,9 @@ Array StorageForShortName --> SHORT_NAME_BUFFER_LEN;
return RunTimeError(2, obj, prop);
}
}

#Ifdef TARGET_ZCODE;
StorageForShortName->WORDSIZE = VM_LowerToUpperCase(StorageForShortName->WORDSIZE);
for (i=WORDSIZE: i<length+WORDSIZE: i++) print (char) StorageForShortName->i;
VM_PrintBuffer(StorageForShortName, length);
#Ifnot;
if (length > SHORT_NAME_BUFFER_LEN) length = SHORT_NAME_BUFFER_LEN;
if (length)
Expand All @@ -60,6 +59,7 @@ Array StorageForShortName --> SHORT_NAME_BUFFER_LEN;
return;
];

! No longer used within Printing.i6t
[ Cap str nocaps;
if (nocaps) print (string) str;
else CPrintOrRun(str, 0);
Expand All @@ -71,52 +71,54 @@ process we print just the name itself (without articles attached), and we
do it by carrying out an activity.

=
[ PSN__ o;
if (o == 0) { LW_Response('Y'); rtrue; }
switch (metaclass(o)) {
Routine: print "<routine ", o, ">"; rtrue;
String: print "<string ~", (string) o, "~>"; rtrue;
nothing: print "<illegal object number ", o, ">"; rtrue;
}
RegardingSingleObject(o);
CarryOutActivity(PRINTING_THE_NAME_ACT, o);
[ PSN__ o i;
if (~~o) { LW_Response('Y'); rtrue; }
switch (metaclass(o)) {
Routine: print "<routine ", o, ">"; rtrue;
String: print "<string ~", (string) o, "~>"; rtrue;
nothing: print "<illegal object number ", o, ">"; rtrue;
}
RegardingSingleObject(o);
CarryOutActivity(PRINTING_THE_NAME_ACT, o);
];

[ PrintShortName obj i;
i = indef_mode; indef_mode = NULL;
PSN__(obj); indef_mode = i;
[ PrintShortName obj;
@push indef_mode;
indef_mode = NULL;
PSN__(obj);
@pull indef_mode;
];

@h Standard Name Printing Rule.

In its initial state, the "printing the name of" activity has just one rule:
the following "for" rule.

=

Global caps_mode = false;

[ STANDARD_NAME_PRINTING_R obj;
obj = parameter_value;
if (obj == 0) {
LW_Response('Y'); return;
}
switch (metaclass(obj)) {
Routine: print "<routine ", obj, ">"; return;
String: print "<string ~", (string) obj, "~>"; return;
nothing: print "<illegal object number ", obj, ">"; return;
if (~~parameter_value) { LW_Response('Y'); return; }
obj = parameter_value;
switch (metaclass(obj)) {
Routine: print "<routine ", obj, ">"; return;
String: print "<string ~", (string) obj, "~>"; return;
nothing: print "<illegal object number ", obj, ">"; return;
}
if (obj == player) {
PRINT_PROTAGONIST_INTERNAL_R();
return;
}
PRINT_PROTAGONIST_INTERNAL_R();
return;
}
if (LanguagePrintShortName(obj)) return;
if (indef_mode && obj provides short_name_indef &&
PrintOrRun(obj, short_name_indef, true) ~= 0) return;
PrintOrRun(obj, short_name_indef, true) ~= 0) return;
if (caps_mode &&
obj provides cap_short_name && PrintOrRun(obj, cap_short_name, true) ~= 0) {
caps_mode = false;
return;
obj provides cap_short_name && PrintOrRun(obj, cap_short_name, true) ~= 0) {
caps_mode = false;
return;
}
if (obj provides short_name && PrintOrRun(obj, short_name, true) ~= 0) return;
if (obj.&short_name && PrintOrRun(obj, short_name, true) ~= 0) return;
print (object) obj;
];

Expand Down Expand Up @@ -147,117 +149,125 @@ indefinite singular depends on the text of the object's name.
=
Global short_name_case;

[ PrefaceByArticle obj acode pluralise capitalise i artform findout artval;
if (obj provides articles) {
artval=(obj.&articles)-->(acode+short_name_case*LanguageCases);
if (capitalise)
print (Cap) artval;
else
print (string) artval;
if (pluralise) return;
print (PSN__) obj; return;
}

i = GetGNAOfObject(obj);
if (pluralise) {
if (i < 3 || (i >= 6 && i < 9)) i = i + 3;
}
i = LanguageGNAsToArticles-->i;

artform = LanguageArticles
+ 3*WORDSIZE*LanguageContractionForms*(short_name_case + i*LanguageCases);

switch (LanguageContractionForms) {
2: if (artform-->acode ~= artform-->(acode+3)) findout = true;
3: if (artform-->acode ~= artform-->(acode+3)) findout = true;
if (artform-->(acode+3) ~= artform-->(acode+6)) findout = true;
4: if (artform-->acode ~= artform-->(acode+3)) findout = true;
if (artform-->(acode+3) ~= artform-->(acode+6)) findout = true;
if (artform-->(acode+6) ~= artform-->(acode+9)) findout = true;
default: findout = true;
}
[ PrefaceByArticle obj acode pluralise capitalise i artform findout artval length;
if (obj provides articles) {
artval = (obj.&articles)-->(acode + (short_name_case * LanguageCases));
if (capitalise) CPrintOrRun(artval);
else print (string) artval;
print " ";
if (pluralise) return;
print (PSN__) obj;
return;
}
i = GetGNAOfObject(obj);
if (pluralise && (i < 3 || (i >= 6 && i < 9))) { i = i + 3; }
i = LanguageGNAsToArticles-->i;

artform = LanguageArticles + ARTBLOCK_LEN * WORDSIZE * LanguageContractionForms * (short_name_case + i * LanguageCases);

findout = ((LanguageContractionForms > 4 || LanguageContractionForms < 2) ||
(artform-->acode ~= artform-->(acode+ARTBLOCK_LEN)) ||
((LanguageContractionForms >= 3) && (artform-->(acode+ARTBLOCK_LEN) ~= artform-->(acode+(2*ARTBLOCK_LEN)))) ||
((LanguageContractionForms == 4) && (artform-->(acode+(2*ARTBLOCK_LEN)) ~= artform-->(acode+(3*ARTBLOCK_LEN)))));
if (findout) {
#Ifdef TARGET_ZCODE;
if (standard_interpreter ~= 0 && findout) {
StorageForShortName-->0 = SHORT_NAME_BUFFER_LEN;
@output_stream 3 StorageForShortName;
if (pluralise) print (number) pluralise; else print (PSN__) obj;
@output_stream -3;
acode = acode + 3*LanguageContraction(StorageForShortName + 2);
}
if (pluralise) { length = VM_PrintToBuffer(StorageForShortName, SHORT_NAME_BUFFER_LEN, LanguageNumber, pluralise); }
else { length = VM_PrintToBuffer(StorageForShortName, SHORT_NAME_BUFFER_LEN, PSN__, obj); }
acode = acode + ARTBLOCK_LEN * LanguageContraction(StorageForShortName + 2);
#Ifnot; ! TARGET_GLULX
if (findout) {
if (pluralise)
Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, EnglishNumber, pluralise);
else
Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, PSN__, obj);
acode = acode + 3*LanguageContraction(StorageForShortName);
if (pluralise) {
length = Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, LanguageNumber, pluralise);
}
#Endif; ! TARGET_

Cap (artform-->acode, ~~capitalise); ! print article
if (pluralise) return;
print (PSN__) obj;
else {
length = Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, PSN__, obj);
}
if (length > SHORT_NAME_BUFFER_LEN) length = SHORT_NAME_BUFFER_LEN;
acode = acode + ARTBLOCK_LEN * LanguageContraction(StorageForShortName);
#Endif; ! TARGET_GLULX
}

print (string) artform-->acode;
if (pluralise) return;

#ifdef TARGET_GLULX;
if (findout) glk_put_buffer_uni(StorageForShortName, length);
#ifnot; ! TARGET_ZCODE
print (PSN__) obj;
#endif;
];

@h Object Names III.
The routines accessible from outside this segment.

=
[ IndefArt obj i s;
if (obj == 0) { LW_Response('Y'); rtrue; }
i = indef_mode; indef_mode = true; s = self; self = obj;
if (obj has proper) { indef_mode = NULL; print (PSN__) obj; indef_mode = i; self = s; return; }
if ((obj provides article) && (TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE) ~= 0)) {
PrintOrRun(obj, article, true); print " ", (PSN__) obj; indef_mode = i; self = s;
return;
}
PrefaceByArticle(obj, 2); indef_mode = i; self = s;
[ IndefArt obj;
if (~~obj) { LW_Response('Y'); rtrue; }
@push indef_mode;
@push self;
indef_mode = true;
self = obj;
if (obj has proper) {
indef_mode = NULL;
print (PSN__) obj;
}
else if ((obj provides article) && (TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE))) {
PrintOrRun(obj, article, true);
print " ", (PSN__) obj;
}
else { PrefaceByArticle(obj, INDEFART_INDEX); }
@pull self;
@pull indef_mode;
];

[ CIndefArt obj i s;
if (obj == 0) { LW_Response('X'); rtrue; }
i = indef_mode; indef_mode = true; s = self; self = obj;
if (obj has proper) {
indef_mode = NULL;
caps_mode = true;
print (PSN__) obj;
indef_mode = i;
caps_mode = false;
self = s;
return;
}
if ((obj provides article) && (TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE) ~= 0)) {
TEXT_TY_Say_Capitalised(obj.article); print " ", (PSN__) obj; indef_mode = i; self = s;
return;
}
PrefaceByArticle(obj, 2, 0, 1); indef_mode = i; self = s;
[ CIndefArt obj;
if (~~obj) { LW_Response('X'); rtrue; }
@push indef_mode;
@push self;
indef_mode = true;
self = obj;
if (obj has proper) {
indef_mode = NULL;
caps_mode = true;
! print "CIA->P";
print (PSN__) obj;
caps_mode = false;
}
else if ((obj provides article) && TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE)) {
TEXT_TY_Say_Capitalised(obj.article);
print " ", (PSN__) obj;
}
else {
PrefaceByArticle(obj, CINDEFART_INDEX, 0, 1); ! (obj, acode, pluralise, capitalise)
}
@pull self;
@pull indef_mode;
];

[ DefArt obj i s;
i = indef_mode; indef_mode = false; s = self; self = obj;
if ((~~obj ofclass Object) || obj has proper) {
indef_mode = NULL; print (PSN__) obj; indef_mode = i; self = s;
return;
}
PrefaceByArticle(obj, 1); indef_mode = i; self = s;
[ DefArt obj;
@push indef_mode;
@push self;
indef_mode = false;
self = obj;
if ((~~obj ofclass Object) || obj has proper) print (PSN__) obj;
else PrefaceByArticle(obj, DEFART_INDEX);
@pull self;
@pull indef_mode;
];

[ CDefArt obj i s;
i = indef_mode; indef_mode = false; s = self; self = obj;
if ((obj ofclass Object) && (obj has proper || obj == player)) {
indef_mode = NULL;
caps_mode = true;
print (PSN__) obj;
indef_mode = i;
caps_mode = false;
self = s;
return;
}
if ((~~obj ofclass Object) || obj has proper) {
indef_mode = NULL; print (PSN__) obj; indef_mode = i; self = s;
return;
}
PrefaceByArticle(obj, 0); indef_mode = i; self = s;
@push indef_mode;
@push self;
indef_mode = NULL;
self = obj;
if ((obj ofclass Object) && (obj has proper || obj == player)) {
caps_mode = true;
print (PSN__) obj;
caps_mode = false;
}
else if ((~~obj ofclass Object) || obj has proper) print (PSN__) obj;
else { PrefaceByArticle(obj, CDEFART_INDEX, 0, 1); }
@pull self;
@pull indef_mode;
];

@h Printing in number bases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,24 @@ Constant LanguageCases = 1; ! The number of article cases; English has one

Array LanguageArticles -->

! Contraction form 0: Contraction form 1:
! Cdef Def Indef Cdef Def Indef
! Contraction form 0: Contraction form 1:
! Cdef Def CIndef Indef Cdef Def CIndef Indef

"The " "the " "a " "The " "the " "an " ! Case 0, articles 0
"The " "the " "some " "The " "the " "some "; ! Case 0, articles 1

"The " "the " "A " "a " "The " "the " "An " "an " ! Articles 0
"The " "the " "Some " "some " "The " "the " "Some " "some "; ! Articles 1
! a i
! s p s p
! m f n m f n m f n m f n

Array LanguageGNAsToArticles --> 0 0 0 1 1 1 0 0 0 1 1 1;

Constant CDEFART_INDEX = 0;
Constant DEFART_INDEX = 1;
Constant CINDEFART_INDEX = 2;
Constant INDEFART_INDEX = 3;
Constant ARTBLOCK_LEN = 4;

@h Commands.
`LanguageVerbLikesAdverb` is called by `PrintCommand` when printing an `UPTO_PE`
error or an inference message. Words which are intransitive verbs, i.e.,
Expand Down
Loading