summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defs.h75
-rw-r--r--main.c1
-rw-r--r--preproc.c2
-rw-r--r--preproc.h76
4 files changed, 76 insertions, 78 deletions
diff --git a/defs.h b/defs.h
deleted file mode 100644
index c3bbd4b..0000000
--- a/defs.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#pragma once
-
-#include "utils.h"
-
-
-typedef struct Region Region;
-
-
-// Lexing stage
-typedef enum {
- UN_Q,
- SINGLE_Q,
- DOUBLE_Q,
-} QuotationMode;
-
-typedef enum {
- LITERAL,
- REGION_EXP,
- VAR_EXP, // TODO: Later include other exps
-} ChunkKind;
-
-typedef struct {
- ChunkKind kind;
- QuotationMode qmode;
- union {
- char* literal_str;
- Region* reg_ptr;
- char* varname;
- } as;
-} Chunk;
-DECLARE_MAYBE(Chunk, MaybeChunk);
-DECLARE_VEC(Chunk*, Word)
-
-typedef enum {
- TOK_WORD,
- TOK_SPECIAL,
- TOK_PROCSUB_IN,
- TOK_PROCSUB_OUT,
-} TokenKind;
-
-typedef enum {
- PIPE,
- WRITE_REDIR_TRUNC,
- WRITE_REDIR_APPEND,
- READ_REDIR,
- EOL,
-} SpecialToken;
-DECLARE_MAYBE(SpecialToken, MaybeSpecialToken)
-
-typedef struct {
- TokenKind kind;
-
- union {
- Word word;
- SpecialToken spec;
- Region* procsub_region;
- } as;
-} Token;
-
-
-DECLARE_VEC(Token*, TokenPtrVec)
-
-
-typedef enum {
- CMDS,
- ARITHM,
-} RegionMode;
-
-struct Region {
- RegionMode mode;
- TokenPtrVec tokens;
-};
-DECLARE_VEC(Region, RegionVec)
-
-
diff --git a/main.c b/main.c
index 2bd2081..3fe10bf 100644
--- a/main.c
+++ b/main.c
@@ -3,7 +3,6 @@
#include <readline/readline.h>
#include <string.h>
-#include "defs.h"
#include "preproc.h"
#include "exec.h"
diff --git a/preproc.c b/preproc.c
index 474a108..c982636 100644
--- a/preproc.c
+++ b/preproc.c
@@ -7,9 +7,9 @@
#include "preproc.h"
#include "utils.h"
-#include "defs.h"
+// Lexing
typedef struct {
char* str;
diff --git a/preproc.h b/preproc.h
index 6dca467..1ba76cf 100644
--- a/preproc.h
+++ b/preproc.h
@@ -1,11 +1,85 @@
#pragma once
-#include "defs.h"
#include "utils.h"
+typedef struct Region Region;
+
+
+// Lexing stage
+typedef enum {
+ UN_Q,
+ SINGLE_Q,
+ DOUBLE_Q,
+} QuotationMode;
+
+typedef enum {
+ LITERAL,
+ REGION_EXP,
+ VAR_EXP, // TODO: Later include other exps
+} ChunkKind;
+
+typedef struct {
+ ChunkKind kind;
+ QuotationMode qmode;
+ union {
+ char* literal_str;
+ Region* reg_ptr;
+ char* varname;
+ } as;
+} Chunk;
+DECLARE_MAYBE(Chunk, MaybeChunk);
+DECLARE_VEC(Chunk*, Word)
+
+typedef enum {
+ TOK_WORD,
+ TOK_SPECIAL,
+ TOK_PROCSUB_IN,
+ TOK_PROCSUB_OUT,
+} TokenKind;
+
+typedef enum {
+ PIPE,
+ WRITE_REDIR_TRUNC,
+ WRITE_REDIR_APPEND,
+ READ_REDIR,
+ EOL,
+} SpecialToken;
+DECLARE_MAYBE(SpecialToken, MaybeSpecialToken)
+
+typedef struct {
+ TokenKind kind;
+
+ union {
+ Word word;
+ SpecialToken spec;
+ Region* procsub_region;
+ } as;
+} Token;
+
+
+DECLARE_VEC(Token*, TokenPtrVec)
+
+
+typedef enum {
+ CMDS,
+ ARITHM,
+} RegionMode;
+
+struct Region {
+ RegionMode mode;
+ TokenPtrVec tokens;
+};
+DECLARE_VEC(Region, RegionVec)
+
+
+
DECLARE_VEC(Chunk, ChunkVec)
DECLARE_VEC(Token, TokenVec)
+
+
+// Lexing
+
typedef struct {
RegionVec regions;
TokenVec tokens;