Mercurial > hg-old > index.cgi
comparison lwasm/pragma.c @ 352:f5b77989f675
Added PRAGMA and *PRAGMA
author | lost@starbug |
---|---|
date | Tue, 30 Mar 2010 20:56:54 -0600 |
parents | 619fd6ad4ab9 |
children | a9521955554f |
comparison
equal
deleted
inserted
replaced
351:4dba8c7e242c | 352:f5b77989f675 |
---|---|
22 #include <config.h> | 22 #include <config.h> |
23 | 23 |
24 #include <lw_string.h> | 24 #include <lw_string.h> |
25 | 25 |
26 #include "lwasm.h" | 26 #include "lwasm.h" |
27 #include "instab.h" | |
27 | 28 |
28 struct pragma_list | 29 struct pragma_list |
29 { | 30 { |
30 const char *str; | 31 const char *str; |
31 int flag; | 32 int flag; |
49 { "nocescapes", PRAGMA_CESCAPES }, | 50 { "nocescapes", PRAGMA_CESCAPES }, |
50 { "noimportundefexport", PRAGMA_IMPORTUNDEFEXPORT }, | 51 { "noimportundefexport", PRAGMA_IMPORTUNDEFEXPORT }, |
51 { 0, 0 } | 52 { 0, 0 } |
52 }; | 53 }; |
53 | 54 |
54 int parse_pragma_string(asmstate_t *as, char *str) | 55 int parse_pragma_string(asmstate_t *as, char *str, int ignoreerr) |
55 { | 56 { |
56 char *p; | 57 char *p; |
57 int i; | 58 int i; |
58 const char *np = str; | 59 const char *np = str; |
59 int pragmas = as -> pragmas; | 60 int pragmas = as -> pragmas; |
76 pragmas &= ~(reset_pragmas[i].flag); | 77 pragmas &= ~(reset_pragmas[i].flag); |
77 goto out; | 78 goto out; |
78 } | 79 } |
79 } | 80 } |
80 /* unrecognized pragma here */ | 81 /* unrecognized pragma here */ |
81 lw_free(p); | 82 if (!ignoreerr) |
82 return 0; | 83 { |
83 | 84 lw_free(p); |
85 return 0; | |
86 } | |
84 out: | 87 out: |
85 lw_free(p); | 88 lw_free(p); |
86 } | 89 } |
87 as -> pragmas = pragmas; | 90 as -> pragmas = pragmas; |
88 return 1; | 91 return 1; |
89 } | 92 } |
93 | |
94 PARSEFUNC(pseudo_parse_pragma) | |
95 { | |
96 char *ps, *t; | |
97 | |
98 for (t = *p; *t && !isspace(*t); t++) | |
99 /* do nothing */ ; | |
100 | |
101 ps = lw_strndup(*p, t - *p); | |
102 *p = t; | |
103 | |
104 if (parse_pragma_string(as, ps, 0) == 0) | |
105 { | |
106 lwasm_register_error(as, l, "Unrecognized pragma string"); | |
107 } | |
108 lw_free(ps); | |
109 } | |
110 | |
111 PARSEFUNC(pseudo_parse_starpragma) | |
112 { | |
113 char *ps, *t; | |
114 | |
115 for (t = *p; *t && !isspace(*t); t++) | |
116 /* do nothing */ ; | |
117 | |
118 ps = lw_strndup(*p, t - *p); | |
119 *p = t; | |
120 | |
121 // *pragma must NEVER throw an error | |
122 parse_pragma_string(as, ps, 1); | |
123 lw_free(ps); | |
124 } |