1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 10:04:21 +03:00
inform7/inter/Chapter 1/Basics.w
2019-08-24 11:21:48 +01:00

82 lines
2 KiB
OpenEdge ABL
Executable file

[Basics::] Basics.
Some fundamental definitions.
@h Build identity.
First we define the build, using a notation which tangles out to the current
build number as specified in the contents section of this web.
@d INTOOL_NAME "inter"
@d INTER_BUILD "inter [[Build Number]]"
@ Since we want to include the words module, we have to define the following
structure and initialiser:
@d VOCABULARY_MEANING_INITIALISER Basics::ignore
=
typedef struct vocabulary_meaning {
int enigmatic_number;
} vocabulary_meaning;
@
@d LEXER_PROBLEM_HANDLER Basics::lexer_problem_handler
=
vocabulary_meaning Basics::ignore(vocabulary_entry *ve) {
vocabulary_meaning vm;
vm.enigmatic_number = 16339;
return vm;
}
void Basics::lexer_problem_handler(int err, text_stream *problem_source_description, wchar_t *word) {
if (err == MEMORY_OUT_LEXERERROR)
Errors::fatal("Out of memory: unable to create lexer workspace");
TEMPORARY_TEXT(word_t);
if (word) WRITE_TO(word_t, "%w", word);
switch (err) {
case STRING_TOO_LONG_LEXERERROR:
Errors::with_text("Too much text in quotation marks: %S", word_t);
break;
case WORD_TOO_LONG_LEXERERROR:
Errors::with_text("Word too long: %S", word_t);
break;
case I6_TOO_LONG_LEXERERROR:
Errors::with_text("I6 inclusion too long: %S", word_t);
break;
case STRING_NEVER_ENDS_LEXERERROR:
Errors::with_text("Quoted text never ends: %S", problem_source_description);
break;
case COMMENT_NEVER_ENDS_LEXERERROR:
Errors::with_text("Square-bracketed text never ends: %S", problem_source_description);
break;
case I6_NEVER_ENDS_LEXERERROR:
Errors::with_text("I6 inclusion text never ends: %S", problem_source_description);
break;
default:
internal_error("unknown lexer error");
}
DISCARD_TEXT(word_t);
}
@
= (early code)
typedef void kind;
kind *K_value = NULL;
@
@d PREFORM_LANGUAGE_TYPE void
@h Setting up the memory manager.
We need to itemise the structures we'll want to allocate:
@e inter_file_MT
@ And then expand:
=
ALLOCATE_INDIVIDUALLY(inter_file)