1cd8169f0Sbostic /*- 2*e049d966Sbostic * Copyright (c) 1980, 1993 3*e049d966Sbostic * The Regents of the University of California. All rights reserved. 41ad2eee4Sdist * 5cd8169f0Sbostic * %sccs.include.proprietary.c% 6cd8169f0Sbostic * 7*e049d966Sbostic * @(#)ex_re.h 8.1 (Berkeley) 06/09/93 81ad2eee4Sdist */ 91ad2eee4Sdist 10187cc065Smark /* 11187cc065Smark * Regular expression definitions. 12187cc065Smark * The regular expressions in ex are similar to those in ed, 13187cc065Smark * with the addition of the word boundaries from Toronto ed 14187cc065Smark * and allowing character classes to have [a-b] as in the shell. 15187cc065Smark * The numbers for the nodes below are spaced further apart then 16187cc065Smark * necessary because I at one time partially put in + and | (one or 17187cc065Smark * more and alternation.) 18187cc065Smark */ 19187cc065Smark struct regexp { 20187cc065Smark char Expbuf[ESIZE + 2]; 21187cc065Smark bool Circfl; 22187cc065Smark short Nbra; 23187cc065Smark }; 24187cc065Smark 25187cc065Smark /* 26187cc065Smark * There are three regular expressions here, the previous (in re), 27187cc065Smark * the previous substitute (in subre) and the previous scanning (in scanre). 28187cc065Smark * It would be possible to get rid of "re" by making it a stack parameter 29187cc065Smark * to the appropriate routines. 30187cc065Smark */ 3168dd2190Sdist var struct regexp re; /* Last re */ 3268dd2190Sdist var struct regexp scanre; /* Last scanning re */ 3368dd2190Sdist var struct regexp subre; /* Last substitute re */ 34187cc065Smark 35187cc065Smark /* 36187cc065Smark * Defining circfl and expbuf like this saves us from having to change 37187cc065Smark * old code in the ex_re.c stuff. 38187cc065Smark */ 39187cc065Smark #define expbuf re.Expbuf 40187cc065Smark #define circfl re.Circfl 41187cc065Smark #define nbra re.Nbra 42187cc065Smark 43187cc065Smark /* 44187cc065Smark * Since the phototypesetter v7-epsilon 45187cc065Smark * C compiler doesn't have structure assignment... 46187cc065Smark */ 47187cc065Smark #define savere(a) copy(&a, &re, sizeof (struct regexp)) 48187cc065Smark #define resre(a) copy(&re, &a, sizeof (struct regexp)) 49187cc065Smark 50187cc065Smark /* 51187cc065Smark * Definitions for substitute 52187cc065Smark */ 5368dd2190Sdist var char *braslist[NBRA]; /* Starts of \(\)'ed text in lhs */ 5468dd2190Sdist var char *braelist[NBRA]; /* Ends... */ 5568dd2190Sdist var char rhsbuf[RHSSIZE]; /* Rhs of last substitute */ 56187cc065Smark 57187cc065Smark /* 58187cc065Smark * Definitions of codes for the compiled re's. 59187cc065Smark * The re algorithm is described in a paper 60187cc065Smark * by K. Thompson in the CACM about 10 years ago 61187cc065Smark * and is the same as in ed. 62187cc065Smark */ 63187cc065Smark #define STAR 1 64187cc065Smark 65187cc065Smark #define CBRA 1 66187cc065Smark #define CDOT 4 67187cc065Smark #define CCL 8 68187cc065Smark #define NCCL 12 69187cc065Smark #define CDOL 16 70289b02e1Smark #define CEOFC 17 71187cc065Smark #define CKET 18 72187cc065Smark #define CCHR 20 73187cc065Smark #define CBRC 24 74187cc065Smark #define CLET 25 75