/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1995-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include <ast.h>
#include <ccode.h>
#include <error.h>
#include "regex.h"
typedef struct {
unsigned char *w; /* write pointer */
unsigned char *e; /* end */
unsigned char *s; /* start */
} Text;
extern void printscript(Text*);
extern void synwarn(char*);
extern void syntax(char*);
extern int ateof(void);
extern void coda(void);
#define exch(a, b, t) ((t)=(a), (a)=(b), (b)=(t))
/* space management; assure room for n more chars in Text */
#define assure(t, n) \
do if((t)->s==0 || (t)->w>=(t)->e-(n)-1) grow((t), (n));while(0)
/* round character pointer up to word pointer.
portable to the cray; simpler tricks are not */
extern int reflags;
extern int recno;
extern int nflag;
extern int qflag;
extern int sflag;
extern int bflag;
extern char* stdouterr;
extern unsigned char* map;
/* SCRIPT LAYOUT
script commands are packed thus:
0,1,or2 address words signed + for numbers - for regexp
if 2 addresses, then another word indicates activity
positive: active, the record number where activated
negative: inactive, sign or-ed with number where deactivated
instruction word
high byte IMASK+flags; flags are NEG and SEL
next byte command code (a letter)
next two bytes, length of this command, including addrs
(length is a multiple of 4; capacity could be expanded
by counting the length in words instead of bytes)
after instruction word
on s command
offset of regexp in rebuf
word containing flags p,w plus n (g => n=0)
replacement text
word containing file designator, if flag w
on y command
256-byte transliteration table
on b and t command
offset of label in script
*/