6.2. qweave.hh


6.2.1

Declarations and such which are used by both qweave.cc and the lexical analysers in other files.


6.2.2
#ifndef qef_INC_qweave_HH_
#define qef_INC_qweave_HH_

#include <string>
#include <list>

6.2.3

An enumeration of the styles which can be used by the pretty printers.

enum TextStyleTypes
{
   STYLE_KEYWORD = 1,
   STYLE_CONSTANT = 2,
   STYLE_COMMENT = 3,
   STYLE_CODE = 4,
   STYLE_VAL = 5,
   STYLE_VAR = 6,
   STYLE_FUNC = 7,
   STYLE_PREPROC = 8,
   STYLE_INCLUDE_FILE = 9,
   STYLE_TYPEWORD = 10,
   STYLE_STRING_LIT = 11,
   STYLE_PATH = 12,
   STYLE_COMMENT_HL = 13,
   STYLE_STRING_ESC = 14,
   STYLE_SMALL_CAPS = 15
};

6.2.4

Symbolic names for the source languages which can be specified in the header of a QefDoc file.

enum Language
{
   LANG_Text = 1,
   LANG_Cxx = 2,
   LANG_Perl = 3,
   LANG_Lex = 4,
   LANG_Python = 5,
   LANG_Sed = 6
};

6.2.5

The `Chunk' class stores the documentation and source for a single chunk. Either string may be empty, but not both of them.

class Chunk
{
 public:
   string doc;
   string src;

   Chunk (const string &d, const string &s)
      : doc (d), src (s) { assert (!(doc.empty() && src.empty())); }
};

6.2.6

A Class which represents a single input file and stores all the information associated with it.

class QefDocFile
{
 public:
   string filename, preproc_filename;
   string title, section;
   int secnum, filenum;

6.2.7

The list of chunks which have been read. The chunks aren't deleted when the program finishes because there's no point.

   list <const Chunk *> chunks;

6.2.8

The language which is being parsed. If it is specified in the first line of the QefDoc file then a language-specific pretty printer will be used. language_names stores string names corresponding to the Language values which can be used for printing error messages.

   Language language;

   QefDocFile (const string &name, const string &sec, int secn, int file);

   void set_language (const string &name);
};

6.2.9

Search for a file in the list read from the index, and return a pointer to its `QefDocFile' object, or `0' if it does not exist.

QefDocFile * find_file_from_index (const string &filename);

6.2.10

The structure `Word' and the function `find_word' are used by the pretty printers to look up identifiers in a list of known keywords.

struct Word
{
   const char *word;
   int type;
};

int find_word (const Word *words, const char *w);

6.2.11

A few global variables, which are declared in qweave.cc.

#ifdef QWEAVE_NO_EXTERNS
#  define EXTERN /* not extern */
#else
#  define EXTERN extern
   extern bool use_html;
   extern bool option_split;
#endif

6.2.12

Functions which are defined in qweave.cc and used by the pretty printers.

EXTERN const char *style_start (TextStyleTypes style);
EXTERN const char *style_end (TextStyleTypes style);
EXTERN string style_text (TextStyleTypes style, const string &text);
EXTERN void format_text (char c, string &enc, bool source_mode = false);
EXTERN string format_text (const string &s, bool source_mode = false);

6.2.13

This is for the Lex input files. It makes them read from a string instead of from a file.

TODO: make this work in blocks of chars.

#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
{ \
   if (src_index ≥ src->size()) \
      result = YY_NULL; \
   else \
   { \
      buf[0] = (*src)[src_index++]; \
      result = 1; \
   } \
}

6.2.14
#endif   // qef_INC_qweave_HH_