Files parser.{h,cpp} splitted into parser.{h,cpp} and tokens.{h,cpp}.
[qshowdiff.git] / src / parser / parser.h
blob9050e7922e4faf56a7385783b7506f1afc5d326e
1 #ifndef _PARSER_H_
2 #define _PARSER_H_
4 #include <string>
5 #include <vector>
6 #include <QTextStream>
8 #include "tokens.h"
9 #include "../diff/diff.h"
11 class Parser{
12 private:
13 enum states{
14 START_STATE = 0,
15 FILE_STATE,
16 HUNK_STATE,
17 CONTEXT_STATE,
18 ADDED_STATE,
19 DELETED_STATE,
20 CHANGED_STATE,
21 END_STATE
24 states _current_state;
25 QString _current_line;
26 Tokens::token _current_token;
28 QTextStream *_in;
29 Tokens *_tokens;
31 File *_cur_file;
32 Hunk *_cur_hunk;
33 Text _cur_context;
34 Text _cur_deleted;
35 Text _cur_added;
37 void _changeState(states);
38 void _readNextLine();
39 QString _capCurrentLine(int);
41 void _createNewFile();
42 void _finishFile();
44 void _createNewHunk();
45 void _finishHunk();
47 void _addCurrentLineToContext();
48 void _finishContext();
49 void _addCurrentLineToAdded();
50 void _finishAdded();
51 void _addCurrentLineToDeleted();
52 void _finishDeleted();
53 void _finishChanged();
55 void _start();
56 void _file();
57 void _hunk();
58 void _context();
59 void _added();
60 void _deleted();
61 void _changed();
62 void _end();
63 public:
64 Parser(std::string type, QTextStream *in) :
65 _current_state(START_STATE),
66 _in(in),
67 _cur_file(NULL), _cur_hunk(NULL) { _tokens = factory(type); }
68 void parse();
71 #endif