-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwnt_Lexer.h
53 lines (40 loc) · 1.74 KB
/
wnt_Lexer.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
/*=====================================================================
Lexer.h
-------
Copyright Glare Technologies Limited 2016 -
File created by ClassTemplate on Wed Jun 11 01:53:25 2008
=====================================================================*/
#pragma once
#include "TokenBase.h"
#include "BaseException.h"
#include "wnt_SourceBuffer.h"
#include <utils/Reference.h>
#include <string>
#include <vector>
class Parser;
namespace Winter
{
class LexerExcep : public ExceptionWithPosition
{
public:
LexerExcep(const std::string& text_, const BufferPosition& pos) : ExceptionWithPosition(text_, pos) {}
};
/*=====================================================================
Lexer
-----
=====================================================================*/
class Lexer
{
public:
static void process(const SourceBufferRef& src, std::vector<Reference<TokenBase> >& tokens_out);
static void test();
private:
static BufferPosition errorPosition(const SourceBufferRef& buffer, size_t pos);
static void parseStringLiteral(const SourceBufferRef& buffer, Parser& parser, std::vector<Reference<TokenBase> >& tokens_out);
static void parseCharLiteral(const SourceBufferRef& buffer, Parser& parser, std::vector<Reference<TokenBase> >& tokens_out);
static void parseNumericLiteral(const SourceBufferRef& buffer, Parser& parser, std::vector<Reference<TokenBase> >& tokens_out);
static void parseIdentifier(const SourceBufferRef& buffer, Parser& parser, std::vector<Reference<TokenBase> >& tokens_out);
static void parseComment(const SourceBufferRef& buffer, Parser& parser);
static void parseUnicodeEscapedChar(const SourceBufferRef& buffer, Parser& parser, std::string& s);
};
} //end namespace Winter