88 Token ScanIdentifier();
91 if (m_pos < m_in.size()) {
92 [[likely]] m_current = m_in[m_pos];
102 if (m_pos < m_in.size()) {
103 [[likely]] m_current = m_in[m_pos];
113 return {kind, m_in.substr(m_tokenStart, m_pos - m_tokenStart)};
118 size_t m_tokenStart = 0;
125using EnumValues = std::vector<std::pair<std::string, int64_t>>;
171 const std::string&
GetError()
const {
return m_error; }
180 m_token = m_lexer.
Scan();
185 if (m_token.
Is(kind)) {
186 [[likely]]
return true;
Raw struct schema lexer.
Definition: SchemaParser.h:62
Lexer(std::string_view in)
Construct a raw struct schema lexer.
Definition: SchemaParser.h:69
size_t GetPosition() const
Gets the starting position of the last lexed token.
Definition: SchemaParser.h:84
Token Scan()
Gets the next token.
Raw struct schema parser.
Definition: SchemaParser.h:148
Parser(std::string_view in)
Construct a raw struct schema parser.
Definition: SchemaParser.h:155
const std::string & GetError() const
Gets the parser error if one occurred.
Definition: SchemaParser.h:171
bool Parse(ParsedSchema *out)
Parses the schema.
basic_string_view< char > string_view
Definition: core.h:501
constexpr auto in(type t, int set) -> bool
Definition: core.h:611
Definition: SchemaParser.h:14
std::vector< std::pair< std::string, int64_t > > EnumValues
Raw struct set of enumerated values.
Definition: SchemaParser.h:125
std::string_view ToString(Token::Kind kind)
Raw struct schema declaration.
Definition: SchemaParser.h:130
EnumValues enumValues
Definition: SchemaParser.h:133
unsigned int bitWidth
Definition: SchemaParser.h:135
std::string typeString
Definition: SchemaParser.h:131
std::string name
Definition: SchemaParser.h:132
size_t arraySize
Definition: SchemaParser.h:134
Raw struct schema.
Definition: SchemaParser.h:141
std::vector< ParsedDeclaration > declarations
Definition: SchemaParser.h:142
A lexed raw struct schema token.
Definition: SchemaParser.h:19
std::string_view text
Definition: SchemaParser.h:54
bool Is(Kind k) const
Definition: SchemaParser.h:51
Kind kind
Definition: SchemaParser.h:53
Kind
A lexed raw struct schema token kind.
Definition: SchemaParser.h:21
@ kInteger
Integer.
Definition: SchemaParser.h:25
@ kRightBrace
Right curly brace.
Definition: SchemaParser.h:35
@ kColon
Colon.
Definition: SchemaParser.h:37
@ kEquals
Equals.
Definition: SchemaParser.h:43
@ kLeftBrace
Left curly brace.
Definition: SchemaParser.h:33
@ kRightBracket
Right square bracket.
Definition: SchemaParser.h:31
@ kEndOfInput
End of input.
Definition: SchemaParser.h:45
@ kComma
Comma.
Definition: SchemaParser.h:41
@ kIdentifier
Identifier.
Definition: SchemaParser.h:27
@ kLeftBracket
Left square bracket.
Definition: SchemaParser.h:29
@ kUnknown
Unknown.
Definition: SchemaParser.h:23
@ kSemicolon
Semicolon.
Definition: SchemaParser.h:39
Token(Kind kind, std::string_view text)
Definition: SchemaParser.h:49