parse.h - 9base - revived minimalist port of Plan 9 userland to Unix
(HTM) git clone git://git.suckless.org/9base
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
parse.h (1909B)
---
1 typedef struct Addr Addr;
2 typedef struct Cmd Cmd;
3 struct Addr
4 {
5 char type; /* # (char addr), l (line addr), / ? . $ + - , ; */
6 union{
7 String *re;
8 Addr *aleft; /* left side of , and ; */
9 } g;
10 Posn num;
11 Addr *next; /* or right side of , and ; */
12 };
13
14 #define are g.re
15 #define left g.aleft
16
17 struct Cmd
18 {
19 Addr *addr; /* address (range of text) */
20 String *re; /* regular expression for e.g. 'x' */
21 union{
22 Cmd *cmd; /* target of x, g, {, etc. */
23 String *text; /* text of a, c, i; rhs of s */
24 Addr *addr; /* address for m, t */
25 } g;
26 Cmd *next; /* pointer to next element in {} */
27 short num;
28 ushort flag; /* whatever */
29 ushort cmdc; /* command character; 'x' etc. */
30 };
31
32 #define ccmd g.cmd
33 #define ctext g.text
34 #define caddr g.addr
35
36 extern struct cmdtab{
37 ushort cmdc; /* command character */
38 uchar text; /* takes a textual argument? */
39 uchar regexp; /* takes a regular expression? */
40 uchar addr; /* takes an address (m or t)? */
41 uchar defcmd; /* default command; 0==>none */
42 uchar defaddr; /* default address */
43 uchar count; /* takes a count e.g. s2/// */
44 char *token; /* takes text terminated by one of these */
45 int (*fn)(File*, Cmd*); /* function to call with parse tree */
46 }cmdtab[];
47
48 enum Defaddr{ /* default addresses */
49 aNo,
50 aDot,
51 aAll
52 };
53
54 int nl_cmd(File*, Cmd*), a_cmd(File*, Cmd*), b_cmd(File*, Cmd*);
55 int c_cmd(File*, Cmd*), cd_cmd(File*, Cmd*), d_cmd(File*, Cmd*);
56 int D_cmd(File*, Cmd*), e_cmd(File*, Cmd*);
57 int f_cmd(File*, Cmd*), g_cmd(File*, Cmd*), i_cmd(File*, Cmd*);
58 int k_cmd(File*, Cmd*), m_cmd(File*, Cmd*), n_cmd(File*, Cmd*);
59 int p_cmd(File*, Cmd*), q_cmd(File*, Cmd*);
60 int s_cmd(File*, Cmd*), u_cmd(File*, Cmd*), w_cmd(File*, Cmd*);
61 int x_cmd(File*, Cmd*), X_cmd(File*, Cmd*), plan9_cmd(File*, Cmd*);
62 int eq_cmd(File*, Cmd*);
63
64
65 String *getregexp(int);
66 Addr *newaddr(void);
67 Address address(Addr*, Address, int);
68 int cmdexec(File*, Cmd*);