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
|
#pragma once
#include <string>
#include <iostream>
namespace cps {
enum Token {
tok_eof = -1,
tok_declare = -2,
tok_integer_kw = -3, // INTEGER
tok_input = -4,
tok_output = -5,
tok_identifier = -6,
tok_number = -7,
tok_assign = -8, // <-
tok_colon = -9, // :
tok_if = -10,
tok_then = -11,
tok_else = -12,
tok_endif = -13,
tok_eq = -20, // =
tok_ne = -21, // <>
tok_le = -22, // <=
tok_ge = -23 // >=
};
class Lexer {
public:
std::string IdentifierStr;
int NumVal;
int gettok();
};
} // namespace cps
|