comparison lwasm/macro.c @ 370:8764142b3192

Convert internal error/warning handling framework to a new unified system Replace the ad hoc error and warning handling with a new system that codifies the errors with specific codes. This makes it possible in the future for error numbers to be used for testing and other purposes. It also makes sure the error strings themselves are consistent. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 22 Jun 2015 18:49:38 -0600
parents 03f7192fcd20
children 39490cf2d1c2
comparison
equal deleted inserted replaced
369:682524a1f32f 370:8764142b3192
46 return; 46 return;
47 } 47 }
48 48
49 if (as -> inmacro) 49 if (as -> inmacro)
50 { 50 {
51 lwasm_register_error(as, l, "Attempt to define a macro inside a macro"); 51 lwasm_register_error(as, l, E_MACRO_RECURSE);
52 return; 52 return;
53 } 53 }
54 54
55 if (!(l -> sym)) 55 if (!(l -> sym))
56 { 56 {
57 lwasm_register_error(as, l, "Missing macro name"); 57 lwasm_register_error(as, l, E_MACRO_NONAME);
58 return; 58 return;
59 } 59 }
60 60
61 for (m = as -> macros; m; m = m -> next) 61 for (m = as -> macros; m; m = m -> next)
62 { 62 {
63 if (!strcmp(m -> name, l -> sym)) 63 if (!strcmp(m -> name, l -> sym))
64 break; 64 break;
65 } 65 }
66 if (m) 66 if (m)
67 { 67 {
68 lwasm_register_error(as, l, "Duplicate macro definition"); 68 lwasm_register_error(as, l, E_MACRO_DUPE);
69 return; 69 return;
70 } 70 }
71 71
72 m = lw_alloc(sizeof(macrotab_t)); 72 m = lw_alloc(sizeof(macrotab_t));
73 m -> name = lw_strdup(l -> sym); 73 m -> name = lw_strdup(l -> sym);
100 return; 100 return;
101 } 101 }
102 102
103 if (!as -> inmacro) 103 if (!as -> inmacro)
104 { 104 {
105 lwasm_register_error(as, l, "ENDM without MACRO"); 105 lwasm_register_error(as, l, E_MACRO_ENDM);
106 return; 106 return;
107 } 107 }
108 108
109 as -> inmacro = 0; 109 as -> inmacro = 0;
110 110