X-Git-Url: https://jxself.org/git/?p=inform.git;a=blobdiff_plain;f=src%2Fsyntax.c;fp=src%2Fsyntax.c;h=08e61c90da922db2ccc7dc159f2026419d8683bc;hp=0896af9b3427441e3972eafe91f9ebe947ea4da4;hb=8760c1ba6442153afe76bcac742e086f90c59fe8;hpb=46cb3ffad9e3ed318a9109ff96421882f6642b2b diff --git a/src/syntax.c b/src/syntax.c index 0896af9..08e61c9 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1,9 +1,8 @@ /* ------------------------------------------------------------------------- */ /* "syntax" : Syntax analyser and compiler */ /* */ -/* Copyright (c) Graham Nelson 1993 - 2020 */ -/* */ -/* This file is part of Inform. */ +/* Part of Inform 6.35 */ +/* copyright (c) Graham Nelson 1993 - 2020 */ /* */ /* Inform is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ @@ -16,7 +15,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with Inform. If not, see https://gnu.org/licenses/ */ +/* along with Inform. If not, see https://gnu.org/licenses/ * /* */ /* ------------------------------------------------------------------------- */ @@ -85,13 +84,7 @@ extern void get_next_token_with_directives(void) This is called while parsing a long construct, such as Class or Object, where we want to support internal #ifdefs. (Although - function-parsing predates this and doesn't make use of it.) - - (Technically this permits *any* #-directive, which means you - can define global variables or properties or what-have-you in - the middle of an object. You can do that in the middle of an - object, too. Don't. It's about as well-supported as Wile E. - Coyote one beat before the plummet-lines kick in.) */ + function-parsing predates this and doesn't make use of it.) */ int directives_save, segment_markers_save, statements_save; @@ -157,6 +150,8 @@ extern int parse_directive(int internal_flag) TRUE if encountered with a # prefix inside a routine or object definition. + (Only directives like #ifdef are permitted inside a definition.) + Returns: TRUE if program continues, FALSE if end of file reached. */ int routine_symbol, rep_symbol; @@ -185,12 +180,15 @@ extern int parse_directive(int internal_flag) df_dont_note_global_symbols = TRUE; get_next_token(); df_dont_note_global_symbols = FALSE; - if ((token_type != SYMBOL_TT) - || ((!(sflags[token_value] & UNKNOWN_SFLAG)) - && (!(sflags[token_value] & REPLACE_SFLAG)))) + if (token_type != SYMBOL_TT) { ebf_error("routine name", token_text); return(FALSE); } + if ((!(sflags[token_value] & UNKNOWN_SFLAG)) + && (!(sflags[token_value] & REPLACE_SFLAG))) + { ebf_symbol_error("routine name", token_text, typename(stypes[token_value]), slines[token_value]); + return(FALSE); + } routine_symbol = token_value; @@ -614,6 +612,11 @@ extern void parse_code_block(int break_label, int continue_label, { do { begin_syntax_line(TRUE); get_next_token(); + + if ((token_type == SEP_TT) && (token_value == HASH_SEP)) + { parse_directive(TRUE); + continue; + } if (token_type == SEP_TT && token_value == CLOSE_BRACE_SEP) { if (switch_clause_made && (!default_clause_made)) assemble_label_no(switch_label);