/* Created: BP21500-05-15
 *          -- Sian Leitch <algol68@sleitch.nildram.co.uk>
 * Modified: 2012-02-02
 *       -- Sian Mountbatten <poenikatu@fastmail.co.uk>
 * Modified: 2013-02-02 06:58:55
 *          -- Sian Mountbatten <poenikatu@fastmail.co.uk>
 */

// Web 68 colour highlighting
// Tokens
#define ALGOL68_TOKEN_BANG        1
#define ALGOL68_TOKEN_BAR         2
#define ALGOL68_TOKEN_BOLD_TAG    3
#define ALGOL68_TOKEN_BRACKET     4
#define ALGOL68_TOKEN_COMMENT     5
#define ALGOL68_TOKEN_CONSTRUCT   ALGOL68_TOKEN_BOLD_TAG
#define ALGOL68_TOKEN_FORMAT      6
#define ALGOL68_TOKEN_IDENTIFIER  7
#define ALGOL68_TOKEN_NUMBER      8
#define ALGOL68_TOKEN_OPERATOR    9
#define ALGOL68_TOKEN_PUNCTUATION 10
#define ALGOL68_TOKEN_STRING      11
#define ALGOL68_TOKEN_WEB68       12

volatile int algol68_token;

// Various global names
keytable web68_tab;

user char Matchdelim_web68 = 1;
user int web68_tab_override = 3;
buffer int web68_in_comment = 0;

user char auto_show_web68_delimiters = 1;
user char web68_auto_show_delim_chars[10] = "{[()]}";
user char compile_web68_cmd[128] = "ca -s %f";

volatile char algol68_op_chars[20]   = ":-+*/%^&~<>=";
volatile char algol68_colon_chars[5] = ":/=";

#define WEB68_HTML_STATE        0
#define WEB68_ALGOL68_STATE     1
#define ALGOL68_LIMITED_STATE   2

// state values
volatile int web68_state = WEB68_HTML_STATE;
volatile int prev_state;

// debug values
char debug_buffer[20] = "Web-68-debug";
int web68_dbg;      /* debug buffer num */
int debug_web68 = 0;    /* set to 1 for debugging */

// Search patterns
char algol68_construct_pat[] = "|ALIEN|BEGIN|BY|CASE|CODE|CONTEXT|DECS|DO|ELIF"
                     "|ELSE|END|ESAC|EXIT|FI|FINISH|FOR|FROM|GO"
                "|GOTO|IF|IN|KEEP|OD|OF|OUSE|OUT|PAR|PRIO"
                "|PROGRAM|THEN|TO|USE|WHILE|";
char algol68_mode_pat[]      = "|FLEX|HEAP|LOC|REF|STRUCT|UNION|OP|PROC"
                "|BITS|BOOL|BYTES|CHANNEL|CHAR|COMPL|FILE"
                "|FORMAT|INT|LONG|REAL|SHORT|STRING|VOID|";
char algol68_num_pat[]       = "|FALSE|NIL|SKIP|TRUE|";
char algol68_operator_pat[]  = "|ABS|AND|BIN|DIVAB|ENTIER|EQ|GE|GT|LE|LENG|LT"
                "|LWB|MINUSAB|MOD|MODAB|NE|NOT|ODD|OR|OVER"
                "|OVERAB|PLUSAB|PLUSTO|REPR|ROUND|SHL|SHORTEN"
                "|SHR|TIMESAB|UPB|";
char algol68_comment_pat[]   = "|CO|COMMENT|";
char algol68_punctuation[]   = "()[];,";

// Define colours for Algol 68
#define orange       MAKE_RGB(255, 165, 0)
#define pink         MAKE_RGB(255, 192, 203)

// Color_classes for Algol 68
color_class algol68_bold_tag cyan;
color_class algol68_comment orange;
color_class algol68_construct cyan;
color_class algol68_html pink;
color_class algol68_html_tag orange;
color_class algol68_identifier white;
color_class algol68_mode cyan;
color_class algol68_number red;
color_class algol68_operator magenta;
color_class algol68_punctuation green;
color_class algol68_string yellow;

int color_web68_from_here(int safe);
int color_web68_range(int from, int to);
