-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScanner.h
84 lines (64 loc) · 1.67 KB
/
Scanner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Generated by Flexc++ V0.98.00 on Fri, 01 Jun 2012 11:19:01 +0300
#ifndef Scanner_H_INCLUDED_
#define Scanner_H_INCLUDED_
// $insert baseclass_h
#include "Scannerbase.h"
#include <stack>
using namespace std;
// $insert classHead
class Scanner: public ScannerBase
{
public:
explicit Scanner(std::istream &in = std::cin,
std::ostream &out = std::cout);
Scanner(std::string const &infile, std::string const &outfile);
// $insert lexFunctionDecl
int lex();
void PushValue(const std::string& value);
std::string PopValue();
std::string SeeValue();
private:
std::stack<string> valueStack;
int lex__();
int executeAction__(size_t ruleNr);
void print();
void preCode(); // re-implement this function for code that must
// be exec'ed before the patternmatching starts
};
// $insert scannerConstructors
inline Scanner::Scanner(std::istream &in, std::ostream &out)
:
ScannerBase(in, out)
{}
inline Scanner::Scanner(std::string const &infile, std::string const &outfile)
:
ScannerBase(infile, outfile)
{}
// $insert inlineLexFunction
inline int Scanner::lex()
{
return lex__();
}
inline void Scanner::preCode()
{
// optionally replace by your own code
}
inline void Scanner::print()
{
print__();
}
inline void Scanner::PushValue(const std::string& value)
{
valueStack.push(value);
}
inline std::string Scanner::PopValue()
{
string val = SeeValue();
valueStack.pop();
return val;
}
inline std::string Scanner::SeeValue()
{
return valueStack.top();
}
#endif // Scanner_H_INCLUDED_