Renamed viz -> printing, and tidied up the code a bit

This commit is contained in:
Bruce Hill 2021-01-08 01:06:43 -08:00
parent 668c7baf55
commit 03c790d5b6
5 changed files with 18 additions and 16 deletions

View File

@ -7,7 +7,7 @@ CWARN=-Wall -Wpedantic -Wextra -Wsign-conversion -Wtype-limits -Wunused-result
G=
O=-O3
CFILES=compiler.c grammar.c utils.c vm.c file_loader.c viz.c json.c
CFILES=compiler.c grammar.c utils.c vm.c file_loader.c printing.c json.c
OBJFILES=$(CFILES:.c=.o)
all: $(NAME)

2
bp.c
View File

@ -15,8 +15,8 @@
#include "file_loader.h"
#include "grammar.h"
#include "json.h"
#include "printing.h"
#include "utils.h"
#include "viz.h"
#include "vm.h"
static const char *usage = (

View File

@ -1,16 +1,21 @@
/*
* viz.c - Visualize matches.
* printing.c - Code for printing and visualizing matches.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "printing.h"
#include "types.h"
#include "utils.h"
#include "viz.h"
#include "vm.h"
typedef struct match_node_s {
match_t *m;
struct match_node_s *next;
} match_node_t;
typedef struct {
size_t line, printed_line;
const char *color;

View File

@ -1,13 +1,15 @@
/*
* Header file for viz.c (visualizing matches)
* Header file for printing.c (printing/visualizing matches)
*/
#ifndef VIZ__H
#define VIZ__H
#ifndef PRINTING__H
#define PRINTING__H
typedef struct match_node_s {
match_t *m;
struct match_node_s *next;
} match_node_t;
#include "types.h"
typedef enum {
PRINT_COLOR = 1<<0,
PRINT_LINE_NUMBERS = 1<<1,
} print_options_t;
__attribute__((nonnull))
void visualize_match(match_t *m);

5
vm.h
View File

@ -8,11 +8,6 @@
#include "types.h"
typedef enum {
PRINT_COLOR = 1<<0,
PRINT_LINE_NUMBERS = 1<<1,
} print_options_t;
const char *opcode_name(enum VMOpcode o);
__attribute__((hot, nonnull))
match_t *match(grammar_t *g, file_t *f, const char *str, vm_op_t *op, unsigned int flags);