home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / wxwin140 / utils / wxhelp / src / tex2help.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  2.6 KB  |  111 lines

  1. /*
  2.  * tex2help.h
  3.  *
  4.  * Read in a Latex file (subset) and write it out in
  5.  * Help format
  6.  *
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include "wx.h"
  11. #include "wx_utils.h"
  12. #include "wx_list.h"
  13.  
  14. /*
  15.  * We have a list of macro definitions which we must define
  16.  * in advance to enable the parsing to recognize macros.
  17.  */
  18.  
  19. class TexMacroDef: public wxObject
  20. {
  21.  public:
  22.   int no_args;
  23.   char *name;
  24.   Bool ignore;
  25.  
  26.   TexMacroDef(char *the_name, int n, Bool ig);
  27.   ~TexMacroDef(void);
  28. };
  29.  
  30. #define CHUNK_TYPE_MACRO    1
  31. #define CHUNK_TYPE_ARG      2
  32. #define CHUNK_TYPE_STRING   3
  33.  
  34. /*
  35.  We have nested lists to represent the Tex document.
  36.  Each element of a list of chunks can be one of:
  37.   - a plain string
  38.   - a macro with/without arguments. Arguments are lists of TexChunks.
  39.  
  40. Example (\toplevel is implicit but made explicit here):
  41.  
  42. AddMacroDef("mymat", 2);
  43.  
  44. \toplevel{The cat sat on the \mymat{very coarse and {\it cheap}}{mat}}.
  45.  
  46. Parsed as:
  47.  
  48. TexChunk: type = macro, name = toplevel, no_args = 1
  49.   Children:
  50.  
  51.     TexChunk: type = argument
  52.  
  53.       Children:
  54.         TexChunk: type = string, value = "The cat sat on the "
  55.         TexChunk: type = macro, name = mymat, no_args = 2
  56.  
  57.           Children:
  58.             TexChunk: type = argument
  59.  
  60.               Children:
  61.                 TexChunk: type = string, value = "very coarse and "
  62.                 TexChunk: type = macro, name = it, no_args = 1
  63.  
  64.                   Children:
  65.                     TexChunk: type = argument
  66.  
  67.                       Children:
  68.                         TexChunk: type = string, value = "cheap"
  69.  
  70.             TexChunk: type = argument
  71.  
  72.               Children:
  73.                 TexChunk: type = string, value = mat
  74.  */
  75.  
  76. class TexChunk: public wxObject
  77. {
  78.  public:
  79.   int type;
  80.   char *name;
  81.   char *value;
  82.   int no_args;
  83.   int argn;
  84.   wxList children;
  85.   TexChunk(int the_type);
  86.   ~TexChunk(void);
  87. };
  88.  
  89. Bool read_a_line(FILE *fd, char *buf);
  90. Bool LoadFile(char *filename);
  91. int ParseArg(wxList& children, char *buffer, int pos, char *environment = NULL);
  92. int ParseMacroBody(char *macro_name, wxList& children, int no_args,
  93.                    char *buffer, int pos, char *environment = NULL);
  94. void TraverseDocument(TexChunk *chunk);
  95. void SetCurrentOutput(FILE *fd);
  96. void SetCurrentOutputs(FILE *fd1, FILE *fd2);
  97. void AddMacroDef(char *name, int n, Bool ignore = FALSE);
  98. void Initialize(void);
  99. void Output(char *s);
  100.  
  101. /*
  102.  * Client-defined
  103.  *
  104.  */
  105.  
  106. // Called on start/end of macro examination
  107. void OnMacro(char *name, int no_args, Bool start);
  108.  
  109. // Called on start/end of argument examination
  110. void OnArgument(char *macro_name, int arg_no, Bool start);
  111.