diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-17 19:58:23 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-17 19:58:23 +0200 |
commit | d216a7cbc174a35b93c1e5af66b7bc2e1b0284db (patch) | |
tree | 38b6394607b919693dce8668fa8f488a120f26b4 | |
parent | 2491e0485e6851a3a3f3a5e1f5c399780e04fae5 (diff) |
MLKReadtable: Stylistic improvements.
-rw-r--r-- | MLKReadtable.m | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/MLKReadtable.m b/MLKReadtable.m index 08539d9..9a9b357 100644 --- a/MLKReadtable.m +++ b/MLKReadtable.m @@ -84,35 +84,20 @@ enum MLKCharacterTrait [self isTerminatingMacroCharacter:ch]); } --(BOOL) isNonTerminatingMacroCharacter:(unichar)ch; -{ - return ([[_syntaxTable objectForKey:[NSNumber numberWithLong:ch]] - isEqual:[NSNumber numberWithShort:NONTERMINATING_MACRO]]); -} --(BOOL) isTerminatingMacroCharacter:(unichar)ch; -{ - return ([[_syntaxTable objectForKey:[NSNumber numberWithLong:ch]] - isEqual:[NSNumber numberWithShort:TERMINATING_MACRO]]); -} +#define DEFINE_SYNTAX_PREDICATE(SELECTOR, SYNTAX_TYPE) \ + -(BOOL) SELECTOR (unichar)ch \ + { \ + return ([[_syntaxTable objectForKey:[NSNumber numberWithLong:ch]] \ + isEqual:[NSNumber numberWithShort:SYNTAX_TYPE]]); \ + } --(BOOL) isSingleEscapeCharacter:(unichar)ch; -{ - return ([[_syntaxTable objectForKey:[NSNumber numberWithLong:ch]] - isEqual:[NSNumber numberWithShort:SINGLE_ESCAPE]]); -} +DEFINE_SYNTAX_PREDICATE(isNonTerminatingMacroCharacter:, NONTERMINATING_MACRO) +DEFINE_SYNTAX_PREDICATE(isTerminatingMacroCharacter:, TERMINATING_MACRO) +DEFINE_SYNTAX_PREDICATE(isSingleEscapeCharacter:, SINGLE_ESCAPE) +DEFINE_SYNTAX_PREDICATE(isMultipleEscapeCharacter:, MULTI_ESCAPE) +DEFINE_SYNTAX_PREDICATE(isConstituentCharacter:, CONSTITUENT) --(BOOL) isMultipleEscapeCharacter:(unichar)ch; -{ - return ([[_syntaxTable objectForKey:[NSNumber numberWithLong:ch]] - isEqual:[NSNumber numberWithShort:MULTI_ESCAPE]]); -} - --(BOOL) isConstituentCharacter:(unichar)ch; -{ - return ([[_syntaxTable objectForKey:[NSNumber numberWithLong:ch]] - isEqual:[NSNumber numberWithShort:CONSTITUENT]]); -} -(BOOL) characterHasCase:(unichar)ch { @@ -149,12 +134,12 @@ enum MLKCharacterTrait } -#define DEFINE_TRAIT_PREDICATE(SELECTOR, TRAIT) \ --(BOOL) SELECTOR (unichar)ch \ -{ \ - return ([[_traits objectForKey:[NSNumber numberWithLong:ch]] \ - isEqual:[NSNumber numberWithShort:TRAIT]]); \ -} +#define DEFINE_TRAIT_PREDICATE(SELECTOR, TRAIT) \ + -(BOOL) SELECTOR (unichar)ch \ + { \ + return ([[_traits objectForKey:[NSNumber numberWithLong:ch]] \ + isEqual:[NSNumber numberWithShort:TRAIT]]); \ + } DEFINE_TRAIT_PREDICATE(isInvalid:, INVALID) DEFINE_TRAIT_PREDICATE(isAlphabetic:, ALPHABETIC) @@ -169,6 +154,7 @@ DEFINE_TRAIT_PREDICATE(isPlusSign:, PLUS_SIGN) DEFINE_TRAIT_PREDICATE(isSign:, SIGN) DEFINE_TRAIT_PREDICATE(isDot:, DOT) + -(BOOL) isDecimalDigit:(unichar)ch { return [self isDigit:ch inBase:10]; @@ -193,5 +179,4 @@ DEFINE_TRAIT_PREDICATE(isDot:, DOT) else return (ch - 'a' + 10); } - @end |