X-Git-Url: https://pd.if.org/git/?p=pdutils;a=blobdiff_plain;f=utils%2Fsh%2Ftok.h;fp=utils%2Fsh%2Ftok.h;h=fa95d55053df25768e67c5c5742b8a957d6bc5ef;hp=0000000000000000000000000000000000000000;hb=dce1707cec7cd4268fe73371c7488052e5058181;hpb=5cd80baaa2b300ac0e2bded7bf9dfc7b74022ab8 diff --git a/utils/sh/tok.h b/utils/sh/tok.h new file mode 100644 index 0000000..fa95d55 --- /dev/null +++ b/utils/sh/tok.h @@ -0,0 +1,42 @@ +#ifndef TOK_H_ +#define TOK_H_ 1 +#include +/* START HEADER */ +struct token { + int type; + int rtype; /* a "real type", e.g. In, NAME, etc. */ + int length; + int delimiter; + int nondigits; + int nonnames; + struct token *next; + char text[2048]; +}; + +struct token_state { + FILE *input; + struct token *tok; + + char *strinput; + int is_string; + int strlen; + int cursor; + + int pc; /* previous char */ + int cc; /* current char */ + int nc; /* next char */ + int push_back; /* true if next char is valid */ + + int prev_op; /* previous character was used as part of an operator */ + int prev_word; /* previous character is part of a word */ + int quoting; /* type of quoting */ + + char buf[2048]; + int buflen; +}; + +struct token_state *ts_init(struct token_state *ts, FILE *f); +int get_token(struct token_state *ts, struct token *tok); + +/* END HEADER */ +#endif