Subversion Repositories wimsdev

Rev

Rev 8185 | Rev 8219 | 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 "../../includes.h"
  24. #include "../../Lib/libwims.h"
  25.  
  26.         /* Maximum of blocks. Limited to sizeof(short). */
  27. #define MAX_BLOCKS      8192
  28.         /* Maximum of pools. Limited to sizeof(short). */
  29. #define MAX_POOLS       10240
  30.         /* Maximum of variable names. */
  31. #define MAX_NAMELEN     63
  32.         /* Maximum of (complete) file names. */
  33. #define MAX_FNAME       199
  34.         /* Maximum of dictionaries, including reserved ones. */
  35. #define MAX_DICS        15
  36.         /* Maximum of lists in permdata. Very limited. */
  37. #define MAX_PERMLIST    4
  38.         /* Size of list buffer */
  39. #define MAX_LISTS       65536
  40.         /* Limit of the length of builtin command names */
  41. #define MAX_BINAME      10
  42.         /* Limit to nesting levels */
  43. #define MAX_LEVELS      16384
  44.         /* How many picks at most */
  45. #define MAX_PICKS       64
  46.         /* limit of entries in a dictionary */
  47. #define MAX_DICENTRIES 512*1024
  48.         /* limit of any single dictionary size */
  49. #define MAX_DICSIZE     10240*1024
  50.  
  51.         /* int or short */
  52. #define listtype        short int
  53.         /* default dictionary directory */
  54. #define defaultdir      "scripts"
  55.  
  56. #define char_punct      ".,;:?!\""
  57. #define char_math       "+-*/=|%<>()_"
  58. #define char_parenth    "()[]{}"
  59. #define char_cs         "_&$#`\\@~"
  60. #define char_quote      "`'\""
  61.  
  62. typedef struct block {
  63.     char *string;               /* string for compare */
  64.     int (*fn) (struct block *blk, char *start, int level);
  65.     listtype nextblock, sublock;        /* subblocks are always consecutive */
  66.     listtype len, lcnt, lind1, lind2, lstart, pool, mpool, mend;
  67.     listtype *listlen;
  68.     listtype *lists[MAX_PERMLIST];      /* permutation lists */
  69. } block;
  70.  
  71. typedef struct poolstruct {
  72.     listtype block, lastpool, ind1, ind2, dirty, len;
  73.     char *string;
  74.     listtype *tag;              /* level tags for recursion */
  75. } poolstruct;
  76.  
  77. /* from translate.c */
  78. extern struct entry {
  79.     unsigned char *original, *replace;
  80.     int olen,earlier;
  81. } entry[];
  82.  
  83. int search_dic(struct entry *list, int items, size_t item_size, const char *str);
  84.  
  85. extern struct dic {
  86.     char name[MAX_FNAME+1];
  87.     char unknown[256];
  88.     char *buf;
  89.     int unknown_type;
  90.     int start;
  91.     int len;
  92. } dic[MAX_DICS];
  93. enum {
  94.     unk_delete, unk_leave, unk_replace
  95. };
  96. int transdic, macrodic;
  97. int diccnt;
  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;
  106. int nextpool, nexttag;
  107. extern poolstruct poolbuf[MAX_POOLS];
  108. extern block blockbuf[MAX_BLOCKS];
  109. #define OUTSIZE 4096
  110. extern char *outptr, *wptr, outbuf[OUTSIZE];
  111. extern listtype tagbuf[MAX_BLOCKS];
  112. extern int nextblock, nextlist;
  113. extern char wbuf[MAX_LINELEN+1];
  114. extern listtype listbuf[MAX_LISTS];
  115. extern int options;
  116. #define op_nocase    (1<<0)
  117. #define op_deaccent  (1<<1)
  118. #define op_reaccent  (1<<2)
  119. #define op_nopunct   (1<<3)
  120. #define op_nomath    (1<<4)
  121. #define op_noparenth (1<<5)
  122. #define op_nocs      (1<<6)
  123. #define op_noquote   (1<<7)
  124. #define op_matchall  (1<<8)
  125. #define op_alphaonly (1<<9)
  126. #define op_alnumonly (1<<10)
  127. void sym_error(char *msg,...);
  128. void _getdef(char buf[], char *name, char value[]);
  129. /* from match.c */
  130. int mt_string(struct block *blk, char *start, int level);
  131. int mt_permpick(struct block *blk, char *start, int level);
  132. int mt_m(struct block *blk, char *start, int level);
  133. int mt_neg(struct block *blk, char *start, int level);
  134. int mt_dic(struct block *blk, char *start, int level);
  135. int mt_w(struct block *blk, char *start, int level);
  136. int mt_wild(struct block *blk, char *start, int level);
  137. int mt_out(struct block *blk, char *start, int level);
  138. int mt_nomatch(struct block *blk, char *start, int level);
  139.  
  140. /* from suffix.c */
  141. extern int suffixcnt;
  142. void suffix_translate(char *p);
  143. void _translate(char *p, int i);
  144. void suffix_dic(char *sdicname);
  145.  
  146. /* from compile.c */
  147. void strfold(char *p);
  148. extern struct builtin {
  149.     char *name;
  150.     void (*fn) (char *p, struct block *blk, int next);
  151. } builtin[];
  152. void compile(char *p);
  153.  
  154. extern int builtincnt, Mcnt;
  155. extern char Mbuf[MAX_LINELEN+1];
  156. extern char *Mnext;
  157.  
  158. /* from match.c */
  159. int match(char *p);
  160. #endif
  161.  
  162.  
  163.  
  164.