1 
2 /* Web Polygraph       http://www.web-polygraph.org/
3  * Copyright 2003-2011 The Measurement Factory
4  * Licensed under the Apache License, Version 2.0 */
5 
6 #ifndef POLYGRAPH__PGL_PGLPP_H
7 #define POLYGRAPH__PGL_PGLPP_H
8 
9 #include "xstd/Array.h"
10 #include "xparser/Lexer.h"
11 
12 class String;
13 class GLexer;
14 
15 // PGL preprocessor
16 
17 class PglPp: public Lexer {
18 	public:
19 		PglPp(const String &fname);
20 		virtual ~PglPp();
21 
image()22 		const String image() const { return theImage; }
23 
24 	protected:
25 		virtual LexToken scan();
26 		void advance();
27 
lexer()28 		GLexer *lexer() { return theLexers[theDepth-1]; }
lexer()29 		const GLexer *lexer() const { return theLexers[theDepth-1]; }
30 
31 		bool filtered();
32 		void ignoreLineCmnt();
33 		void ignoreBlockCmnt();
34 		void ppdInclude();
35 		void ppDirective();
36 		void system();
37 
38 		void open(const String &fname);
39 		void open(istream &is, const String &fname);
40 		void close();
41 
42 		void printLexers(ostream &os) const;
43 
44 		void syncImage();
45 		bool spaceAfter(char c) const;
46 
47 	public:
48 		static Array<String*> TheDirs;
49 
50 	protected:
51 		GLexer *theLexers[256]; // replace with Array
52 		int theDepth;           // nesting depth
53 
54 		String theImage;  // pre-processed image buffer
55 		String theIndent; // indentation when building theImage
56 };
57 
58 #endif
59