aboutsummaryrefslogtreecommitdiffstats
path: root/token.h
blob: 3decdbccaed84d8f18036cb52b68937b1f94f483 (plain) (blame)
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
#ifndef INCLUDE_BLASSIC_TOKEN_H
#define INCLUDE_BLASSIC_TOKEN_H

// token.h
// Revision 7-feb-2005


#include "blassic.h"

#include <string>


class Tokenizer {
public:
	enum Type { Empty, EndLine, Blank, Plain, Literal, Integer };
	Tokenizer (const std::string & source);

	// Members of token are public accessible for simplicity.
	// Use with care.
	class Token {
	public:
		Token () :
			type (Empty)
		{ }
		Token (Type t) :
			type (t)
		{ }
		Token (Type t, const std::string & str) :
			type (t), str (str)
		{ }
		Token (BlInteger n) :
			type (Integer), n (n)
		{ }
		Type type;
		std::string str;
		BlInteger n;
	};
	Token get ();
	std::string getrest ();
	unsigned char peek ();
private:
	unsigned char peeknospace ();
	unsigned char nextchar ();
	unsigned char nextcharnospace ();
	void ungetchar ();
	std::string str;
	std::string::size_type pos;
	const std::string::size_type limit;
};

#endif

// Fin de token.h
Un proyecto texto-plano.xyz