summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MLKReadtable.m51
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