esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
lexer.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <string>
8#include <vector>
9
10namespace protogen {
11
12enum class TokKind {
13 Identifier, // [A-Za-z_][A-Za-z0-9_.]* (dots kept so "google.protobuf.X" is one token)
14 Number, // integer / float literal, optional leading '-'
15 String, // contents of a "..." literal (unescaped minimally)
16 Symbol, // single punctuation char: { } [ ] ( ) = ; , < > .
17 End,
18};
19
20struct Token {
22 std::string text;
23 int line = 0;
24};
25
27std::vector<Token> lex(const std::string& src, const std::string& filename);
28
29} // namespace protogen
Definition emit.hpp:12
std::vector< Token > lex(const std::string &src, const std::string &filename)
Tokenize proto source. Throws std::runtime_error on a lexical error.
Definition lexer.cpp:23
TokKind
Definition lexer.hpp:12
Definition lexer.hpp:20
int line
Definition lexer.hpp:23
TokKind kind
Definition lexer.hpp:21
std::string text
Definition lexer.hpp:22