aboutsummaryrefslogtreecommitdiff
path: root/include/lexer.h
blob: d6936f3da1c82a3652399aaacb4580cd01421db6 (plain)
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
#ifndef __LEXER_H
#define __LEXER_H

#include <list.h>
#include <token.h>

class Lexer
{
private:
  char *m_script;
  List *m_tokens;

private:
  size_t m_start;
  size_t m_current;
  size_t m_end;
  size_t m_line;
  bool m_errored;

private:
  bool at_end(void);
  char advance(void);
  char peek(void);
  bool match(char c);

private:
  void string(void);

private:
  void add_token(token_type_e type);
  void scan_token(void);

public:
  void init(char *script);
  List *scan(void);
  void clean(void);
};

#endif