]> git.tdb.fi Git - libs/datafile.git/blob - source/parser.h
e127c5b3653fbfd02e77bbec7c344e5061ed113e
[libs/datafile.git] / source / parser.h
1 /* $Id$
2
3 This file is part of libmspdatafile
4 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7 #ifndef MSP_DATAFILE_PARSER_H_
8 #define MSP_DATAFILE_PARSER_H_
9
10 #include <istream>
11 #include <string>
12 #include "input.h"
13
14 namespace Msp {
15 namespace DataFile {
16
17 class Statement;
18 struct Token;
19
20 class Parser
21 {
22 public:
23         Parser(std::istream &, const std::string &);
24         Statement parse();
25         operator bool() const { return in; }
26 private:
27         Input       in;
28         std::string src;
29         bool        good;
30
31         Statement parse_(const Token *);
32         Token parse_token();
33         bool  is_delimiter(int);
34         bool  isodigit(int);
35         std::string unescape_string(const std::string &);
36         std::string get_location();
37         void  parse_error(int, int);
38 };
39
40 } // namespace DataFile
41 } // namespace Msp
42
43 #endif