1 /*#pragma varargck argpos editerror 1*/
3 typedef struct Addr Addr;
4 typedef struct Address Address;
5 typedef struct Cmd Cmd;
6 typedef struct List List;
7 typedef struct String String;
11 int n; /* excludes NUL */
12 Rune *r; /* includes NUL */
18 char type; /* # (char addr), l (line addr), / ? . $ + - , ; */
21 Addr *left; /* left side of , and ; */
24 Addr *next; /* or right side of , and ; */
35 Addr *addr; /* address (range of text) */
36 String *re; /* regular expression for e.g. 'x' */
38 Cmd *cmd; /* target of x, g, {, etc. */
39 String *text; /* text of a, c, i; rhs of s */
40 Addr *mtaddr; /* address for m, t */
42 Cmd *next; /* pointer to next element in {} */
44 ushort flag; /* whatever */
45 ushort cmdc; /* command character; 'x' etc. */
49 ushort cmdc; /* command character */
50 uchar text; /* takes a textual argument? */
51 uchar regexp; /* takes a regular expression? */
52 uchar addr; /* takes an address (m or t)? */
53 uchar defcmd; /* default command; 0==>none */
54 uchar defaddr; /* default address */
55 uchar count; /* takes a count e.g. s2/// */
56 char *token; /* takes text terminated by one of these */
57 int (*fn)(Text*, Cmd*); /* function to call with parse tree */
60 #define INCR 25 /* delta when growing list */
62 struct List /* code depends on a long being able to hold a pointer */
76 enum Defaddr{ /* default addresses */
82 int nl_cmd(Text*, Cmd*), a_cmd(Text*, Cmd*), b_cmd(Text*, Cmd*);
83 int c_cmd(Text*, Cmd*), d_cmd(Text*, Cmd*);
84 int B_cmd(Text*, Cmd*), D_cmd(Text*, Cmd*), e_cmd(Text*, Cmd*);
85 int f_cmd(Text*, Cmd*), g_cmd(Text*, Cmd*), i_cmd(Text*, Cmd*);
86 int k_cmd(Text*, Cmd*), m_cmd(Text*, Cmd*), n_cmd(Text*, Cmd*);
87 int p_cmd(Text*, Cmd*);
88 int s_cmd(Text*, Cmd*), u_cmd(Text*, Cmd*), w_cmd(Text*, Cmd*);
89 int x_cmd(Text*, Cmd*), X_cmd(Text*, Cmd*), pipe_cmd(Text*, Cmd*);
90 int eq_cmd(Text*, Cmd*);
92 String *allocstring(int);
93 void freestring(String*);
94 String *getregexp(int);
96 Address cmdaddress(Addr*, Address, int);
97 int cmdexec(Text*, Cmd*);
98 void editerror(char*, ...);
101 void Straddc(String*, int);