Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
SkSL::Lexer Class Reference

#include <SkSLLexer.h>

Classes

struct  Checkpoint
 

Public Member Functions

void start (std::string_view text)
 
Token next ()
 
Checkpoint getCheckpoint () const
 
void rewindToCheckpoint (Checkpoint checkpoint)
 

Detailed Description

Definition at line 123 of file SkSLLexer.h.

Member Function Documentation

◆ getCheckpoint()

Checkpoint SkSL::Lexer::getCheckpoint ( ) const
inline

Definition at line 136 of file SkSLLexer.h.

136{ return {fOffset}; }

◆ next()

Token SkSL::Lexer::next ( )

Definition at line 800 of file SkSLLexer.cpp.

800 {
801 // Note that we cheat here: normally a lexer needs to worry about the case
802 // where a token has a prefix which is not itself a valid token - for instance,
803 // maybe we have a valid token 'while', but 'w', 'wh', etc. are not valid
804 // tokens. Our grammar doesn't have this property, so we can simplify the logic
805 // a bit.
806 int32_t startOffset = fOffset;
807 State state = 1;
808 for (;;) {
809 if (fOffset >= (int32_t)fText.length()) {
810 if (startOffset == (int32_t)fText.length() || kAccepts[state] == 255) {
811 return Token(Token::Kind::TK_END_OF_FILE, startOffset, 0);
812 }
813 break;
814 }
815 uint8_t c = (uint8_t)(fText[fOffset] - 9);
816 if (c >= 118) {
817 c = kInvalidChar;
818 }
819 State newState = get_transition(kMappings[c], state);
820 if (!newState) {
821 break;
822 }
823 state = newState;
824 ++fOffset;
825 }
827 return Token(kind, startOffset, fOffset - startOffset);
828}
AtkStateType state
static const uint8_t kAccepts[427]
static State get_transition(uint8_t transition, State state)
static constexpr uint8_t kInvalidChar
Definition SkSLLexer.cpp:15
static constexpr uint8_t kMappings[118]
Definition SkSLLexer.cpp:16

◆ rewindToCheckpoint()

void SkSL::Lexer::rewindToCheckpoint ( Checkpoint  checkpoint)
inline

Definition at line 138 of file SkSLLexer.h.

138{ fOffset = checkpoint.fOffset; }

◆ start()

void SkSL::Lexer::start ( std::string_view  text)
inline

Definition at line 125 of file SkSLLexer.h.

125 {
126 fText = text;
127 fOffset = 0;
128 }
std::u16string text

The documentation for this class was generated from the following files: