home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
-
- LanguageModule.h
-
- Interface file for Preditor language modules
-
- © Copyright Evatac Software 1988-1995
- All rights reserved
-
- ************************************************************
-
- Language modules are compose of resources, and code.
- The header file deals with the code in a language module.
-
- The language module code is based on Preditor extensions.
- Language modules main entry point gets called just as
- an extension would -- the only difference being that there
- are 2 additional parameters -- the "what to do" parameter,
- and the 'data' parameter. Language modules also have
- legitimate access to the "TokenReturn" extension entry point.
-
- Your definition of 'main' should look like this:
-
- void main(
- ExternalCallbackBlock *callbacks,
- WindowRef window
- long command,
- void *data
- );
-
- The 'data' value is defined for the following commands:
-
- kLanguageTemplate (long) Index of template to insert
- kLanguageElectric (Char) electric character typed
-
- ************************************************************/
-
- #ifndef __LANGUAGEMODULE__
- #define __LANGUAGEMODULE__
-
- #include "PreditorExtension.h"
-
-
- /*
- * * * * * * * * * CONSTANTS AND MACRO DEFINITIONS * * * * * * * * * *
- */
-
- /*
- * Language commands -- 'command' parameter to language module.
- * These are the built-in/required command -- all language
- * modules must handle these in some fashion.
- */
- enum {
- kLanguageParse = 0,
- kLanguageFunctions,
- kLanguageIncludes,
- kLanguageTemplate,
- kLanguageIndent,
- kLanguageElectric
- };
-
- #define kTokenStringSize 64
- #define kEOL 13
-
- /*
- * * * * * * * * * TYPE AND STRUCTURE DEFINITIONS * * * * * * * * * *
- */
-
- /*
- * The 'languageToken' is returned though the "TokenReturn"
- * callback. The language module call this when determing
- * functions, language-tokens and includes for a source file
- */
-
- typedef struct languageToken {
- Int16 type;
- Int16 majorType;
-
- Char string[kTokenStringSize + 2];
-
- Int32 startLocation;
- Int32 endLocation;
- Int32 commentLocation;
- } languageToken;
-
- typedef struct languageGlobals {
- Handle tokenTable;
- Handle customTokenTable;
- languageToken token;
- Int32 position;
- Int32 startLastComment;
- short ungetBuffer[3];
- short ungetCount;
- Boolean expired;
- } languageGlobals;
-
- #if GENERATINGCFM
-
- enum {
- LanguageUPPInfo = kCStackBased
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ExternalCallbackBlock *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowRef)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void *)))
- };
-
- #endif
-
- /*
- * * * * * * * * * FUNCTION PROTOTYPES * * * * * * * * * *
- */
-
- /*
- * Your language module can make calls to the following public
- * entry points, found in the LanguageModuleLib
- */
-
- void languageInit(
- languageGlobals *info,
- ExternalCallbackBlock *callbacks,
- long options
- );
-
- void languageDone(
- languageGlobals *info,
- ExternalCallbackBlock *callbacks
- );
-
- void languageDefaultHandler(
- languageGlobals *info,
- ExternalCallbackBlock *callbacks,
- long options,
- void *data
- );
-
- int languageGetChar(
- languageGlobals *info,
- ExternalCallbackBlock *callbacks
- );
-
- int languageUngetChar(
- languageGlobals *info,
- ExternalCallbackBlock *callbacks
- );
-
- int languagePeekChar(
- languageGlobals *info,
- ExternalCallbackBlock *callbacks
- );
-
- short languageCStringCompare(
- Char *s1,
- Char *s2
- );
-
- /*
- * This function does a hash lookup for the given cstring, returning
- * true if it's a reserved token. This table is only defined
- * for the kLanguageParse & kLanguageIncludes commands.
- */
-
- Boolean languageTableLookup(
- languageGlobals *info,
- Char cstring
- );
-
- Boolean languageCustomTableLookup(
- languageGlobals *info,
- Char cstring
- );
-
- Boolean languageHasTable(
- languageGlobals *info
- );
-
- /*
- * These are private --- used by the language builder application
- */
-
- Handle stringTableCreate(void);
-
- void stringTableDestroy(
- Handle table
- );
-
- void stringTableIntern(
- Handle table,
- Char *name
- );
-
- void stringTableWriteResource(
- Handle table,
- short resourceId
- );
-
- Handle stringTableReadResource(
- short resourceId
- );
-
- Boolean stringTableLookup(
- Handle table,
- Char *name
- );
-
- /*
- * * * * * * * * * PRIVATE MACROS * * * * * * * * * *
- */
-
- #define languageUngetChar(g,c) ((g)->ungetBuffer[(g)->ungetCount++] = (c), \
- (g)->position--)
- #define languageHasTable(g) ((g)->tokenTable != nil)
- #define languageTableLookup(g,c) stringTableLookup(g->tokenTable, c)
- #define languageCustomTableLookup(g,c) stringTableLookup(g->customTokenTable, c)
-
- #endif
-