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