44 string file; |
44 string file; |
45 int line; |
45 int line; |
46 int column; |
46 int column; |
47 }; |
47 }; |
48 |
48 |
49 using token_list = list<token>; |
49 using token_list = list<token>; |
50 using iterator = token_list::iterator; |
50 using iterator = token_list::iterator; |
51 |
51 |
52 public: |
52 public: |
53 lexer(); |
53 lexer(); |
54 ~lexer(); |
54 ~lexer(); |
55 |
55 |
56 void process_file (string file_name); |
56 void process_file (string file_name); |
57 bool get_next (e_token req = tk_any); |
57 bool get_next (e_token req = tk_any); |
58 void must_get_next (e_token tok = tk_any); |
58 void must_get_next (e_token tok = tk_any); |
59 void must_get_any_of (const list<e_token>& toks); |
59 void must_get_any_of (const list<e_token>& toks); |
60 int get_one_symbol (const string_list& syms); |
60 int get_one_symbol (const string_list& syms); |
61 void must_be (e_token tok); |
61 void must_be (e_token tok); |
62 bool peek_next (token* tk = null); |
62 bool peek_next (token* tk = null); |
63 |
63 |
64 inline bool has_valid_token() const |
64 inline bool has_valid_token() const |
65 { |
65 { |
66 return (m_token_position < m_tokens.end() && m_token_position >= m_tokens.begin()); |
66 return (m_token_position < m_tokens.end() && m_token_position >= m_tokens.begin()); |
67 } |
67 } |
105 private: |
105 private: |
106 token_list m_tokens; |
106 token_list m_tokens; |
107 iterator m_token_position; |
107 iterator m_token_position; |
108 |
108 |
109 // read a mandatory token from scanner |
109 // read a mandatory token from scanner |
110 void must_get_next_from_scanner (lexer_scanner& sc, e_token tok = tk_any); |
110 void must_get_next_from_scanner (lexer_scanner& sc, e_token tt = tk_any); |
|
111 void check_file_header (lexer_scanner& sc); |
111 |
112 |
112 static string describe_token_private (e_token tok_type, token* tok); |
113 static string describe_token_private (e_token tok_type, token* tok); |
113 }; |
114 }; |
114 |
115 |
115 #endif // BOTC_LEXER_H |
116 #endif // BOTC_LEXER_H |