]> pd.if.org Git - pdutils/blob - utils/sh/tok.h
fa95d55053df25768e67c5c5742b8a957d6bc5ef
[pdutils] / utils / sh / tok.h
1 #ifndef TOK_H_
2 #define TOK_H_ 1
3 #include <stdio.h>
4 /* START HEADER */
5 struct token {
6         int type;
7         int rtype; /* a "real type", e.g. In, NAME, etc. */
8         int length;
9         int delimiter;
10         int nondigits;
11         int nonnames;
12         struct token *next;
13         char text[2048];
14 };
15
16 struct token_state {
17         FILE *input;
18         struct token *tok;
19
20         char *strinput;
21         int is_string;
22         int strlen;
23         int cursor;
24
25         int pc; /* previous char */
26         int cc; /* current char */
27         int nc; /* next char */
28         int push_back; /* true if next char is valid */
29
30         int prev_op; /* previous character was used as part of an operator */
31         int prev_word; /* previous character is part of a word */
32         int quoting; /* type of quoting */
33
34         char buf[2048];
35         int buflen;
36 };
37
38 struct token_state *ts_init(struct token_state *ts, FILE *f);
39 int get_token(struct token_state *ts, struct token *tok);
40
41 /* END HEADER */
42 #endif