1 /* ------------------------------------------------------------------------- */
2 /* Header file for Inform: Z-machine ("Infocom" format) compiler */
6 /* This header file and the others making up the Inform source code are */
7 /* copyright (c) Graham Nelson 1993 - 2024 */
9 /* Inform is free software: you can redistribute it and/or modify */
10 /* it under the terms of the GNU General Public License as published by */
11 /* the Free Software Foundation, either version 3 of the License, or */
12 /* (at your option) any later version. */
14 /* Inform is distributed in the hope that it will be useful, */
15 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
16 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
17 /* GNU General Public License for more details. */
19 /* You should have received a copy of the GNU General Public License */
20 /* along with Inform. If not, see https://gnu.org/licenses/ */
22 /* *** To compile this program in one of the existing ports, you must */
23 /* at least change the machine definition (on the next page). */
24 /* In most cases no other work will be needed. *** */
28 /* Machine/host OS definitions (in alphabetical order) */
29 /* Default definitions */
30 /* Standard ANSI inclusions, macro definitions, structures */
31 /* Definitions of internal code numbers */
32 /* Extern declarations for linkage (in alphabetical order of file) */
34 /* ------------------------------------------------------------------------- */
36 /* For releases, set to the release date in the form "1st January 2000" */
37 #define RELEASE_DATE "10th February 2024"
38 #define RELEASE_NUMBER 1642
39 #define GLULX_RELEASE_NUMBER 38
40 #define VNUMBER RELEASE_NUMBER
42 /* N indicates an intermediate release for Inform 7 */
43 /*#define RELEASE_SUFFIX "N"*/
45 /* ------------------------------------------------------------------------- */
46 /* Our host machine or OS for today is... */
48 /* [ Inform should compile (possibly with warnings) and work safely */
51 /* #define AMIGA - for the Commodore Amiga under SAS/C */
52 /* #define ARCHIMEDES - for Acorn RISC OS machines under Norcroft C */
53 /* #define ATARIST - for the Atari ST */
54 /* #define BEOS - for the BeBox */
55 /* #define LINUX - for Linux under gcc (essentially as Unix) */
56 /* #define MACOS - for the Apple Mac with OS X (another Unix) */
57 /* #define MAC_CLASSIC - for the Apple Mac under Think C or Codewarrior */
58 /* #define MAC_MPW - for MPW under Codewarrior (and maybe Think C) */
59 /* #define OS2 - for OS/2 32-bit mode under IBM's C Set++ */
60 /* #define PC - for 386+ IBM PCs, eg. Microsoft Visual C/C++ */
61 /* #define PC_QUICKC - for small IBM PCs under QuickC */
62 /* #define PC_WIN32 - for Borland C++ or Microsoft Visual C++ */
63 /* #define UNIX - for Unix under gcc (or big IBM PC under djgpp) */
64 /* #define VMS - for VAX or ALPHA under DEC C, but not VAX C */
66 /* In most cases executables are already available at */
67 /* https://www.ifarchive.org/, and these are sometimes enhanced with */
68 /* e.g. windowed interfaces whose source is not archived with the */
69 /* main Inform source.] */
71 /* (If no machine is defined, then cautious #defines will be made. In */
72 /* most cases, porting to a new machine is a matter of carefully filling */
73 /* out a block of definitions like those below.) */
74 /* ------------------------------------------------------------------------- */
76 /* ------------------------------------------------------------------------- */
77 /* The first task is to include the ANSI header files, and typedef */
78 /* suitable 32-bit integer types. */
79 /* ------------------------------------------------------------------------- */
91 #if SCHAR_MAX >= 0x7FFFFFFFL && SCHAR_MIN <= -0x7FFFFFFFL
92 typedef signed char int32;
93 typedef unsigned char uint32;
94 #elif SHRT_MAX >= 0x7FFFFFFFL && SHRT_MIN <= -0x7FFFFFFFL
95 typedef signed short int int32;
96 typedef unsigned short int uint32;
97 #elif INT_MAX >= 0x7FFFFFFFL && INT_MIN <= -0x7FFFFFFFL
98 typedef signed int int32;
99 typedef unsigned int uint32;
100 #elif LONG_MAX >= 0x7FFFFFFFL && LONG_MIN <= -0x7FFFFFFFL
101 typedef signed long int int32;
102 typedef unsigned long int uint32;
104 #error No type large enough to support 32-bit integers.
107 /* VAX C does not provide these limit constants, contrary to ANSI */
109 typedef unsigned int uint32;
112 /* ------------------------------------------------------------------------- */
113 /* The next part of this file contains blocks of definitions, one for */
114 /* each port, of machine or OS-dependent constants needed by Inform. */
116 /* 1. MACHINE_STRING should be set to the name of the machine or OS. */
118 /* 2. Some miscellaneous #define options (set if the constant is */
119 /* defined, otherwise not set): */
121 /* PROMPT_INPUT - prompt input (don't use Unix-style command line) */
122 /* TIME_UNAVAILABLE - don't use ANSI time routines to work out today's */
124 /* CHAR_IS_UNSIGNED - if on your compiler the type "char" is unsigned */
125 /* by default, you should define this */
126 /* HAS_REALPATH - the POSIX realpath() function is available to */
127 /* find the absolute path to a file */
129 /* 3. This was DEFAULT_MEMORY_SIZE, now withdrawn. */
130 /* ------------------------------------------------------------------------- */
132 /* ------------------------------------------------------------------------- */
133 /* 4. Filenaming definitions: */
135 /* It's assumed that the host OS has the concept of subdirectories and */
136 /* has "pathnames", that is, filenames giving a chain of subdirectories */
137 /* divided by the FN_SEP (filename separator) character: e.g. for Unix */
138 /* FN_SEP is defined below as '/' and a typical name is */
139 /* "users/graham/jigsaw.z5". */
140 /* White space is not allowed in filenames, and nor is the special */
141 /* character FN_ALT, which unless defined here will be a comma and will */
142 /* be used to separate alternative locations in a path variable. */
144 /* If NO_FILE_EXTENSIONS is undefined then the OS allows "file extensions" */
145 /* of 1 to 3 alphanumeric characters like ".txt" (for text files), ".z5" */
146 /* (for game files), etc., to indicate the file's type (and, crucially, */
147 /* regards the same filename but with different extensions -- e.g., */
148 /* "frog.amp" and "frog.lil" -- as being different names). */
149 /* (The file extensions defined below are widely accepted, so please use */
150 /* them unless there's a good reason why not.) */
152 /* You should then define STANDARD_DIRECTORIES (you can define it anyway) */
153 /* in which case Inform will expect by default that files are sorted out */
154 /* by being put into suitable directories (e.g., a "games" directory for */
157 /* If it's convenient for your port you can alter the detailed definitions */
158 /* which these broad settings make. Be careful if NO_FILE_EXTENSIONS */
159 /* is set without STANDARD_DIRECTORIES, as then Inform may */
160 /* overwrite its source with object code. */
162 /* 5. Filenames (or code related to filenames) for temporary files. */
163 /* These included Temporary_Name, Temporary_Directory, and */
164 /* INCLUDE_TASK_ID. These options have been removed, and are listed here */
165 /* only for people who might ask "what happened to 5?" */
167 /* 6. Any other definitions specific to the OS or machine. */
168 /* (In particular DEFAULT_ERROR_FORMAT is 0 on most machines and 1 on PCs; */
169 /* it controls the style of error messages, which is important for some */
170 /* error-throwback debugging tools.) */
171 /* ------------------------------------------------------------------------- */
173 /* ========================================================================= */
174 /* The blocks now follow in alphabetical order. */
175 /* ------------------------------------------------------------------------- */
177 /* ------------------------------------------------------------------------- */
180 #define MACHINE_STRING "Amiga"
184 /* ------------------------------------------------------------------------- */
185 /* ARCHIMEDES block: Acorn/RISC OS settings */
186 /* ------------------------------------------------------------------------- */
189 #define MACHINE_STRING "RISC OS"
191 #define CHAR_IS_UNSIGNED
194 #define STANDARD_DIRECTORIES
195 #define NO_FILE_EXTENSIONS
196 #define Source_Directory "inform"
197 #define ICL_Directory "ICL"
199 #define ARC_THROWBACK
201 /* ------------------------------------------------------------------------- */
203 /* ------------------------------------------------------------------------- */
206 #define MACHINE_STRING "Atari ST"
210 /* ------------------------------------------------------------------------- */
212 /* ------------------------------------------------------------------------- */
215 #define MACHINE_STRING "BeOS"
218 #define FILE_EXTENSIONS
220 /* ------------------------------------------------------------------------- */
222 /* ------------------------------------------------------------------------- */
225 #define MACHINE_STRING "Linux"
232 #if defined(__STDC__) && (__STDC_VERSION__ >= 201112L)
233 #define USE_C11_TIME_API
236 /* ------------------------------------------------------------------------- */
237 /* Macintosh block */
238 /* ------------------------------------------------------------------------- */
246 #define MACHINE_STRING "Macintosh Programmer's Workshop"
248 #define MACHINE_STRING "Macintosh"
252 #define EXTERNAL_SHELL
262 #define Include_Extension ".h"
266 #include "TB Inform.h"
269 #include <CursorCtl.h>
270 #define DEFAULT_ERROR_FORMAT 2
273 /* ------------------------------------------------------------------------- */
275 /* ------------------------------------------------------------------------- */
278 #define MACHINE_STRING "OS/2"
280 #define CHAR_IS_UNSIGNED
284 /* ------------------------------------------------------------------------- */
286 /* ------------------------------------------------------------------------- */
289 #define MACHINE_STRING "MacOS"
296 #if defined(__STDC__) && (__STDC_VERSION__ >= 201112L)
297 #define USE_C11_TIME_API
300 /* ------------------------------------------------------------------------- */
301 /* PC and PC_QUICKC block */
302 /* ------------------------------------------------------------------------- */
309 #define MACHINE_STRING "PC"
313 #define DEFAULT_ERROR_FORMAT 1
315 /* ------------------------------------------------------------------------- */
317 /* ------------------------------------------------------------------------- */
320 #define MACHINE_STRING "Win32"
326 #define DEFAULT_ERROR_FORMAT 1
328 #if _MSC_VER >= 1920 /* Visual C++ 2019 */
329 #define USE_C11_TIME_API
332 /* ------------------------------------------------------------------------- */
334 /* ------------------------------------------------------------------------- */
337 #ifndef MACHINE_STRING
338 #define MACHINE_STRING "Unix"
345 /* ------------------------------------------------------------------------- */
346 /* VMS (Dec VAX and Alpha) block */
347 /* ------------------------------------------------------------------------- */
355 #define MACHINE_STRING "Alpha/VMS"
357 #define MACHINE_STRING "VAX/VMS"
360 #define CHAR_IS_UNSIGNED
363 #define Code_Extension ".zip"
364 #define V4Code_Extension ".zip"
365 #define V5Code_Extension ".zip"
366 #define V6Code_Extension ".zip"
367 #define V7Code_Extension ".zip"
368 #define V8Code_Extension ".zip"
370 /* ========================================================================= */
371 /* Default settings: */
372 /* ------------------------------------------------------------------------- */
374 #ifndef NO_FILE_EXTENSIONS
375 #define FILE_EXTENSIONS
378 #ifndef Transcript_File
379 #ifdef FILE_EXTENSIONS
380 #define Transcript_File "gametext.txt"
382 #define Transcript_File "gametext"
386 #ifndef Debugging_File
387 #ifdef FILE_EXTENSIONS
388 #define Debugging_File "gameinfo.dbg"
390 #define Debugging_File "gamedebug"
394 #ifndef Default_Language
395 #define Default_Language "english"
398 #ifdef FILE_EXTENSIONS
399 #ifndef Source_Extension
400 #define Source_Extension ".inf"
402 #ifndef Include_Extension
403 #define Include_Extension ".h"
405 #ifndef Code_Extension
406 #define Code_Extension ".z3"
408 #ifndef V4Code_Extension
409 #define V4Code_Extension ".z4"
411 #ifndef V5Code_Extension
412 #define V5Code_Extension ".z5"
414 #ifndef V6Code_Extension
415 #define V6Code_Extension ".z6"
417 #ifndef V7Code_Extension
418 #define V7Code_Extension ".z7"
420 #ifndef V8Code_Extension
421 #define V8Code_Extension ".z8"
423 #ifndef GlulxCode_Extension
424 #define GlulxCode_Extension ".ulx"
426 #ifndef ICL_Extension
427 #define ICL_Extension ".icl"
432 #define Source_Extension ""
433 #define Include_Extension ""
434 #define Code_Extension ""
435 #define V4Code_Extension ""
436 #define V5Code_Extension ""
437 #define V6Code_Extension ""
438 #define V7Code_Extension ""
439 #define V8Code_Extension ""
440 #define GlulxCode_Extension ""
441 #define ICL_Extension ""
444 #ifdef STANDARD_DIRECTORIES
445 #ifndef Source_Directory
446 #define Source_Directory "source"
448 #ifndef Include_Directory
449 #define Include_Directory "library"
451 #ifndef Code_Directory
452 #define Code_Directory "games"
454 #ifndef ICL_Directory
455 #define ICL_Directory ""
460 #ifndef Source_Directory
461 #define Source_Directory ""
463 #ifndef Include_Directory
464 #define Include_Directory ""
466 #ifndef Code_Directory
467 #define Code_Directory ""
469 #ifndef ICL_Directory
470 #define ICL_Directory ""
486 #ifndef DEFAULT_ERROR_FORMAT
487 #define DEFAULT_ERROR_FORMAT 0
490 #ifndef CHAR_IS_UNSIGNED
491 typedef unsigned char uchar;
496 #if defined(__GNUC__) || defined(__clang__)
497 #define NORETURN __attribute__((__noreturn__))
498 #endif /* defined(__GNUC__) || defined(__clang__) */
504 /* ------------------------------------------------------------------------- */
505 /* subtract_pointers() measures an address difference in bytes. This is */
507 /* We also declare some memory functions for PC_QUICKC. */
508 /* ------------------------------------------------------------------------- */
511 void _huge * halloc(long, size_t);
513 #define subtract_pointers(p1,p2) (long)((char _huge *)p1-(char _huge *)p2)
515 #define subtract_pointers(p1,p2) (((char *) p1)-((char *) p2))
519 /* ------------------------------------------------------------------------- */
520 /* Definitions for time measurement. TIMEVALUE is a type; TIMEVALUE_NOW() */
521 /* sets it; TIMEVALUE_DIFFERENCE() determines a difference in seconds, */
523 /* Modern platforms should support timespec_get() or clock_gettime(). To */
524 /* use timespec_get(), #define USE_C11_TIME_API. To use clock_gettime(), */
525 /* #define USE_POSIX_TIME_API. To use the old implementation using */
526 /* time(), #define USE_OLD_TIME_API. This can only measure in integer */
527 /* second counts, but it's better than waiting for gnomon. */
528 /* ------------------------------------------------------------------------- */
530 #if !defined(USE_C11_TIME_API) && !defined(USE_POSIX_TIME_API) && !defined(USE_OLD_TIME_API)
531 #define USE_OLD_TIME_API
534 #if defined(USE_OLD_TIME_API)
535 #define TIMEVALUE time_t
536 #define TIMEVALUE_NOW(t) (*t) = time(0)
537 #define TIMEVALUE_DIFFERENCE(begt, endt) (float)(*(endt) - *(begt))
538 #elif defined(USE_C11_TIME_API)
539 #define TIMEVALUE struct timespec
540 #define TIMEVALUE_NOW(t) timespec_get((t), TIME_UTC)
541 #define TIMEVALUE_DIFFERENCE(begt, endt) ((float)((endt)->tv_sec - (begt)->tv_sec) + (float)((endt)->tv_nsec - (begt)->tv_nsec) / 1000000000.0F)
542 #elif defined(USE_POSIX_TIME_API)
543 #define TIMEVALUE struct timespec
544 #define TIMEVALUE_NOW(t) clock_gettime(CLOCK_REALTIME, (t))
545 #define TIMEVALUE_DIFFERENCE(begt, endt) ((float)((endt)->tv_sec - (begt)->tv_sec) + (float)((endt)->tv_nsec - (begt)->tv_nsec) / 1000000000.0F)
548 /* ------------------------------------------------------------------------- */
549 /* SEEK_SET is a constant which should be defined in the ANSI header files */
550 /* but which is not present in some implementations: it's used as a */
551 /* parameter for "fseek", defined in "stdio". In pre-ANSI C, the value */
552 /* 0 was used as a parameter instead, hence the definition below. */
553 /* ------------------------------------------------------------------------- */
559 /* ------------------------------------------------------------------------- */
560 /* A large block of #define'd constant values follows. */
561 /* ------------------------------------------------------------------------- */
566 /* These checked the glulx_mode global during development, but are no
568 #define ASSERT_ZCODE() (0)
569 #define ASSERT_GLULX() (0)
572 #define ReadInt32(ptr) \
573 ( (((uint32)(((uchar *)(ptr))[0])) << 24) \
574 | (((uint32)(((uchar *)(ptr))[1])) << 16) \
575 | (((uint32)(((uchar *)(ptr))[2])) << 8) \
576 | (((uint32)(((uchar *)(ptr))[3])) ) )
578 #define ReadInt16(ptr) \
579 ( (((uint32)(((uchar *)(ptr))[0])) << 8) \
580 | (((uint32)(((uchar *)(ptr))[1])) ) )
582 #define WriteInt32(ptr, val) \
583 ((ptr)[0] = (uchar)(((int32)(val)) >> 24), \
584 (ptr)[1] = (uchar)(((int32)(val)) >> 16), \
585 (ptr)[2] = (uchar)(((int32)(val)) >> 8), \
586 (ptr)[3] = (uchar)(((int32)(val)) ) )
588 #define WriteInt16(ptr, val) \
589 ((ptr)[0] = (uchar)(((int32)(val)) >> 8), \
590 (ptr)[1] = (uchar)(((int32)(val)) ) )
592 /* ------------------------------------------------------------------------- */
593 /* If your compiler doesn't recognise \t, and you use ASCII, you could */
594 /* define T_C as (char) 9; failing that, it _must_ be defined as ' ' */
595 /* (space) and is _not_ allowed to be 0 or any recognisable character. */
596 /* ------------------------------------------------------------------------- */
598 #define TAB_CHARACTER '\t'
600 /* ------------------------------------------------------------------------- */
602 /* ------------------------------------------------------------------------- */
604 #define MAX_ERRORS 100
605 #define MAX_NUM_ATTR_BYTES 39
606 #define MAX_VERB_WORD_SIZE 120
608 #define VENEER_CONSTRAINT_ON_CLASSES_Z 256
609 #define VENEER_CONSTRAINT_ON_IP_TABLE_SIZE_Z 128
610 #define VENEER_CONSTRAINT_ON_CLASSES_G 32768
611 #define VENEER_CONSTRAINT_ON_IP_TABLE_SIZE_G 32768
612 #define VENEER_CONSTRAINT_ON_CLASSES \
613 (glulx_mode ? VENEER_CONSTRAINT_ON_CLASSES_G \
614 : VENEER_CONSTRAINT_ON_CLASSES_Z)
615 #define VENEER_CONSTRAINT_ON_IP_TABLE_SIZE \
616 (glulx_mode ? VENEER_CONSTRAINT_ON_IP_TABLE_SIZE_G \
617 : VENEER_CONSTRAINT_ON_IP_TABLE_SIZE_Z)
619 #define GLULX_HEADER_SIZE 36
620 /* Number of bytes in the header. */
621 #define GLULX_STATIC_ROM_SIZE 24
622 /* Number of bytes in the Inform-specific block right after the header. */
623 #define GPAGESIZE 256
624 /* All Glulx memory boundaries must be multiples of GPAGESIZE. */
626 /* ------------------------------------------------------------------------- */
627 /* Structure definitions (there are a few others local to files) */
628 /* ------------------------------------------------------------------------- */
630 /* A memory list is a sequential array of items. The list grows as
631 necessary, but it is *not* sparse.
632 This can optionally maintain an external pointer (of any type) which
633 also refers to the allocated array. The external pointer will always
634 have the same value as data.
635 (Note: the external pointer must itself have a stable location, because
636 we keep a pointer *to* it. It cannot live in another memory list or
637 realloced array. Most of our memory lists refer to global or static
638 variables, so that's fine.)
640 typedef struct memory_list_s
642 char *whatfor; /* must be a static string */
643 void *data; /* allocated array of count*itemsize bytes */
644 void **extpointer; /* pointer to keep in sync */
645 size_t itemsize; /* item size in bytes */
646 size_t count; /* number of items allocated */
649 typedef struct brief_location_s
652 int32 orig_file_index;
653 int32 orig_line_number;
656 typedef struct assembly_operand_t
657 { int type; /* ?_OT value */
659 int symindex; /* index in symbols array, if derived from a symbol */
660 int marker; /* ?_MV value */
663 #define INITAOTV(aop, typ, val) ((aop)->type=(typ), (aop)->value=(val), (aop)->marker=0, (aop)->symindex=-1)
664 #define INITAOT(aop, typ) INITAOTV(aop, typ, 0)
665 #define INITAO(aop) INITAOTV(aop, 0, 0)
667 typedef struct variableinfo_s {
668 int32 token; /* Symbol table index for variable name */
669 int usage; /* TRUE if referred to */
672 typedef struct verbt {
674 int *l; /* alloced array of grammar line indexes
675 (positions in grammar_lines[]) */
676 int size; /* allocated size of l */
677 brief_location line; /* originally defined at */
678 int used; /* only set at locate_dead_grammar_lines() time */
681 typedef struct actioninfo_s {
682 int32 symbol; /* The symbol table index of the action name */
683 int32 byte_offset; /* The (byte) offset in the Z-machine code area of
684 the ...Sub routine */
687 /* Information about an object class. */
688 typedef struct classinfo_s {
689 /* The number of the prototype-object for this class */
691 /* The offset of properties block for this class (always an offset inside the properties table) */
693 /* Class name symbol number */
697 /* Common property information. */
698 typedef struct commonpropinfo_s {
699 int32 default_value; /* Common property default value */
700 int is_long; /* "Long" means "never write a 1-byte value to
701 this property", and is an obsolete feature:
702 since Inform 5 all properties have been "long" */
703 int is_additive; /* "Additive" means that values accumulate rather
704 than erase each other during class inheritance */
707 /* Property entry record (Z). */
708 typedef struct prop {
710 assembly_operand ao[32];
713 /* Properties and attributes of the object currently being constructed (Z). */
714 /* Only one of this object. */
715 typedef struct fpropt {
719 int32 symbol; /* name symbol or 0 */
722 /* Constructed object (Z). */
723 typedef struct objecttz {
725 int parent, next, child;
727 int32 symbol; /* name symbol or 0 */
730 /* Property entry record (G). */
731 typedef struct propg {
739 /* Properties and attributes of the object currently being constructed (G). */
740 /* Only one of this object. */
741 typedef struct fproptg {
742 uchar atts[MAX_NUM_ATTR_BYTES];
744 propg *props; /* allocated to numprops */
745 memory_list props_memlist;
747 assembly_operand *propdata; /* allocated to propdatasize */
748 memory_list propdata_memlist;
750 /* It's safe to use memory_lists in this object because there's just
751 one and it's static. */
752 int32 symbol; /* name symbol or 0 */
755 /* Constructed object (G). */
756 typedef struct objecttg {
757 /* attributes are stored in a separate array */
759 int32 parent, next, child;
762 int32 symbol; /* name symbol or 0 */
765 typedef struct abbreviation_s {
769 int textpos; /* in abbreviations_text */
773 typedef struct maybe_file_position_S
776 } maybe_file_position;
778 typedef struct debug_location_s
780 int32 beginning_byte_index;
781 int32 end_byte_index;
782 int32 beginning_line_number;
783 int32 end_line_number;
784 int32 beginning_character_number;
785 int32 end_character_number;
786 int32 orig_file_index;
787 int32 orig_beg_line_number;
788 int32 orig_beg_char_number;
789 /* We only track the beginning #origsource location, not the end. */
792 typedef struct debug_locations_s
793 { debug_location location;
794 struct debug_locations_s *next;
798 typedef struct debug_location_beginning_s
799 { debug_locations *head;
800 int32 beginning_byte_index;
801 int32 beginning_line_number;
802 int32 beginning_character_number;
803 int32 orig_file_index;
804 int32 orig_beg_line_number;
805 int32 orig_beg_char_number;
806 } debug_location_beginning;
808 #define MAX_KEYWORD_GROUP_SIZE (159)
810 typedef struct keyword_group_s
811 { char *keywords[MAX_KEYWORD_GROUP_SIZE+1]; /* empty-string-terminated */
812 int change_token_type;
817 typedef struct lexeme_data_s {
818 char *text; /* points at lextexts array */
820 int type; /* a *_TT value */
821 int newsymbol; /* (for SYMBOL_TT) this token created the symbol */
822 debug_location location;
823 int lextext; /* index of text string in lextexts */
824 int context; /* lexical context used to interpret this token */
827 typedef struct token_data_s {
830 int type; /* a *_TT value */
837 typedef struct symbolinfo_s {
838 char *name; /* Points into a symbol_name_space_chunk */
840 int marker; /* ?_MV value */
842 unsigned int flags; /* ?_SFLAGS bitmask */
843 uchar type; /* ?_T value */
844 int next_entry; /* Linked list for symbol hash table */
847 typedef struct symboldebuginfo_s {
848 maybe_file_position backpatch_pos;
849 maybe_file_position replacement_backpatch_pos;
852 typedef struct arrayinfo_s {
853 int32 symbol; /* index in symbols[] */
854 int size; /* length of array */
855 int type; /* BYTE_ARRAY, WORD_ARRAY, etc */
856 int loc; /* true for static, false for dynamic (regular) arrays */
859 typedef struct labelinfo_s {
860 int32 offset; /* Offset (zmachine_pc) value */
861 int32 symbol; /* Symbol numbers if defined in source */
862 int next; /* For linked list */
863 int prev; /* For linked list */
866 typedef struct sequencepointinfo_s {
867 int label; /* Label number */
868 debug_location location; /* Source code reference (used for making
872 typedef struct FileId_s /* Source code file identifier: */
873 { char *filename; /* The filename (after translation) */
874 FILE *handle; /* Handle of file (when open), or
876 int is_input; /* Is this a source file that we are
877 parsing? If not, this is an
878 origsource filename (and handle
880 int initial_buffering; /* Are we still in the initial
881 begin_buffering_file() call? */
884 typedef struct ErrorPosition_s
895 /* This serves for both Z-code and Glulx instructions. Glulx doesn't use
896 the text, store_variable_number, branch_label_number, or branch_flag
898 typedef struct assembly_instruction_t
899 { int internal_number;
900 int store_variable_number;
901 int32 branch_label_number;
903 char *text; /* if set, generally points to token_text */
905 assembly_operand operand[8];
906 } assembly_instruction;
908 typedef struct expression_tree_node_s
910 /* Data used in tree construction */
913 int operator_number; /* Only meaningful for non-leaves */
914 assembly_operand value; /* Only meaningful for leaves */
916 /* Attributes synthesised during code generation */
918 int must_produce_value; /* e.g. FALSE in a void context */
920 int label_after; /* -1, or "put this label after code" */
921 int to_expression; /* TRUE if a condition used as numeric val */
922 int true_label; /* On condition "true", jump to this (or keep
924 int false_label; /* Likewise if the condition is "false". */
926 } expression_tree_node;
928 typedef struct operator_s
929 { int precedence; /* Level 0 to 13 (13 is highest) */
930 int token_type; /* Lexical token type */
931 int token_value; /* Lexical token value */
932 int usage; /* Infix (IN_U), prefix or postfix */
933 int associativity; /* Left (L_A), right (R_A)
934 or 0 for "it is an error to
935 implicitly associate this" */
936 int requires_lvalue; /* TRUE if the first operand must
937 be an "lvalue" (the name of some
938 storage object, such as a variable
939 or an array entry) */
940 int opcode_number_z; /* Translation number (see below) */
941 int opcode_number_g; /* Translation number (see below) */
942 int side_effect; /* TRUE if evaluating the operator
943 has potential side-effects in
944 terms of changing the Z-machine */
945 int negation; /* 0 for an unconditional operator,
946 otherwise the negation operator */
947 char *description; /* Text describing the operator
948 for error messages and tracing */
951 /* The translation number of an operator is as follows:
954 an internal opcode number if the operator can be translated
955 directly to a single Z-machine opcode;
956 400+n if it can be translated to branch opcode n;
957 800+n if to the negated form of branch opcode n;
958 (using n = 200, 201 for two conditions requiring special
962 an internal opcode number if the operator can be translated
963 directly to a single Glulx opcode;
964 FIRST_CC to LAST_CC if it is a condition;
967 /* ------------------------------------------------------------------------- */
968 /* Assembly operand types. */
969 /* ------------------------------------------------------------------------- */
971 /* For Z-machine... */
973 #define LONG_CONSTANT_OT 0 /* General constant */
974 #define SHORT_CONSTANT_OT 1 /* Constant in range 0 to 255 */
975 #define VARIABLE_OT 2 /* Variable (global, local or sp) */
976 #define OMITTED_OT 3 /* Value used in type field to indicate
977 that no operand is supplied */
978 #define EXPRESSION_OT 4 /* Meaning: to determine this value, run code
979 equivalent to the expression tree whose
980 root node-number is the value given */
984 /* #define OMITTED_OT 3 */ /* Same as above */
985 /* #define EXPRESSION_OT 4 */ /* Same as above */
986 #define CONSTANT_OT 5 /* Four-byte constant */
987 #define HALFCONSTANT_OT 6 /* Two-byte constant */
988 #define BYTECONSTANT_OT 7 /* One-byte constant */
989 #define ZEROCONSTANT_OT 8 /* Constant zero (no bytes of data) */
990 #define SYSFUN_OT 9 /* System function value */
991 #define DEREFERENCE_OT 10 /* Value at this address */
992 #define GLOBALVAR_OT 11 /* Global variable */
993 #define LOCALVAR_OT 12 /* Local variable or sp */
995 /* ------------------------------------------------------------------------- */
996 /* Internal numbers representing assemble-able Z-opcodes */
997 /* (Must match opcodes_table_z[] and opcode_list_z[]) */
998 /* ------------------------------------------------------------------------- */
1003 #define dec_chk_zc 3
1004 #define inc_chk_zc 4
1009 #define test_attr_zc 9
1010 #define set_attr_zc 10
1011 #define clear_attr_zc 11
1013 #define insert_obj_zc 13
1016 #define get_prop_zc 16
1017 #define get_prop_addr_zc 17
1018 #define get_next_prop_zc 18
1025 #define storew_zc 25
1026 #define storeb_zc 26
1027 #define put_prop_zc 27
1029 #define print_char_zc 29
1030 #define print_num_zc 30
1031 #define random_zc 31
1034 #define split_window_zc 34
1035 #define set_window_zc 35
1036 #define output_stream_zc 36
1037 #define input_stream_zc 37
1038 #define sound_effect_zc 38
1040 #define get_sibling_zc 40
1041 #define get_child_zc 41
1042 #define get_parent_zc 42
1043 #define get_prop_len_zc 43
1046 #define print_addr_zc 46
1047 #define remove_obj_zc 47
1048 #define print_obj_zc 48
1051 #define print_paddr_zc 51
1055 #define rfalse_zc 55
1057 #define print_ret_zc 57
1060 #define restore_zc 60
1061 #define restart_zc 61
1062 #define ret_popped_zc 62
1065 #define new_line_zc 65
1066 #define show_status_zc 66
1067 #define verify_zc 67
1068 #define call_2s_zc 68
1069 #define call_vs_zc 69
1071 #define call_vs2_zc 71
1072 #define erase_window_zc 72
1073 #define erase_line_zc 73
1074 #define set_cursor_zc 74
1075 #define get_cursor_zc 75
1076 #define set_text_style_zc 76
1077 #define buffer_mode_zc 77
1078 #define read_char_zc 78
1079 #define scan_table_zc 79
1080 #define call_1s_zc 80
1081 #define call_2n_zc 81
1082 #define set_colour_zc 82
1084 #define call_vn_zc 84
1085 #define call_vn2_zc 85
1086 #define tokenise_zc 86
1087 #define encode_text_zc 87
1088 #define copy_table_zc 88
1089 #define print_table_zc 89
1090 #define check_arg_count_zc 90
1091 #define call_1n_zc 91
1093 #define piracy_zc 93
1094 #define log_shift_zc 94
1095 #define art_shift_zc 95
1096 #define set_font_zc 96
1097 #define save_undo_zc 97
1098 #define restore_undo_zc 98
1099 #define draw_picture_zc 99
1100 #define picture_data_zc 100
1101 #define erase_picture_zc 101
1102 #define set_margins_zc 102
1103 #define move_window_zc 103
1104 #define window_size_zc 104
1105 #define window_style_zc 105
1106 #define get_wind_prop_zc 106
1107 #define scroll_window_zc 107
1108 #define pop_stack_zc 108
1109 #define read_mouse_zc 109
1110 #define mouse_window_zc 110
1111 #define push_stack_zc 111
1112 #define put_wind_prop_zc 112
1113 #define print_form_zc 113
1114 #define make_menu_zc 114
1115 #define picture_table_zc 115
1116 #define print_unicode_zc 116
1117 #define check_unicode_zc 117
1118 #define set_true_colour_zc 118
1119 #define buffer_screen_zc 119
1122 /* ------------------------------------------------------------------------- */
1123 /* Internal numbers representing assemble-able Glulx opcodes */
1124 /* (Must match opcodes_table_g[] and opcode_list_g[]) */
1126 /* This is not a complete list. It only needs to include opcodes that are */
1127 /* directly created by the compiler or listed in the operator tables. */
1128 /* ------------------------------------------------------------------------- */
1140 #define bitnot_gc 10
1141 #define shiftl_gc 11
1142 #define sshiftr_gc 12
1143 #define ushiftr_gc 13
1158 #define return_gc 28
1161 #define tailcall_gc 31
1168 #define aloads_gc 38
1169 #define aloadb_gc 39
1170 #define aloadbit_gc 40
1171 #define astore_gc 41
1172 #define astores_gc 42
1173 #define astoreb_gc 43
1174 #define astorebit_gc 44
1175 #define stkcount_gc 45
1176 #define stkpeek_gc 46
1177 #define stkswap_gc 47
1178 #define stkroll_gc 48
1179 #define stkcopy_gc 49
1180 #define streamchar_gc 50
1181 #define streamnum_gc 51
1182 #define streamstr_gc 52
1183 #define gestalt_gc 53
1184 #define debugtrap_gc 54
1185 #define getmemsize_gc 55
1186 #define setmemsize_gc 56
1187 #define jumpabs_gc 57
1188 #define random_gc 58
1189 #define setrandom_gc 59
1191 #define verify_gc 61
1192 #define restart_gc 62
1194 #define restore_gc 64
1195 #define saveundo_gc 65
1196 #define restoreundo_gc 66
1197 #define protect_gc 67
1199 #define getstringtbl_gc 69
1200 #define setstringtbl_gc 70
1201 #define getiosys_gc 71
1202 #define setiosys_gc 72
1203 #define linearsearch_gc 73
1204 #define binarysearch_gc 74
1205 #define linkedsearch_gc 75
1207 #define callfi_gc 77
1208 #define callfii_gc 78
1209 #define callfiii_gc 79
1210 #define streamunichar_gc 80
1213 #define malloc_gc 83
1215 #define accelfunc_gc 85
1216 #define accelparam_gc 86
1218 /* ------------------------------------------------------------------------- */
1219 /* Index numbers into the keyword group "opcode_macros_g" (see "lexer.c") */
1220 /* ------------------------------------------------------------------------- */
1228 #define SYMBOL_TT 0 /* symbol.
1229 value = index in symbol table */
1230 #define NUMBER_TT 1 /* number (including hex, float,
1232 value = the number */
1233 #define DQ_TT 2 /* double-quoted string.
1234 no value; look at the text */
1235 #define SQ_TT 3 /* single-quoted string.
1237 #define UQ_TT 4 /* unquoted string; only when
1238 dont_enter_into_symbol_table
1241 #define SEP_TT 5 /* separator (punctuation).
1242 value = the _SEP code */
1243 #define EOF_TT 6 /* end of file.
1246 #define STATEMENT_TT 100 /* a statement keyword */
1247 #define SEGMENT_MARKER_TT 101 /* with/has/class etc. */
1248 #define DIRECTIVE_TT 102 /* a directive keyword */
1249 #define CND_TT 103 /* in/has/etc. */
1250 #define SYSFUN_TT 105 /* built-in function */
1251 #define LOCAL_VARIABLE_TT 106 /* local variable */
1252 #define OPCODE_NAME_TT 107 /* opcode name */
1253 #define MISC_KEYWORD_TT 108 /* keyword like "char" used in
1254 syntax for a statement */
1255 #define DIR_KEYWORD_TT 109 /* keyword like "meta" used in
1256 syntax for a directive */
1257 #define TRACE_KEYWORD_TT 110 /* keyword used in debugging */
1258 #define SYSTEM_CONSTANT_TT 111 /* such as "code_offset" */
1259 #define OPCODE_MACRO_TT 112 /* fake opcode for compatibility */
1261 #define OP_TT 200 /* value = operator no */
1262 #define ENDEXP_TT 201 /* no value */
1263 #define SUBOPEN_TT 202 /* ( used for subexpr */
1264 #define SUBCLOSE_TT 203 /* ) used to close subexp */
1265 #define LARGE_NUMBER_TT 204 /* constant not in range 0-255 */
1266 #define SMALL_NUMBER_TT 205 /* constant in range 0-255 */
1267 /* In Glulx, that's the range -0x8000 to 0x7fff instead. */
1268 #define VARIABLE_TT 206 /* variable name */
1269 #define DICTWORD_TT 207 /* literal 'word' */
1270 #define ACTION_TT 208 /* action name */
1272 #define VOID_CONTEXT 1
1273 #define CONDITION_CONTEXT 2
1274 #define CONSTANT_CONTEXT 3
1275 #define QUANTITY_CONTEXT 4
1276 #define ACTION_Q_CONTEXT 5
1277 #define ASSEMBLY_CONTEXT 6
1278 #define ARRAY_CONTEXT 7
1279 #define FORINIT_CONTEXT 8
1280 #define RETURN_Q_CONTEXT 9
1282 #define LOWEST_SYSTEM_VAR_NUMBER 249 /* globals 249 to 255 are used
1283 in compiled code (Z-code
1284 only; in Glulx, the range can
1287 /* ------------------------------------------------------------------------- */
1288 /* Symbol flag definitions (in no significant order) */
1289 /* ------------------------------------------------------------------------- */
1291 #define UNKNOWN_SFLAG 1 /* no definition known */
1292 #define REPLACE_SFLAG 2 /* routine marked for Replace */
1293 #define USED_SFLAG 4 /* referred to in code */
1294 #define DEFCON_SFLAG 8 /* defined by Default */
1295 #define STUB_SFLAG 16 /* defined by Stub */
1296 #define UNHASHED_SFLAG 32 /* removed from hash chain */
1297 #define DISCARDED_SFLAG 64 /* removed and should never have been used */
1298 #define ALIASED_SFLAG 128 /* defined as property/attribute alias name */
1300 #define CHANGE_SFLAG 256 /* defined by Default with a value,
1301 or symbol has a backpatchable value */
1302 #define SYSTEM_SFLAG 512 /* created by compiler */
1303 #define INSF_SFLAG 1024 /* created in System_File */
1304 #define UERROR_SFLAG 2048 /* "No such constant" error issued */
1305 #define ACTION_SFLAG 4096 /* action name constant (Foo_A) */
1306 #define REDEFINABLE_SFLAG 8192 /* built-in symbol that can be redefined
1308 #define STAR_SFLAG 16384 /* function defined with "*" or property named
1311 /* ------------------------------------------------------------------------- */
1312 /* Symbol type definitions */
1313 /* ------------------------------------------------------------------------- */
1317 #define GLOBAL_VARIABLE_T 3
1319 #define CONSTANT_T 5
1320 #define ATTRIBUTE_T 6
1321 #define PROPERTY_T 7
1322 #define INDIVIDUAL_PROPERTY_T 8
1325 #define FAKE_ACTION_T 11
1326 #define STATIC_ARRAY_T 12
1328 /* These types never occur in the symbol table; they exist only as
1329 type-checking requirements. */
1330 #define STRING_REQ_T 13
1331 #define DICT_WORD_REQ_T 14
1333 /* ------------------------------------------------------------------------- */
1334 /* Statusline_flag values */
1335 /* ------------------------------------------------------------------------- */
1337 #define SCORE_STYLE 0
1338 #define TIME_STYLE 1
1340 /* ------------------------------------------------------------------------- */
1341 /* Inform keyword definitions */
1342 /* ------------------------------------------------------------------------- */
1344 /* Index numbers into the keyword group "directives" (see "lexer.c") */
1346 #define ABBREVIATE_CODE 0
1347 #define ARRAY_CODE 1
1348 #define ATTRIBUTE_CODE 2
1349 #define CLASS_CODE 3
1350 #define CONSTANT_CODE 4
1351 #define DEFAULT_CODE 5
1352 #define DICTIONARY_CODE 6
1354 #define ENDIF_CODE 8
1355 #define EXTEND_CODE 9
1356 #define FAKE_ACTION_CODE 10
1357 #define GLOBAL_CODE 11
1358 #define IFDEF_CODE 12
1359 #define IFNDEF_CODE 13
1360 #define IFNOT_CODE 14
1361 #define IFV3_CODE 15
1362 #define IFV5_CODE 16
1363 #define IFTRUE_CODE 17
1364 #define IFFALSE_CODE 18
1365 #define IMPORT_CODE 19
1366 #define INCLUDE_CODE 20
1367 #define LINK_CODE 21
1368 #define LOWSTRING_CODE 22
1369 #define MESSAGE_CODE 23
1370 #define NEARBY_CODE 24
1371 #define OBJECT_CODE 25
1372 #define ORIGSOURCE_CODE 26
1373 #define PROPERTY_CODE 27
1374 #define RELEASE_CODE 28
1375 #define REPLACE_CODE 29
1376 #define SERIAL_CODE 30
1377 #define SWITCHES_CODE 31
1378 #define STATUSLINE_CODE 32
1379 #define STUB_CODE 33
1380 #define SYSTEM_CODE 34
1381 #define TRACE_CODE 35
1382 #define UNDEF_CODE 36
1383 #define VERB_CODE 37
1384 #define VERSION_CODE 38
1385 #define ZCHARACTER_CODE 39
1387 #define OPENBLOCK_CODE 100
1388 #define CLOSEBLOCK_CODE 101
1390 /* Index numbers into the keyword group "statements" (see "lexer.c") */
1393 #define BREAK_CODE 1
1394 #define CONTINUE_CODE 2
1395 #define SDEFAULT_CODE 3
1402 #define INVERSION_CODE 10
1403 #define JUMP_CODE 11
1404 #define MOVE_CODE 12
1405 #define NEW_LINE_CODE 13
1406 #define OBJECTLOOP_CODE 14
1407 #define PRINT_CODE 15
1408 #define PRINT_RET_CODE 16
1409 #define QUIT_CODE 17
1410 #define READ_CODE 18
1411 #define REMOVE_CODE 19
1412 #define RESTORE_CODE 20
1413 #define RETURN_CODE 21
1414 #define RFALSE_CODE 22
1415 #define RTRUE_CODE 23
1416 #define SAVE_CODE 24
1417 #define SPACES_CODE 25
1418 #define STRING_CODE 26
1419 #define STYLE_CODE 27
1420 #define SWITCH_CODE 28
1421 #define UNTIL_CODE 29
1422 #define WHILE_CODE 30
1424 #define ASSIGNMENT_CODE 100
1425 #define FUNCTION_CODE 101
1427 /* Index numbers into the keyword group "conditions" (see "lexer.c") */
1430 #define HASNT_COND 1
1432 #define NOTIN_COND 3
1433 #define OFCLASS_COND 4
1435 #define PROVIDES_COND 6
1437 /* Index numbers into the keyword group "segment_markers" (see "lexer.c") */
1439 #define CLASS_SEGMENT 0
1440 #define HAS_SEGMENT 1
1441 #define PRIVATE_SEGMENT 2
1442 #define WITH_SEGMENT 3
1444 /* Index numbers into the keyword group "misc_keywords" (see "lexer.c") */
1451 #define CAP_THE_MK 5
1454 #define REVERSE_MK 8
1456 #define UNDERLINE_MK 10
1461 #define ADDRESS_MK 15
1462 #define STRING_MK 16
1463 #define OBJECT_MK 17
1466 #define PROPERTY_MK 20
1469 /* Index numbers into the keyword group "directive_keywords" (see "lexer.c") */
1473 #define ADDITIVE_DK 2
1479 #define MULTIHELD_DK 8
1480 #define MULTIEXCEPT_DK 9
1481 #define MULTIINSIDE_DK 10
1482 #define CREATURE_DK 11
1483 #define SPECIAL_DK 12
1484 #define NUMBER_DK 13
1487 #define REVERSE_DK 16
1490 #define REPLACE_DK 19
1493 #define STRING_DK 22
1495 #define BUFFER_DK 24
1497 #define INITIAL_DK 26
1498 #define INITSTR_DK 27
1500 #define PRIVATE_DK 29
1504 #define FATALERROR_DK 33
1505 #define WARNING_DK 34
1506 #define TERMINATING_DK 35
1507 #define STATIC_DK 36
1508 #define INDIVIDUAL_DK 37
1510 /* Index numbers into the keyword group "trace_keywords" (see "lexer.c") */
1512 #define DICTIONARY_TK 0
1513 #define SYMBOLS_TK 1
1514 #define OBJECTS_TK 2
1516 #define ASSEMBLY_TK 4
1517 #define EXPRESSIONS_TK 5
1524 /* Index numbers into the keyword group "system_constants" (see "lexer.c") */
1526 #define NO_SYSTEM_CONSTANTS 62
1528 #define adjectives_table_SC 0
1529 #define actions_table_SC 1
1530 #define classes_table_SC 2
1531 #define identifiers_table_SC 3
1532 #define preactions_table_SC 4
1533 #define version_number_SC 5
1534 #define largest_object_SC 6
1535 #define strings_offset_SC 7
1536 #define code_offset_SC 8
1537 #define dict_par1_SC 9
1538 #define dict_par2_SC 10
1539 #define dict_par3_SC 11
1540 #define actual_largest_object_SC 12
1541 #define static_memory_offset_SC 13
1542 #define array_names_offset_SC 14
1543 #define readable_memory_offset_SC 15
1544 #define cpv__start_SC 16
1545 #define cpv__end_SC 17
1546 #define ipv__start_SC 18
1547 #define ipv__end_SC 19
1548 #define array__start_SC 20
1549 #define array__end_SC 21
1551 #define lowest_attribute_number_SC 22
1552 #define highest_attribute_number_SC 23
1553 #define attribute_names_array_SC 24
1555 #define lowest_property_number_SC 25
1556 #define highest_property_number_SC 26
1557 #define property_names_array_SC 27
1559 #define lowest_action_number_SC 28
1560 #define highest_action_number_SC 29
1561 #define action_names_array_SC 30
1563 #define lowest_fake_action_number_SC 31
1564 #define highest_fake_action_number_SC 32
1565 #define fake_action_names_array_SC 33
1567 #define lowest_routine_number_SC 34
1568 #define highest_routine_number_SC 35
1569 #define routines_array_SC 36
1570 #define routine_names_array_SC 37
1571 #define routine_flags_array_SC 38
1573 #define lowest_global_number_SC 39
1574 #define highest_global_number_SC 40
1575 #define globals_array_SC 41
1576 #define global_names_array_SC 42
1577 #define global_flags_array_SC 43
1579 #define lowest_array_number_SC 44
1580 #define highest_array_number_SC 45
1581 #define arrays_array_SC 46
1582 #define array_names_array_SC 47
1583 #define array_flags_array_SC 48
1585 #define lowest_constant_number_SC 49
1586 #define highest_constant_number_SC 50
1587 #define constants_array_SC 51
1588 #define constant_names_array_SC 52
1590 #define lowest_class_number_SC 53
1591 #define highest_class_number_SC 54
1592 #define class_objects_array_SC 55
1594 #define lowest_object_number_SC 56
1595 #define highest_object_number_SC 57
1597 #define oddeven_packing_SC 58
1599 #define grammar_table_SC 59
1600 #define dictionary_table_SC 60
1601 #define dynam_string_table_SC 61 /* Glulx-only */
1604 /* Index numbers into the keyword group "system_functions" (see "lexer.c") */
1606 #define NUMBER_SYSTEM_FUNCTIONS 12
1608 #define CHILD_SYSF 0
1609 #define CHILDREN_SYSF 1
1610 #define ELDER_SYSF 2
1611 #define ELDEST_SYSF 3
1612 #define INDIRECT_SYSF 4
1613 #define PARENT_SYSF 5
1614 #define RANDOM_SYSF 6
1615 #define SIBLING_SYSF 7
1616 #define YOUNGER_SYSF 8
1617 #define YOUNGEST_SYSF 9
1618 #define METACLASS_SYSF 10
1619 #define GLK_SYSF 11 /* Glulx-only */
1621 /* Index numbers into the operators group "separators" (see "lexer.c") */
1623 #define NUMBER_SEPARATORS 49
1626 #define DARROW_SEP 1
1632 #define DIVIDE_SEP 7
1633 #define REMAINDER_SEP 8
1635 #define ARTOR_SEP 10
1636 #define LOGAND_SEP 11
1637 #define ARTAND_SEP 12
1638 #define LOGNOT_SEP 13
1639 #define NOTEQUAL_SEP 14
1640 #define ARTNOT_SEP 15
1641 #define CONDEQUALS_SEP 16
1642 #define SETEQUALS_SEP 17
1644 #define GREATER_SEP 19
1647 #define OPENB_SEP 22
1648 #define CLOSEB_SEP 23
1649 #define COMMA_SEP 24
1650 #define PROPADD_SEP 25
1651 #define PROPNUM_SEP 26
1652 #define MPROPADD_SEP 27
1653 #define MPROPNUM_SEP 28
1654 #define MESSAGE_SEP 29
1655 #define PROPERTY_SEP 30
1656 #define SUPERCLASS_SEP 31
1657 #define COLON_SEP 32
1659 #define SEMICOLON_SEP 34
1660 #define OPEN_SQUARE_SEP 35
1661 #define CLOSE_SQUARE_SEP 36
1662 #define OPEN_BRACE_SEP 37
1663 #define CLOSE_BRACE_SEP 38
1664 #define DOLLAR_SEP 39
1665 #define NBRANCH_SEP 40
1666 #define BRANCH_SEP 41
1667 #define HASHADOLLAR_SEP 42
1668 #define HASHGDOLLAR_SEP 43
1669 #define HASHNDOLLAR_SEP 44
1670 #define HASHRDOLLAR_SEP 45
1671 #define HASHWDOLLAR_SEP 46
1672 #define HASHHASH_SEP 47
1675 #define UNARY_MINUS_SEP 100
1676 #define POST_INC_SEP 101
1677 #define POST_DEC_SEP 102
1679 /* ------------------------------------------------------------------------- */
1680 /* Internal numbers used to refer to operators (in expressions) */
1681 /* (must correspond to entries in the operators table in "express.c") */
1682 /* ------------------------------------------------------------------------- */
1684 #define NUM_OPERATORS 68
1694 #define SETEQUALS_OP 1
1700 #define NONZERO_OP 6
1701 #define CONDEQUALS_OP 7
1702 #define NOTEQUAL_OP 8
1704 #define GREATER_OP 10
1711 #define OFCLASS_OP 17
1712 #define PROVIDES_OP 18
1713 #define NOTOFCLASS_OP 19
1714 #define NOTPROVIDES_OP 20
1720 #define DIVIDE_OP 25
1721 #define REMAINDER_OP 26
1722 #define ARTAND_OP 27
1724 #define ARTNOT_OP 29
1726 #define DARROW_OP 31
1727 #define UNARY_MINUS_OP 32
1729 #define POST_INC_OP 34
1731 #define POST_DEC_OP 36
1732 #define PROP_ADD_OP 37
1733 #define PROP_NUM_OP 38
1734 #define MPROP_ADD_OP 39
1735 #define MPROP_NUM_OP 40
1737 #define MESSAGE_OP 42
1738 #define PROPERTY_OP 43
1739 #define SUPERCLASS_OP 44
1741 #define ARROW_SETEQUALS_OP 45
1742 #define DARROW_SETEQUALS_OP 46
1743 #define MESSAGE_SETEQUALS_OP 47
1744 #define PROPERTY_SETEQUALS_OP 48
1746 #define ARROW_INC_OP 49
1747 #define DARROW_INC_OP 50
1748 #define MESSAGE_INC_OP 51
1749 #define PROPERTY_INC_OP 52
1751 #define ARROW_DEC_OP 53
1752 #define DARROW_DEC_OP 54
1753 #define MESSAGE_DEC_OP 55
1754 #define PROPERTY_DEC_OP 56
1756 #define ARROW_POST_INC_OP 57
1757 #define DARROW_POST_INC_OP 58
1758 #define MESSAGE_POST_INC_OP 59
1759 #define PROPERTY_POST_INC_OP 60
1761 #define ARROW_POST_DEC_OP 61
1762 #define DARROW_POST_DEC_OP 62
1763 #define MESSAGE_POST_DEC_OP 63
1764 #define PROPERTY_POST_DEC_OP 64
1766 #define PROP_CALL_OP 65
1767 #define MESSAGE_CALL_OP 66
1769 #define PUSH_OP 67 /* Glulx only */
1771 /* ------------------------------------------------------------------------- */
1772 /* The five types of compiled array */
1773 /* ------------------------------------------------------------------------- */
1775 #define BYTE_ARRAY 0
1776 #define WORD_ARRAY 1
1777 #define STRING_ARRAY 2
1778 #define TABLE_ARRAY 3
1779 #define BUFFER_ARRAY 4
1781 /* ------------------------------------------------------------------------- */
1782 /* Internal numbers used to refer to veneer routines */
1783 /* (must correspond to entries in the table in "veneer.c") */
1784 /* ------------------------------------------------------------------------- */
1786 #define VENEER_ROUTINES 48
1788 #define Box__Routine_VR 0
1790 #define R_Process_VR 1
1792 #define InDefArt_VR 3
1793 #define CDefArt_VR 4
1794 #define CInDefArt_VR 5
1795 #define PrintShortName_VR 6
1796 #define EnglishNumber_VR 7
1797 #define Print__Pname_VR 8
1800 #define RV__Pr_VR 10
1801 #define CA__Pr_VR 11
1802 #define IB__Pr_VR 12
1803 #define IA__Pr_VR 13
1804 #define DB__Pr_VR 14
1805 #define DA__Pr_VR 15
1806 #define RA__Pr_VR 16
1807 #define RL__Pr_VR 17
1808 #define RA__Sc_VR 18
1809 #define OP__Pr_VR 19
1810 #define OC__Cl_VR 20
1812 #define Copy__Primitive_VR 21
1813 #define RT__Err_VR 22
1814 #define Z__Region_VR 23
1815 #define Unsigned__Compare_VR 24
1816 #define Metaclass_VR 25
1817 #define CP__Tab_VR 26
1818 #define Cl__Ms_VR 27
1819 #define RT__ChT_VR 28
1820 #define RT__ChR_VR 29
1821 #define RT__ChG_VR 30
1822 #define RT__ChGt_VR 31
1823 #define RT__ChPS_VR 32
1824 #define RT__ChPR_VR 33
1825 #define RT__TrPS_VR 34
1826 #define RT__ChLDB_VR 35
1827 #define RT__ChLDW_VR 36
1828 #define RT__ChSTB_VR 37
1829 #define RT__ChSTW_VR 38
1830 #define RT__ChPrintC_VR 39
1831 #define RT__ChPrintA_VR 40
1832 #define RT__ChPrintS_VR 41
1833 #define RT__ChPrintO_VR 42
1835 /* Glulx-only veneer routines */
1836 #define OB__Move_VR 43
1837 #define OB__Remove_VR 44
1838 #define Print__Addr_VR 45
1839 #define Glk__Wrap_VR 46
1840 #define Dynam__String_VR 47
1842 /* ------------------------------------------------------------------------- */
1843 /* Run-time-error numbers (must correspond with RT__Err code in veneer) */
1844 /* ------------------------------------------------------------------------- */
1848 #define PARENT_RTE 4
1849 #define ELDEST_RTE 5
1851 #define YOUNGER_RTE 7
1852 #define SIBLING_RTE 8
1853 #define CHILDREN_RTE 9
1854 #define YOUNGEST_RTE 10
1855 #define ELDER_RTE 11
1856 #define OBJECTLOOP_RTE 12
1857 #define OBJECTLOOP2_RTE 13
1859 #define REMOVE_RTE 15
1860 #define MOVE1_RTE 16
1861 #define MOVE2_RTE 17
1862 /* 18 = creating a loop in object tree */
1863 /* 19 = giving a non-existent attribute */
1864 #define DBYZERO_RTE 20
1865 #define PROP_ADD_RTE 21
1866 #define PROP_NUM_RTE 22
1867 #define PROPERTY_RTE 23
1868 /* 24 = reading with -> out of range */
1869 /* 25 = reading with --> out of range */
1870 /* 26 = writing with -> out of range */
1871 /* 27 = writing with --> out of range */
1872 #define ABOUNDS_RTE 28
1873 /* similarly 29, 30, 31 */
1874 #define OBJECTLOOP_BROKEN_RTE 32
1875 /* 33 = print (char) out of range */
1876 /* 34 = print (address) out of range */
1877 /* 35 = print (string) out of range */
1878 /* 36 = print (object) out of range */
1880 /* ------------------------------------------------------------------------- */
1881 /* Z-region areas (used to refer to module positions in markers) */
1882 /* ------------------------------------------------------------------------- */
1884 #define LOW_STRINGS_ZA 1
1885 #define PROP_DEFAULTS_ZA 2
1886 #define OBJECT_TREE_ZA 3
1888 #define CLASS_NUMBERS_ZA 5
1889 #define INDIVIDUAL_PROP_ZA 6
1890 #define DYNAMIC_ARRAY_ZA 7
1891 #define GRAMMAR_ZA 8
1892 #define ACTIONS_ZA 9
1893 #define PREACTIONS_ZA 10
1894 #define ADJECTIVES_ZA 11
1895 #define DICTIONARY_ZA 12
1897 #define STATIC_STRINGS_ZA 14
1898 #define LINK_DATA_ZA 15
1900 #define SYMBOLS_ZA 16
1901 #define STATIC_ARRAY_ZA 17 /* Z-code only */
1902 #define GLOBALVAR_ZA 18 /* Glulx only */
1904 /* ------------------------------------------------------------------------- */
1905 /* "Marker values", used for backpatching and linkage */
1906 /* ------------------------------------------------------------------------- */
1908 #define NULL_MV 0 /* Null */
1910 /* Marker values used in backpatch areas: */
1912 #define DWORD_MV 1 /* Dictionary word address */
1913 #define STRING_MV 2 /* Static string */
1914 #define INCON_MV 3 /* "Hardware" constant (table address) */
1915 #define IROUTINE_MV 4 /* Call to internal routine */
1916 #define VROUTINE_MV 5 /* Call to veneer routine */
1917 #define ARRAY_MV 6 /* Ref to internal dynam array address */
1918 #define NO_OBJS_MV 7 /* Ref to number of game objects */
1919 #define INHERIT_MV 8 /* Inherited property value */
1920 #define INHERIT_INDIV_MV 9 /* Inherited indiv property value */
1921 #define MAIN_MV 10 /* "Main" routine */
1922 #define SYMBOL_MV 11 /* Forward ref to unassigned symbol */
1924 /* Additional marker values used in module backpatch areas (most are
1926 /* (In Glulx, OBJECT_MV and VARIABLE_MV are used in backpatching, even
1927 without modules.) */
1929 #define VARIABLE_MV 12 /* Global variable */
1930 #define IDENT_MV 13 /* Property identifier number */
1931 #define INDIVPT_MV 14 /* Individual prop table address */
1932 #define ACTION_MV 15 /* Action number */
1933 #define OBJECT_MV 16 /* Ref to internal object number */
1934 #define STATIC_ARRAY_MV 17 /* Ref to internal static array address */
1936 #define ERROR_MV 18 /* An error was reported while
1937 generating this value */
1938 #define LARGEST_BPATCH_MV 18 /* Larger marker values are never written
1939 to backpatch tables */
1941 /* Values 32-35 were used only for module import/export. */
1943 /* Values used only in branch backpatching: */
1944 /* BRANCH_MV must be last; Glulx uses the whole range from BRANCH_MV
1947 #define LABEL_MV 36 /* Ditto: marks "jump" operands */
1948 #define DELETED_MV 37 /* Ditto: marks bytes deleted from code */
1949 #define BRANCH_MV 38 /* Used in "asm.c" for routine coding */
1950 #define BRANCHMAX_MV 102 /* In fact, the range BRANCH_MV to
1951 BRANCHMAX_MV all means the same thing.
1952 The position within the range means
1953 how far back from the label to go
1954 to find the opmode byte to modify. */
1956 /* ------------------------------------------------------------------------- */
1957 /* "String contexts"; the purpose for a given string. This info gets */
1958 /* written to the transcript file (gametext.txt). */
1959 /* ------------------------------------------------------------------------- */
1961 #define STRCTX_INFO 0 /* comment; not stored in game file */
1962 #define STRCTX_GAME 1 /* strings area */
1963 #define STRCTX_GAMEOPC 2 /* inline text in opcode (Z-code only) */
1964 #define STRCTX_VENEER 3 /* strings area, from veneer code */
1965 #define STRCTX_VENEEROPC 4 /* inline text, veneer code (Z-code only) */
1966 #define STRCTX_LOWSTRING 5 /* lowmem (Z-code); also dynamic-str literals */
1967 #define STRCTX_ABBREV 6 /* abbreviation */
1968 #define STRCTX_DICT 7 /* dictionary word */
1969 #define STRCTX_OBJNAME 8 /* object "hardware name" */
1970 #define STRCTX_SYMBOL 9 /* prop/attr/etc names */
1971 #define STRCTX_INFIX 10 /* text printed in asterisk traces */
1973 /* ------------------------------------------------------------------------- */
1974 /* Bit-flags applying to the execution_never_reaches_here variable. */
1975 /* Note that if any flags are set, UNREACHABLE is set, so we can easily */
1976 /* test "if (execution_never_reaches_here)..." */
1977 /* ------------------------------------------------------------------------- */
1979 #define EXECSTATE_REACHABLE 0 /* compile normally */
1980 #define EXECSTATE_UNREACHABLE 1 /* execution cannot reach this line */
1981 #define EXECSTATE_ENTIRE 2 /* execution cannot reach this entire
1982 statement or code block */
1983 #define EXECSTATE_NOWARN 4 /* do not print a warning about unreachable
1986 /* ========================================================================= */
1987 /* Initialisation extern definitions */
1989 /* Note that each subsystem in Inform provides four routines to keep */
1990 /* track of variables and data structures: */
1992 /* init_*_vars should set variables to initial values (they must */
1993 /* not be initialised directly in their declarations */
1994 /* as Inform may need to compile several times in a */
1997 /* *_begin_pass any variable/array initialisation that needs to */
1998 /* happen at the start of the pass through the source */
2000 /* *_allocate_arrays should use my_malloc/my_calloc (see memory.c) */
2001 /* to allocate any arrays or workspace needed */
2003 /* *_free_arrays should use my_free to free all memory allocated */
2004 /* (with one exception in "text.c") */
2006 /* ========================================================================= */
2008 /* > READ INFORM SOURCE */
2010 /* My Source Book */
2012 extern void init_arrays_vars(void); /* arrays: construct tableaux */
2013 extern void init_asm_vars(void); /* asm: assemble even rare or v6 codes */
2014 extern void init_bpatch_vars(void); /* bpatch: backpatches code */
2015 extern void init_chars_vars(void); /* chars: translate character sets */
2016 extern void init_directs_vars(void); /* directs: ponder directives */
2017 extern void init_errors_vars(void); /* errors: issue diagnostics */
2018 extern void init_expressc_vars(void); /* expressc: compile expressions */
2019 extern void init_expressp_vars(void); /* expressp: parse expressions */
2020 extern void init_files_vars(void); /* files: handle files */
2021 /* void init_vars(void); inform: decide what to do */
2022 extern void init_lexer_vars(void); /* lexer: lexically analyse source */
2023 extern void init_memory_vars(void); /* memory: manage memory settings */
2024 extern void init_objects_vars(void); /* objects: cultivate object tree */
2025 extern void init_states_vars(void); /* states: translate statements to code*/
2026 extern void init_symbols_vars(void); /* symbols: construct symbols table */
2027 extern void init_syntax_vars(void); /* syntax: parse the program */
2028 extern void init_tables_vars(void); /* tables: glue tables into the output */
2029 extern void init_text_vars(void); /* text: encode text and dictionary */
2030 extern void init_veneer_vars(void); /* veneer: compile a layer of code */
2031 extern void init_verbs_vars(void); /* verbs: lay out grammar */
2033 extern void files_begin_prepass(void); /* These routines initialise just */
2034 extern void lexer_begin_prepass(void); /* enough to begin loading source */
2036 extern void arrays_begin_pass(void);
2037 extern void asm_begin_pass(void);
2038 extern void bpatch_begin_pass(void);
2039 extern void chars_begin_pass(void);
2040 extern void directs_begin_pass(void);
2041 extern void errors_begin_pass(void);
2042 extern void expressc_begin_pass(void);
2043 extern void expressp_begin_pass(void);
2044 extern void files_begin_pass(void);
2045 /* void begin_pass(void); */
2046 extern void lexer_begin_pass(void);
2047 extern void memory_begin_pass(void);
2048 extern void objects_begin_pass(void);
2049 extern void states_begin_pass(void);
2050 extern void symbols_begin_pass(void);
2051 extern void syntax_begin_pass(void);
2052 extern void tables_begin_pass(void);
2053 extern void text_begin_pass(void);
2054 extern void veneer_begin_pass(void);
2055 extern void verbs_begin_pass(void);
2057 extern void lexer_endpass(void);
2059 extern void arrays_allocate_arrays(void);
2060 extern void asm_allocate_arrays(void);
2061 extern void bpatch_allocate_arrays(void);
2062 extern void chars_allocate_arrays(void);
2063 extern void directs_allocate_arrays(void);
2064 extern void errors_allocate_arrays(void);
2065 extern void expressc_allocate_arrays(void);
2066 extern void expressp_allocate_arrays(void);
2067 extern void files_allocate_arrays(void);
2068 /* void allocate_arrays(void); */
2069 extern void lexer_allocate_arrays(void);
2070 extern void memory_allocate_arrays(void);
2071 extern void objects_allocate_arrays(void);
2072 extern void states_allocate_arrays(void);
2073 extern void symbols_allocate_arrays(void);
2074 extern void syntax_allocate_arrays(void);
2075 extern void tables_allocate_arrays(void);
2076 extern void text_allocate_arrays(void);
2077 extern void veneer_allocate_arrays(void);
2078 extern void verbs_allocate_arrays(void);
2080 extern void arrays_free_arrays(void);
2081 extern void asm_free_arrays(void);
2082 extern void bpatch_free_arrays(void);
2083 extern void chars_free_arrays(void);
2084 extern void directs_free_arrays(void);
2085 extern void errors_free_arrays(void);
2086 extern void expressc_free_arrays(void);
2087 extern void expressp_free_arrays(void);
2088 extern void files_free_arrays(void);
2089 /* void free_arrays(void); */
2090 extern void lexer_free_arrays(void);
2091 extern void memory_free_arrays(void);
2092 extern void objects_free_arrays(void);
2093 extern void states_free_arrays(void);
2094 extern void symbols_free_arrays(void);
2095 extern void syntax_free_arrays(void);
2096 extern void tables_free_arrays(void);
2097 extern void text_free_arrays(void);
2098 extern void veneer_free_arrays(void);
2099 extern void verbs_free_arrays(void);
2101 /* ========================================================================= */
2102 /* Remaining extern definitions are given by file in alphabetical order */
2103 /* ------------------------------------------------------------------------- */
2104 /* Extern definitions for "arrays" */
2105 /* ------------------------------------------------------------------------- */
2107 #define MAX_ZCODE_GLOBAL_VARS (240)
2109 extern int no_globals, no_arrays;
2110 extern int dynamic_array_area_size;
2111 extern uchar *dynamic_array_area;
2112 extern memory_list dynamic_array_area_memlist;
2113 extern int static_array_area_size;
2114 extern uchar *static_array_area;
2115 extern memory_list static_array_area_memlist;
2116 extern int32 *global_initial_value;
2117 extern arrayinfo *arrays;
2119 extern void make_global(void);
2120 extern void set_variable_value(int i, int32 v);
2121 extern void make_array(void);
2122 extern void check_globals(void);
2123 extern int32 begin_table_array(void);
2124 extern int32 begin_word_array(void);
2125 extern void array_entry(int32 i, int is_static, assembly_operand VAL);
2126 extern void finish_array(int32 i, int is_static);
2128 /* ------------------------------------------------------------------------- */
2129 /* Extern definitions for "asm" */
2130 /* ------------------------------------------------------------------------- */
2132 extern uchar *zcode_area;
2133 extern memory_list zcode_area_memlist;
2134 extern int32 zmachine_pc;
2136 extern int32 no_instructions;
2137 extern int sequence_point_follows;
2138 extern int uses_unicode_features, uses_memheap_features,
2139 uses_acceleration_features, uses_float_features,
2140 uses_extundo_features, uses_double_features;
2141 extern debug_location statement_debug_location;
2142 extern int execution_never_reaches_here;
2143 extern variableinfo *variables;
2144 extern memory_list variables_memlist;
2145 extern int next_label, no_sequence_points;
2146 extern assembly_instruction AI;
2147 extern int32 *named_routine_symbols;
2149 extern void print_operand(const assembly_operand *o, int annotate);
2150 extern char *variable_name(int32 i);
2151 extern void set_constant_ot(assembly_operand *AO);
2152 extern int is_constant_ot(int otval);
2153 extern int is_variable_ot(int otval);
2154 extern void assemblez_instruction(const assembly_instruction *a);
2155 extern void assembleg_instruction(const assembly_instruction *a);
2156 extern void assemble_label_no(int n);
2157 extern int assemble_forward_label_no(int n);
2158 extern void assemble_jump(int n);
2159 extern void define_symbol_label(int symbol);
2160 extern int32 assemble_routine_header(int debug_flag,
2161 char *name, int embedded_flag, int the_symbol);
2162 extern void assemble_routine_end(int embedded_flag, debug_locations locations);
2164 extern void assemblez_0(int internal_number);
2165 extern void assemblez_0_to(int internal_number, assembly_operand o1);
2166 extern void assemblez_0_branch(int internal_number, int label, int flag);
2167 extern void assemblez_1(int internal_number, assembly_operand o1);
2168 extern void assemblez_1_to(int internal_number,
2169 assembly_operand o1, assembly_operand st);
2170 extern void assemblez_1_branch(int internal_number,
2171 assembly_operand o1, int label, int flag);
2172 extern void assemblez_objcode(int internal_number,
2173 assembly_operand o1, assembly_operand st,
2174 int label, int flag);
2175 extern void assemblez_2(int internal_number,
2176 assembly_operand o1, assembly_operand o2);
2177 extern void assemblez_2_to(int internal_number,
2178 assembly_operand o1, assembly_operand o2,
2179 assembly_operand st);
2180 extern void assemblez_2_branch(int internal_number,
2181 assembly_operand o1, assembly_operand o2,
2182 int label, int flag);
2183 extern void assemblez_3(int internal_number,
2184 assembly_operand o1, assembly_operand o2,
2185 assembly_operand o3);
2186 extern void assemblez_3_branch(int internal_number,
2187 assembly_operand o1, assembly_operand o2,
2188 assembly_operand o3, int label, int flag);
2189 extern void assemblez_3_to(int internal_number,
2190 assembly_operand o1, assembly_operand o2,
2191 assembly_operand o3, assembly_operand st);
2192 extern void assemblez_4(int internal_number,
2193 assembly_operand o1, assembly_operand o2,
2194 assembly_operand o3, assembly_operand o4);
2195 extern void assemblez_5(int internal_number,
2196 assembly_operand o1, assembly_operand o2,
2197 assembly_operand o3, assembly_operand o4,
2198 assembly_operand o5);
2199 extern void assemblez_6(int internal_number,
2200 assembly_operand o1, assembly_operand o2,
2201 assembly_operand o3, assembly_operand o4,
2202 assembly_operand o5, assembly_operand o6);
2203 extern void assemblez_4_branch(int internal_number,
2204 assembly_operand o1, assembly_operand o2,
2205 assembly_operand o3, assembly_operand o4,
2206 int label, int flag);
2207 extern void assemblez_4_to(int internal_number,
2208 assembly_operand o1, assembly_operand o2,
2209 assembly_operand o3, assembly_operand o4,
2210 assembly_operand st);
2211 extern void assemblez_5_to(int internal_number,
2212 assembly_operand o1, assembly_operand o2,
2213 assembly_operand o3, assembly_operand o4,
2214 assembly_operand o5, assembly_operand st);
2216 extern void assemblez_inc(assembly_operand o1);
2217 extern void assemblez_dec(assembly_operand o1);
2218 extern void assemblez_store(assembly_operand o1, assembly_operand o2);
2219 extern void assemblez_jump(int n);
2221 extern void assembleg_0(int internal_number);
2222 extern void assembleg_1(int internal_number, assembly_operand o1);
2223 extern void assembleg_2(int internal_number, assembly_operand o1,
2224 assembly_operand o2);
2225 extern void assembleg_3(int internal_number, assembly_operand o1,
2226 assembly_operand o2, assembly_operand o3);
2227 extern void assembleg_4(int internal_number, assembly_operand o1,
2228 assembly_operand o2, assembly_operand o3, assembly_operand o4);
2229 extern void assembleg_5(int internal_number, assembly_operand o1,
2230 assembly_operand o2, assembly_operand o3, assembly_operand o4,
2231 assembly_operand o5);
2232 extern void assembleg_0_branch(int internal_number,
2234 extern void assembleg_1_branch(int internal_number,
2235 assembly_operand o1, int label);
2236 extern void assembleg_2_branch(int internal_number,
2237 assembly_operand o1, assembly_operand o2, int label);
2238 extern void assembleg_call_1(assembly_operand oaddr, assembly_operand o1,
2239 assembly_operand odest);
2240 extern void assembleg_call_2(assembly_operand oaddr, assembly_operand o1,
2241 assembly_operand o2, assembly_operand odest);
2242 extern void assembleg_call_3(assembly_operand oaddr, assembly_operand o1,
2243 assembly_operand o2, assembly_operand o3, assembly_operand odest);
2244 extern void assembleg_inc(assembly_operand o1);
2245 extern void assembleg_dec(assembly_operand o1);
2246 extern void assembleg_store(assembly_operand o1, assembly_operand o2);
2247 extern void assembleg_jump(int n);
2249 extern void parse_assembly(void);
2251 /* ------------------------------------------------------------------------- */
2252 /* Extern definitions for "bpatch" */
2253 /* ------------------------------------------------------------------------- */
2255 extern uchar *staticarray_backpatch_table;
2256 extern memory_list staticarray_backpatch_table_memlist;
2257 extern uchar *zmachine_backpatch_table;
2258 extern memory_list zmachine_backpatch_table_memlist;
2259 extern uchar *zcode_backpatch_table;
2260 extern memory_list zcode_backpatch_table_memlist;
2261 extern int32 zcode_backpatch_size, staticarray_backpatch_size,
2262 zmachine_backpatch_size;
2263 extern int backpatch_marker, backpatch_error_flag;
2265 extern char *describe_mv(int mval);
2266 extern char *describe_mv_short(int mval);
2268 extern int32 backpatch_value(int32 value);
2269 extern void backpatch_zmachine_image_z(void);
2270 extern void backpatch_zmachine_image_g(void);
2271 extern void backpatch_zmachine(int mv, int zmachine_area, int32 offset);
2273 /* ------------------------------------------------------------------------- */
2274 /* Extern definitions for "chars" */
2275 /* ------------------------------------------------------------------------- */
2277 extern uchar source_to_iso_grid[];
2278 extern int32 iso_to_unicode_grid[];
2279 extern int character_digit_value[];
2280 extern uchar alphabet[3][27];
2281 extern int alphabet_modified;
2282 extern int zscii_defn_modified;
2283 extern int zscii_high_water_mark;
2284 extern char alphabet_used[];
2285 extern int iso_to_alphabet_grid[];
2286 extern int zscii_to_alphabet_grid[];
2287 extern int textual_form_length;
2289 extern int iso_to_unicode(int iso);
2290 extern int unicode_to_zscii(int32 u);
2291 extern int32 zscii_to_unicode(int z);
2292 extern int32 text_to_unicode(char *text);
2293 extern void zscii_to_text(char *text, int zscii);
2294 extern char *name_of_iso_set(int s);
2295 extern void change_character_set(void);
2296 extern void new_alphabet(char *text, int alphabet);
2297 extern void new_zscii_character(int32 unicode, int plus_flag);
2298 extern void new_zscii_finished(void);
2299 extern void map_new_zchar(int32 unicode);
2300 extern void make_lower_case(char *str);
2301 extern void make_upper_case(char *str);
2303 /* ------------------------------------------------------------------------- */
2304 /* Extern definitions for "directs" */
2305 /* ------------------------------------------------------------------------- */
2307 extern brief_location routine_starts_line;
2309 extern int no_routines, no_named_routines, no_termcs;
2310 extern int terminating_characters[];
2312 extern int parse_given_directive(int internal_flag);
2314 /* ------------------------------------------------------------------------- */
2315 /* Extern definitions for "errors" */
2316 /* ------------------------------------------------------------------------- */
2318 #define FORERRORS_SIZE (512)
2319 extern char *forerrors_buff;
2320 extern int forerrors_pointer;
2321 extern int no_errors, no_warnings, no_suppressed_warnings, no_compiler_errors;
2323 extern ErrorPosition ErrorReport;
2325 extern void fatalerror(char *s) NORETURN;
2326 extern void fatalerror_fmt(const char *format, ...) NORETURN;
2327 extern void fatalerror_named(char *s1, char *s2) NORETURN;
2328 extern void fatalerror_memory_out(int32 size, int32 howmany, char *name) NORETURN;
2330 extern void error(char *s);
2331 extern void error_fmt(const char *format, ...);
2332 extern void error_named(char *s1, char *s2);
2333 extern void error_named_at(char *s1, char *s2, brief_location report_line);
2334 extern void ebf_error(char *s1, char *s2);
2335 extern void ebf_curtoken_error(char *s);
2336 extern void ebf_symbol_error(char *s1, char *name, char *type, brief_location report_line);
2337 extern void char_error(char *s, int ch);
2338 extern void unicode_char_error(char *s, int32 uni);
2339 extern void error_max_dynamic_strings(int index);
2340 extern void error_max_abbreviations(int index);
2342 extern void warning(char *s);
2343 extern void warning_fmt(const char *format, ...);
2344 extern void warning_named(char *s1, char *s2);
2345 extern void warning_at(char *name, brief_location report_line);
2346 extern void symtype_warning(char *context, char *name, char *type, char *wanttype);
2347 extern void dbnu_warning(char *type, char *name, brief_location report_line);
2348 extern void uncalled_routine_warning(char *type, char *name, brief_location report_line);
2349 extern void obsolete_warning(char *s1);
2351 extern int compiler_error(char *s);
2352 extern int compiler_error_named(char *s1, char *s2);
2353 extern void print_sorry_message(void);
2354 extern char *current_location_text(void);
2356 #ifdef ARC_THROWBACK
2357 extern int throwback_switch;
2359 extern void throwback(int severity, char * error);
2360 extern void throwback_start(void);
2361 extern void throwback_end(void);
2364 /* ------------------------------------------------------------------------- */
2365 /* Extern definitions for "expressc" */
2366 /* ------------------------------------------------------------------------- */
2368 extern int vivc_flag;
2369 extern operator operators[];
2371 extern assembly_operand stack_pointer, temp_var1, temp_var2, temp_var3,
2372 temp_var4, zero_operand, one_operand, two_operand, three_operand,
2373 four_operand, valueless_operand;
2375 assembly_operand code_generate(assembly_operand AO, int context, int label);
2376 assembly_operand check_nonzero_at_runtime(assembly_operand AO1, int label,
2379 /* ------------------------------------------------------------------------- */
2380 /* Extern definitions for "expressp" */
2381 /* ------------------------------------------------------------------------- */
2383 extern int system_function_usage[];
2384 extern expression_tree_node *ET;
2386 extern int z_system_constant_list[];
2387 extern int glulx_system_constant_list[];
2389 extern int32 value_of_system_constant(int t);
2390 extern char *name_of_system_constant(int t);
2391 extern void clear_expression_space(void);
2392 extern void show_tree(const assembly_operand *AO, int annotate);
2393 extern assembly_operand parse_expression(int context);
2394 extern int test_for_incdec(assembly_operand AO);
2395 extern int test_constant_op_list(const assembly_operand *AO, assembly_operand *ops_found, int max_ops_found);
2397 /* ------------------------------------------------------------------------- */
2398 /* Extern definitions for "files" */
2399 /* ------------------------------------------------------------------------- */
2401 extern int total_files;
2402 extern int current_input_file;
2403 extern int total_input_files;
2404 extern FileId *InputFiles;
2406 extern int32 total_chars_read;
2408 extern void open_transcript_file(char *what_of);
2409 extern void write_to_transcript_file(char *text, int linetype);
2410 extern void close_transcript_file(void);
2411 extern void abort_transcript_file(void);
2413 extern void nullify_debug_file_position(maybe_file_position *position);
2415 extern void begin_debug_file(void);
2417 extern void debug_file_printf(const char*format, ...);
2418 extern void debug_file_print_with_entities(const char*string);
2419 extern void debug_file_print_base_64_triple
2420 (uchar first, uchar second, uchar third);
2421 extern void debug_file_print_base_64_pair(uchar first, uchar second);
2422 extern void debug_file_print_base_64_single(uchar first);
2424 extern void write_debug_location(debug_location location);
2425 extern void write_debug_locations(debug_locations locations);
2426 extern void write_debug_optional_identifier(int32 symbol_index);
2427 extern void write_debug_symbol_backpatch(int32 symbol_index);
2428 extern void write_debug_symbol_optional_backpatch(int32 symbol_index);
2429 extern void write_debug_object_backpatch(int32 object_number);
2430 extern void write_debug_packed_code_backpatch(int32 offset);
2431 extern void write_debug_code_backpatch(int32 offset);
2432 extern void write_debug_global_backpatch(int32 offset);
2433 extern void write_debug_array_backpatch(int32 offset);
2434 extern void write_debug_grammar_backpatch(int32 offset);
2436 extern void begin_writing_debug_sections(void);
2437 extern void write_debug_section(const char*name, int32 beginning_address);
2438 extern void end_writing_debug_sections(int32 end_address);
2440 extern void write_debug_undef(int32 symbol_index);
2442 extern void end_debug_file(void);
2444 extern void add_to_checksum(void *address);
2446 extern void load_sourcefile(char *story_name, int style);
2447 extern int file_load_chars(int file_number, char *buffer, int length);
2448 extern void close_all_source(void);
2449 extern int register_orig_sourcefile(char *filename);
2451 extern void output_file(void);
2453 /* ------------------------------------------------------------------------- */
2454 /* Extern definitions for "inform" */
2455 /* ------------------------------------------------------------------------- */
2457 extern char Code_Name[];
2458 extern int endofpass_flag;
2460 extern int version_number, instruction_set_number, extend_memory_map;
2461 extern int32 scale_factor, length_scale_factor;
2463 extern int WORDSIZE, INDIV_PROP_START,
2464 OBJECT_BYTE_LENGTH, DICT_ENTRY_BYTE_LENGTH, DICT_ENTRY_FLAG_POS;
2465 extern int32 MAXINTWORD;
2467 extern int asm_trace_level, expr_trace_level, tokens_trace_level;
2471 economy_switch, frequencies_setting,
2472 ignore_switches_switch, debugfile_switch,
2473 files_trace_setting, memout_switch, printprops_switch,
2474 printactions_switch,
2475 obsolete_switch, optabbrevs_trace_setting,
2476 transcript_switch, statistics_switch, optimise_switch,
2477 version_set_switch, nowarnings_switch, hash_switch,
2479 define_DEBUG_switch, define_INFIX_switch,
2480 runtime_error_checking_switch,
2481 list_verbs_setting, list_dict_setting, list_objects_setting,
2482 list_symbols_setting;
2484 extern int oddeven_packing_switch;
2486 extern int glulx_mode, compression_switch;
2487 extern int32 requested_glulx_version, final_glulx_version;
2489 extern int error_format, store_the_text, asm_trace_setting,
2490 expr_trace_setting, tokens_trace_setting,
2491 bpatch_trace_setting, symdef_trace_setting,
2492 double_space_setting, trace_fns_setting, character_set_setting,
2493 character_set_unicode;
2495 extern char Debugging_Name[];
2496 extern char Transcript_Name[];
2497 extern char Language_Name[];
2498 extern char Charset_Map[];
2500 extern char banner_line[];
2502 extern void select_version(int vn);
2503 extern void switches(char *, int);
2504 extern int translate_in_filename(int last_value, char *new_name, char *old_name,
2505 int same_directory_flag, int command_line_flag);
2506 extern void translate_out_filename(char *new_name, char *old_name);
2509 extern char *riscos_file_type(void);
2512 /* For the benefit of the MAC_FACE port these are declared extern, though
2513 unused outside "inform" in the compiler itself */
2515 extern void allocate_arrays(void);
2516 extern void free_arrays(void);
2518 /* ------------------------------------------------------------------------- */
2519 /* Extern definitions for "lexer" */
2520 /* ------------------------------------------------------------------------- */
2522 extern int hash_printed_since_newline;
2523 extern int total_source_line_count;
2524 extern int dont_enter_into_symbol_table;
2525 extern int return_sp_as_variable;
2526 extern int next_token_begins_syntax_line;
2527 extern int no_locals;
2528 extern int *local_variable_name_offsets;
2530 extern int32 token_value;
2531 extern int token_type;
2532 extern char *token_text;
2534 extern debug_location get_token_location(void);
2535 extern debug_locations get_token_locations(void);
2536 extern debug_location_beginning get_token_location_beginning(void);
2537 extern void discard_token_location(debug_location_beginning beginning);
2538 extern debug_locations get_token_location_end(debug_location_beginning beginning);
2540 extern void describe_token_triple(const char *text, int32 value, int type);
2541 #define describe_current_token() describe_token_triple(token_text, token_value, token_type)
2542 /* The describe_token() macro works on both token_data and lexeme_data structs. */
2543 #define describe_token(t) describe_token_triple((t)->text, (t)->value, (t)->type)
2545 extern void construct_local_variable_tables(void);
2546 extern void clear_local_variables(void);
2547 extern void add_local_variable(char *name);
2548 extern char *get_local_variable_name(int index);
2550 extern void declare_systemfile(void);
2551 extern int is_systemfile(void);
2552 extern void report_errors_at_current_line(void);
2553 extern debug_location get_current_debug_location(void);
2554 extern debug_location get_error_report_debug_location(void);
2555 extern int32 get_current_line_start(void);
2556 extern void set_origsource_location(char *source, int32 line, int32 charnum);
2557 extern brief_location get_brief_location(ErrorPosition *errpos);
2558 extern void export_brief_location(brief_location loc, ErrorPosition *errpos);
2559 extern brief_location blank_brief_location;
2561 extern void put_token_back(void);
2562 extern void get_next_token(void);
2563 extern void release_token_texts(void);
2564 extern void restart_lexer(char *lexical_source, char *name);
2566 extern keyword_group directives, statements, segment_markers,
2567 conditions, system_functions, local_variables, opcode_names,
2568 misc_keywords, directive_keywords, trace_keywords, system_constants,
2571 /* ------------------------------------------------------------------------- */
2572 /* Extern definitions for "memory" */
2573 /* ------------------------------------------------------------------------- */
2575 extern size_t malloced_bytes;
2577 extern int HASH_TAB_SIZE,
2579 MAX_DYNAMIC_STRINGS;
2581 extern int32 MAX_STACK_SIZE, MEMORY_MAP_EXTENSION;
2583 extern int MAX_LOCAL_VARIABLES;
2584 extern int DICT_WORD_SIZE, DICT_CHAR_SIZE, DICT_WORD_BYTES;
2585 extern int ZCODE_HEADER_EXT_WORDS, ZCODE_HEADER_FLAGS_3;
2586 extern int ZCODE_LESS_DICT_DATA;
2587 extern int ZCODE_MAX_INLINE_STRING;
2588 extern int NUM_ATTR_BYTES, GLULX_OBJECT_EXT_BYTES;
2589 extern int WARN_UNUSED_ROUTINES, OMIT_UNUSED_ROUTINES;
2590 extern int STRIP_UNREACHABLE_LABELS;
2591 extern int OMIT_SYMBOL_TABLE;
2592 extern int LONG_DICT_FLAG_BUG;
2593 extern int TRANSCRIPT_FORMAT;
2595 /* These macros define offsets that depend on the value of NUM_ATTR_BYTES.
2596 (Meaningful only for Glulx.) */
2597 /* GOBJFIELD: word offsets of various elements in the object structure. */
2598 #define GOBJFIELD_CHAIN() (1+((NUM_ATTR_BYTES)/4))
2599 #define GOBJFIELD_NAME() (2+((NUM_ATTR_BYTES)/4))
2600 #define GOBJFIELD_PROPTAB() (3+((NUM_ATTR_BYTES)/4))
2601 #define GOBJFIELD_PARENT() (4+((NUM_ATTR_BYTES)/4))
2602 #define GOBJFIELD_SIBLING() (5+((NUM_ATTR_BYTES)/4))
2603 #define GOBJFIELD_CHILD() (6+((NUM_ATTR_BYTES)/4))
2605 extern void *my_malloc(size_t size, char *whatfor);
2606 extern void my_realloc(void *pointer, size_t oldsize, size_t size,
2608 extern void *my_calloc(size_t size, size_t howmany, char *whatfor);
2609 extern void my_recalloc(void *pointer, size_t size, size_t oldhowmany,
2610 size_t howmany, char *whatfor);
2611 extern void my_free(void *pointer, char *whatitwas);
2613 extern void set_memory_sizes(void);
2614 extern void adjust_memory_sizes(void);
2615 extern void memory_command(char *command);
2616 extern void print_memory_usage(void);
2618 extern void initialise_memory_list(memory_list *ML, size_t itemsize, size_t initalloc, void **extpointer, char *whatfor);
2619 extern void deallocate_memory_list(memory_list *ML);
2620 extern void ensure_memory_list_available(memory_list *ML, size_t count);
2622 /* ------------------------------------------------------------------------- */
2623 /* Extern definitions for "objects" */
2624 /* ------------------------------------------------------------------------- */
2626 extern int no_attributes, no_properties;
2627 extern int no_individual_properties;
2628 extern int individuals_length;
2629 extern uchar *individuals_table;
2630 extern memory_list individuals_table_memlist;
2631 extern int no_classes, no_objects;
2632 extern objecttz *objectsz;
2633 extern memory_list objectsz_memlist;
2634 extern objecttg *objectsg;
2635 extern uchar *objectatts;
2636 extern classinfo *class_info;
2637 extern memory_list class_info_memlist;
2639 extern commonpropinfo *commonprops;
2640 extern uchar *properties_table;
2641 extern memory_list properties_table_memlist;
2642 extern int properties_table_size;
2644 extern void make_attribute(void);
2645 extern void make_property(void);
2646 extern void make_object(int nearby_flag,
2647 char *textual_name, int specified_parent, int specified_class,
2649 extern void make_class(char *metaclass_name);
2650 extern int object_provides(int obj, int id);
2651 extern void list_object_tree(void);
2652 extern void write_the_identifier_names(void);
2654 /* ------------------------------------------------------------------------- */
2655 /* Extern definitions for "symbols" */
2656 /* ------------------------------------------------------------------------- */
2658 extern int no_named_constants;
2659 extern int no_symbols;
2660 extern symbolinfo *symbols;
2661 extern symboldebuginfo *symbol_debug_info;
2662 extern int32 *individual_name_strings;
2663 extern int32 *attribute_name_strings;
2664 extern int32 *action_name_strings;
2665 extern int32 *array_name_strings;
2666 extern int track_unused_routines;
2667 extern int df_dont_note_global_symbols;
2668 extern uint32 df_total_size_before_stripping;
2669 extern uint32 df_total_size_after_stripping;
2671 extern char *typename(int type);
2672 extern int hash_code_from_string(char *p);
2673 extern int strcmpcis(char *p, char *q);
2674 extern int get_symbol_index(char *p);
2675 extern int symbol_index(char *lexeme_text, int hashcode, int *created);
2676 extern void end_symbol_scope(int k, int neveruse);
2677 extern void describe_symbol(int k);
2678 extern void list_symbols(int level);
2679 extern void assign_marked_symbol(int index, int marker, int32 value, int type);
2680 extern void assign_symbol(int index, int32 value, int type);
2681 extern void check_warn_symbol_type(const assembly_operand *AO, int wanttype, int wanttype2, char *label);
2682 extern void check_warn_symbol_has_metaclass(const assembly_operand *AO, char *context);
2683 extern void issue_unused_warnings(void);
2684 extern void issue_debug_symbol_warnings(void);
2685 extern void add_config_symbol_definition(char *symbol, int32 value);
2686 extern void add_symbol_replacement_mapping(int original, int renamed);
2687 extern int find_symbol_replacement(int *value);
2688 extern void df_note_function_start(char *name, uint32 address,
2689 int embedded_flag, brief_location source_line);
2690 extern void df_note_function_end(uint32 endaddress);
2691 extern void df_note_function_symbol(int symbol);
2692 extern void locate_dead_functions(void);
2693 extern uint32 df_stripped_address_for_address(uint32);
2694 extern uint32 df_stripped_offset_for_code_offset(uint32, int *);
2695 extern void df_prepare_function_iterate(void);
2696 extern uint32 df_next_function_iterate(int *);
2698 /* ------------------------------------------------------------------------- */
2699 /* Extern definitions for "syntax" */
2700 /* ------------------------------------------------------------------------- */
2702 extern int no_syntax_lines;
2704 extern void panic_mode_error_recovery(void);
2705 extern void get_next_token_with_directives(void);
2706 extern int parse_directive(int internal_flag);
2707 extern void parse_program(char *source);
2708 extern int32 parse_routine(char *source, int embedded_flag, char *name,
2709 int veneer_flag, int r_symbol);
2710 extern void parse_code_block(int break_label, int continue_label,
2713 /* ------------------------------------------------------------------------- */
2714 /* Extern definitions for "states" */
2715 /* ------------------------------------------------------------------------- */
2717 extern void match_close_bracket(void);
2718 extern void parse_statement(int break_label, int continue_label);
2719 extern void parse_statement_singleexpr(assembly_operand AO);
2720 extern int parse_label(void);
2722 /* ------------------------------------------------------------------------- */
2723 /* Extern definitions for "tables" */
2724 /* ------------------------------------------------------------------------- */
2726 extern uchar *zmachine_paged_memory;
2728 code_offset, actions_offset, preactions_offset,
2729 dictionary_offset, strings_offset, adjectives_offset,
2730 variables_offset, class_numbers_offset, individuals_offset,
2731 identifier_names_offset, prop_defaults_offset, prop_values_offset,
2732 static_memory_offset, array_names_offset, attribute_names_offset,
2733 action_names_offset, fake_action_names_offset,
2734 routine_names_offset, routines_array_offset, routine_flags_array_offset,
2735 global_names_offset, global_flags_array_offset,
2736 array_flags_array_offset, constant_names_offset, constants_array_offset,
2737 static_arrays_offset;
2739 arrays_offset, object_tree_offset, grammar_table_offset,
2740 abbreviations_offset; /* For Glulx */
2742 extern int32 Out_Size, Write_Code_At, Write_Strings_At;
2743 extern int32 RAM_Size, Write_RAM_At; /* For Glulx */
2745 extern int release_number, statusline_flag;
2746 extern int flags2_requirements[];
2747 extern int serial_code_given_in_program;
2748 extern char serial_code_buffer[];
2750 extern void construct_storyfile(void);
2751 extern void write_serial_number(char *buffer);
2753 /* ------------------------------------------------------------------------- */
2754 /* Extern definitions for "text" */
2755 /* ------------------------------------------------------------------------- */
2757 extern uchar *translated_text;
2759 extern uchar *low_strings;
2760 extern int32 low_strings_top;
2762 extern int no_abbreviations;
2763 extern int abbrevs_lookup_table_made, is_abbreviation;
2764 extern abbreviation *abbreviations;
2766 extern int32 total_chars_trans, total_bytes_trans,
2767 zchars_trans_in_last_string;
2768 extern int put_strings_in_low_memory;
2769 extern int dict_entries;
2770 extern uchar *dictionary;
2771 extern int32 dictionary_top;
2772 extern int *final_dict_order;
2774 extern uchar *static_strings_area;
2775 extern memory_list static_strings_area_memlist;
2776 extern int32 static_strings_extent;
2778 /* And now, a great many declarations for dealing with Glulx string
2781 extern int32 no_strings, no_dynamic_strings;
2782 extern int no_unicode_chars;
2784 typedef struct unicode_usage_s unicode_usage_t;
2785 struct unicode_usage_s {
2787 int next; /* index in unicode_usage_entries of next */
2790 extern unicode_usage_t *unicode_usage_entries;
2792 /* This is the maximum number of (8-bit) bytes that can encode a single
2793 Huffman entity. Four should be plenty, unless someone starts encoding
2794 an ideographic language. */
2795 #define MAXHUFFBYTES (4)
2797 typedef struct huffbitlist_struct {
2798 uchar b[MAXHUFFBYTES];
2800 typedef struct huffentity_struct {
2813 extern huffentity_t *huff_entities;
2815 extern int32 compression_table_size, compression_string_size;
2816 extern int32 *compressed_offsets;
2817 extern int no_huff_entities;
2818 extern int huff_abbrev_start, huff_dynam_start, huff_unicode_start;
2819 extern int huff_entity_root;
2821 extern void compress_game_text(void);
2823 /* end of the Glulx string compression stuff */
2825 extern void ao_free_arrays(void);
2826 extern void extract_all_text(void);
2827 extern int32 compile_string(char *b, int strctx);
2828 extern int32 translate_text(int32 p_limit, char *s_text, int strctx);
2829 extern void optimise_abbreviations(void);
2830 extern void make_abbreviation(char *text);
2831 extern char *abbreviation_text(int num);
2832 extern void show_dictionary(int level);
2833 extern void word_to_ascii(uchar *p, char *result);
2834 extern void print_dict_word(int node);
2835 extern void write_dictionary_to_transcript(void);
2836 extern void sort_dictionary(void);
2837 extern void dictionary_prepare(char *dword, uchar *optresult);
2838 extern int dictionary_add(char *dword, int x, int y, int z);
2839 extern void dictionary_set_verb_number(char *dword, int to);
2840 extern int compare_sorts(uchar *d1, uchar *d2);
2841 extern void copy_sorts(uchar *d1, uchar *d2);
2843 /* ------------------------------------------------------------------------- */
2844 /* Extern definitions for "veneer" */
2845 /* ------------------------------------------------------------------------- */
2847 extern int veneer_mode;
2848 extern int32 veneer_routine_address[];
2850 extern void compile_initial_routine(void);
2851 extern assembly_operand veneer_routine(int code);
2852 extern char *veneer_routine_name(int code);
2853 extern void compile_veneer(void);
2855 /* ------------------------------------------------------------------------- */
2856 /* Extern definitions for "verbs" */
2857 /* ------------------------------------------------------------------------- */
2859 extern int no_adjectives, no_Inform_verbs, no_grammar_token_routines,
2860 no_fake_actions, no_actions, no_grammar_lines, no_grammar_tokens,
2861 grammar_version_number;
2862 extern int32 grammar_version_symbol;
2863 extern verbt *Inform_verbs;
2864 extern uchar *grammar_lines;
2865 extern int32 grammar_lines_top;
2866 extern actioninfo *actions;
2867 extern memory_list actions_memlist;
2868 extern int32 *grammar_token_routine,
2871 extern void find_the_actions(void);
2872 extern void make_fake_action(void);
2873 extern assembly_operand action_of_name(char *name);
2874 extern void locate_dead_grammar_lines(void);
2875 extern void make_verb(void);
2876 extern void extend_verb(void);
2877 extern void list_verb_table(void);
2879 /* ========================================================================= */