#ifndef FUNCS_H
#define FUNCS_H

// library functions
Prototype LibCall struct ParserData     *MountScanner(void);
Prototype LibCall ULONG                  StartScanner(register __a0 struct GlobalConfig *, register __a1 struct EditConfig *, register __d0 struct SyntaxChunk *);
Prototype LibCall ULONG                  CloseScanner(register __d0 ULONG);
Prototype LibCall void                   FlushScanner(register __d0 ULONG);
Prototype LibCall void                   SetupScanner(register __a0 struct GlobalConfig *);
Prototype LibCall struct RefreshRequest *BriefScanner(register __d0 ULONG, register __a0 struct ScannerNotify *);
Prototype LibCall struct SyntaxChunk    *ParseLine   (register __d0 ULONG, register __a0 struct LineNode *, register __d1 ULONG);
Prototype LibCall void                   UnparseLines(register __a0 struct LineNode *, register __d0 ULONG);
Prototype LibCall void                   ParseSection(register __d0 ULONG, register __a0 struct LineNode *, register __d1 ULONG);

// Locale function
Prototype LibCall STRPTR GetString(register __a0 struct LocaleInfo *, register __d0 LONG);

// ARexx function
Prototype ULONG *SendRexxCommand(UBYTE *, UBYTE *, struct MsgPort *, UBYTE *);

// Buffer handles are allocated for each text buffer to keep track of ressources:
struct BufferHandle {
    struct EditConfig     *bh_EditConfig;            // pointer to text data
    struct GlobalConfig   *bh_GlobalConfig;          // editor configuration
    struct SyntaxChunk    *bh_SyntaxStack;           // parser output
    struct RefreshRequest  bh_RefreshRequest;        // display refresh request
    #ifdef ISPELL
    struct MsgPort        *bh_ReplyPort;             // replyPort for Rexx msg
    #endif
    UBYTE                  bh_Command[4096];         // ISpell command buffer
    UBYTE                  bh_Results[4096];         // ISpell result buffer
};

#define EMPTY_STACK ((struct SyntaxChunk *)~0)       // empty stack flag

// States of syntaxic analyser
#define INT  0
#ifdef ISPELL
#define CHK  1
#endif
#define INS  2
#define INSD 3
#define INSH 4
#define ARG  5
#define ARGD 6
#define NBH  7
#define NBHD 8
#define NBO  9
#define NBOD 10
#define ASC  11
#define SIG  12
#define NBR  13
#define DEC  14
#define DECD 15
#define ASCD 16
#define END  17

// Number of syntaxic groups
#ifdef ISPELL
#define CHKNBR 14   // + Standard text
#else
#define CHKNBR 13   // + Standard text
#endif
// Syntaxic groups
#define STDT 0      // Standard text
#define INTL 1      // Long instructions
#define INTS 2      // Short instructions
#define INTH 3      // Hidden instructions
#define GRPE 4      // Groups {}
#define OPTI 5      // Options []
#define NBRE 6      // Numbers
#define DIME 7      // Dimensions
#define COMM 8      // Comments
#define MATH 9      // Math mode
#define MTHS 10     // Lower - Exponent
#define INSC 11     // Uncutable car
#define MACA 12     // Macro arguments
#ifdef ISPELL
#define ISPE 13     // ISpell error
#endif
// Macro for car test
#define isodigit(x) (isdigit(x) && (x <= '7'))
#ifdef ISPELL
#define isword(x) (isalpha(x) || (x >= 'À' && x <= 'ÿ'))
#endif

#endif
