spudplate
Template scaffolding compiler for spudlang .spud files
Loading...
Searching...
No Matches
lexer.h
1#ifndef SPUDPLATE_LEXER_H
2#define SPUDPLATE_LEXER_H
3
4#include <cstddef>
5#include <string>
6
7#include "spudplate/token.h"
8
9namespace spudplate {
10
18class Lexer {
19 public:
21 explicit Lexer(std::string source);
22
25
26 private:
27 std::string source_;
28 std::size_t pos_;
29 int line_;
30 int column_;
31
32 [[nodiscard]] char current() const;
33 char advance();
34 [[nodiscard]] bool isAtEnd() const;
35 void skipWhitespace();
36 void skipLineContinuation();
37 Token readIdentifierOrKeyword();
38 Token readStringLiteral();
39 Token readIntegerLiteral();
40};
41
42} // namespace spudplate
43
44#endif // SPUDPLATE_LEXER_H
Tokenises a spudlang source string into a stream of Token values.
Definition lexer.h:18
Token nextToken()
Returns the next Token from the source, advancing the position.
Definition lexer.cpp:122
A single lexical token with source location.
Definition token.h:84