comparison lwasm/lwasm.h @ 519:724bcc4508bc

Add SETSTR/INCLUDESTR for some basic code building It seemed useful to have the ability to build up a variable containing arbitrary text and then to be able to include that in the assembly process like an include file. So add, undocumented for now, the following: SETTSTR varname="string" INCLUDESTSR "string" "string" must be enclosed in double quotes and may contain most of the usual escape sequences (\t, \r, etc.) as well as %(varname) to interpolate a variable value. To use it to create assembleable source code, you need to make sure it creates lines (ended by either \r or \n) with appropriate whitespace in appropriate places.
author William Astle <lost@l-w.ca>
date Sun, 19 Dec 2021 17:01:42 -0700
parents bab891d85a53
children e10618b48e68
comparison
equal deleted inserted replaced
518:b530ff19f7c0 519:724bcc4508bc
27 #endif 27 #endif
28 28
29 #include <lw_expr.h> 29 #include <lw_expr.h>
30 #include <lw_stringlist.h> 30 #include <lw_stringlist.h>
31 #include <lw_stack.h> 31 #include <lw_stack.h>
32 #include <lw_dict.h>
32 33
33 #include <version.h> 34 #include <version.h>
34 35
35 // these are allowed chars BELOW 0x80 for symbols 36 // these are allowed chars BELOW 0x80 for symbols
36 // first is symbol start chars, second is anywhere in symbol 37 // first is symbol start chars, second is anywhere in symbol
424 lw_stringlist_t input_files; // files to assemble 425 lw_stringlist_t input_files; // files to assemble
425 void *input_data; // opaque data used by the input system 426 void *input_data; // opaque data used by the input system
426 lw_stringlist_t include_list; // include paths 427 lw_stringlist_t include_list; // include paths
427 lw_stack_t file_dir; // stack of the "current file" dir 428 lw_stack_t file_dir; // stack of the "current file" dir
428 lw_stack_t includelist; 429 lw_stack_t includelist;
430 lw_dict_t stringvars; // dictionary of string variables (SETSTR/INCLUDESTR)
431
429 432
430 structtab_t *structs; // defined structures 433 structtab_t *structs; // defined structures
431 structtab_t *cstruct; // current structure 434 structtab_t *cstruct; // current structure
432 lw_expr_t savedaddr; // old address counter before struct started 435 lw_expr_t savedaddr; // old address counter before struct started
433 int exportcheck; // set if we need to collapse out the section base to 0 436 int exportcheck; // set if we need to collapse out the section base to 0
494 497
495 /* some functions for parsing */ 498 /* some functions for parsing */
496 /* skip to the start of the next token if the current parsing mode allows it */ 499 /* skip to the start of the next token if the current parsing mode allows it */
497 void lwasm_skip_to_next_token(line_t *cl, char **p); 500 void lwasm_skip_to_next_token(line_t *cl, char **p);
498 501
502 /* parse a generalized string enclosed in double quotes */
503 char *lwasm_parse_general_string(line_t *cl, char **p);
504
499 #endif /* ___lwasm_h_seen___ */ 505 #endif /* ___lwasm_h_seen___ */