1: /* webcpp - engine.h
     2:  * Copyright (C)2001-2003 Jeffrey Bakker
     3: 
     4:  * This program is free software; you can redistribute it and/or modify
     5:  * it under the terms of the GNU General Public License as published by
     6:  * the Free Software Foundation; either version 2 of the License, or
     7:  * (at your option) any later version.
     8: 
     9:  * This program is distributed in the hope that it will be useful,
    10:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12:  * GNU General Public License for more details.
    13: 
    14:  * You should have received a copy of the GNU General Public License
    15:  * along with this program; if not, write to the Free Software
    16:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    17:    ___________________________________ .. .
    18:  */
    19: 
    20: #ifndef _ENGINE_H 
    21: #define _ENGINE_H 
    22: 
    23: #define DBL_QUOTES   0x22 
    24: #define SIN_QUOTES   0x27 
    25: #define BCK_QUOTES   0x60 
    26: 
    27: #define Yes          true 
    28: #define No           false 
    29: 
    30: #include "cffile.h" 
    31: #include "theme.h" 
    32: #include <vector> 
    33: #include <string> 
    34: using namespace std;
    35: 
    36: class Engine {
    37: 
    38:  public:
    39: 	virtual ~Engine() {IO.close();}
    40: 	
    41: 	void init_switches();
    42: 
    43: 	void pre_parse();
    44: 	void makeMargin();
    45: 	void makeAnchor();
    46: 
    47: 	bool abortParse();
    48: 	bool abortColour(int index);
    49: 
    50: 	bool isInsideIt(int index, string start, string end);
    51: 	bool isInsideTag(int index);
    52: 	bool isNotWord(int index);
    53: 	void eraseTags(int start, int fin);
    54: 
    55: 	void parsePreProc();
    56: 
    57: 	void parseSymbol();
    58: 	bool colourSymbol(int start, int end);
    59: 	bool isSymbol(char c);
    60: 
    61: 	void parseLabel();
    62: 	void colourLabel(int start, int end);
    63: 
    64: 	void parseNum();
    65: 	bool colourNum(int start, int end);
    66: 
    67: 	void parseString(char quotetype, bool &inside);
    68: 	void colourString(int   index, bool &inside, string cssclass);
    69: 
    70: 	void parseBigComment(string start, string end, bool &inside);
    71: 
    72: 	void parseKeys();
    73: 	void colourKeys(int index, string key, string cssclass);
    74: 	bool isKey(int start, int end) const;
    75: 	int  noCaseFind(string search, int index);
    76: 	
    77: 	void parseVariable(string var);
    78: 	void colourVariable(int index);
    79: 	
    80: 	void parseComment(string cmnt);
    81: 	void colourComment(int index);
    82: 	void parseCharZeroComment(char zchar);
    83: 
    84: 	void loadKeys();
    85: 	void doParsing();
    86: 
    87: 	void begHtml(string name);
    88: 	void endHtml();
    89: 
    90: 	void hyperTagMe();
    91: 	void hyperLinkMe();
    92: 	void hyperNameMe();
    93: 	void hyperIncludeMe();
    94: 	
    95: 	int  getLineCount() {return lncount;}
    96: 
    97: 	virtual
    98: 	void fill() = 0;
    99: 
   100: 	void toggleBigtab() {opt_bigtab = !opt_bigtab;}
   101: 	void toggleWebcpp() {opt_webcpp = !opt_webcpp;}
   102: 	void toggleHypinc() {opt_hypinc = !opt_hypinc;}
   103: 	void toggleFollow() {opt_follow = !opt_follow;}
   104: 	void toggleAnchor() {opt_anchor = !opt_anchor;}
   105: 	void toggleNumber() {opt_number = !opt_number;}
   106: 	void toggleExtcss() {opt_extcss = !opt_extcss;}
   107: 
   108: 	void setTabWidth(string width);
   109: 
   110:  //options
   111:  protected:
   112: 	bool opt_bigtab;
   113: 	bool opt_webcpp;
   114: 	bool opt_hypinc;
   115: 	bool opt_follow;
   116: 	bool opt_number;
   117: 	bool opt_extcss;
   118: 	bool opt_anchor;
   119: 	
   120:  //parsing rules
   121:  protected:
   122: 	bool doStrings;
   123: 	bool doSymbols;
   124: 	bool doNumbers;
   125: 	bool doKeywords;
   126: 	bool doCaseKeys;
   127: 	bool doLabels;
   128: 	bool doPreProc;
   129: 	bool doScalars;
   130: 	bool doArrays;
   131: 	bool doHashes;
   132: 	bool doHtmlTags;
   133: 	bool doCComnt;
   134: 	bool doHskComnt;
   135: 	bool doHtmComnt;
   136: 	bool doPasComnt;
   137: 	bool doBigComnt;
   138: 	bool doCinComnt;
   139: 	bool doAdaComnt;
   140: 	bool doUnxComnt;
   141: 	bool doAsmComnt;
   142: 	bool doRemComnt;
   143: 	bool doFtnComnt;
   144: 	bool doTclComnt;
   145: 	bool doAspComnt;
   146: 	bool doBatComnt;
   147: 
   148:  //theme file I/O engine
   149:  public:
   150: 	CFfile IO;
   151: 	Theme  Scs2;
   152: //    vector<string> incref;
   153: 
   154:  //internal data
   155:  protected:
   156: 	int lncount;
   157: 	int tabwidth;
   158: 	string tw;
   159: 	string buffer;
   160: 	vector<string> keys;
   161: 	vector<string> types;
   162: 
   163: 	bool inDblQuotes;
   164: 	bool inSinQuotes;
   165: 	bool inBckQuotes;
   166: 	bool inHtmTags;
   167: 	bool inComment;
   168: 	bool endComment;
   169: };
   170: 
   171: #endif  // _ENGINE_H 
   172: 



w e b c p p
web c plus plus