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