Blob


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 };
14 #define are g.re
15 #define left g.aleft
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 };
32 #define ccmd g.cmd
33 #define ctext g.text
34 #define caddr g.addr
36 typedef struct Cmdtab Cmdtab;
37 struct Cmdtab {
38 ushort cmdc; /* command character */
39 uchar text; /* takes a textual argument? */
40 uchar regexp; /* takes a regular expression? */
41 uchar addr; /* takes an address (m or t)? */
42 uchar defcmd; /* default command; 0==>none */
43 uchar defaddr; /* default address */
44 uchar count; /* takes a count e.g. s2/// */
45 char *token; /* takes text terminated by one of these */
46 int (*fn)(File*, Cmd*); /* function to call with parse tree */
47 };
48 extern Cmdtab cmdtab[];
50 enum Defaddr{ /* default addresses */
51 aNo,
52 aDot,
53 aAll
54 };
56 int nl_cmd(File*, Cmd*), a_cmd(File*, Cmd*), b_cmd(File*, Cmd*);
57 int c_cmd(File*, Cmd*), cd_cmd(File*, Cmd*), d_cmd(File*, Cmd*);
58 int D_cmd(File*, Cmd*), e_cmd(File*, Cmd*);
59 int f_cmd(File*, Cmd*), g_cmd(File*, Cmd*), i_cmd(File*, Cmd*);
60 int k_cmd(File*, Cmd*), m_cmd(File*, Cmd*), n_cmd(File*, Cmd*);
61 int p_cmd(File*, Cmd*), q_cmd(File*, Cmd*);
62 int s_cmd(File*, Cmd*), u_cmd(File*, Cmd*), w_cmd(File*, Cmd*);
63 int x_cmd(File*, Cmd*), X_cmd(File*, Cmd*), plan9_cmd(File*, Cmd*);
64 int eq_cmd(File*, Cmd*);
67 String *getregexp(int);
68 Addr *newaddr(void);
69 Address address(Addr*, Address, int);
70 int cmdexec(File*, Cmd*);