aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-08 01:06:43 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-08 01:06:43 -0800
commit03c790d5b61ecc07a34e6d113a5b434b72c835fe (patch)
treec6e1423f4083c62aabd36c22b36ea8c3fba54054
parent668c7baf55d07cb429b30b92ea8ce302f9de053a (diff)
Renamed viz -> printing, and tidied up the code a bit
-rw-r--r--Makefile2
-rw-r--r--bp.c2
-rw-r--r--printing.c (renamed from viz.c)9
-rw-r--r--printing.h (renamed from viz.h)16
-rw-r--r--vm.h5
5 files changed, 18 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 90b3c40..39ea023 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/bp.c b/bp.c
index a9ffe01..cefb5aa 100644
--- a/bp.c
+++ b/bp.c
@@ -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 = (
diff --git a/viz.c b/printing.c
index a4aa565..68faf22 100644
--- a/viz.c
+++ b/printing.c
@@ -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;
diff --git a/viz.h b/printing.h
index 8b11bcc..7059562 100644
--- a/viz.h
+++ b/printing.h
@@ -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);
diff --git a/vm.h b/vm.h
index 2c17743..148f2b5 100644
--- a/vm.h
+++ b/vm.h
@@ -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);