comparison lwasm/unicorns.c @ 222:03f7192fcd20

Add --unicorns option for IDE integration This version of unicorns adds RESOURCE: lines to the output which specify files and macros discovered during the assembly process.
author William Astle <lost@l-w.ca>
date Sun, 15 Jul 2012 10:50:46 -0600
parents
children 211fc8038b8d
comparison
equal deleted inserted replaced
221:2b784a28428e 222:03f7192fcd20
1 /*
2 unicorns.c
3
4 Copyright © 2012 William Astle
5
6 This file is part of LWTOOLS.
7
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation, either version 3 of the License, or (at your option) any later
11 version.
12
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 more details.
17
18 You should have received a copy of the GNU General Public License along with
19 this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 /*
23 This adds output to lwasm that is suitable for IDEs and other tools
24 that are interesting in the doings of the assembler.
25 */
26
27 #include <stdio.h>
28 #include <string.h>
29
30 #include "lwasm.h"
31 #include "lw_alloc.h"
32
33 void lwasm_do_unicorns(asmstate_t *as)
34 {
35 char *n;
36 macrotab_t *me;
37
38 /* output file list */
39 while ((n = lw_stack_pop(as -> includelist)))
40 {
41 fprintf(stdout, "RESOURCE: file:%s\n", n);
42 lw_free(n);
43 }
44
45 /* output macro list */
46 for (me = as -> macros; me; me = me -> next)
47 {
48 fprintf(stdout, "RESOURCE: macro:%s,%d,%s\n", me -> name, me -> definedat -> lineno, me -> definedat -> linespec);
49 }
50 }