diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-08-07 14:21:27 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-08-07 14:21:27 +0200 |
commit | 3329eeafa1f08c5b9d410e57f761011d2e1ac1d6 (patch) | |
tree | eb7fbe019e09e569894f29c37fe9081060ace32c /functions.m | |
parent | a3f6140ef3dde8184ce2b46119e73d9dca63e73f (diff) |
Centralise declaration and documentation string handling.
Diffstat (limited to 'functions.m')
-rw-r--r-- | functions.m | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/functions.m b/functions.m index d74b1fa..895b70b 100644 --- a/functions.m +++ b/functions.m @@ -18,6 +18,7 @@ #import "functions.h" #import "util.h" +#import "MLKCons.h" #import "MLKCharacter.h" #import "MLKInteger.h" #import "MLKPackage.h" @@ -147,6 +148,7 @@ id MLKMultiplyFixnums (id x, id y) static MLKSymbol *INT, *SHORT, *LONG, *VOID, *POINTER, *UINT, *USHORT, *ULONG, *STRING, *ID, *BOOLEAN, *CLASS, *UNICHAR, *CHAR, *ERROR; +static MLKSymbol *DECLARE; static MLKPackage *keyword = nil, *cl = nil; #define INTERN_KEYWORD(VAR, NAME) \ @@ -174,6 +176,53 @@ static void init_symbols () INTERN_KEYWORD (CHAR, @"CHAR"); INTERN_KEYWORD (ERROR, @"ERROR"); INTERN_KEYWORD (VOID, @"VOID"); + + DECLARE = [cl intern:@"DECLARE"]; +} + + +void MLKSplitDeclarationsDocAndForms (id *decls, id *doc, id *forms, id body) +{ + id declarations; + + init_symbols (); + + *doc = nil; + + declarations = nil; + while (([[body car] isKindOfClass:[MLKCons class]] + && [[body car] car] == DECLARE) + || [[body car] isKindOfClass:[NSString class]]) + { + id thing = [body car]; + + if ([thing isKindOfClass:[NSString class]]) + { + if (*doc) + { + body = [body cdr]; + break; + } + else + { + *doc = thing; + } + } + else + { + thing = [thing cdr]; + + if (declarations) + declarations = [declarations listByAppendingObject:thing]; + else + declarations = thing; + } + + body = [body cdr]; + } + + *decls = declarations; + *forms = body; } |