28 lines
481 B
C
28 lines
481 B
C
#include "../gen.h"
|
|
|
|
void gen_output_expr(struct generator *gen, struct expr *expr)
|
|
{
|
|
int line = expr->line_no,
|
|
len = expr->byte_end - expr->byte_start,
|
|
nl = true,
|
|
c = EOF;
|
|
FILE *file = gen->parser.lexer.file;
|
|
|
|
fseek(file, expr->byte_start, SEEK_SET);
|
|
|
|
while (len--) {
|
|
c = getc(file);
|
|
if (c == EOF || c == '\0')
|
|
break;
|
|
if (nl) {
|
|
fprintf(stderr, "\t%d | ", line);
|
|
line++;
|
|
nl = false;
|
|
}
|
|
if (c == '\n')
|
|
nl = true;
|
|
putc(c, stderr);
|
|
}
|
|
|
|
}
|
|
|