Mercurial > hg > index.cgi
annotate lwasm/pragma.c @ 287:d2f04fa0103b ccdev
Set up .hgignore to ignore the lwcc driver program.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 08 Sep 2013 12:37:57 -0600 |
parents | 0c4b3e8b4d0b |
children | 507f442dc71e |
rev | line source |
---|---|
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
2 pragma.c |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
3 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
4 Copyright © 2010 William Astle |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
5 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
6 This file is part of LWTOOLS. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
7 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
8 LWTOOLS is free software: you can redistribute it and/or modify it under the |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
9 terms of the GNU General Public License as published by the Free Software |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
10 Foundation, either version 3 of the License, or (at your option) any later |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
11 version. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
12 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, but WITHOUT |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
16 more details. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
17 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License along with |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
19 this program. If not, see <http://www.gnu.org/licenses/>. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
20 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
21 |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
22 #include <string.h> |
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
23 #include <ctype.h> |
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
24 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
25 #include <lw_string.h> |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
26 #include <lw_alloc.h> |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
27 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
28 #include "lwasm.h" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
29 #include "instab.h" |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
30 #include "input.h" |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
31 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
32 struct pragma_list |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
33 { |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
34 const char *setstr; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
35 const char *resetstr; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
36 int flag; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
37 }; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
38 |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
39 struct pragma_stack_entry |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
40 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
41 int magic; // must always be at the start of any input stack entry |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
42 int flag; // the pragma flag bit |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
43 char str[1]; // magic number - this will be allocated bigger |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
44 // string will be what's needed to re-instate a pragma |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
45 }; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
46 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
47 static const struct pragma_list set_pragmas[] = |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
48 { |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
49 { "dollarnotlocal", "nodollarnotlocal", PRAGMA_DOLLARNOTLOCAL }, |
118
b6b8c2645f5c
Add back the dollarlocal and nodollarlocal pragma strings for compatibility with the documentation.
lost@l-w.ca
parents:
115
diff
changeset
|
50 { "nodollarlocal", "dollarlocal", PRAGMA_DOLLARNOTLOCAL }, |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
51 { "noindex0tonone", "index0tonone", PRAGMA_NOINDEX0TONONE }, |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
52 { "undefextern", "noundefextern", PRAGMA_UNDEFEXTERN }, |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
53 { "cescapes", "nocescapes", PRAGMA_CESCAPES }, |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
54 { "importundefexport", "noimportundefexport", PRAGMA_IMPORTUNDEFEXPORT }, |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
55 { "pcaspcr", "nopcaspcr", PRAGMA_PCASPCR }, |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
56 { "shadow", "noshadow", PRAGMA_SHADOW }, |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
57 { "nolist", "list", PRAGMA_NOLIST }, |
115
344cfc25afec
Added initial infrastructure for pragma autobranchlength (suggested by Ebonhand on irc)
lost@l-w.ca
parents:
110
diff
changeset
|
58 { "autobranchlength", "noautobranchlength", PRAGMA_AUTOBRANCHLENGTH }, |
206 | 59 { "export", "noexport", PRAGMA_EXPORT }, |
207
07e1fac76321
Added pragma to allow non case sensitive symbols
William Astle <lost@l-w.ca>
parents:
206
diff
changeset
|
60 { "symbolnocase", "nosymbolnocase", PRAGMA_SYMBOLNOCASE }, |
07e1fac76321
Added pragma to allow non case sensitive symbols
William Astle <lost@l-w.ca>
parents:
206
diff
changeset
|
61 { "nosymbolcase", "symbolcase", PRAGMA_SYMBOLNOCASE }, |
210 | 62 { "condundefzero", "nocondundefzero", PRAGMA_CONDUNDEFZERO }, |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
63 { 0, 0, 0} |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
64 }; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
65 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
66 int parse_pragma_string(asmstate_t *as, char *str, int ignoreerr) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
67 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
68 char *p; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
69 int i; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
70 const char *np = str; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
71 int pragmas = as -> pragmas; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
72 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
73 while (np) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
74 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
75 p = lw_token(np, ',', &np); |
259
0c4b3e8b4d0b
Fix pragma nosymbolcase interaction with -D
William Astle <lost@l-w.ca>
parents:
210
diff
changeset
|
76 debug_message(as, 200, "Setting pragma %s", p); |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
77 for (i = 0; set_pragmas[i].setstr; i++) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
78 { |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
79 if (!strcasecmp(p, set_pragmas[i].setstr)) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
80 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
81 pragmas |= set_pragmas[i].flag; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
82 goto out; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
83 } |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
84 if (!strcasecmp(p, set_pragmas[i].resetstr)) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
85 { |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
86 pragmas &= ~(set_pragmas[i].flag); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
87 goto out; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
88 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
89 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
90 /* unrecognized pragma here */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
91 if (!ignoreerr) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
92 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
93 lw_free(p); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
94 return 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
95 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
96 out: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
97 lw_free(p); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
98 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
99 as -> pragmas = pragmas; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
100 return 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
101 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
102 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
103 PARSEFUNC(pseudo_parse_pragma) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
104 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
105 char *ps, *t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
106 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
107 for (t = *p; *t && !isspace(*t); t++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
108 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
109 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
110 ps = lw_strndup(*p, t - *p); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
111 *p = t; |
56 | 112 |
113 l -> len = 0; | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
114 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
115 if (parse_pragma_string(as, ps, 0) == 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
116 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
117 lwasm_register_error(as, l, "Unrecognized pragma string"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
118 } |
81
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
56
diff
changeset
|
119 if (as -> pragmas & PRAGMA_NOLIST) |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
56
diff
changeset
|
120 l -> pragmas |= PRAGMA_NOLIST; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
121 lw_free(ps); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
122 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
123 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
124 PARSEFUNC(pseudo_parse_starpragma) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
125 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
126 char *ps, *t; |
85 | 127 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
128 for (t = *p; *t && !isspace(*t); t++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
129 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
130 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
131 ps = lw_strndup(*p, t - *p); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
132 *p = t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
133 |
56 | 134 l -> len = 0; |
135 | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
136 // *pragma must NEVER throw an error |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
137 parse_pragma_string(as, ps, 1); |
81
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
56
diff
changeset
|
138 if (as -> pragmas & PRAGMA_NOLIST) |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
56
diff
changeset
|
139 l -> pragmas |= PRAGMA_NOLIST; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
140 lw_free(ps); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
141 } |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
142 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
143 static int pragma_stack_compare(input_stack_entry *e, void *d) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
144 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
145 int flag = *((int *)d); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
146 struct pragma_stack_entry *pse = (struct pragma_stack_entry *)e; |
110 | 147 |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
148 if (pse -> flag == flag) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
149 return 1; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
150 return 0; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
151 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
152 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
153 PARSEFUNC(pseudo_parse_starpragmapop) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
154 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
155 char *ps, *t; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
156 char *pp; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
157 int i; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
158 const char *np; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
159 struct pragma_stack_entry *pse; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
160 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
161 for (t = *p; *t && !isspace(*t); t++) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
162 /* do nothing */ ; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
163 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
164 ps = lw_strndup(*p, t - *p); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
165 *p = t; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
166 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
167 l -> len = 0; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
168 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
169 // *pragma stuff must never throw an error |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
170 np = ps; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
171 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
172 while (np) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
173 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
174 pp = lw_token(np, ',', &np); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
175 for (i = 0; set_pragmas[i].setstr; i++) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
176 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
177 if (!strcasecmp(pp, set_pragmas[i].setstr) || !strcasecmp(pp, set_pragmas[i].resetstr)) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
178 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
179 pse = (struct pragma_stack_entry *)input_stack_pop(as, 0x42424242, pragma_stack_compare, (void *)&(set_pragmas[i].flag)); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
180 if (pse) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
181 { |
110 | 182 debug_message(as, 100, "Popped pragma string %s", pse->str); |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
183 parse_pragma_string(as, (char *)&(pse->str), 1); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
184 lw_free(pse); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
185 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
186 if (set_pragmas[i].flag == PRAGMA_NOLIST) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
187 l -> pragmas |= PRAGMA_NOLIST; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
188 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
189 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
190 lw_free(pp); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
191 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
192 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
193 lw_free(ps); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
194 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
195 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
196 PARSEFUNC(pseudo_parse_starpragmapush) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
197 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
198 char *ps, *t; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
199 char *pp; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
200 int i; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
201 const char *np; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
202 struct pragma_stack_entry *pse; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
203 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
204 for (t = *p; *t && !isspace(*t); t++) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
205 /* do nothing */ ; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
206 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
207 ps = lw_strndup(*p, t - *p); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
208 *p = t; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
209 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
210 l -> len = 0; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
211 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
212 // *pragma stuff must never throw an error |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
213 np = ps; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
214 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
215 while (np) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
216 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
217 pp = lw_token(np, ',', &np); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
218 for (i = 0; set_pragmas[i].setstr; i++) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
219 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
220 if (!strcasecmp(pp, set_pragmas[i].setstr) || !strcasecmp(pp, set_pragmas[i].resetstr)) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
221 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
222 /* found set or reset pragma */ |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
223 /* push pragma state */ |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
224 if (as -> pragmas & (set_pragmas[i].flag)) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
225 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
226 /* use set string */ |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
227 t = (char *)set_pragmas[i].setstr; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
228 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
229 else |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
230 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
231 /* use reset string */ |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
232 t = (char *)set_pragmas[i].resetstr; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
233 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
234 pse = lw_alloc(sizeof(struct pragma_stack_entry) + strlen(t)); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
235 pse -> flag = set_pragmas[i].flag; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
236 pse -> magic = 0x42424242; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
237 strcpy((char *)&(pse -> str), t); |
110 | 238 debug_message(as, 100, "Pushed pragma string %s", pse->str); |
239 | |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
240 input_stack_push(as, (input_stack_entry *)pse); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
241 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
242 if (set_pragmas[i].flag == PRAGMA_NOLIST) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
243 l -> pragmas |= PRAGMA_NOLIST; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
244 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
245 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
246 lw_free(pp); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
247 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
248 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
249 lw_free(ps); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
250 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
85
diff
changeset
|
251 |