X-Git-Url: https://jxself.org/git/?p=inform.git;a=blobdiff_plain;f=directs.c;h=5c622ba547b2bccab0ba285f31e489c79ff450e8;hp=37bbf82c411c78cba7d45c43190c0f633a1d8997;hb=37041256066b0f4023b2664ae4932a23b9b09d55;hpb=5154191043a9b7227ef0eee1a2b40299fc188655 diff --git a/directs.c b/directs.c index 37bbf82..5c622ba 100644 --- a/directs.c +++ b/directs.c @@ -28,7 +28,7 @@ int no_routines, /* Number of routines compiled so far */ no_termcs; /* Number of terminating characters */ int terminating_characters[32]; -int32 routine_starts_line; /* Source code line on which the current +brief_location routine_starts_line; /* Source code location where the current routine starts. (Useful for reporting "unused variable" warnings on the start line rather than the end line.) */ @@ -662,6 +662,72 @@ Fake_Action directives to a point after the inclusion of \"Parser\".)"); make_object(FALSE, NULL, -1, -1, -1); return FALSE; /* See "objects.c" */ + /* --------------------------------------------------------------------- */ + /* Origsource */ + /* Origsource */ + /* Origsource */ + /* Origsource */ + /* */ + /* The first three forms declare that all following lines are derived */ + /* from the named Inform 7 source file (with an optional line number */ + /* and character number). This will be reported in error messages and */ + /* in debug output. The declaration holds through the next Origsource */ + /* directive (but does not apply to included files). */ + /* */ + /* The fourth form, with no arguments, clears the declaration. */ + /* */ + /* Unlike the Include directive, Origsource does not open the named */ + /* file or even verify that it exists. The filename is treated as an */ + /* opaque string. */ + /* --------------------------------------------------------------------- */ + + case ORIGSOURCE_CODE: + { + char *origsource_file = NULL; + int32 origsource_line = 0; + int32 origsource_char = 0; + + /* Parse some optional tokens followed by a mandatory semicolon. */ + + get_next_token(); + if (!((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))) { + if (token_type != DQ_TT) { + return ebf_error_recover("a file name in double-quotes", + token_text); + } + origsource_file = token_text; + + get_next_token(); + if (!((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))) { + if (token_type != NUMBER_TT) { + return ebf_error_recover("a file line number", + token_text); + } + origsource_line = token_value; + if (origsource_line < 0) + origsource_line = 0; + + get_next_token(); + if (!((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))) { + if (token_type != NUMBER_TT) { + return ebf_error_recover("a file line number", + token_text); + } + origsource_char = token_value; + if (origsource_char < 0) + origsource_char = 0; + + get_next_token(); + } + } + } + + put_token_back(); + + set_origsource_location(origsource_file, origsource_line, origsource_char); + } + break; + /* --------------------------------------------------------------------- */ /* Property [long] [additive] name [alias oldname] */ /* --------------------------------------------------------------------- */