MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / Lex

Method Lex

LuaParser/src/Lexer/LuaLexer.cpp:96–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96LuaTokenKind LuaLexer::Lex() {
97 _reader.ResetBuffer();
98
99 for (;;) {
100 int ch = _reader.GetCurrentChar();
101 switch (ch) {
102 case '\n':
103 case '\r': {
104 IncLinenumber();
105 break;
106 }
107 case ' ':
108 case '\f':
109 case '\t':
110 case '\v': {
111 _reader.NextChar();
112 break;
113 }
114 case '-': {
115 _reader.SaveAndNext();
116 if (_reader.GetCurrentChar() != '-') {
117 if (_supportNonStandardSymbol && _reader.CheckNext1('=')) {
118 return '=';
119 }
120 return '-';
121 }
122 // is comment
123 _reader.SaveAndNext();
124
125 LuaTokenKind type = TK_SHORT_COMMENT;
126 if (_reader.GetCurrentChar() == '[') {
127 std::size_t sep = SkipSep();
128 if (sep >= 2) {
129 ReadLongString(sep);
130 return TK_LONG_COMMENT;
131 }
132 } else if (_reader.GetCurrentChar() == '-') {
133 _reader.SaveAndNext();
134 }
135
136 // is short comment
137 while (!CurrentIsNewLine() && _reader.GetCurrentChar() != EOZ) {
138 _reader.SaveAndNext();
139 }
140
141 return type;
142 }
143 case '+': {
144 _reader.SaveAndNext();
145 if (_supportNonStandardSymbol && _reader.CheckNext1('=')) {
146 return '=';
147 }
148 return '+';
149 }
150 case '*': {
151 _reader.SaveAndNext();
152 if (_supportNonStandardSymbol && _reader.CheckNext1('=')) {
153 return '=';

Callers

nothing calls this directly

Calls 11

TextRangeClass · 0.85
ResetBufferMethod · 0.80
GetCurrentCharMethod · 0.80
NextCharMethod · 0.80
SaveAndNextMethod · 0.80
CheckNext1Method · 0.80
GetPosMethod · 0.80
EatWhileMethod · 0.80
GetSaveTextMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected