Skip to content

Commit

Permalink
Modified the symbol error reporting functions to include colored aste…
Browse files Browse the repository at this point in the history
…risks.
  • Loading branch information
grnt426 committed Mar 7, 2012
1 parent 05e22c1 commit 3fd6a82
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions symbols.c
Expand Up @@ -11,6 +11,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "symbols.h"
#include "idents.h"
#include "strlib.h"

void add_symbol(char *iden, int val, struct symbol_table *tbl, int pos){
if(!tbl)
Expand Down Expand Up @@ -83,6 +85,9 @@ void print_symbols(struct symbol_table *tbl){
}

void print_symbol_not_found(const char *bad_sym, struct program *prog){
print_asterisk(RED_C, stderr);
fprintf(stderr, "%s:\n", prog->input);
print_asterisk(RED_C, stderr);
fprintf(stderr, "\tUnknown Symbol '%s'.\n", bad_sym);
prog->error_code = -1; // TODO: create actual error_code

Expand All @@ -91,8 +96,9 @@ void print_symbol_not_found(const char *bad_sym, struct program *prog){

void print_symbol_not_used(const struct symbol *sym, const char *sym_type,
const struct program *prog){

fprintf(stderr, "%s: %d:\n", prog->input, sym->pos);
print_asterisk(YLW_C, stderr);
fprintf(stderr, "%s, %d:\n", prog->input, sym->pos);
print_asterisk(YLW_C, stderr);
fprintf(stderr, "\tWarning: %s '%s' is not used.\n", sym_type, sym->iden);
}

0 comments on commit 3fd6a82

Please sign in to comment.