home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / stex2-18.zip / SeeTeX / libtex / sdecode.h < prev    next >
C/C++ Source or Header  |  1990-07-10  |  2KB  |  55 lines

  1. /*
  2.  * Copyright (c) 1989 University of Maryland
  3.  * Department of Computer Science.  All rights reserved.
  4.  * Permission to copy for any purpose is hereby granted
  5.  * so long as this copyright notice remains intact.
  6.  */
  7.  
  8. /*
  9.  * Specials consist of keyword/value groupings, with the simple syntax
  10.  * suggested by the BNF
  11.  *
  12.  *    list ::=    kv | list ',' kv
  13.  *    kv ::=        word opt_eq words
  14.  *    opt_eq ::=    '=' | <empty>
  15.  *    words ::=    word | words ' ' word
  16.  *
  17.  * `Words' include any character that is not a space, comma, or quote,
  18.  * and can include these by using quoting.  Inside and outside quotes,
  19.  * `\"' produces `"'; `\\' produces `\'; and `\,' produces `,'.
  20.  *
  21.  * No single word can exceed WDMAX characters (after quotes are interpreted).
  22.  * WDMAX is defined in sdecode.c, and is typically large (>= 1024).
  23.  *
  24.  * Each special is typed according to its arguments, which are collected
  25.  * and decoded, and passed to the special function as ordinary parameters.
  26.  * All possible argument-types must be known to the special decoder.
  27.  * The function also receives its own name (from the table) as its
  28.  * first argument.
  29.  */
  30.  
  31. /* value argument types */
  32. enum sd_args {
  33.     sda_none,    /* no arguments, just a flag */
  34.     sda_s,        /* one string argument (`foo abc') */
  35.     sda_d,        /* one decimal (i32) argument (`foo 2') */
  36.     sda_f,        /* one floating (double) argument (`foo 3.14') */
  37.     sda_dd,        /* two decimal arguments (`foo 3 4') */
  38.     sda_ff,        /* two floating arguments (`foo .3 .4') */
  39.     sda_ddddff,    /* four decimal args, then 2 floating args */
  40.     sda_nd,        /* array n of decimal arguments */
  41.     sda_nx,        /* array n of hex arguments (`x 1a00 d02f ...') */
  42.     sda_rest    /* fn(len1, ptr, len2); uses up rest of input */
  43. };
  44.  
  45. struct sdecode {
  46.     char    *sd_name;    /* keyword to match */
  47.     enum sd_args sd_args;    /* arguments to collect */
  48.     void    (*sd_fn)();    /* actual arguments depend on sd_args */
  49. };
  50.  
  51. void    SDecode(/* FILE *, i32, struct sdecode *, size_t */);
  52. void    SDsetclass(/* char *spaces, char *semis */);
  53.  
  54. #define    SDsize(tab) ((int)(sizeof(tab) / sizeof(*tab)))
  55.