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