Improved parser and corrected background color.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20636 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-01-30 19:30:56 +00:00
parent 39017d82d8
commit 769457a1cb
9 changed files with 109 additions and 92 deletions

View file

@ -1,3 +1,13 @@
2005-01-30 14:34 Gregory John Casamento <greg_casamento@yahoo.com>
* GormObjCHeaderParser/GNUmakefile: Added new files.
* GormObjCHeaderParser/OCClass.m: Uses lookAhead function
* GormObjCHeaderParser/OCIVarDecl.m: Uses lookAhead function
* GormObjCHeaderParser/OCIVar.m: Uses lookAhead function
* GormObjCHeaderParser/ParserFunctions.[hm]: New functions for
use by the class parser.
* Resources/GormDocument.gorm: Corrected background color.
2005-01-30 00:33 Gregory John Casamento <greg_casamento@yahoo.com>
* GNUmakefile: Build new file.

View file

@ -41,24 +41,27 @@ libGormObjCHeaderParser_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LI
#
libGormObjCHeaderParser_HEADER_FILES= \
OCHeaderParser.h \
NSScanner+OCHeaderParser.h \
OCClass.h \
OCHeaderParser.h \
OCIVar.h \
OCIVarDecl.h \
OCMethod.h \
NSScanner+OCHeaderParser.h
ParserFunctions.h
#
# Class files
#
libGormObjCHeaderParser_OBJC_FILES= \
OCHeaderParser.m \
NSScanner+OCHeaderParser.m \
OCClass.m \
OCHeaderParser.m \
OCIVar.m \
OCIVarDecl.m \
OCMethod.m \
NSScanner+OCHeaderParser.m
ParserFunctions.m
#
# C files

View file

@ -32,6 +32,7 @@
#include <GormObjCHeaderParser/OCIVar.h>
#include <GormObjCHeaderParser/OCIVarDecl.h>
#include <GormObjCHeaderParser/NSScanner+OCHeaderParser.h>
#include <GormObjCHeaderParser/ParserFunctions.h>
@implementation OCClass
- (id) initWithString: (NSString *)string
@ -138,15 +139,13 @@
NSString *interfaceLine = nil;
NSString *methodsString = nil;
NSString *ivarsString = nil;
NSRange range;
NSRange notFound = NSMakeRange(NSNotFound,0);
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSCharacterSet *pmcs = [NSCharacterSet characterSetWithCharactersInString: @"+-"];
// get the interface line... look ahead...
[self _strip];
scanner = [NSScanner scannerWithString: classString];
if(NSEqualRanges(range = [classString rangeOfString: @"{"], notFound) == NO)
if(lookAhead(classString, @"{"))
{
[scanner scanUpToString: @"@interface" intoString: NULL];
[scanner scanUpToString: @"{" intoString: &interfaceLine];
@ -160,7 +159,7 @@
}
// look ahead...
if(NSEqualRanges([interfaceLine rangeOfString: @":"], notFound) == NO)
if(lookAhead(interfaceLine, @":"))
{
NSString *cn = nil, *scn = nil;

View file

@ -26,6 +26,7 @@
#include <Foundation/Foundation.h>
#include <GormObjCHeaderParser/OCIVar.h>
#include <GormObjCHeaderParser/NSScanner+OCHeaderParser.h>
#include <GormObjCHeaderParser/ParserFunctions.h>
@implementation OCIVar
@ -71,6 +72,7 @@
NSString *resultString = [NSString stringWithString: @""];
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
// string whitespace
while(![stripScanner isAtEnd])
{
NSString *string = nil;
@ -87,16 +89,13 @@
- (void) parse
{
NSRange notFound = NSMakeRange(NSNotFound,0);
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSScanner *scanner = nil; // [NSScanner scannerWithString: ivarString];
NSRange range;
NSScanner *scanner = nil;
NSString *tempName = nil;
[self _strip];
scanner = [NSScanner scannerWithString: ivarString];
if(NSEqualRanges((range = [ivarString rangeOfString: @"IBOutlet"]),notFound) == NO &&
range.location == 0)
if(lookAhead(ivarString,@"IBOutlet"))
{
[scanner scanUpToAndIncludingString: @"IBOutlet" intoString: NULL]; // return type
[scanner scanCharactersFromSet: wsnl intoString: NULL];
@ -105,8 +104,7 @@
[scanner scanUpToCharactersFromSet: wsnl intoString: &tempName]; // variable name...
[self setIsOutlet: YES];
}
else if(NSEqualRanges((range = [ivarString rangeOfString: @"id"]),notFound) == NO &&
range.location == 0)
else if(lookAhead(ivarString, @"id"))
{
[scanner scanUpToCharactersFromSet: wsnl intoString: NULL]; // id
[scanner scanCharactersFromSet: wsnl intoString: NULL];

View file

@ -1,9 +1,9 @@
/* OCHeaderParser.m
/* OCIVarDecl.m
*
* Copyright (C) 1999 Free Software Foundation, Inc.
* Copyright (C) 2004 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 1999, 2002
* Date: 2004
*
* This file is part of GNUstep.
*
@ -27,6 +27,7 @@
#include <GormObjCHeaderParser/OCIVar.h>
#include <GormObjCHeaderParser/OCIVarDecl.h>
#include <GormObjCHeaderParser/NSScanner+OCHeaderParser.h>
#include <GormObjCHeaderParser/ParserFunctions.h>
@implementation OCIVarDecl
@ -60,31 +61,39 @@
- (void) _strip
{
NSScanner *stripScanner = [NSScanner scannerWithString: ivarString];
NSString *resultString = [NSString stringWithString: @""];
NSString *resultString = nil;
NSString *tempString = [NSString stringWithString: @""];
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *typeName = [NSString stringWithString: @""];
NSString *varName = [NSString stringWithString: @""];
while(![stripScanner isAtEnd])
{
NSString *string = nil;
[stripScanner scanUpToCharactersFromSet: wsnl intoString: &string];
resultString = [resultString stringByAppendingString: string];
tempString = [tempString stringByAppendingString: string];
if(![stripScanner isAtEnd])
{
resultString = [resultString stringByAppendingString: @" "];
tempString = [tempString stringByAppendingString: @" "];
}
}
// strip protocol qualifiers
stripScanner = [NSScanner scannerWithString: tempString];
[stripScanner scanUpToString: @"<" intoString: &typeName];
[stripScanner scanUpToAndIncludingString: @">" intoString: NULL];
[stripScanner scanUpToCharactersFromSet: wsnl intoString: &varName];
resultString = [typeName stringByAppendingString: varName];
ASSIGN(ivarString, resultString);
}
- (void) parse
{
NSRange notFound = NSMakeRange(NSNotFound,0);
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSRange range;
[self _strip];
if(NSEqualRanges((range = [ivarString rangeOfString: @","]),notFound) == NO)
if(lookAhead(ivarString,@","))
{
OCIVar *ivar = nil;
NSScanner *scanner = [NSScanner scannerWithString: ivarString];

View file

@ -0,0 +1,32 @@
/* ParserFunctions.h
*
* Copyright (C) 2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: Jan 2005
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef INCLUDED_ParserFunctions_h
#define INCLUDED_ParserFunctions_h
#include <Foundation/NSString.h>
BOOL lookAhead(NSString *stringToScan, NSString *stringToFind);
#endif

View file

@ -0,0 +1,34 @@
/* ParserFunctions.m
*
* Copyright (C) 2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: Jan 2005
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <Foundation/Foundation.h>
#include "ParserFunctions.h"
BOOL lookAhead(NSString *stringToScan, NSString *stringToFind)
{
NSRange range;
return (NSEqualRanges((range = [stringToScan rangeOfString: stringToFind]),
NSMakeRange(NSNotFound,0)) == NO);
}

View file

@ -2,74 +2,6 @@
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"alignCenter:",
"alignLeft:",
"arrangeInFront:",
"capitalizeWord:",
"checkSpelling:",
"complete:",
"copyFont:",
"cut:",
"deleteBackward:",
"deleteToBeginningOfLine:",
"deleteToEndOfLine:",
"deleteToMark:",
"deleteWordForward:",
"deselectAll:",
"hide:",
"indent:",
"lowerBaseline:",
"makeKeyAndOrderFront:",
"miniaturizeAll:",
"moveBackwardAndModifySelection:",
"moveDownAndModifySelection:",
"moveForwardAndModifySelection:",
"moveRight:",
"moveToBeginningOfLine:",
"moveToEndOfDocument:",
"moveToEndOfParagraph:",
"moveUpAndModifySelection:",
"moveWordBackwardAndModifySelection:",
"moveWordForwardAndModifySelection:",
"ok:",
"openDocument:",
"orderFront:",
"orderFrontDataLinkPanel:",
"orderFrontStandardAboutPanel:",
"orderOut:",
"pageUp:",
"pasteAsPlainText:",
"pasteFont:",
"performClose:",
"performZoom:",
"raiseBaseline:",
"runPageLayout:",
"saveAllDocuments:",
"saveDocumentAs:",
"scrollLineDown:",
"scrollPageDown:",
"scrollViaScroller:",
"selectLine:",
"selectParagraph:",
"selectText:",
"selectWord:",
"showGuessPanel:",
"showWindow:",
"subscript:",
"swapWithMark:",
"takeFloatValueFrom:",
"takeObjectValueFrom:",
"terminate:",
"toggle:",
"toggleRuler:",
"toggleTraditionalCharacterShape:",
"transposeWords:",
"turnOffLigatures:",
"unhide:",
"unscript:",
"useAllLigatures:",
"useStandardLigatures:",
"zoom:",
"selectArchiveType:"
);
Super = NSObject;