Schnek
deckscanner.hpp
1 /*
2  * deckscanner.hpp
3  *
4  * Created on: 26 Apr 2012
5  * Author: Holger Schmitz
6  * Email: holger@notjustphysics.com
7  *
8  * Copyright 2012 Holger Schmitz
9  *
10  * This file is part of Schnek.
11  *
12  * Schnek is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * Schnek is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with Schnek. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef SCHNEK_DECKSCANNER_HPP_
28 #define SCHNEK_DECKSCANNER_HPP_
29 
30 #include "tokenlist.hpp"
31 
32 namespace schnek {
33 
34 
36 {
37 
38  private:
39  std::istream *input;
40  TokenList tokens;
41 
42  public:
43  DeckScanner(std::string filename_) : tokens(filename_) {}
44  void scan(std::istream *input_, bool newscan=true)
45  {
46  input = input_;
47  if (newscan) {
48  tokens.reset();
49  do_scan(tokens);
50  }
51  else
52  {
53  TokenList tklist("");
54  do_scan(tklist);
55  tokens.insert(tklist);
56  }
57  }
58 
59  const TokenList & getTokens()
60  {
61  return tokens;
62  }
63  private:
64 
65  void do_scan(TokenList &tlist);
66 };
67 
68 } // namespace
69 
70 #endif // SCHNEK_DECKSCANNER_HPP_
Definition: tokenlist.hpp:114
void insert(int line, int token)
Insert an individual token onto the list.
Definition: tokenlist.hpp:141
Definition: algo.hpp:30
Definition: deckscanner.hpp:35
void reset(std::string filename_)
Empties the list and reassigns the filename.
Definition: tokenlist.hpp:127