esphome-api-client
0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
tools
protogen
lexer.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <string>
8
#include <vector>
9
10
namespace
protogen
{
11
12
enum 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
20
struct
Token
{
21
TokKind
kind
=
TokKind::End
;
22
std::string
text
;
23
int
line
= 0;
24
};
25
27
std::vector<Token>
lex
(
const
std::string& src,
const
std::string& filename);
28
29
}
// namespace protogen
protogen
Definition
emit.hpp:12
protogen::lex
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
protogen::TokKind
TokKind
Definition
lexer.hpp:12
protogen::TokKind::Symbol
@ Symbol
protogen::TokKind::String
@ String
protogen::TokKind::Identifier
@ Identifier
protogen::TokKind::End
@ End
protogen::TokKind::Number
@ Number
protogen::Token
Definition
lexer.hpp:20
protogen::Token::line
int line
Definition
lexer.hpp:23
protogen::Token::kind
TokKind kind
Definition
lexer.hpp:21
protogen::Token::text
std::string text
Definition
lexer.hpp:22
Generated by
1.9.8