Added @default constants feature

This commit is contained in:
Graham Nelson 2020-03-28 16:59:54 +00:00
parent 973501f52e
commit 23da5e16b2
13 changed files with 271 additions and 112 deletions

View file

@ -24,6 +24,7 @@ typedef struct source_line {
int category; /* what sort of line this is: an |*_LCAT| value */
int command_code; /* used only for |COMMAND_LCAT| lines: a |*_CMD| value */
int default_defn; /* used only for |BEGIN_DEFINITION_LCAT| lines */
int is_commentary; /* flag */
struct function *function_defined; /* if any C-like function is defined on this line */
struct preform_nonterminal *preform_nonterminal_defined; /* similarly */
@ -46,6 +47,7 @@ source_line *Lines::new_source_line(text_stream *line, text_file_position *tfp)
sl->category = NO_LCAT; /* that is, unknown category as yet */
sl->command_code = NO_CMD;
sl->default_defn = FALSE;
sl->is_commentary = FALSE;
sl->function_defined = NULL;
sl->preform_nonterminal_defined = NULL;

View file

@ -392,6 +392,11 @@ long forms |@define|, |@enum| and |@heading|, and plain old |@| remain.
if (S->using_syntax < V2_SYNTAX)
Parser::wrong_version(S->using_syntax, L, "'@define' for definitions (use '@d' instead)", V2_SYNTAX);
@<Deal with the define marker@>;
} else if (Str::eq_wide_string(command_text, L"default")) {
if (S->using_syntax < V2_SYNTAX)
Parser::wrong_version(S->using_syntax, L, "'@default' for definitions", V2_SYNTAX);
L->default_defn = TRUE;
@<Deal with the define marker@>;
} else if (Str::eq_wide_string(command_text, L"enum")) @<Deal with the enumeration marker@>
else if ((Str::eq_wide_string(command_text, L"e")) && (S->using_syntax >= V2_SYNTAX))
@<Deal with the enumeration marker@>

View file

@ -71,21 +71,31 @@ extend across multiple lines.
chapter *C;
section *S;
LOOP_WITHIN_TANGLE(C, S, target)
if (L->category == BEGIN_DEFINITION_LCAT) {
if (L->owning_paragraph == NULL) Main::error_in_web(I"misplaced definition", L);
else Tags::open_ifdefs(OUT, L->owning_paragraph);
Languages::start_definition(OUT, lang,
L->text_operand,
L->text_operand2, S, L);
while ((L->next_line) && (L->next_line->category == CONT_DEFINITION_LCAT)) {
L = L->next_line;
Languages::prolong_definition(OUT, lang, L->text, S, L);
if (L->category == BEGIN_DEFINITION_LCAT)
if (L->default_defn == FALSE)
@<Define the constant@>;
LOOP_WITHIN_TANGLE(C, S, target)
if (L->category == BEGIN_DEFINITION_LCAT)
if (L->default_defn) {
Languages::open_ifdef(OUT, lang, L->text_operand, FALSE);
@<Define the constant@>;
Languages::close_ifdef(OUT, lang, L->text_operand, FALSE);
}
Languages::end_definition(OUT, lang, S, L);
if (L->owning_paragraph) Tags::close_ifdefs(OUT, L->owning_paragraph);
}
Enumerations::define_extents(OUT, target, lang);
@<Define the constant@> =
if (L->owning_paragraph == NULL) Main::error_in_web(I"misplaced definition", L);
else Tags::open_ifdefs(OUT, L->owning_paragraph);
Languages::start_definition(OUT, lang,
L->text_operand,
L->text_operand2, S, L);
while ((L->next_line) && (L->next_line->category == CONT_DEFINITION_LCAT)) {
L = L->next_line;
Languages::prolong_definition(OUT, lang, L->text, S, L);
}
Languages::end_definition(OUT, lang, S, L);
if (L->owning_paragraph) Tags::close_ifdefs(OUT, L->owning_paragraph);
@<Tangle any imported headers@> =
filename *F;
LOOP_OVER_LINKED_LIST(F, filename, W->headers)

View file

@ -63,14 +63,15 @@ example shows all three being used:
| return TRUE;|
|}|
@ Definitions are made using one of two commands: |@d| or |@define|, or
|@e| or |@enum|. These create new constants in the program, with the values
given: they are the equivalent of a |#define| directive in C. |@define| is
the simpler form. For example,
@ Definitions are made using one of three commands: |@d| or |@define|; or
|@e| or |@enum|; or |@default|, which is rarely used and has no abbreviation.
These create new constants in the program, with the values given: they are
the equivalent of a |#define| directive in C. |@define| is the simpler form.
For example,
|@define USEFUL_PRIME 16339|
|@define ENIGMATIC_NUMBER 90125|
sets |USEFUL_PRIME| to 16339. Unlike in the C preprocessor, multi-line
sets |ENIGMATIC_NUMBER| to 90125. Unlike in the C preprocessor, multi-line
definitions are automatically handled, so for example:
|@ The following macro defines a function:|
@ -113,6 +114,24 @@ from anywhere in the web, including in sections or paragraphs earlier than
the ones in which they are defined. (The tangler automatically arranges code
as necessary to make this work.)
A symbol defined with |@default| has the given value only if some other use
of |@d| or |@e| in the web has not already defined it. For example, if the
web contains:
|@default MAX_HEADROOM 100|
|@d MAX_HEADROOM 99|
or
|@d MAX_HEADROOM 99|
|@default MAX_HEADROOM 100|
then the value is 99, but if only
|@default MAX_HEADROOM 100|
then the value is 100.
@ Finally, a paragraph can contain code. This is introduced with an equals
sign: in some sense, the value of the paragraph is the code it contains.
In many paragraphs, as in the example above, the divider is just

View file

@ -1444,6 +1444,7 @@ typedef struct source_line {
int category; /* what sort of line this is: an |*_LCAT| value */
int command_code; /* used only for |COMMAND_LCAT| lines: a |*_CMD| value */
int default_defn; /* used only for |BEGIN_DEFINITION_LCAT| lines */
int is_commentary; /* flag */
struct function *function_defined; /* if any C-like function is defined on this line */
struct preform_nonterminal *preform_nonterminal_defined; /* similarly */
@ -1456,7 +1457,7 @@ typedef struct source_line {
struct source_line *next_line; /* within the owning section's linked list */
struct paragraph *owning_paragraph; /* for lines falling under paragraphs; |NULL| if not */
} source_line;
#line 585 "inweb/Chapter 2/The Parser.w"
#line 590 "inweb/Chapter 2/The Parser.w"
typedef struct paragraph {
int above_bar; /* placed above the dividing bar in its section (in Version 1 syntax) */
int placed_early; /* should appear early in the tangled code */
@ -2877,15 +2878,15 @@ pathname * Modules__find(web *W, module_search *ms, text_stream *name) ;
int Modules__exists(pathname *P) ;
#line 121 "inweb/Chapter 2/Modules.w"
module * Modules__find_loaded_by_name(text_file_position *tfp, text_stream *name) ;
#line 41 "inweb/Chapter 2/Line Categories.w"
#line 42 "inweb/Chapter 2/Line Categories.w"
source_line * Lines__new_source_line(text_stream *line, text_file_position *tfp) ;
#line 100 "inweb/Chapter 2/Line Categories.w"
#line 102 "inweb/Chapter 2/Line Categories.w"
char * Lines__category_name(int cat) ;
#line 17 "inweb/Chapter 2/The Parser.w"
void Parser__parse_web(web *W, int inweb_mode) ;
#line 670 "inweb/Chapter 2/The Parser.w"
#line 675 "inweb/Chapter 2/The Parser.w"
text_stream * Parser__extract_purpose(text_stream *prologue, source_line *XL, section *S, source_line **adjust) ;
#line 691 "inweb/Chapter 2/The Parser.w"
#line 696 "inweb/Chapter 2/The Parser.w"
void Parser__wrong_version(int using, source_line *L, char *feature, int need) ;
#line 20 "inweb/Chapter 2/Paragraph Macros.w"
para_macro * Macros__create(section *S, paragraph *P, source_line *L, text_stream *name) ;
@ -2977,11 +2978,11 @@ void Weaver__show_endnotes_on_previous_paragraph(OUTPUT_STREAM, weave_target *w
int Weaver__weave_table_of_contents(OUTPUT_STREAM, weave_target *wv, section *S) ;
#line 14 "inweb/Chapter 3/The Tangler.w"
void Tangler__go(web *W, tangle_target *target, filename *dest_file) ;
#line 99 "inweb/Chapter 3/The Tangler.w"
#line 109 "inweb/Chapter 3/The Tangler.w"
void Tangler__tangle_paragraph(OUTPUT_STREAM, paragraph *P) ;
#line 134 "inweb/Chapter 3/The Tangler.w"
#line 144 "inweb/Chapter 3/The Tangler.w"
void Tangler__tangle_code(OUTPUT_STREAM, text_stream *original, section *S, source_line *L) ;
#line 231 "inweb/Chapter 3/The Tangler.w"
#line 241 "inweb/Chapter 3/The Tangler.w"
tangle_target * Tangler__primary_target(web *W) ;
#line 35 "inweb/Chapter 4/Programming Languages.w"
programming_language * Languages__default(void) ;
@ -5698,7 +5699,7 @@ int escapes_category[2][128]; /* one of the |*_ECAT| values above */
void *the_escapes[2][128]; /* the function to call to implement this */
#line 45 "inweb/foundation-module/Chapter 2/Writers and Loggers.w"
#ifdef WORDING_LOGS_ALLOWED
#ifdef WORDS_MODULE
typedef void (*writer_function_W)(text_stream *, char *, wording);
typedef void (*log_function_W)(text_stream *, wording);
#endif
@ -5730,7 +5731,7 @@ void Writers__register_writer_I(int esc, void (*f)(text_stream *, char *, int))
void Writers__register_logger_I(int esc, void (*f)(text_stream *, int)) {
Writers__register_writer_p(1, esc, (void *) f, INTSIZED_ECAT);
}
#ifdef WORDING_LOGS_ALLOWED
#ifdef WORDS_MODULE
#define Writers__register_writer_W(esc, f) Writers__register_writer_p(0, esc, (void *) f, WORDING_ECAT);
#define Writers__register_logger_W(esc, f) Writers__register_writer_p(1, esc, (void *) f, WORDING_ECAT);
#endif
@ -5822,7 +5823,7 @@ void Writers__printf(text_stream *stream, char *fmt, ...) {
break;
}
case WORDING_ECAT: {
#ifdef WORDING_LOGS_ALLOWED
#ifdef WORDS_MODULE
if (set == 0) {
writer_function_W f = (writer_function_W) the_escapes[0][esc_number];
wording W = va_arg(ap, wording);
@ -5927,7 +5928,7 @@ void Writers__printf(text_stream *stream, char *fmt, ...) {
break;
}
case WORDING_ECAT: {
#ifdef WORDING_LOGS_ALLOWED
#ifdef WORDS_MODULE
if (set == 0) {
writer_function_W f = (writer_function_W) the_escapes[0][esc_number];
wording W = va_arg(ap, wording);
@ -6777,11 +6778,11 @@ int CommandLine__read_pair_p(text_stream *opt, text_stream *opt_val, int N,
; innocuous = TRUE; break;
case VERSION_CLSW: {
PRINT("inweb");
char *svn = "7-alpha.1+1A04";
char *svn = "7-alpha.1+1A05";
if (svn[0]) PRINT(" version %s", svn);
char *vname = "Escape to Danger";
if (vname[0]) PRINT(" '%s'", vname);
char *d = "27 March 2020";
char *d = "28 March 2020";
if (d[0]) PRINT(" (%s)", d);
PRINT("\n");
innocuous = TRUE; break;
@ -13683,9 +13684,9 @@ module *Modules__find_loaded_by_name(text_file_position *tfp, text_stream *name)
return NULL;
}
#line 39 "inweb/Chapter 2/Line Categories.w"
#line 40 "inweb/Chapter 2/Line Categories.w"
#line 41 "inweb/Chapter 2/Line Categories.w"
#line 42 "inweb/Chapter 2/Line Categories.w"
source_line *Lines__new_source_line(text_stream *line, text_file_position *tfp) {
source_line *sl = CREATE(source_line);
sl->text = Str__duplicate(line);
@ -13694,6 +13695,7 @@ source_line *Lines__new_source_line(text_stream *line, text_file_position *tfp)
sl->category = NO_LCAT; /* that is, unknown category as yet */
sl->command_code = NO_CMD;
sl->default_defn = FALSE;
sl->is_commentary = FALSE;
sl->function_defined = NULL;
sl->preform_nonterminal_defined = NULL;
@ -13708,11 +13710,11 @@ source_line *Lines__new_source_line(text_stream *line, text_file_position *tfp)
return sl;
}
#line 71 "inweb/Chapter 2/Line Categories.w"
#line 73 "inweb/Chapter 2/Line Categories.w"
#line 95 "inweb/Chapter 2/Line Categories.w"
#line 97 "inweb/Chapter 2/Line Categories.w"
#line 100 "inweb/Chapter 2/Line Categories.w"
#line 102 "inweb/Chapter 2/Line Categories.w"
char *Lines__category_name(int cat) {
switch (cat) {
case NO_LCAT: return "(uncategorised)";
@ -13744,7 +13746,7 @@ char *Lines__category_name(int cat) {
return "(?unknown)";
}
#line 140 "inweb/Chapter 2/Line Categories.w"
#line 142 "inweb/Chapter 2/Line Categories.w"
#line 17 "inweb/Chapter 2/The Parser.w"
void Parser__parse_web(web *W, int inweb_mode) {
@ -14160,7 +14162,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
#line 382 "inweb/Chapter 2/The Parser.w"
if (Str__eq_wide_string(command_text, L"Purpose:"))
{
#line 424 "inweb/Chapter 2/The Parser.w"
#line 429 "inweb/Chapter 2/The Parser.w"
if (before_bar == FALSE) Main__error_in_web(TL_IS_109, L);
if (S->using_syntax >= V2_SYNTAX)
Parser__wrong_version(S->using_syntax, L, "'@Purpose'", V1_SYNTAX);
@ -14174,7 +14176,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
else if (Str__eq_wide_string(command_text, L"Interface:"))
{
#line 433 "inweb/Chapter 2/The Parser.w"
#line 438 "inweb/Chapter 2/The Parser.w"
if (S->using_syntax >= V2_SYNTAX)
Parser__wrong_version(S->using_syntax, L, "'@Interface'", V1_SYNTAX);
if (before_bar == FALSE) Main__error_in_web(TL_IS_110, L);
@ -14193,7 +14195,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
else if (Str__eq_wide_string(command_text, L"Definitions:"))
{
#line 447 "inweb/Chapter 2/The Parser.w"
#line 452 "inweb/Chapter 2/The Parser.w"
if (S->using_syntax >= V2_SYNTAX)
Parser__wrong_version(S->using_syntax, L, "'@Definitions' headings", V1_SYNTAX);
if (before_bar == FALSE) Main__error_in_web(TL_IS_111, L);
@ -14207,7 +14209,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
else if (Regexp__match(&mr, command_text, L"----+"))
{
#line 459 "inweb/Chapter 2/The Parser.w"
#line 464 "inweb/Chapter 2/The Parser.w"
if (S->using_syntax >= V2_SYNTAX)
Parser__wrong_version(S->using_syntax, L, "the bar '----...'", V1_SYNTAX);
if (before_bar == FALSE) Main__error_in_web(TL_IS_112, L);
@ -14226,7 +14228,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
((S->using_syntax == V1_SYNTAX) && (Str__eq_wide_string(command_text, L"e"))))
{
#line 476 "inweb/Chapter 2/The Parser.w"
#line 481 "inweb/Chapter 2/The Parser.w"
if (S->using_syntax > V1_SYNTAX)
Parser__wrong_version(S->using_syntax, L, "'@c' and '@x'", V1_SYNTAX);
L->category = BEGIN_CODE_LCAT;
@ -14241,7 +14243,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
else if (Str__eq_wide_string(command_text, L"d"))
{
#line 489 "inweb/Chapter 2/The Parser.w"
#line 494 "inweb/Chapter 2/The Parser.w"
L->category = BEGIN_DEFINITION_LCAT;
code_lcat_for_body = CONT_DEFINITION_LCAT;
match_results mr = Regexp__create_mr();
@ -14265,7 +14267,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
Parser__wrong_version(S->using_syntax, L, "'@define' for definitions (use '@d' instead)", V2_SYNTAX);
{
#line 489 "inweb/Chapter 2/The Parser.w"
#line 494 "inweb/Chapter 2/The Parser.w"
L->category = BEGIN_DEFINITION_LCAT;
code_lcat_for_body = CONT_DEFINITION_LCAT;
match_results mr = Regexp__create_mr();
@ -14283,10 +14285,35 @@ void Parser__parse_web(web *W, int inweb_mode) {
}
#line 394 "inweb/Chapter 2/The Parser.w"
;
} else if (Str__eq_wide_string(command_text, L"default")) {
if (S->using_syntax < V2_SYNTAX)
Parser__wrong_version(S->using_syntax, L, "'@default' for definitions", V2_SYNTAX);
L->default_defn = TRUE;
{
#line 494 "inweb/Chapter 2/The Parser.w"
L->category = BEGIN_DEFINITION_LCAT;
code_lcat_for_body = CONT_DEFINITION_LCAT;
match_results mr = Regexp__create_mr();
if (Regexp__match(&mr, remainder, L"(%C+) (%c+)")) {
L->text_operand = Str__duplicate(mr.exp[0]); /* name of term defined */
L->text_operand2 = Str__duplicate(mr.exp[1]); /* Value */
} else {
L->text_operand = Str__duplicate(remainder); /* name of term defined */
L->text_operand2 = Str__new(); /* no value given */
}
Analyser__mark_reserved_word(S, L->text_operand, CONSTANT_COLOUR);
comment_mode = FALSE;
L->is_commentary = FALSE;
Regexp__dispose_of(&mr);
}
#line 399 "inweb/Chapter 2/The Parser.w"
;
} else if (Str__eq_wide_string(command_text, L"enum"))
{
#line 508 "inweb/Chapter 2/The Parser.w"
#line 513 "inweb/Chapter 2/The Parser.w"
L->category = BEGIN_DEFINITION_LCAT;
text_stream *from = NULL;
match_results mr = Regexp__create_mr();
@ -14315,12 +14342,12 @@ void Parser__parse_web(web *W, int inweb_mode) {
Regexp__dispose_of(&mr);
}
#line 395 "inweb/Chapter 2/The Parser.w"
#line 400 "inweb/Chapter 2/The Parser.w"
else if ((Str__eq_wide_string(command_text, L"e")) && (S->using_syntax >= V2_SYNTAX))
{
#line 508 "inweb/Chapter 2/The Parser.w"
#line 513 "inweb/Chapter 2/The Parser.w"
L->category = BEGIN_DEFINITION_LCAT;
text_stream *from = NULL;
match_results mr = Regexp__create_mr();
@ -14349,7 +14376,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
Regexp__dispose_of(&mr);
}
#line 397 "inweb/Chapter 2/The Parser.w"
#line 402 "inweb/Chapter 2/The Parser.w"
else {
int weight = -1, new_page = FALSE;
@ -14371,7 +14398,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
}
if (weight >= 0)
{
#line 560 "inweb/Chapter 2/The Parser.w"
#line 565 "inweb/Chapter 2/The Parser.w"
comment_mode = TRUE;
L->is_commentary = TRUE;
L->category = PARAGRAPH_START_LCAT;
@ -14390,7 +14417,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
}
{
#line 607 "inweb/Chapter 2/The Parser.w"
#line 612 "inweb/Chapter 2/The Parser.w"
paragraph *P = CREATE(paragraph);
if (S->using_syntax > V1_SYNTAX) {
P->above_bar = FALSE;
@ -14423,7 +14450,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
current_paragraph = P;
}
#line 576 "inweb/Chapter 2/The Parser.w"
#line 581 "inweb/Chapter 2/The Parser.w"
;
L->owning_paragraph = current_paragraph;
@ -14431,7 +14458,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
Regexp__dispose_of(&mr);
}
#line 416 "inweb/Chapter 2/The Parser.w"
#line 421 "inweb/Chapter 2/The Parser.w"
else Main__error_in_web(TL_IS_108, L);
}
@ -14449,7 +14476,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
;
if (comment_mode)
{
#line 641 "inweb/Chapter 2/The Parser.w"
#line 646 "inweb/Chapter 2/The Parser.w"
match_results mr = Regexp__create_mr();
if (Regexp__match(&mr, L->text, L">> (%c+)")) {
L->category = SOURCE_DISPLAY_LCAT;
@ -14462,7 +14489,7 @@ void Parser__parse_web(web *W, int inweb_mode) {
;
if (comment_mode == FALSE)
{
#line 653 "inweb/Chapter 2/The Parser.w"
#line 658 "inweb/Chapter 2/The Parser.w"
if ((L->category != BEGIN_DEFINITION_LCAT) && (L->category != COMMAND_LCAT))
L->category = code_lcat_for_body;
@ -14515,9 +14542,9 @@ void Parser__parse_web(web *W, int inweb_mode) {
Languages__further_parsing(W, W->main_language);
}
#line 605 "inweb/Chapter 2/The Parser.w"
#line 610 "inweb/Chapter 2/The Parser.w"
#line 670 "inweb/Chapter 2/The Parser.w"
#line 675 "inweb/Chapter 2/The Parser.w"
text_stream *Parser__extract_purpose(text_stream *prologue, source_line *XL, section *S, source_line **adjust) {
text_stream *P = Str__duplicate(prologue);
while ((XL) && (XL->next_line) && (XL->owning_section == S) &&
@ -14533,7 +14560,7 @@ text_stream *Parser__extract_purpose(text_stream *prologue, source_line *XL, sec
return P;
}
#line 691 "inweb/Chapter 2/The Parser.w"
#line 696 "inweb/Chapter 2/The Parser.w"
void Parser__wrong_version(int using, source_line *L, char *feature, int need) {
TEMPORARY_TEXT(warning);
WRITE_TO(warning, "%s is a feature available only in version %d syntax (you're using version %d)",
@ -16891,19 +16918,50 @@ void Tangler__go(web *W, tangle_target *target, filename *dest_file) {
chapter *C;
section *S;
LOOP_WITHIN_TANGLE(C, S, target)
if (L->category == BEGIN_DEFINITION_LCAT) {
if (L->owning_paragraph == NULL) Main__error_in_web(TL_IS_200, L);
else Tags__open_ifdefs(OUT, L->owning_paragraph);
Languages__start_definition(OUT, lang,
L->text_operand,
L->text_operand2, S, L);
while ((L->next_line) && (L->next_line->category == CONT_DEFINITION_LCAT)) {
L = L->next_line;
Languages__prolong_definition(OUT, lang, L->text, S, L);
if (L->category == BEGIN_DEFINITION_LCAT)
if (L->default_defn == FALSE)
{
#line 87 "inweb/Chapter 3/The Tangler.w"
if (L->owning_paragraph == NULL) Main__error_in_web(TL_IS_200, L);
else Tags__open_ifdefs(OUT, L->owning_paragraph);
Languages__start_definition(OUT, lang,
L->text_operand,
L->text_operand2, S, L);
while ((L->next_line) && (L->next_line->category == CONT_DEFINITION_LCAT)) {
L = L->next_line;
Languages__prolong_definition(OUT, lang, L->text, S, L);
}
Languages__end_definition(OUT, lang, S, L);
if (L->owning_paragraph) Tags__close_ifdefs(OUT, L->owning_paragraph);
}
#line 76 "inweb/Chapter 3/The Tangler.w"
;
LOOP_WITHIN_TANGLE(C, S, target)
if (L->category == BEGIN_DEFINITION_LCAT)
if (L->default_defn) {
Languages__open_ifdef(OUT, lang, L->text_operand, FALSE);
{
#line 87 "inweb/Chapter 3/The Tangler.w"
if (L->owning_paragraph == NULL) Main__error_in_web(TL_IS_200, L);
else Tags__open_ifdefs(OUT, L->owning_paragraph);
Languages__start_definition(OUT, lang,
L->text_operand,
L->text_operand2, S, L);
while ((L->next_line) && (L->next_line->category == CONT_DEFINITION_LCAT)) {
L = L->next_line;
Languages__prolong_definition(OUT, lang, L->text, S, L);
}
Languages__end_definition(OUT, lang, S, L);
if (L->owning_paragraph) Tags__close_ifdefs(OUT, L->owning_paragraph);
}
#line 81 "inweb/Chapter 3/The Tangler.w"
;
Languages__close_ifdef(OUT, lang, L->text_operand, FALSE);
}
Languages__end_definition(OUT, lang, S, L);
if (L->owning_paragraph) Tags__close_ifdefs(OUT, L->owning_paragraph);
}
Enumerations__define_extents(OUT, target, lang);
}
@ -16933,7 +16991,7 @@ void Tangler__go(web *W, tangle_target *target, filename *dest_file) {
{
#line 90 "inweb/Chapter 3/The Tangler.w"
#line 100 "inweb/Chapter 3/The Tangler.w"
filename *F;
LOOP_OVER_LINKED_LIST(F, filename, W->headers)
Shell__copy(F, Reader__tangled_folder(W), "");
@ -16944,7 +17002,7 @@ void Tangler__go(web *W, tangle_target *target, filename *dest_file) {
Languages__additional_tangling(lang, W, target);
}
#line 99 "inweb/Chapter 3/The Tangler.w"
#line 109 "inweb/Chapter 3/The Tangler.w"
void Tangler__tangle_paragraph(OUTPUT_STREAM, paragraph *P) {
Tags__open_ifdefs(OUT, P);
int contiguous = FALSE;
@ -16953,14 +17011,14 @@ void Tangler__tangle_paragraph(OUTPUT_STREAM, paragraph *P) {
if (Languages__will_insert_in_tangle(P->under_section->sect_language, L)) {
{
#line 124 "inweb/Chapter 3/The Tangler.w"
#line 134 "inweb/Chapter 3/The Tangler.w"
if (contiguous == FALSE) {
contiguous = TRUE;
Languages__insert_line_marker(OUT, P->under_section->sect_language, L);
}
}
#line 105 "inweb/Chapter 3/The Tangler.w"
#line 115 "inweb/Chapter 3/The Tangler.w"
;
Languages__insert_in_tangle(OUT, P->under_section->sect_language, L);
}
@ -16969,14 +17027,14 @@ void Tangler__tangle_paragraph(OUTPUT_STREAM, paragraph *P) {
} else {
{
#line 124 "inweb/Chapter 3/The Tangler.w"
#line 134 "inweb/Chapter 3/The Tangler.w"
if (contiguous == FALSE) {
contiguous = TRUE;
Languages__insert_line_marker(OUT, P->under_section->sect_language, L);
}
}
#line 111 "inweb/Chapter 3/The Tangler.w"
#line 121 "inweb/Chapter 3/The Tangler.w"
;
Tangler__tangle_code(OUT, L->text, P->under_section, L); WRITE("\n");
}
@ -16984,7 +17042,7 @@ void Tangler__tangle_paragraph(OUTPUT_STREAM, paragraph *P) {
Tags__close_ifdefs(OUT, P);
}
#line 134 "inweb/Chapter 3/The Tangler.w"
#line 144 "inweb/Chapter 3/The Tangler.w"
void Tangler__tangle_code(OUTPUT_STREAM, text_stream *original, section *S, source_line *L) {
int mlen, slen;
int mpos = Regexp__find_expansion(original, '@', '<', '@', '>', &mlen);
@ -16993,7 +17051,7 @@ void Tangler__tangle_code(OUTPUT_STREAM, text_stream *original, section *S, sour
(Languages__allow_expansion(S->sect_language, original)))
{
#line 166 "inweb/Chapter 3/The Tangler.w"
#line 176 "inweb/Chapter 3/The Tangler.w"
TEMPORARY_TEXT(temp);
Str__copy(temp, original); Str__truncate(temp, mpos);
Languages__tangle_code(OUT, S->sect_language, temp);
@ -17019,12 +17077,12 @@ void Tangler__tangle_code(OUTPUT_STREAM, text_stream *original, section *S, sour
DISCARD_TEXT(temp);
}
#line 140 "inweb/Chapter 3/The Tangler.w"
#line 150 "inweb/Chapter 3/The Tangler.w"
else if (spos >= 0)
{
#line 206 "inweb/Chapter 3/The Tangler.w"
#line 216 "inweb/Chapter 3/The Tangler.w"
web *W = S->owning_chapter->owning_web;
TEMPORARY_TEXT(temp);
@ -17047,13 +17105,13 @@ void Tangler__tangle_code(OUTPUT_STREAM, text_stream *original, section *S, sour
DISCARD_TEXT(temp);
}
#line 142 "inweb/Chapter 3/The Tangler.w"
#line 152 "inweb/Chapter 3/The Tangler.w"
else
Languages__tangle_code(OUT, S->sect_language, original); /* this is usually what happens */
}
#line 231 "inweb/Chapter 3/The Tangler.w"
#line 241 "inweb/Chapter 3/The Tangler.w"
tangle_target *Tangler__primary_target(web *W) {
if (W == NULL) internal_error("no such web");
return FIRST_IN_LINKED_LIST(tangle_target, W->tangle_targets);

View file

@ -74,7 +74,7 @@ because the loggers don't use format strings.)
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">void</span><span class="plain"> (*</span><span class="identifier">writer_function_I</span><span class="plain">)(</span><span class="reserved">text_stream</span><span class="plain"> *, </span><span class="reserved">char</span><span class="plain"> *, </span><span class="reserved">int</span><span class="plain">);</span>
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">void</span><span class="plain"> (*</span><span class="identifier">log_function</span><span class="plain">)(</span><span class="reserved">text_stream</span><span class="plain"> *, </span><span class="reserved">void</span><span class="plain"> *);</span>
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">void</span><span class="plain"> (*</span><span class="identifier">log_function_I</span><span class="plain">)(</span><span class="reserved">text_stream</span><span class="plain"> *, </span><span class="reserved">int</span><span class="plain">);</span>
<span class="plain">#</span><span class="identifier">ifdef</span><span class="plain"> </span><span class="identifier">WORDING_LOGS_ALLOWED</span>
<span class="plain">#</span><span class="identifier">ifdef</span><span class="plain"> </span><span class="identifier">WORDS_MODULE</span>
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">void</span><span class="plain"> (*</span><span class="identifier">writer_function_W</span><span class="plain">)(</span><span class="reserved">text_stream</span><span class="plain"> *, </span><span class="reserved">char</span><span class="plain"> *, </span><span class="identifier">wording</span><span class="plain">);</span>
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">void</span><span class="plain"> (*</span><span class="identifier">log_function_W</span><span class="plain">)(</span><span class="reserved">text_stream</span><span class="plain"> *, </span><span class="identifier">wording</span><span class="plain">);</span>
<span class="plain">#</span><span class="identifier">endif</span>
@ -121,7 +121,7 @@ because the loggers don't use format strings.)
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Writers::register_logger_I</span><span class="plain">(</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">esc</span><span class="plain">, </span><span class="reserved">void</span><span class="plain"> (*</span><span class="identifier">f</span><span class="plain">)(</span><span class="reserved">text_stream</span><span class="plain"> *, </span><span class="reserved">int</span><span class="plain">)) {</span>
<span class="functiontext">Writers::register_writer_p</span><span class="plain">(1, </span><span class="identifier">esc</span><span class="plain">, (</span><span class="reserved">void</span><span class="plain"> *) </span><span class="identifier">f</span><span class="plain">, </span><span class="constant">INTSIZED_ECAT</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">#</span><span class="identifier">ifdef</span><span class="plain"> </span><span class="identifier">WORDING_LOGS_ALLOWED</span>
<span class="plain">#</span><span class="identifier">ifdef</span><span class="plain"> </span><span class="identifier">WORDS_MODULE</span>
<span class="plain">#</span><span class="identifier">define</span><span class="plain"> </span><span class="identifier">Writers::register_writer_W</span><span class="plain">(</span><span class="identifier">esc</span><span class="plain">, </span><span class="identifier">f</span><span class="plain">) </span><span class="functiontext">Writers::register_writer_p</span><span class="plain">(0, </span><span class="identifier">esc</span><span class="plain">, (</span><span class="reserved">void</span><span class="plain"> *) </span><span class="identifier">f</span><span class="plain">, </span><span class="constant">WORDING_ECAT</span><span class="plain">);</span>
<span class="plain">#</span><span class="identifier">define</span><span class="plain"> </span><span class="identifier">Writers::register_logger_W</span><span class="plain">(</span><span class="identifier">esc</span><span class="plain">, </span><span class="identifier">f</span><span class="plain">) </span><span class="functiontext">Writers::register_writer_p</span><span class="plain">(1, </span><span class="identifier">esc</span><span class="plain">, (</span><span class="reserved">void</span><span class="plain"> *) </span><span class="identifier">f</span><span class="plain">, </span><span class="constant">WORDING_ECAT</span><span class="plain">);</span>
<span class="plain">#</span><span class="identifier">endif</span>
@ -285,7 +285,7 @@ waiting for:
<span class="reserved">break</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">WORDING_ECAT</span><span class="plain">: {</span>
<span class="plain">#</span><span class="identifier">ifdef</span><span class="plain"> </span><span class="identifier">WORDING_LOGS_ALLOWED</span>
<span class="plain">#</span><span class="identifier">ifdef</span><span class="plain"> </span><span class="identifier">WORDS_MODULE</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">set</span><span class="plain"> == 0) {</span>
<span class="identifier">writer_function_W</span><span class="plain"> </span><span class="identifier">f</span><span class="plain"> = (</span><span class="identifier">writer_function_W</span><span class="plain">) </span><span class="identifier">the_escapes</span><span class="plain">[0][</span><span class="identifier">esc_number</span><span class="plain">];</span>
<span class="identifier">wording</span><span class="plain"> </span><span class="identifier">W</span><span class="plain"> = </span><span class="identifier">va_arg</span><span class="plain">(</span><span class="identifier">ap</span><span class="plain">, </span><span class="identifier">wording</span><span class="plain">);</span>

View file

@ -510,7 +510,7 @@ source:
<p class="inwebparagraph"></p>
<p class="endnote">The function Main::error_in_web is used in 1/cnf (<a href="1-cnf.html#SP5">&#167;5</a>), 2/tp (<a href="2-tp.html#SP1_1_6_3">&#167;1.1.6.3</a>, <a href="2-tp.html#SP1_1_6_4">&#167;1.1.6.4</a>, <a href="2-tp.html#SP1_1_6_6">&#167;1.1.6.6</a>, <a href="2-tp.html#SP1_1_6_5_1">&#167;1.1.6.5.1</a>, <a href="2-tp.html#SP1_1_6_5_1_1">&#167;1.1.6.5.1.1</a>, <a href="2-tp.html#SP1_1_6_5_1_2">&#167;1.1.6.5.1.2</a>, <a href="2-tp.html#SP1_1_6_5_1_3">&#167;1.1.6.5.1.3</a>, <a href="2-tp.html#SP1_1_6_5_1_4">&#167;1.1.6.5.1.4</a>, <a href="2-tp.html#SP1_1_6_5_1_7">&#167;1.1.6.5.1.7</a>, <a href="2-tp.html#SP3">&#167;3</a>), 2/ec (<a href="2-ec.html#SP3_1">&#167;3.1</a>, <a href="2-ec.html#SP3_2">&#167;3.2</a>, <a href="2-ec.html#SP3_3">&#167;3.3</a>), 3/ta (<a href="3-ta.html#SP4_1">&#167;4.1</a>), 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>, <a href="3-tt.html#SP3_1">&#167;3.1</a>), 4/pl (<a href="4-pl.html#SP10">&#167;10</a>), 4/cl (<a href="4-cl.html#SP3">&#167;3</a>, <a href="4-cl.html#SP3_1">&#167;3.1</a>, <a href="4-cl.html#SP3_4_2_1">&#167;3.4.2.1</a>, <a href="4-cl.html#SP3_4_2_5">&#167;3.4.2.5</a>, <a href="4-cl.html#SP22">&#167;22</a>).</p>
<p class="endnote">The function Main::error_in_web is used in 1/cnf (<a href="1-cnf.html#SP5">&#167;5</a>), 2/tp (<a href="2-tp.html#SP1_1_6_3">&#167;1.1.6.3</a>, <a href="2-tp.html#SP1_1_6_4">&#167;1.1.6.4</a>, <a href="2-tp.html#SP1_1_6_6">&#167;1.1.6.6</a>, <a href="2-tp.html#SP1_1_6_5_1">&#167;1.1.6.5.1</a>, <a href="2-tp.html#SP1_1_6_5_1_1">&#167;1.1.6.5.1.1</a>, <a href="2-tp.html#SP1_1_6_5_1_2">&#167;1.1.6.5.1.2</a>, <a href="2-tp.html#SP1_1_6_5_1_3">&#167;1.1.6.5.1.3</a>, <a href="2-tp.html#SP1_1_6_5_1_4">&#167;1.1.6.5.1.4</a>, <a href="2-tp.html#SP1_1_6_5_1_7">&#167;1.1.6.5.1.7</a>, <a href="2-tp.html#SP3">&#167;3</a>), 2/ec (<a href="2-ec.html#SP3_1">&#167;3.1</a>, <a href="2-ec.html#SP3_2">&#167;3.2</a>, <a href="2-ec.html#SP3_3">&#167;3.3</a>), 3/ta (<a href="3-ta.html#SP4_1">&#167;4.1</a>), 3/tt (<a href="3-tt.html#SP1_1_1_1">&#167;1.1.1.1</a>, <a href="3-tt.html#SP3_1">&#167;3.1</a>), 4/pl (<a href="4-pl.html#SP10">&#167;10</a>), 4/cl (<a href="4-cl.html#SP3">&#167;3</a>, <a href="4-cl.html#SP3_1">&#167;3.1</a>, <a href="4-cl.html#SP3_4_2_1">&#167;3.4.2.1</a>, <a href="4-cl.html#SP3_4_2_5">&#167;3.4.2.5</a>, <a href="4-cl.html#SP22">&#167;22</a>).</p>
<hr class="tocbar">
<ul class="toc"><li><a href="1-bsc.html">Back to 'Basics'</a></li><li><a href="1-cnf.html">Continue with 'Configuration'</a></li></ul><hr class="tocbar">

View file

@ -51,6 +51,7 @@ correspond to one of these:
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">category</span><span class="plain">; </span> <span class="comment">what sort of line this is: an <code class="display"><span class="extract">*_LCAT</span></code> value</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">command_code</span><span class="plain">; </span> <span class="comment">used only for <code class="display"><span class="extract">COMMAND_LCAT</span></code> lines: a <code class="display"><span class="extract">*_CMD</span></code> value</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">default_defn</span><span class="plain">; </span> <span class="comment">used only for <code class="display"><span class="extract">BEGIN_DEFINITION_LCAT</span></code> lines</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">is_commentary</span><span class="plain">; </span> <span class="comment">flag</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="reserved">function</span><span class="plain"> *</span><span class="identifier">function_defined</span><span class="plain">; </span> <span class="comment">if any C-like function is defined on this line</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="reserved">preform_nonterminal</span><span class="plain"> *</span><span class="identifier">preform_nonterminal_defined</span><span class="plain">; </span> <span class="comment">similarly</span>
@ -81,6 +82,7 @@ correspond to one of these:
<span class="identifier">sl</span><span class="plain">-</span><span class="element">&gt;category</span><span class="plain"> = </span><span class="constant">NO_LCAT</span><span class="plain">; </span> <span class="comment">that is, unknown category as yet</span>
<span class="identifier">sl</span><span class="plain">-</span><span class="element">&gt;command_code</span><span class="plain"> = </span><span class="constant">NO_CMD</span><span class="plain">;</span>
<span class="identifier">sl</span><span class="plain">-</span><span class="element">&gt;default_defn</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="identifier">sl</span><span class="plain">-</span><span class="element">&gt;is_commentary</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="identifier">sl</span><span class="plain">-</span><span class="element">&gt;function_defined</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">sl</span><span class="plain">-</span><span class="element">&gt;preform_nonterminal_defined</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>

View file

@ -215,9 +215,9 @@ doesn't specify a tag.)
<p class="inwebparagraph"></p>
<p class="endnote">The function Tags::open_ifdefs is used in 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>, <a href="3-tt.html#SP2">&#167;2</a>), 4/cl (<a href="4-cl.html#SP7">&#167;7</a>, <a href="4-cl.html#SP9_1">&#167;9.1</a>, <a href="4-cl.html#SP9_3">&#167;9.3</a>, <a href="4-cl.html#SP9_4">&#167;9.4</a>).</p>
<p class="endnote">The function Tags::open_ifdefs is used in 3/tt (<a href="3-tt.html#SP1_1_1_1">&#167;1.1.1.1</a>, <a href="3-tt.html#SP2">&#167;2</a>), 4/cl (<a href="4-cl.html#SP7">&#167;7</a>, <a href="4-cl.html#SP9_1">&#167;9.1</a>, <a href="4-cl.html#SP9_3">&#167;9.3</a>, <a href="4-cl.html#SP9_4">&#167;9.4</a>).</p>
<p class="endnote">The function Tags::close_ifdefs is used in 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>, <a href="3-tt.html#SP2">&#167;2</a>), 4/cl (<a href="4-cl.html#SP7">&#167;7</a>, <a href="4-cl.html#SP9_1">&#167;9.1</a>, <a href="4-cl.html#SP9_3">&#167;9.3</a>, <a href="4-cl.html#SP9_4">&#167;9.4</a>).</p>
<p class="endnote">The function Tags::close_ifdefs is used in 3/tt (<a href="3-tt.html#SP1_1_1_1">&#167;1.1.1.1</a>, <a href="3-tt.html#SP2">&#167;2</a>), 4/cl (<a href="4-cl.html#SP7">&#167;7</a>, <a href="4-cl.html#SP9_1">&#167;9.1</a>, <a href="4-cl.html#SP9_3">&#167;9.3</a>, <a href="4-cl.html#SP9_4">&#167;9.4</a>).</p>
<p class="endnote">The function Tags::show_endnote_on_ifdefs is used in 3/tw (<a href="3-tw.html#SP2">&#167;2</a>).</p>

View file

@ -632,6 +632,11 @@ long forms <code class="display"><span class="extract">@define</span></code>, <c
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;using_syntax</span><span class="plain"> &lt; </span><span class="constant">V2_SYNTAX</span><span class="plain">)</span>
<span class="functiontext">Parser::wrong_version</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;using_syntax</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">, </span><span class="string">"'@define' for definitions (use '@d' instead)"</span><span class="plain">, </span><span class="constant">V2_SYNTAX</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Deal with the define marker</span> <span class="cwebmacronumber">1.1.6.5.1.6</span>&gt;<span class="plain">;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::eq_wide_string</span><span class="plain">(</span><span class="identifier">command_text</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"default"</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;using_syntax</span><span class="plain"> &lt; </span><span class="constant">V2_SYNTAX</span><span class="plain">)</span>
<span class="functiontext">Parser::wrong_version</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;using_syntax</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">, </span><span class="string">"'@default' for definitions"</span><span class="plain">, </span><span class="constant">V2_SYNTAX</span><span class="plain">);</span>
<span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;default_defn</span><span class="plain"> = </span><span class="constant">TRUE</span><span class="plain">;</span>
&lt;<span class="cwebmacro">Deal with the define marker</span> <span class="cwebmacronumber">1.1.6.5.1.6</span>&gt;<span class="plain">;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::eq_wide_string</span><span class="plain">(</span><span class="identifier">command_text</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"enum"</span><span class="plain">)) </span>&lt;<span class="cwebmacro">Deal with the enumeration marker</span> <span class="cwebmacronumber">1.1.6.5.1.7</span>&gt;
<span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> ((</span><span class="functiontext">Str::eq_wide_string</span><span class="plain">(</span><span class="identifier">command_text</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"e"</span><span class="plain">)) &amp;&amp; (</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;using_syntax</span><span class="plain"> &gt;= </span><span class="constant">V2_SYNTAX</span><span class="plain">))</span>
&lt;<span class="cwebmacro">Deal with the enumeration marker</span> <span class="cwebmacronumber">1.1.6.5.1.7</span>&gt;
@ -812,7 +817,7 @@ C preprocessor macros, Inform 6 <code class="display"><span class="extract">Cons
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP1_1_6_5_1">&#167;1.1.6.5.1</a> (twice).</p>
<p class="endnote">This code is used in <a href="#SP1_1_6_5_1">&#167;1.1.6.5.1</a> (three times).</p>
<p class="inwebparagraph"><a id="SP1_1_6_5_1_7"></a><b>&#167;1.1.6.5.1.7. </b>This is for <code class="display"><span class="extract">@e</span></code> (in version 2) and <code class="display"><span class="extract">@enum</span></code>, which makes an automatically
enumerated sort of <code class="display"><span class="extract">@d</span></code>.

View file

@ -123,19 +123,16 @@ extend across multiple lines.
<span class="reserved">chapter</span><span class="plain"> *</span><span class="identifier">C</span><span class="plain">;</span>
<span class="reserved">section</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">;</span>
<span class="identifier">LOOP_WITHIN_TANGLE</span><span class="plain">(</span><span class="identifier">C</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">target</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;category</span><span class="plain"> == </span><span class="constant">BEGIN_DEFINITION_LCAT</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain"> == </span><span class="identifier">NULL</span><span class="plain">) </span><span class="functiontext">Main::error_in_web</span><span class="plain">(</span><span class="identifier">I</span><span class="string">"misplaced definition"</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="functiontext">Tags::open_ifdefs</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain">);</span>
<span class="functiontext">Languages::start_definition</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">,</span>
<span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text_operand</span><span class="plain">,</span>
<span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text_operand2</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="reserved">while</span><span class="plain"> ((</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;next_line</span><span class="plain">) &amp;&amp; (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;next_line</span><span class="plain">-</span><span class="element">&gt;category</span><span class="plain"> == </span><span class="constant">CONT_DEFINITION_LCAT</span><span class="plain">)) {</span>
<span class="identifier">L</span><span class="plain"> = </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;next_line</span><span class="plain">;</span>
<span class="functiontext">Languages::prolong_definition</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;category</span><span class="plain"> == </span><span class="constant">BEGIN_DEFINITION_LCAT</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;default_defn</span><span class="plain"> == </span><span class="constant">FALSE</span><span class="plain">)</span>
&lt;<span class="cwebmacro">Define the constant</span> <span class="cwebmacronumber">1.1.1.1</span>&gt;<span class="plain">;</span>
<span class="identifier">LOOP_WITHIN_TANGLE</span><span class="plain">(</span><span class="identifier">C</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">target</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;category</span><span class="plain"> == </span><span class="constant">BEGIN_DEFINITION_LCAT</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;default_defn</span><span class="plain">) {</span>
<span class="functiontext">Languages::open_ifdef</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text_operand</span><span class="plain">, </span><span class="constant">FALSE</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Define the constant</span> <span class="cwebmacronumber">1.1.1.1</span>&gt;<span class="plain">;</span>
<span class="functiontext">Languages::close_ifdef</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text_operand</span><span class="plain">, </span><span class="constant">FALSE</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="functiontext">Languages::end_definition</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain">) </span><span class="functiontext">Tags::close_ifdefs</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="functiontext">Enumerations::define_extents</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">target</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">);</span>
</pre>
@ -143,6 +140,29 @@ extend across multiple lines.
<p class="endnote">This code is used in <a href="#SP1_1">&#167;1.1</a>.</p>
<p class="inwebparagraph"><a id="SP1_1_1_1"></a><b>&#167;1.1.1.1. </b><code class="display">
&lt;<span class="cwebmacrodefn">Define the constant</span> <span class="cwebmacronumber">1.1.1.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain"> == </span><span class="identifier">NULL</span><span class="plain">) </span><span class="functiontext">Main::error_in_web</span><span class="plain">(</span><span class="identifier">I</span><span class="string">"misplaced definition"</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="functiontext">Tags::open_ifdefs</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain">);</span>
<span class="functiontext">Languages::start_definition</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">,</span>
<span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text_operand</span><span class="plain">,</span>
<span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text_operand2</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="reserved">while</span><span class="plain"> ((</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;next_line</span><span class="plain">) &amp;&amp; (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;next_line</span><span class="plain">-</span><span class="element">&gt;category</span><span class="plain"> == </span><span class="constant">CONT_DEFINITION_LCAT</span><span class="plain">)) {</span>
<span class="identifier">L</span><span class="plain"> = </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;next_line</span><span class="plain">;</span>
<span class="functiontext">Languages::prolong_definition</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;text</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="functiontext">Languages::end_definition</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">lang</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain">) </span><span class="functiontext">Tags::close_ifdefs</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">L</span><span class="plain">-</span><span class="element">&gt;owning_paragraph</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP1_1_1">&#167;1.1.1</a> (twice).</p>
<p class="inwebparagraph"><a id="SP1_2"></a><b>&#167;1.2. </b><code class="display">
&lt;<span class="cwebmacrodefn">Tangle any imported headers</span> <span class="cwebmacronumber">1.2</span>&gt; =
</code></p>

View file

@ -315,11 +315,11 @@ then subsequent lines are fed in order to <code class="display"><span class="ext
<p class="inwebparagraph"></p>
<p class="endnote">The function Languages::start_definition is used in 2/ec (<a href="2-ec.html#SP4">&#167;4</a>), 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>).</p>
<p class="endnote">The function Languages::start_definition is used in 2/ec (<a href="2-ec.html#SP4">&#167;4</a>), 3/tt (<a href="3-tt.html#SP1_1_1_1">&#167;1.1.1.1</a>).</p>
<p class="endnote">The function Languages::prolong_definition is used in 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>).</p>
<p class="endnote">The function Languages::prolong_definition is used in 3/tt (<a href="3-tt.html#SP1_1_1_1">&#167;1.1.1.1</a>).</p>
<p class="endnote">The function Languages::end_definition is used in 2/ec (<a href="2-ec.html#SP4">&#167;4</a>), 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>).</p>
<p class="endnote">The function Languages::end_definition is used in 2/ec (<a href="2-ec.html#SP4">&#167;4</a>), 3/tt (<a href="3-tt.html#SP1_1_1_1">&#167;1.1.1.1</a>).</p>
<p class="inwebparagraph"><a id="SP11"></a><b>&#167;11. </b>Then we have some "predeclarations"; for example, for C-like languages we
automatically predeclare all functions, obviating the need for header files.
@ -495,9 +495,9 @@ for a preprocessor to conditionally read: that is, to tangle code which contains
<p class="inwebparagraph"></p>
<p class="endnote">The function Languages::open_ifdef is used in 2/tgs (<a href="2-tgs.html#SP7">&#167;7</a>).</p>
<p class="endnote">The function Languages::open_ifdef is used in 2/tgs (<a href="2-tgs.html#SP7">&#167;7</a>), 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>).</p>
<p class="endnote">The function Languages::close_ifdef is used in 2/tgs (<a href="2-tgs.html#SP7">&#167;7</a>).</p>
<p class="endnote">The function Languages::close_ifdef is used in 2/tgs (<a href="2-tgs.html#SP7">&#167;7</a>), 3/tt (<a href="3-tt.html#SP1_1_1">&#167;1.1.1</a>).</p>
<p class="inwebparagraph"><a id="SP18"></a><b>&#167;18. </b>Now a routine to tangle a comment. Languages without comment should write nothing.
</p>

View file

@ -130,20 +130,21 @@ example shows all three being used:
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. </b>Definitions are made using one of two commands: <code class="display"><span class="extract">@d</span></code> or <code class="display"><span class="extract">@define</span></code>, or
<code class="display"><span class="extract">@e</span></code> or <code class="display"><span class="extract">@enum</span></code>. These create new constants in the program, with the values
given: they are the equivalent of a <code class="display"><span class="extract">#define</span></code> directive in C. <code class="display"><span class="extract">@define</span></code> is
the simpler form. For example,
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. </b>Definitions are made using one of three commands: <code class="display"><span class="extract">@d</span></code> or <code class="display"><span class="extract">@define</span></code>; or
<code class="display"><span class="extract">@e</span></code> or <code class="display"><span class="extract">@enum</span></code>; or <code class="display"><span class="extract">@default</span></code>, which is rarely used and has no abbreviation.
These create new constants in the program, with the values given: they are
the equivalent of a <code class="display"><span class="extract">#define</span></code> directive in C. <code class="display"><span class="extract">@define</span></code> is the simpler form.
For example,
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">@define USEFUL_PRIME 16339</span>
<span class="plain">@define ENIGMATIC_NUMBER 90125</span>
</pre>
<p class="inwebparagraph">sets <code class="display"><span class="extract">USEFUL_PRIME</span></code> to 16339. Unlike in the C preprocessor, multi-line
<p class="inwebparagraph">sets <code class="display"><span class="extract">ENIGMATIC_NUMBER</span></code> to 90125. Unlike in the C preprocessor, multi-line
definitions are automatically handled, so for example:
</p>
@ -207,6 +208,43 @@ the ones in which they are defined. (The tangler automatically arranges code
as necessary to make this work.)
</p>
<p class="inwebparagraph">A symbol defined with <code class="display"><span class="extract">@default</span></code> has the given value only if some other use
of <code class="display"><span class="extract">@d</span></code> or <code class="display"><span class="extract">@e</span></code> in the web has not already defined it. For example, if the
web contains:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">@default MAX_HEADROOM 100</span>
<span class="plain">@d MAX_HEADROOM 99</span>
</pre>
<p class="inwebparagraph">or
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">@d MAX_HEADROOM 99</span>
<span class="plain">@default MAX_HEADROOM 100</span>
</pre>
<p class="inwebparagraph">then the value is 99, but if only
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">@default MAX_HEADROOM 100</span>
</pre>
<p class="inwebparagraph">then the value is 100.
</p>
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. </b>Finally, a paragraph can contain code. This is introduced with an equals
sign: in some sense, the value of the paragraph is the code it contains.
In many paragraphs, as in the example above, the divider is just