1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/* DSTART */
/* */
/* maildrop - mail delivery agent with filtering abilities */
/* */
/* Copyright 1998, Double Precision Inc. */
/* */
/* This program is distributed under the terms of the GNU General Public */
/* License. See COPYING for additional information. */
/* DEND */
#ifndef recipe_h
#define recipe_h
static const char recipe_h_rcsid[]="$Id: recipe.h 1.1 1998/04/17 00:08:53 mrsam Exp $";
#include "recipenode.h"
#include "token.h"
class Lexer;
class Token;
//////////////////////////////////////////////////////////////////////////
//
// Class Recipe - parsed structure of a recipe file.
// This class reads tokens from the Lexer class, and arranges them in a
// logical structure that represents the recipe file. The Recipe object
// maints a list of RecipeNode objects, which roughly represent individual
// statements, and elements of a recipe file. There is more or less a
// one-to-one relationship between Tokens and Recipenodes. Usually one
// RecipeNode is created for each token - but not always. The RecipeNode
// objects are automatically created by the Recipe object when ParseRecipe()
// is called to translate the tokens returned by the Lexer class into
// the RecipeNode structure. When the Recipe object is destroyed, it
// automatically destroys all RecipeNode objects it has allocated.
// The RecipeNode objects are created using a simple recursive-descent
// parser.
//
// The ExecuteRecipe() function actually starts the ball rolling by
// calling the Evaluate() function of the first RecipeNode object in the
// structure.
//
//////////////////////////////////////////////////////////////////////////
class Recipe {
RecipeNode *firstNode, *lastNode; // All nodes in this recipe.
RecipeNode *topNode; // Topmost node.
RecipeNode *alloc(RecipeNode::RecipeNodeType);
Lexer *lex;
Token cur_tok;
public:
Recipe();
~Recipe();
int ParseRecipe(Lexer &);
void ExecuteRecipe();
void errmsg(RecipeNode &, const char *);
private:
// This is, essentially, a recursive-descent parser that builds
// the RecipeNode tree.
RecipeNode *ParseExpr()
{
return (ParseAssign());
}
RecipeNode *ParseAssign();
RecipeNode *ParseLogicalOr();
RecipeNode *ParseLogicalAnd();
RecipeNode *ParseComparison();
RecipeNode *ParseBitwiseOr();
RecipeNode *ParseBitwiseAnd();
RecipeNode *ParseAddSub();
RecipeNode *ParseMultDiv();
RecipeNode *ParseStrRegExp();
RecipeNode *ParseStatementList();
RecipeNode *ParseStatement();
RecipeNode *ParseSubStatement();
RecipeNode *ParseString();
RecipeNode *ParseElement();
} ;
#endif
|