summaryrefslogtreecommitdiff
path: root/fpcsrc/utils/sim_pasc/token.h
blob: b849a2b202985025d92f63b9ed223cdfc058f632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*	This file is part of the software similarity tester SIM.
	Written by Dick Grune, Vrije Universiteit, Amsterdam.
	$Id: token.h,v 2.4 2001/11/13 12:55:59 dick Exp $
*/

/*
	Token interface.
	Since the definition of a token has been a continual source of
	problems, it is now defined as an Abstract Data Type.
	To allow stronger type checking, there is a special version for use
	by lint.
*/

#include	<stdio.h>

#ifndef	TOKEN

#ifdef	lint
#define	TESTTOKEN
#endif

#ifdef	TESTTOKEN				/* strict version */

struct cccc {
	int cccc;
};

typedef struct cccc *lintTOKEN;
#define	TOKEN		lintTOKEN
#define	TOKEN2int(c)	((int)(c))
#define	int2TOKEN(i)	((TOKEN)(i))
extern int TOKEN_EQ(TOKEN t1, TOKEN t2);

#else						/* production version */

#define	TOKEN		unsigned char
#define	TOKEN2int(c)	((c)&0377)
#define	int2TOKEN(i)	((TOKEN)(i))
#define	TOKEN_EQ(t1,t2)	(TOKEN2int(t1) == TOKEN2int(t2))

#endif	/* TESTTOKEN */

#endif	/* TOKEN */

/* Macros for the composition of tokens */
#define	NORM(ch)	int2TOKEN((ch)&0377)
#define	CTRL(ch)	int2TOKEN((ch)&0037)
#define	META(ch)	int2TOKEN((ch)|0200)
#define	MTCT(ch)	int2TOKEN(((ch)&0037)|0200)
#define	NOTOKEN		int2TOKEN(0)

extern void print_token(FILE *ofile, TOKEN tk);	/* in two characters */