| 94 | } |
| 95 | |
| 96 | LuaTokenKind 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 '='; |
nothing calls this directly
no test coverage detected