Rev 8219 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 2002-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program; if not, write to the Free Software |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
17 | |||
18 | #ifndef SYMTEXT_H |
||
19 | #define SYMTEXT_H 1 |
||
20 | |||
21 | #include <time.h> |
||
22 | |||
8161 | bpr | 23 | #include "../../Lib/libwims.h" |
10 | reyssat | 24 | |
25 | /* Maximum of blocks. Limited to sizeof(short). */ |
||
26 | #define MAX_BLOCKS 8192 |
||
27 | /* Maximum of pools. Limited to sizeof(short). */ |
||
28 | #define MAX_POOLS 10240 |
||
29 | /* Maximum of variable names. */ |
||
30 | #define MAX_NAMELEN 63 |
||
31 | /* Maximum of (complete) file names. */ |
||
32 | #define MAX_FNAME 199 |
||
33 | /* Maximum of dictionaries, including reserved ones. */ |
||
34 | #define MAX_DICS 15 |
||
35 | /* Maximum of lists in permdata. Very limited. */ |
||
36 | #define MAX_PERMLIST 4 |
||
37 | /* Size of list buffer */ |
||
38 | #define MAX_LISTS 65536 |
||
39 | /* Limit of the length of builtin command names */ |
||
40 | #define MAX_BINAME 10 |
||
41 | /* Limit to nesting levels */ |
||
42 | #define MAX_LEVELS 16384 |
||
43 | /* How many picks at most */ |
||
44 | #define MAX_PICKS 64 |
||
45 | /* limit of entries in a dictionary */ |
||
46 | #define MAX_DICENTRIES 512*1024 |
||
47 | /* limit of any single dictionary size */ |
||
48 | #define MAX_DICSIZE 10240*1024 |
||
49 | |||
50 | /* int or short */ |
||
51 | #define listtype short int |
||
52 | /* default dictionary directory */ |
||
53 | #define defaultdir "scripts" |
||
54 | |||
55 | #define char_punct ".,;:?!\"" |
||
56 | #define char_math "+-*/=|%<>()_" |
||
57 | #define char_parenth "()[]{}" |
||
58 | #define char_cs "_&$#`\\@~" |
||
59 | #define char_quote "`'\"" |
||
60 | |||
61 | typedef struct block { |
||
62 | char *string; /* string for compare */ |
||
63 | int (*fn) (struct block *blk, char *start, int level); |
||
64 | listtype nextblock, sublock; /* subblocks are always consecutive */ |
||
65 | listtype len, lcnt, lind1, lind2, lstart, pool, mpool, mend; |
||
66 | listtype *listlen; |
||
67 | listtype *lists[MAX_PERMLIST]; /* permutation lists */ |
||
68 | } block; |
||
69 | |||
70 | typedef struct poolstruct { |
||
71 | listtype block, lastpool, ind1, ind2, dirty, len; |
||
72 | char *string; |
||
73 | listtype *tag; /* level tags for recursion */ |
||
74 | } poolstruct; |
||
75 | |||
8161 | bpr | 76 | /* from translate.c */ |
77 | extern struct entry { |
||
78 | unsigned char *original, *replace; |
||
79 | int olen,earlier; |
||
80 | } entry[]; |
||
81 | |||
82 | int search_dic(struct entry *list, int items, size_t item_size, const char *str); |
||
83 | |||
84 | extern struct dic { |
||
85 | char name[MAX_FNAME+1]; |
||
86 | char unknown[256]; |
||
87 | char *buf; |
||
88 | int unknown_type; |
||
89 | int start; |
||
90 | int len; |
||
91 | } dic[MAX_DICS]; |
||
92 | enum { |
||
93 | unk_delete, unk_leave, unk_replace |
||
94 | }; |
||
14873 | georgesk | 95 | extern int transdic; |
96 | extern int macrodic; |
||
97 | extern int diccnt; |
||
8161 | bpr | 98 | struct dic *prepare_dic(char *fname); |
99 | int getdic(char *dicname); |
||
100 | |||
101 | /*from symtext.c */ |
||
102 | |||
103 | extern char styledir[], defbuf[]; |
||
104 | char *mkfname(char buf[], char *s,...); |
||
105 | extern int debug; |
||
14873 | georgesk | 106 | extern int nextpool; |
107 | extern int nexttag; |
||
8161 | bpr | 108 | extern poolstruct poolbuf[MAX_POOLS]; |
109 | extern block blockbuf[MAX_BLOCKS]; |
||
110 | #define OUTSIZE 4096 |
||
111 | extern char *outptr, *wptr, outbuf[OUTSIZE]; |
||
112 | extern listtype tagbuf[MAX_BLOCKS]; |
||
113 | extern int nextblock, nextlist; |
||
114 | extern char wbuf[MAX_LINELEN+1]; |
||
115 | extern listtype listbuf[MAX_LISTS]; |
||
116 | extern int options; |
||
117 | #define op_nocase (1<<0) |
||
118 | #define op_deaccent (1<<1) |
||
119 | #define op_reaccent (1<<2) |
||
120 | #define op_nopunct (1<<3) |
||
121 | #define op_nomath (1<<4) |
||
122 | #define op_noparenth (1<<5) |
||
123 | #define op_nocs (1<<6) |
||
124 | #define op_noquote (1<<7) |
||
125 | #define op_matchall (1<<8) |
||
126 | #define op_alphaonly (1<<9) |
||
127 | #define op_alnumonly (1<<10) |
||
8195 | bpr | 128 | void sym_error(char *msg,...); |
8161 | bpr | 129 | void _getdef(char buf[], char *name, char value[]); |
130 | /* from match.c */ |
||
131 | int mt_string(struct block *blk, char *start, int level); |
||
132 | int mt_permpick(struct block *blk, char *start, int level); |
||
133 | int mt_m(struct block *blk, char *start, int level); |
||
134 | int mt_neg(struct block *blk, char *start, int level); |
||
135 | int mt_dic(struct block *blk, char *start, int level); |
||
136 | int mt_w(struct block *blk, char *start, int level); |
||
137 | int mt_wild(struct block *blk, char *start, int level); |
||
138 | int mt_out(struct block *blk, char *start, int level); |
||
139 | int mt_nomatch(struct block *blk, char *start, int level); |
||
140 | |||
141 | /* from suffix.c */ |
||
142 | extern int suffixcnt; |
||
143 | void suffix_translate(char *p); |
||
144 | void _translate(char *p, int i); |
||
145 | void suffix_dic(char *sdicname); |
||
146 | |||
147 | /* from compile.c */ |
||
148 | void strfold(char *p); |
||
149 | extern struct builtin { |
||
150 | char *name; |
||
151 | void (*fn) (char *p, struct block *blk, int next); |
||
152 | } builtin[]; |
||
153 | void compile(char *p); |
||
154 | |||
155 | extern int builtincnt, Mcnt; |
||
156 | extern char Mbuf[MAX_LINELEN+1]; |
||
157 | extern char *Mnext; |
||
158 | |||
159 | /* from match.c */ |
||
160 | int match(char *p); |
||
10 | reyssat | 161 | #endif |
162 | |||
8161 | bpr | 163 | |
164 |