home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TextParser.h
-
- Contains: International Text Parser Interfaces.
-
- Version: Technology: System 8
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __TEXTPARSER__
- #define __TEXTPARSER__
-
- #ifndef __CONDITIONALMACROS__
- #include <ConditionalMacros.h>
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __TEXTOBJECTS__
- #include <TextObjects.h>
- #endif
- #ifndef __TEXTCOMMON__
- #include <TextCommon.h>
- #endif
- #ifndef __LOCALEOBJECTS__
- #include <LocaleObjects.h>
- #endif
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- #if FOR_SYSTEM8_PREEMPTIVE
- #define kParserTableLocaleKeyName "\pparsetable"
- typedef struct OpaqueTTextParseRef* TTextParseRef;
- typedef UInt32 ParsingToken;
- typedef ParsingToken BasicToken;
- typedef ParsingToken RangeToken;
- typedef ParsingToken KeywordToken;
- typedef ParsingToken MultiChoiceToken;
- typedef ParsingToken ComposedToken;
- /*defintions for the future*/
- typedef ParsingToken RegExpToken;
- typedef ParsingToken GrammarRuleToken;
- /*definition of Pointers to tokens*/
- typedef ParsingToken *ParsingTokenPtr;
- typedef ParsingTokenPtr BasicTokenPtr;
- typedef ParsingTokenPtr RangeTokenPtr;
- typedef ParsingTokenPtr KeywordTokenPtr;
- typedef ParsingTokenPtr MultiChoiceTokenPtr;
- typedef ParsingTokenPtr ComposedTokenPtr;
- typedef OptionBits ParsingOptionBits;
- typedef LocaleObjectRef ParserLocaleObjectRef;
-
- enum {
- /*ParsingOptionBits*/
- kParseMainTokenOptionBit = 0,
- kIsAlphaNumericKeyWordOptionBit = 1,
- kIsCaseSensitiveParsingOptionBit = 2,
- kIsDiacreticSensitiveParsingOptionBit = 3,
- kParseTextEnclosedByLitearlDelimitersOptionBit = 4,
- kIsCommentsAllowedOptionBit = 5
- };
-
-
- enum {
- /*ParsingOptionMask*/
- kStandardParsingOptionsMask = 0,
- kParseMainTokenOptionMask = 1L << kParseMainTokenOptionBit,
- kIsAlphaNumericKeyWordOptionMask = 1L << kIsAlphaNumericKeyWordOptionBit,
- kIsCaseSensitiveParsingOptionMask = 1L << kIsCaseSensitiveParsingOptionBit,
- kIsDiacreticSensitiveParsingOptionMask = 1L << kIsDiacreticSensitiveParsingOptionBit,
- kParseTextEnclosedByLitearlDelimitersOptionMask = 1L << kParseTextEnclosedByLitearlDelimitersOptionBit,
- kIsCommentsAllowedOptionMask = 1L << kIsCommentsAllowedOptionBit
- };
-
- /* Basic Tokens definitions (try to match system 7 tokens when possible*/
-
- enum {
- kBasicTokenUnknown = 0, /*characters that don't have token definition*/
- kBasicTokenEscape = 10, /*character escape (e.g. '\' in "\n", "\t")*/
- kBasicTokenLeftParen = 16, /*open parenthesis*/
- kBasicTokenRightParen = 17, /*close parenthesis*/
- kBasicTokenLeftBracket = 18, /*open square bracket*/
- kBasicTokenRightBracket = 19, /*close square bracket*/
- kBasicTokenLeftCurly = 20,
- kBasicTokenRightCurly = 21, /*close curly bracket*/
- kBasicTokentokenLeftEnclose = 22, /*open guillemet*/
- kBasicTokenRightEnclose = 23, /*close guillemet*/
- kBasicTokenPlus = 24,
- kBasicTokenMinus = 25,
- kBasicTokenAsterisk = 26, /*times/multiply*/
- kBasicTokenDivide = 27,
- kBasicTokenPlusMinus = 28, /*plus or minus symbol*/
- kBasicTokenSlash = 29,
- kBasicTokenBackSlash = 30,
- kBasicTokenLess = 31, /*less than symbol*/
- kBasicTokenGreat = 32, /*greater than symbol*/
- kBasicTokenEqual = 33,
- kBasicTokenLessEqual1 = 35, /*less than or equal, 1 character*/
- kBasicTokenGreatEqual1 = 37, /*greater than or equal, 1 character*/
- kBasicTokenNotEqual = 40, /*not equal, 1 character*/
- kBasicTokenExclam = 43, /*exclamation point*/
- kBasicTokenTilde = 44, /*centered tilde*/
- kBasicTokenComma = 45,
- kBasicTokenPeriod = 46,
- kBasicTokenLeft2Quote = 47, /*open double quote*/
- kBasicTokenRight2Quote = 48, /*close double quote*/
- kBasicTokenLeft1Quote = 49, /*open single quote*/
- kBasicTokenRight1Quote = 50, /*close single quote*/
- kBasicToken2Quote = 51, /*double quote*/
- kBasicToken1Quote = 52, /*single quote*/
- kBasicTokenSemicolon = 53,
- kBasicTokenPercent = 54,
- kBasicTokenCaret = 55,
- kBasicTokenUnderline = 56,
- kBasicTokenAmpersand = 57,
- kBasicTokenAtSign = 58,
- kBasicTokenBar = 59, /*vertical bar*/
- kBasicTokenQuestion = 60,
- kBasicTokenPi = 61, /*lower-case pi*/
- kBasicTokenRoot = 62, /*square root symbol*/
- kBasicTokenSigma = 63, /*capital sigma*/
- kBasicTokenIntegral = 64, /*integral sign*/
- kBasicTokenMicro = 65,
- kBasicTokenCapPi = 66, /*capital pi*/
- kBasicTokenInfinity = 67,
- kBasicTokenColon = 68,
- kBasicTokenHash = 69, /*e.g. #*/
- kBasicTokenDollar = 70,
- kBasicTokenNoBreakSpace = 71, /*non-breaking space*/
- kBasicTokenFraction = 72,
- kBasicTokenIntlCurrency = 73,
- kBasicTokenLeftSingGuillemet = 74,
- kBasicTokenRightSingGuillemet = 75,
- kBasicTokenPerThousand = 76,
- kBasicTokenEllipsis = 77,
- kBasicTokenCenterDot = 78,
- kBasicTokenSpace = 128,
- kBasicTokenPasswordChar = 129
- };
-
-
- enum {
- /*predefined composed tokens*/
- kComposedTokenLessEqual2 = 16383, /*less than or equal, 2 characters (e.g. <=)*/
- kComposedTokenEqual2 = 16384, /*greater than or equal, 2 characters (e.g. >=)*/
- kComposedToken2Equal = 16385, /*double equal (e.g. ==)*/
- kComposedTokenColonEqual = 16386, /*colon equal*/
- kComposedTokenLessGreat = 16387, /*less/greater, Pascal not equal (e.g. <>)*/
- kComposedTokenExclamEqual = 16388, /*exclamation equal, C not equal (e.g. !=)*/
- kComposedTokenNewLine = 16389 /*composed may be more than one (10,13)*/
- };
-
-
- enum {
- /*predefined multiple choice tokens*/
- kChoiceTokenWhite = 8192, /*white space (CR,LF,space, non break space)*/
- kChoiceTokenLeftLit = 8193, /*literal begin , can be one or more*/
- kChoiceTokenRightLit = 8194, /*literal end, can be one or more*/
- kChoiceTokenAlpha = 8195, /*alphabetic char*/
- kChoiceTokenNumeric = 8196, /*numeric char*/
- kChoiceTokenPunctuationChar = 8197, /*punctuation char*/
- kChoiceTokenRightComment = 8198, /* can be one or more*/
- kChoiceTokenLeftComment = 8199 /* can be one or more*/
- };
-
-
- enum {
- /*predefined token classes (not overridable for 8.0) mapped to regular expression tokens*/
- kTokenClassIdentifier = 32768L, /* alphabetic or alphanumeric entities*/
- kTokenClassComment = 32769L, /* anything inside comment delimiters */
- kTokenClassliteral = 32770L, /* anything inside literal delimiters */
- kTokenClassIntegerNumber = 32771L, /* text is numeric presentation (integers)*/
- kTokenClassFloatingNumber = 32772L /*text is numeric presentation (float)*/
- };
-
- struct CharacterRange { /* structure defining a range of char*/
- UInt32 theCharRangeBegin;
- UInt32 theCharRangeEnd;
- };
- typedef struct CharacterRange CharacterRange;
-
- typedef CharacterRange *CharacterRangePtr;
- /*============================================================locale object parser APIs====================================================*/
- extern OSStatus GetParserObjectByLocaleID(LocaleIdentifier theLocaleIdentifier, TextEncoding theEncoding, ParserLocaleObjectRef *theParserObject);
-
- extern OSStatus GetParserObjectByLocaleRef(LocaleRef locale, TextEncoding theEncoding, ParserLocaleObjectRef *theParserObject);
-
- extern OSStatus GetCurrentParserObject(ParserLocaleObjectRef *theParserObject);
-
- extern OSStatus GetParserObjectInfo(ParserLocaleObjectRef theParserObject, TextEncoding *theEncoding, LocaleIdentifier *theLocaleIdentifier);
-
- /*======================================================Iterator creation/modifcation==========================================================*/
- extern OSStatus CreateLexicalIterator(ParserLocaleObjectRef localeParserRef, TextObject theTextObject, TextObjectIndex startIndex, TextObjectIndex endIndex, ParsingOptionBits theParsingOptions, TTextParseRef *theParserRef);
-
- extern OSStatus LexicalIteratorGetNextToken(TTextParseRef theParser, ParsingToken *theCurrentToken, TextObjectIndex *startIndex, TextObjectIndex *endIndex);
-
- extern OSStatus LexicalIteratorSetCommentDelimiters(TTextParseRef refLexicalIterator, ParsingToken tokenLeftDel, ParsingToken tokenRightDel);
-
- extern OSStatus LexicalIteratorReset(TTextParseRef refLexicalIterator);
-
- extern OSStatus LexicalIteratorSetText(TTextParseRef refLexicalIterator, TextObject theTextObject, TextObjectIndex startIndex, TextObjectIndex endIndex);
-
- extern OSStatus LexicalIteratorSetTokenToMatch(TTextParseRef refLexicalIterator, ComposedToken theToken);
-
- /*======================================================Tokens Get/Set APIs ==========================================================*/
- extern OSStatus LexicalIteratorDefineBasicToken(TTextParseRef refLexicalIterator, UInt32 theChar, BasicToken theToken);
-
- extern OSStatus GetUniqueBasicToken(TTextParseRef refLexicalIterator, BasicToken *theToken);
-
- extern OSStatus LexicalIteratorDefineKeywordToken(TTextParseRef refLexicalIterator, TextObject theText, TextObjectIndex theStart, TextObjectIndex theEnd, KeywordToken theToken);
-
- extern OSStatus GetUniqueKeywordToken(TTextParseRef refLexicalIterator, KeywordToken *theToken);
-
- extern OSStatus LexicalIteratorDefineRangeToken(TTextParseRef refLexicalIterator, UInt32 rangeBeginChar, UInt32 rangeEndChar, RangeToken theToken);
-
- extern OSStatus GetUniqueRangeToken(TTextParseRef refLexicalIterator, RangeToken *theToken);
-
- extern OSStatus LexicalIteratorDefineMultiChoiceToken(TTextParseRef refLexicalIterator, ItemCount nChoices, ParsingToken theChoices[], MultiChoiceToken *theToken);
-
- extern OSStatus GetUniqueMultiChoiceToken(TTextParseRef refLexicalIterator, MultiChoiceToken *theToken);
-
- extern OSStatus LexicalIteratorDefineComposedToken(TTextParseRef refLexicalIterator, ItemCount nChoices, ParsingToken theChoices[], ComposedToken *theToken);
-
- extern OSStatus GetUniqueComposedToken(TTextParseRef refLexicalIterator, ComposedToken *theToken);
-
- extern OSStatus GetTextFromToken(TTextParseRef refLexicalIterator, ParsingToken theToken, TextObject TheText);
-
- extern OSStatus GetLocaleTextFromToken(ParserLocaleObjectRef localeParserRef, ParsingToken theToken, TextObject TheText);
-
- extern OSStatus GetRangeToken(TTextParseRef refLexicalIterator, RangeToken theToken, UInt32 *beginRangeChar, UInt32 *endRangeChar);
-
- extern OSStatus GetLocaleRangeToken(ParserLocaleObjectRef localeParserRef, RangeToken theToken, UInt32 *beginRangeChar, UInt32 *endRangeChar);
-
- extern OSStatus GetCountTokenChoices(TTextParseRef refLexicalIterator, MultiChoiceToken theToken, ItemCount *nChoices);
-
- extern OSStatus GetLocaleCountTokenChoices(ParserLocaleObjectRef localeParserRef, MultiChoiceToken theToken, ItemCount *nChoices);
-
- extern OSStatus GetMultiChoiceToken(TTextParseRef refLexicalIterator, MultiChoiceToken theToken, ParsingToken theChoices[]);
-
- extern OSStatus GetLocaleMultiChoiceToken(ParserLocaleObjectRef localeParserRef, MultiChoiceToken theToken, ParsingToken theChoices[]);
-
- extern OSStatus GetCountTokenComposition(TTextParseRef refLexicalIterator, ComposedToken theToken, ItemCount *nChoices);
-
- extern OSStatus GetLocaleCountTokenComposition(ParserLocaleObjectRef localeParserRef, ComposedToken theToken, ItemCount *nChoices);
-
- extern OSStatus GetComposedToken(TTextParseRef refLexicalIterator, ComposedToken theToken, ParsingToken theComposition[]);
-
- extern OSStatus GetLocaleComposedToken(ParserLocaleObjectRef localeParserRef, ComposedToken theToken, ParsingToken theChoices[]);
-
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __TEXTPARSER__ */
-
-