cfad47cfa3/t3compiler/tads3/include/tok.h

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#charset "us-ascii"
2
3
/* 
4
 *   Copyright (c) 2000, 2006 Michael J. Roberts
5
 *   
6
 *   This file is part of TADS 3
7
 *   
8
 *   This header defines some macros for the standard tokenizer class.  
9
 */
10
11
/* 
12
 *   token rule flags 
13
 */
14
15
/*
16
 *   The tokenizer's return value is a list of tokens.  Each token
17
 *   represented by a sublist describing the token.  These macros extract
18
 *   information from the token sublist.  
19
 */
20
21
/* 
22
 *   Get the token value.  This is the parsed representation of the token;
23
 *   in most cases, this is simply the text of the original token, although
24
 *   it might be converted in some way (words are usually converted to
25
 *   lower-case, for example).  
26
 */
27
#define getTokVal(tok) ((tok)[1])
28
29
/*
30
 *   Get the token type.  This is a token enum value describing the type of
31
 *   the token. 
32
 */
33
#define getTokType(tok) ((tok)[2])
34
35
/*
36
 *   Get the token's original text.  This is the original text matched from
37
 *   the tokenized string. 
38
 */
39
#define getTokOrig(tok) ((tok)[3])
40
41
/*
42
 *   Some internal convenience macros.  (These are meant for internal use
43
 *   within the tokenizer class, rather than for client code, but we define
44
 *   them here because they're also useful for subclasses of the standard
45
 *   tokenizer.)  
46
 */
47
#define tokRuleName(rule)   (rule[1])
48
#define tokRulePat(rule)    (rule[2])
49
#define tokRuleType(rule)   (rule[3])
50
#define tokRuleVal(rule)    (rule[4])
51
#define tokRuleTest(rule)   (rule[5])
52
53