forked from DOMjudge/checktestdata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscanner.h
94 lines (73 loc) · 2.1 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
84
85
86
87
88
89
90
91
92
93
// Generated by Flexc++ V0.98.00 on Sun, 06 Oct 2013 22:49:41 +0100
#ifndef Scanner_H_INCLUDED_
#define Scanner_H_INCLUDED_
// $insert baseclass_h
#include "scannerbase.h"
#include <string>
#include <exception>
class ScannerException: public std::exception {
private:
std::string msg;
public:
ScannerException(): msg("unknown error") {}
ScannerException(std::string msg_): msg("scanner: "+msg_) {}
const char *what() const throw() { return msg.c_str(); }
};
// $insert classHead
class Scanner: public ScannerBase
{
public:
// Non-zero value indicates that we return that as custom
// start token to the parser in the first call of lex().
int parserStart;
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();
private:
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
#if ( FLEXCPP_VERSION >= 10800LL )
void postCode(PostEnum__ type);
// re-implement this function for code that must
// be exec'ed after the rules's actions.
#endif
};
// $insert scannerConstructors
inline Scanner::Scanner(std::istream &in, std::ostream &out)
:
ScannerBase(in, out), parserStart(0)
{}
inline Scanner::Scanner(std::string const &infile, std::string const &outfile)
:
ScannerBase(infile, outfile), parserStart(0)
{}
// $insert inlineLexFunction
inline int Scanner::lex()
{
if ( parserStart!=0 ) {
int res = parserStart;
parserStart = 0;
return res;
}
return lex__();
}
inline void Scanner::preCode()
{
// optionally replace by your own code
}
#if ( FLEXCPP_VERSION >= 10800LL )
inline void Scanner::postCode(PostEnum__ type)
{
// optionally replace by your own code
}
#endif
inline void Scanner::print()
{
print__();
}
#endif // Scanner_H_INCLUDED_