Subversion Repositories wimsdev

Rev

Rev 8195 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  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.  
  23. #include "../../Lib/libwims.h"
  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.  
  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. };
  95. int transdic, macrodic;
  96. int diccnt;
  97. struct dic *prepare_dic(char *fname);
  98. int getdic(char *dicname);
  99.  
  100. /*from symtext.c */
  101.  
  102. extern char styledir[], defbuf[];
  103. char *mkfname(char buf[], char *s,...);
  104. extern int debug;
  105. int nextpool, nexttag;
  106. extern poolstruct poolbuf[MAX_POOLS];
  107. extern block blockbuf[MAX_BLOCKS];
  108. #define OUTSIZE 4096
  109. extern char *outptr, *wptr, outbuf[OUTSIZE];
  110. extern listtype tagbuf[MAX_BLOCKS];
  111. extern int nextblock, nextlist;
  112. extern char wbuf[MAX_LINELEN+1];
  113. extern listtype listbuf[MAX_LISTS];
  114. extern int options;
  115. #define op_nocase    (1<<0)
  116. #define op_deaccent  (1<<1)
  117. #define op_reaccent  (1<<2)
  118. #define op_nopunct   (1<<3)
  119. #define op_nomath    (1<<4)
  120. #define op_noparenth (1<<5)
  121. #define op_nocs      (1<<6)
  122. #define op_noquote   (1<<7)
  123. #define op_matchall  (1<<8)
  124. #define op_alphaonly (1<<9)
  125. #define op_alnumonly (1<<10)
  126. void sym_error(char *msg,...);
  127. void _getdef(char buf[], char *name, char value[]);
  128. /* from match.c */
  129. int mt_string(struct block *blk, char *start, int level);
  130. int mt_permpick(struct block *blk, char *start, int level);
  131. int mt_m(struct block *blk, char *start, int level);
  132. int mt_neg(struct block *blk, char *start, int level);
  133. int mt_dic(struct block *blk, char *start, int level);
  134. int mt_w(struct block *blk, char *start, int level);
  135. int mt_wild(struct block *blk, char *start, int level);
  136. int mt_out(struct block *blk, char *start, int level);
  137. int mt_nomatch(struct block *blk, char *start, int level);
  138.  
  139. /* from suffix.c */
  140. extern int suffixcnt;
  141. void suffix_translate(char *p);
  142. void _translate(char *p, int i);
  143. void suffix_dic(char *sdicname);
  144.  
  145. /* from compile.c */
  146. void strfold(char *p);
  147. extern struct builtin {
  148.     char *name;
  149.     void (*fn) (char *p, struct block *blk, int next);
  150. } builtin[];
  151. void compile(char *p);
  152.  
  153. extern int builtincnt, Mcnt;
  154. extern char Mbuf[MAX_LINELEN+1];
  155. extern char *Mnext;
  156.  
  157. /* from match.c */
  158. int match(char *p);
  159. #endif
  160.  
  161.  
  162.  
  163.