aboutsummaryrefslogtreecommitdiff
path: root/tools/re2c/scanner.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/re2c/scanner.h')
-rw-r--r--tools/re2c/scanner.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/re2c/scanner.h b/tools/re2c/scanner.h
new file mode 100644
index 0000000..a5720b7
--- /dev/null
+++ b/tools/re2c/scanner.h
@@ -0,0 +1,44 @@
+#ifndef _scanner_h
+#define _scanner_h
+
+#include <stdio.h>
+#include "tools/re2c/token.h"
+
+typedef struct Scanner {
+ FILE *in;
+ unsigned char *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof;
+ unsigned int tchar, tline, cline;
+} Scanner;
+
+void Scanner_init(Scanner*, FILE *);
+static Scanner *Scanner_new(FILE *);
+
+int Scanner_echo(Scanner*, FILE *);
+int Scanner_scan(Scanner*);
+void Scanner_fatal(Scanner*, const char*);
+static SubStr Scanner_token(Scanner*);
+static unsigned int Scanner_line(Scanner*);
+
+static SubStr
+Scanner_token(Scanner *s)
+{
+ SubStr r;
+ SubStr_init_u(&r, s->tok, s->cur - s->tok);
+ return r;
+}
+
+static unsigned int
+Scanner_line(Scanner *s)
+{
+ return s->cline;
+}
+
+static Scanner *
+Scanner_new(FILE *i)
+{
+ Scanner *r = malloc(sizeof(Scanner));
+ Scanner_init(r, i);
+ return r;
+}
+
+#endif