]> git.tdb.fi Git - libs/datafile.git/blob - tool/compiler.h
Emit source file markers in compiled files
[libs/datafile.git] / tool / compiler.h
1 /* $Id$
2
3 This file is part of libmspdatafile
4 Copyright © 2008  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef TOOL_COMPILER_H_
9 #define TOOL_COMPILER_H_
10
11 #include <msp/datafile/loader.h>
12 #include <msp/datafile/statement.h>
13 #include <msp/datafile/writer.h>
14 #include <msp/fs/path.h>
15
16 class Compiler: public Msp::DataFile::Loader
17 {
18         friend class File;
19         friend class ForEach;
20
21 private:
22         Msp::DataFile::Writer &writer;
23         bool reset_src;
24
25 public:
26         Compiler(Msp::DataFile::Writer &);
27 private:
28         void file(const std::string &);
29         void for_each(const std::vector<std::string> &);
30         void write(const Msp::DataFile::Statement &);
31
32         bool process_statement(const Msp::FS::Path &, Msp::DataFile::Statement &);
33         void process_file(const Msp::FS::Path &, const std::list<Msp::DataFile::Statement> &);
34         void process_file(const Msp::FS::Path &);
35 };
36
37
38 class File: public Msp::DataFile::Loader
39 {
40 private:
41         Compiler &compiler;
42         Msp::FS::Path filename;
43         std::list<Msp::DataFile::Statement> write_st;
44
45 public:
46         File(Compiler &, const Msp::FS::Path &);
47 private:
48         virtual void finish();
49
50         void write(const Msp::DataFile::Statement &);
51 };
52
53
54 class ForEach: public Msp::DataFile::Loader
55 {
56 private:
57         Compiler &compiler;
58         Msp::FS::Path base;
59         std::list<std::string> patterns;
60         std::list<std::string> excludes;
61         std::list<Msp::DataFile::Statement> write_st;
62
63 public:
64         ForEach(Compiler &, const Msp::FS::Path &, const std::list<std::string> &);
65 private:
66         virtual void finish();
67
68         void exclude(const std::string &);
69         void pattern(const std::string &);
70         void write(const Msp::DataFile::Statement &);
71 };
72
73 #endif