File: syntax.h

package info (click to toggle)
jupp 3.1.21-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,208 kB
  • sloc: ansic: 27,469; sh: 4,058; makefile: 209
file content (67 lines) | stat: -rw-r--r-- 1,872 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* $MirOS: contrib/code/jupp/syntax.h,v 1.2 2008/05/13 13:08:26 tg Exp $ */

#ifndef _Isyntax
#define _Isyntax 1

#include "hash.h"

/*
 *	Syntax highlighting DFA interpreter
 *	Copyright
 *		(C) 2004 Joseph H. Allen
 *
 *	This file is part of JOE (Joe's Own Editor)
 */

/* Color definition */

struct high_color {
	struct high_color *next;
	unsigned char *name;		/* Symbolic name of color */
	int color;			/* Color value */
};

/* State */

struct high_state {
	int no;				/* State number */
	unsigned char *name;		/* Highlight state name */
	int color;			/* Color for this state */
	struct high_cmd *cmd[256];	/* Character table */
};

/* Command (transition) */

struct high_cmd {
	int noeat;			/* Set to give this character to next state */
	int recolor;			/* No. chars to recolor if <0. */
	int start_buffering;		/* Set if we should start buffering */
	int stop_buffering;		/* Set if we should stop buffering */
	struct high_state *new_state;	/* The new state */
	HASH *keywords;			/* Hash table of keywords */
	int ignore;			/* Set to ignore case */
};

/* Loaded form of syntax file */

struct high_syntax {
	struct high_syntax *next;	/* Linked list of loaded syntaxes */
	unsigned char *name;			/* Name of this syntax */
	struct high_state **states;	/* The states of this syntax.  states[0] is idle state */
	int nstates;			/* No. states */
	int szstates;			/* Malloc size of states array */
	struct high_color *color;	/* Linked list of color definitions */
	int sync_lines;			/* No. lines back to start parsing when we lose sync.  -1 means start at beginning */
	struct high_cmd default_cmd;	/* Default transition for new states */
};

/* Find a syntax.  Load it if necessary. */

struct high_syntax *load_dfa(unsigned char *name);

/* Parse a lines.  Returns new state. */

extern int *attr_buf;
int parse(struct high_syntax *syntax,P *line,int state);

#endif