Commit | Line | Data |
---|---|---|
2791ff57 KB |
1 | /*- |
2 | * Copyright (c) 1980 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.proprietary.c% | |
edf71f48 | 6 | * |
2791ff57 | 7 | * @(#)ex_re.h 7.4 (Berkeley) %G% |
edf71f48 DF |
8 | */ |
9 | ||
a4bbed3a MH |
10 | /* |
11 | * Regular expression definitions. | |
12 | * The regular expressions in ex are similar to those in ed, | |
13 | * with the addition of the word boundaries from Toronto ed | |
14 | * and allowing character classes to have [a-b] as in the shell. | |
15 | * The numbers for the nodes below are spaced further apart then | |
16 | * necessary because I at one time partially put in + and | (one or | |
17 | * more and alternation.) | |
18 | */ | |
19 | struct regexp { | |
20 | char Expbuf[ESIZE + 2]; | |
21 | bool Circfl; | |
22 | short Nbra; | |
23 | }; | |
24 | ||
25 | /* | |
26 | * There are three regular expressions here, the previous (in re), | |
27 | * the previous substitute (in subre) and the previous scanning (in scanre). | |
28 | * It would be possible to get rid of "re" by making it a stack parameter | |
29 | * to the appropriate routines. | |
30 | */ | |
cb3ac212 MH |
31 | var struct regexp re; /* Last re */ |
32 | var struct regexp scanre; /* Last scanning re */ | |
33 | var struct regexp subre; /* Last substitute re */ | |
a4bbed3a MH |
34 | |
35 | /* | |
36 | * Defining circfl and expbuf like this saves us from having to change | |
37 | * old code in the ex_re.c stuff. | |
38 | */ | |
39 | #define expbuf re.Expbuf | |
40 | #define circfl re.Circfl | |
41 | #define nbra re.Nbra | |
42 | ||
43 | /* | |
44 | * Since the phototypesetter v7-epsilon | |
45 | * C compiler doesn't have structure assignment... | |
46 | */ | |
47 | #define savere(a) copy(&a, &re, sizeof (struct regexp)) | |
48 | #define resre(a) copy(&re, &a, sizeof (struct regexp)) | |
49 | ||
50 | /* | |
51 | * Definitions for substitute | |
52 | */ | |
cb3ac212 MH |
53 | var char *braslist[NBRA]; /* Starts of \(\)'ed text in lhs */ |
54 | var char *braelist[NBRA]; /* Ends... */ | |
55 | var char rhsbuf[RHSSIZE]; /* Rhs of last substitute */ | |
a4bbed3a MH |
56 | |
57 | /* | |
58 | * Definitions of codes for the compiled re's. | |
59 | * The re algorithm is described in a paper | |
60 | * by K. Thompson in the CACM about 10 years ago | |
61 | * and is the same as in ed. | |
62 | */ | |
63 | #define STAR 1 | |
64 | ||
65 | #define CBRA 1 | |
66 | #define CDOT 4 | |
67 | #define CCL 8 | |
68 | #define NCCL 12 | |
69 | #define CDOL 16 | |
d266c416 | 70 | #define CEOFC 17 |
a4bbed3a MH |
71 | #define CKET 18 |
72 | #define CCHR 20 | |
73 | #define CBRC 24 | |
74 | #define CLET 25 |