From 2044770601dff8f1bd1c6cb9d0617f669b430e1d Mon Sep 17 00:00:00 2001 From: Dimitar Trendafilov Date: Wed, 7 Nov 2018 09:18:56 +0200 Subject: Replaced go* commands with jmp* commands (#38) --- spasm/src/asm/lexer.cpp | 2787 ++++++++++++++++++++++++++++------------------- 1 file changed, 1664 insertions(+), 1123 deletions(-) (limited to 'spasm/src/asm/lexer.cpp') diff --git a/spasm/src/asm/lexer.cpp b/spasm/src/asm/lexer.cpp index ef650e4..659beae 100644 --- a/spasm/src/asm/lexer.cpp +++ b/spasm/src/asm/lexer.cpp @@ -1,1123 +1,1664 @@ -/* Generated by re2c 0.13.5 on Wed Jun 25 12:01:36 2008 */ -#line 1 "lexer.re" -#include - -#include "lexer.hpp" - -#include "token.hpp" - -namespace SpasmImpl -{ -namespace ASM -{ -//! Namespace for all lexical analisys classes -namespace Lexer -{ -Lexer::Lexer(std::istream& _file, size_t _buffer_size) - : file(&_file), buffer_size(_buffer_size), state(unsigned(-1)), lineno(0) -{ - buffer = new char[buffer_size]; - cursor = limit = marker = token_start = NULL; -} - -Lexer::~Lexer() -{ - delete[] buffer; -} - -bool Lexer::tokenize(TokenStream& ts) -{ -#line 43 "lexer.re" - - switch (state) - { - default: - goto yy0; - case 0: - goto yyFillLabel0; - case 1: - goto yyFillLabel1; - case 2: - goto yyFillLabel2; - case 3: - goto yyFillLabel3; - case 4: - goto yyFillLabel4; - } - - while (1) - { -#line 48 "lexer.cpp" - - yy0: - state = (0); - if ((limit - cursor) < 8) - return true; - yyFillLabel0: - yych = *cursor; - if (yych <= '<') - { - if (yych <= ')') - { - if (yych <= '\n') - { - if (yych <= 0x00) - goto yy30; - if (yych <= 0x08) - goto yy32; - if (yych <= '\t') - goto yy26; - goto yy28; - } - else - { - if (yych <= ' ') - { - if (yych <= 0x1F) - goto yy32; - goto yy26; - } - else - { - if (yych == '%') - goto yy17; - goto yy32; - } - } - } - else - { - if (yych <= '.') - { - if (yych <= '+') - { - if (yych <= '*') - goto yy13; - goto yy11; - } - else - { - if (yych != '-') - goto yy32; - } - } - else - { - if (yych <= '0') - { - if (yych <= '/') - goto yy15; - goto yy4; - } - else - { - if (yych <= '9') - goto yy6; - if (yych <= ';') - goto yy32; - goto yy23; - } - } - } - } - else - { - if (yych <= 'f') - { - if (yych <= '_') - { - if (yych <= '@') - goto yy32; - if (yych <= 'Z') - goto yy25; - if (yych <= '^') - goto yy32; - goto yy25; - } - else - { - if (yych <= 'b') - { - if (yych <= '`') - goto yy32; - goto yy25; - } - else - { - if (yych <= 'c') - goto yy20; - if (yych <= 'd') - goto yy9; - goto yy25; - } - } - } - else - { - if (yych <= 'p') - { - if (yych <= 'k') - { - if (yych <= 'g') - goto yy19; - goto yy25; - } - else - { - if (yych <= 'l') - goto yy21; - if (yych <= 'o') - goto yy25; - goto yy7; - } - } - else - { - if (yych <= 'r') - { - if (yych <= 'q') - goto yy25; - goto yy10; - } - else - { - if (yych <= 's') - goto yy22; - if (yych <= 'z') - goto yy25; - goto yy32; - } - } - } - } - ++cursor; - if ((yych = *cursor) == '0') - goto yy99; -#line 116 "lexer.re" - { - ts.push_token(Token(Token::minus, lineno)); - token_start = cursor; - - continue; - } -#line 138 "lexer.cpp" - yy4: - yych = *(marker = ++cursor); - if (yych == 'X') - goto yy94; - if (yych == 'x') - goto yy94; - yy5: -#line 58 "lexer.re" - { - ts.push_token(Token(Token::integer, lineno, token_start, cursor)); - token_start = cursor; - - continue; - } -#line 152 "lexer.cpp" - yy6: - yych = *++cursor; - goto yy93; - yy7: - ++cursor; - if ((yych = *cursor) <= 'q') - { - if (yych == 'o') - goto yy80; - goto yy37; - } - else - { - if (yych <= 'r') - goto yy81; - if (yych == 'u') - goto yy82; - goto yy37; - } - yy8: -#line 212 "lexer.re" - { - ts.push_token(Token(Token::ident, lineno, token_start, cursor)); - token_start = cursor; - - continue; - } -#line 175 "lexer.cpp" - yy9: - yych = *++cursor; - if (yych == 'u') - goto yy77; - goto yy37; - yy10: - yych = *++cursor; - if (yych == 'e') - goto yy71; - goto yy37; - yy11: - ++cursor; -#line 109 "lexer.re" - { - ts.push_token(Token(Token::plus, lineno)); - token_start = cursor; - - continue; - } -#line 193 "lexer.cpp" - yy13: - ++cursor; -#line 123 "lexer.re" - { - ts.push_token(Token(Token::multiply, lineno)); - token_start = cursor; - - continue; - } -#line 203 "lexer.cpp" - yy15: - ++cursor; -#line 130 "lexer.re" - { - ts.push_token(Token(Token::divide, lineno)); - token_start = cursor; - - continue; - } -#line 213 "lexer.cpp" - yy17: - ++cursor; -#line 137 "lexer.re" - { - ts.push_token(Token(Token::modulus, lineno)); - token_start = cursor; - - continue; - } -#line 223 "lexer.cpp" - yy19: - yych = *++cursor; - if (yych == 'o') - goto yy58; - goto yy37; - yy20: - yych = *++cursor; - if (yych == 'a') - goto yy54; - goto yy37; - yy21: - yych = *++cursor; - if (yych == 'a') - goto yy45; - if (yych == 'o') - goto yy46; - goto yy37; - yy22: - yych = *++cursor; - if (yych == 't') - goto yy40; - goto yy37; - yy23: - ++cursor; - if ((yych = *cursor) == '=') - goto yy38; -#line 198 "lexer.re" - { - ts.push_token(Token(Token::less, lineno)); - token_start = cursor; - - continue; - } -#line 251 "lexer.cpp" - yy25: - yych = *++cursor; - goto yy37; - yy26: - ++cursor; - yych = *cursor; - goto yy35; - yy27: -#line 220 "lexer.re" - { - token_start = cursor; - - continue; - } -#line 266 "lexer.cpp" - yy28: - ++cursor; -#line 226 "lexer.re" - { - ++lineno; - token_start = cursor; - - continue; - } -#line 276 "lexer.cpp" - yy30: - ++cursor; -#line 233 "lexer.re" - { - ts.push_token(Token(Token::endinput, lineno)); - - break; - } -#line 285 "lexer.cpp" - yy32: - ++cursor; -#line 239 "lexer.re" - { - return false; - } -#line 292 "lexer.cpp" - yy34: - ++cursor; - state = (1); - if (limit <= cursor) - return true; - yyFillLabel1: - yych = *cursor; - yy35: - if (yych == '\t') - goto yy34; - if (yych == ' ') - goto yy34; - goto yy27; - yy36: - ++cursor; - state = (2); - if (limit <= cursor) - return true; - yyFillLabel2: - yych = *cursor; - yy37: - if (yych <= 'Z') - { - if (yych <= '/') - goto yy8; - if (yych <= '9') - goto yy36; - if (yych <= '@') - goto yy8; - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych <= '^') - goto yy8; - goto yy36; - } - else - { - if (yych <= '`') - goto yy8; - if (yych <= 'z') - goto yy36; - goto yy8; - } - } - yy38: - ++cursor; -#line 192 "lexer.re" - { - ts.push_token(Token(Token::lesseq, lineno)); - token_start = cursor; - - continue; - } -#line 334 "lexer.cpp" - yy40: - yych = *++cursor; - if (yych != 'o') - goto yy37; - yych = *++cursor; - if (yych != 'r') - goto yy37; - yych = *++cursor; - if (yych != 'e') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy44; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy44; - if (yych <= 'z') - goto yy36; - } - } - yy44: -#line 186 "lexer.re" - { - ts.push_token(Token(Token::store, lineno)); - token_start = cursor; - - continue; - } -#line 363 "lexer.cpp" - yy45: - yych = *++cursor; - if (yych == 'b') - goto yy50; - goto yy37; - yy46: - yych = *++cursor; - if (yych != 'a') - goto yy37; - yych = *++cursor; - if (yych != 'd') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy49; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy49; - if (yych <= 'z') - goto yy36; - } - } - yy49: -#line 179 "lexer.re" - { - ts.push_token(Token(Token::load, lineno)); - token_start = cursor; - - continue; - } -#line 394 "lexer.cpp" - yy50: - yych = *++cursor; - if (yych != 'e') - goto yy37; - yych = *++cursor; - if (yych != 'l') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy53; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy53; - if (yych <= 'z') - goto yy36; - } - } - yy53: -#line 205 "lexer.re" - { - ts.push_token(Token(Token::label, lineno)); - token_start = cursor; - - continue; - } -#line 421 "lexer.cpp" - yy54: - yych = *++cursor; - if (yych != 'l') - goto yy37; - yych = *++cursor; - if (yych != 'l') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy57; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy57; - if (yych <= 'z') - goto yy36; - } - } - yy57: -#line 165 "lexer.re" - { - ts.push_token(Token(Token::call, lineno)); - token_start = cursor; - - continue; - } -#line 448 "lexer.cpp" - yy58: - ++cursor; - if ((yych = *cursor) <= '_') - { - if (yych <= '@') - { - if (yych <= '/') - goto yy59; - if (yych <= '9') - goto yy36; - } - else - { - if (yych <= 'Z') - goto yy36; - if (yych >= '_') - goto yy36; - } - } - else - { - if (yych <= 'f') - { - if (yych <= '`') - goto yy59; - if (yych <= 'e') - goto yy36; - goto yy61; - } - else - { - if (yych == 't') - goto yy60; - if (yych <= 'z') - goto yy36; - } - } - yy59: -#line 158 "lexer.re" - { - ts.push_token(Token(Token::go, lineno)); - token_start = cursor; - - continue; - } -#line 477 "lexer.cpp" - yy60: - yych = *++cursor; - if (yych == 'r') - goto yy67; - goto yy37; - yy61: - yych = *++cursor; - if (yych != 'a') - goto yy37; - yych = *++cursor; - if (yych != 'l') - goto yy37; - yych = *++cursor; - if (yych != 's') - goto yy37; - yych = *++cursor; - if (yych != 'e') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy66; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy66; - if (yych <= 'z') - goto yy36; - } - } - yy66: -#line 151 "lexer.re" - { - ts.push_token(Token(Token::gofalse, lineno)); - token_start = cursor; - - continue; - } -#line 512 "lexer.cpp" - yy67: - yych = *++cursor; - if (yych != 'u') - goto yy37; - yych = *++cursor; - if (yych != 'e') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy70; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy70; - if (yych <= 'z') - goto yy36; - } - } - yy70: -#line 144 "lexer.re" - { - ts.push_token(Token(Token::gotrue, lineno)); - token_start = cursor; - - continue; - } -#line 539 "lexer.cpp" - yy71: - yych = *++cursor; - if (yych == 'a') - goto yy72; - if (yych == 't') - goto yy73; - goto yy37; - yy72: - yych = *++cursor; - if (yych == 'd') - goto yy75; - goto yy37; - yy73: - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy74; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy74; - if (yych <= 'z') - goto yy36; - } - } - yy74: -#line 172 "lexer.re" - { - ts.push_token(Token(Token::ret, lineno)); - token_start = cursor; - - continue; - } -#line 571 "lexer.cpp" - yy75: - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy76; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy76; - if (yych <= 'z') - goto yy36; - } - } - yy76: -#line 95 "lexer.re" - { - ts.push_token(Token(Token::read, lineno)); - token_start = cursor; - - continue; - } -#line 594 "lexer.cpp" - yy77: - yych = *++cursor; - if (yych != 'p') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy79; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy79; - if (yych <= 'z') - goto yy36; - } - } - yy79: -#line 88 "lexer.re" - { - ts.push_token(Token(Token::dup, lineno)); - token_start = cursor; - - continue; - } -#line 619 "lexer.cpp" - yy80: - yych = *++cursor; - if (yych == 'p') - goto yy90; - goto yy37; - yy81: - yych = *++cursor; - if (yych == 'i') - goto yy86; - goto yy37; - yy82: - yych = *++cursor; - if (yych != 's') - goto yy37; - yych = *++cursor; - if (yych != 'h') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy85; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy85; - if (yych <= 'z') - goto yy36; - } - } - yy85: -#line 74 "lexer.re" - { - ts.push_token(Token(Token::push, lineno)); - token_start = cursor; - - continue; - } -#line 654 "lexer.cpp" - yy86: - yych = *++cursor; - if (yych != 'n') - goto yy37; - yych = *++cursor; - if (yych != 't') - goto yy37; - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy89; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy89; - if (yych <= 'z') - goto yy36; - } - } - yy89: -#line 102 "lexer.re" - { - ts.push_token(Token(Token::print, lineno)); - token_start = cursor; - - continue; - } -#line 681 "lexer.cpp" - yy90: - ++cursor; - if ((yych = *cursor) <= 'Z') - { - if (yych <= '/') - goto yy91; - if (yych <= '9') - goto yy36; - if (yych >= 'A') - goto yy36; - } - else - { - if (yych <= '_') - { - if (yych >= '_') - goto yy36; - } - else - { - if (yych <= '`') - goto yy91; - if (yych <= 'z') - goto yy36; - } - } - yy91: -#line 81 "lexer.re" - { - ts.push_token(Token(Token::pop, lineno)); - token_start = cursor; - - continue; - } -#line 704 "lexer.cpp" - yy92: - ++cursor; - state = (3); - if (limit <= cursor) - return true; - yyFillLabel3: - yych = *cursor; - yy93: - if (yych <= '/') - goto yy5; - if (yych <= '9') - goto yy92; - goto yy5; - yy94: - yych = *++cursor; - if (yych <= '@') - { - if (yych <= '/') - goto yy95; - if (yych <= '9') - goto yy96; - } - else - { - if (yych <= 'F') - goto yy96; - if (yych <= '`') - goto yy95; - if (yych <= 'f') - goto yy96; - } - yy95: - cursor = marker; - goto yy5; - yy96: - ++cursor; - state = (4); - if (limit <= cursor) - return true; - yyFillLabel4: - yych = *cursor; - if (yych <= '@') - { - if (yych <= '/') - goto yy98; - if (yych <= '9') - goto yy96; - } - else - { - if (yych <= 'F') - goto yy96; - if (yych <= '`') - goto yy98; - if (yych <= 'f') - goto yy96; - } - yy98: -#line 66 "lexer.re" - { - ts.push_token(Token(Token::xinteger, lineno, token_start, cursor)); - token_start = cursor; - - continue; - } -#line 751 "lexer.cpp" - yy99: - ++cursor; - yych = *cursor; - goto yy5; -#line 243 "lexer.re" - } - return true; -} - -/*! -** Fills up the buffer when neccessary. -** Note the buffer is always filled to the maximum, not just the -** number of bytes neccessary for the lexer to continue. -** -** \param nbytes - the number of bytes -*/ - -void Lexer::buffer_grow(size_t new_size) -{ - char* new_buffer = new char[new_size]; - - std::copy(buffer, limit, new_buffer); - - token_start = new_buffer + (token_start - buffer); - cursor = new_buffer + (cursor - buffer); - limit = new_buffer + new_size; - - buffer_size = new_size; - - delete[] buffer; - buffer = new_buffer; -} - -void Lexer::read(size_t nbytes) -{ - if (token_start + nbytes > limit) - { // we need larger buffer - buffer_grow(token_start - buffer + nbytes); - } - - std::copy(token_start, limit, buffer); - cursor -= token_start - buffer; - char* old_limit = limit - (token_start - buffer); - token_start = buffer; - - file->read(old_limit, limit - old_limit); - if (file->eof()) - { - size_t bytes = file->gcount(); - std::fill(old_limit + bytes, limit, '\0'); - } -} - -void Lexer::buffer_init() -{ - file->read(buffer, buffer_size); - if (file->eof()) - { - size_t bytes = file->gcount(); - std::fill(buffer + bytes, buffer + buffer_size, '\0'); - } - - cursor = marker = token_start = buffer; - limit = buffer + buffer_size; -} - -} // namespace Lexer - -} // namespace ASM -} // namespace SpasmImpl +/* Generated by re2c 1.1.1 on Tue Nov 06 22:08:59 2018 */ +#line 1 "lexer.re" +#include + +#include "lexer.hpp" + +#include "token.hpp" + +namespace SpasmImpl +{ + namespace ASM + { + //! Namespace for all lexical analisys classes + namespace Lexer + { + + Lexer::Lexer (std::istream & _file, size_t _buffer_size) + : file (&_file), buffer_size (_buffer_size), state (unsigned(-1)), + lineno (0) + { + buffer = new char[buffer_size]; + cursor = limit = marker = token_start = NULL; + } + + Lexer::~Lexer () + { + delete [] buffer; + } + + bool Lexer::tokenize (TokenStream &ts) + { +#line 43 "lexer.re" + + + + + while (1) { + + +#line 41 "lexer.cpp" + { + char yych; + if ((limit - cursor) < 6) return true; + yych = *cursor; + switch (yych) { + case 0x00: goto yy2; + case '\t': + case ' ': goto yy6; + case '\n': goto yy9; + case '%': goto yy11; + case '*': goto yy13; + case '+': goto yy15; + case '-': goto yy17; + case '/': goto yy19; + case '0': goto yy21; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy23; + case '<': goto yy25; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'k': + case 'm': + case 'n': + case 'o': + case 'q': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + case 'c': goto yy30; + case 'd': goto yy31; + case 'j': goto yy32; + case 'l': goto yy33; + case 'p': goto yy34; + case 'r': goto yy35; + case 's': goto yy36; + default: goto yy4; + } +yy2: + ++cursor; +#line 233 "lexer.re" + { + ts.push_token (Token (Token::endinput, lineno)); + + break; + } +#line 130 "lexer.cpp" +yy4: + ++cursor; +#line 239 "lexer.re" + { + return false; + } +#line 137 "lexer.cpp" +yy6: + ++cursor; + if (limit <= cursor) return true; + yych = *cursor; + switch (yych) { + case '\t': + case ' ': goto yy6; + default: goto yy8; + } +yy8: +#line 220 "lexer.re" + { + token_start = cursor; + + continue; + } +#line 154 "lexer.cpp" +yy9: + ++cursor; +#line 226 "lexer.re" + { + ++lineno; + token_start = cursor; + + continue; + } +#line 164 "lexer.cpp" +yy11: + ++cursor; +#line 137 "lexer.re" + { + ts.push_token (Token (Token::modulus, lineno)); + token_start = cursor; + + continue; + } +#line 174 "lexer.cpp" +yy13: + ++cursor; +#line 123 "lexer.re" + { + ts.push_token (Token (Token::multiply, lineno)); + token_start = cursor; + + continue; + } +#line 184 "lexer.cpp" +yy15: + ++cursor; +#line 109 "lexer.re" + { + ts.push_token (Token (Token::plus, lineno)); + token_start = cursor; + + continue; + } +#line 194 "lexer.cpp" +yy17: + yych = *++cursor; + switch (yych) { + case '0': goto yy37; + default: goto yy18; + } +yy18: +#line 116 "lexer.re" + { + ts.push_token (Token (Token::minus, lineno)); + token_start = cursor; + + continue; + } +#line 209 "lexer.cpp" +yy19: + ++cursor; +#line 130 "lexer.re" + { + ts.push_token (Token (Token::divide, lineno)); + token_start = cursor; + + continue; + } +#line 219 "lexer.cpp" +yy21: + yych = *(marker = ++cursor); + switch (yych) { + case 'X': + case 'x': goto yy38; + default: goto yy22; + } +yy22: +#line 58 "lexer.re" + { + ts.push_token (Token (Token::integer, lineno, + token_start, cursor)); + token_start = cursor; + + continue; + } +#line 236 "lexer.cpp" +yy23: + ++cursor; + if (limit <= cursor) return true; + yych = *cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy23; + default: goto yy22; + } +yy25: + yych = *++cursor; + switch (yych) { + case '=': goto yy40; + default: goto yy26; + } +yy26: +#line 198 "lexer.re" + { + ts.push_token (Token (Token::less, lineno)); + token_start = cursor; + + continue; + } +#line 268 "lexer.cpp" +yy27: + ++cursor; + if (limit <= cursor) return true; + yych = *cursor; +yy28: + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy29; + } +yy29: +#line 212 "lexer.re" + { + ts.push_token (Token (Token::ident, lineno, token_start, + cursor)); + token_start = cursor; + + continue; + } +#line 349 "lexer.cpp" +yy30: + yych = *++cursor; + switch (yych) { + case 'a': goto yy42; + default: goto yy28; + } +yy31: + yych = *++cursor; + switch (yych) { + case 'u': goto yy43; + default: goto yy28; + } +yy32: + yych = *++cursor; + switch (yych) { + case 'm': goto yy44; + default: goto yy28; + } +yy33: + yych = *++cursor; + switch (yych) { + case 'a': goto yy45; + case 'o': goto yy46; + default: goto yy28; + } +yy34: + yych = *++cursor; + switch (yych) { + case 'o': goto yy47; + case 'r': goto yy48; + case 'u': goto yy49; + default: goto yy28; + } +yy35: + yych = *++cursor; + switch (yych) { + case 'e': goto yy50; + default: goto yy28; + } +yy36: + yych = *++cursor; + switch (yych) { + case 't': goto yy51; + default: goto yy28; + } +yy37: + ++cursor; + goto yy22; +yy38: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': goto yy52; + default: goto yy39; + } +yy39: + cursor = marker; + goto yy22; +yy40: + ++cursor; +#line 192 "lexer.re" + { + ts.push_token (Token (Token::lesseq, lineno)); + token_start = cursor; + + continue; + } +#line 437 "lexer.cpp" +yy42: + yych = *++cursor; + switch (yych) { + case 'l': goto yy55; + default: goto yy28; + } +yy43: + yych = *++cursor; + switch (yych) { + case 'p': goto yy56; + default: goto yy28; + } +yy44: + yych = *++cursor; + switch (yych) { + case 'p': goto yy58; + default: goto yy28; + } +yy45: + yych = *++cursor; + switch (yych) { + case 'b': goto yy60; + default: goto yy28; + } +yy46: + yych = *++cursor; + switch (yych) { + case 'a': goto yy61; + default: goto yy28; + } +yy47: + yych = *++cursor; + switch (yych) { + case 'p': goto yy62; + default: goto yy28; + } +yy48: + yych = *++cursor; + switch (yych) { + case 'i': goto yy64; + default: goto yy28; + } +yy49: + yych = *++cursor; + switch (yych) { + case 's': goto yy65; + default: goto yy28; + } +yy50: + yych = *++cursor; + switch (yych) { + case 'a': goto yy66; + case 't': goto yy67; + default: goto yy28; + } +yy51: + yych = *++cursor; + switch (yych) { + case 'o': goto yy69; + default: goto yy28; + } +yy52: + ++cursor; + if (limit <= cursor) return true; + yych = *cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': goto yy52; + default: goto yy54; + } +yy54: +#line 66 "lexer.re" + { + ts.push_token (Token (Token::xinteger, lineno, + token_start, cursor)); + token_start = cursor; + + continue; + } +#line 537 "lexer.cpp" +yy55: + yych = *++cursor; + switch (yych) { + case 'l': goto yy70; + default: goto yy28; + } +yy56: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy57; + } +yy57: +#line 88 "lexer.re" + { + ts.push_token (Token (Token::dup, lineno)); + token_start = cursor; + + continue; + } +#line 620 "lexer.cpp" +yy58: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + case 'f': goto yy72; + case 't': goto yy74; + default: goto yy59; + } +yy59: +#line 158 "lexer.re" + { + ts.push_token (Token (Token::go, lineno)); + token_start = cursor; + + continue; + } +#line 697 "lexer.cpp" +yy60: + yych = *++cursor; + switch (yych) { + case 'e': goto yy76; + default: goto yy28; + } +yy61: + yych = *++cursor; + switch (yych) { + case 'd': goto yy77; + default: goto yy28; + } +yy62: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy63; + } +yy63: +#line 81 "lexer.re" + { + ts.push_token (Token (Token::pop, lineno)); + token_start = cursor; + + continue; + } +#line 786 "lexer.cpp" +yy64: + yych = *++cursor; + switch (yych) { + case 'n': goto yy79; + default: goto yy28; + } +yy65: + yych = *++cursor; + switch (yych) { + case 'h': goto yy80; + default: goto yy28; + } +yy66: + yych = *++cursor; + switch (yych) { + case 'd': goto yy82; + default: goto yy28; + } +yy67: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy68; + } +yy68: +#line 172 "lexer.re" + { + ts.push_token (Token (Token::ret, lineno)); + token_start = cursor; + + continue; + } +#line 881 "lexer.cpp" +yy69: + yych = *++cursor; + switch (yych) { + case 'r': goto yy84; + default: goto yy28; + } +yy70: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy71; + } +yy71: +#line 165 "lexer.re" + { + ts.push_token (Token (Token::call, lineno)); + token_start = cursor; + + continue; + } +#line 964 "lexer.cpp" +yy72: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy73; + } +yy73: +#line 151 "lexer.re" + { + ts.push_token (Token (Token::gofalse, lineno)); + token_start = cursor; + + continue; + } +#line 1041 "lexer.cpp" +yy74: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy75; + } +yy75: +#line 144 "lexer.re" + { + ts.push_token (Token (Token::gotrue, lineno)); + token_start = cursor; + + continue; + } +#line 1118 "lexer.cpp" +yy76: + yych = *++cursor; + switch (yych) { + case 'l': goto yy85; + default: goto yy28; + } +yy77: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy78; + } +yy78: +#line 179 "lexer.re" + { + ts.push_token (Token (Token::load, lineno)); + token_start = cursor; + + continue; + } +#line 1201 "lexer.cpp" +yy79: + yych = *++cursor; + switch (yych) { + case 't': goto yy87; + default: goto yy28; + } +yy80: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy81; + } +yy81: +#line 74 "lexer.re" + { + ts.push_token (Token (Token::push, lineno)); + token_start = cursor; + + continue; + } +#line 1284 "lexer.cpp" +yy82: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy83; + } +yy83: +#line 95 "lexer.re" + { + ts.push_token (Token (Token::read, lineno)); + token_start = cursor; + + continue; + } +#line 1361 "lexer.cpp" +yy84: + yych = *++cursor; + switch (yych) { + case 'e': goto yy89; + default: goto yy28; + } +yy85: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy86; + } +yy86: +#line 205 "lexer.re" + { + ts.push_token (Token (Token::label, lineno)); + token_start = cursor; + + continue; + } +#line 1444 "lexer.cpp" +yy87: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy88; + } +yy88: +#line 102 "lexer.re" + { + ts.push_token (Token (Token::print, lineno)); + token_start = cursor; + + continue; + } +#line 1521 "lexer.cpp" +yy89: + yych = *++cursor; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy27; + default: goto yy90; + } +yy90: +#line 186 "lexer.re" + { + ts.push_token (Token (Token::store, lineno)); + token_start = cursor; + + continue; + } +#line 1598 "lexer.cpp" + } +#line 243 "lexer.re" + + } + return true; + } + + /*! + ** Fills up the buffer when neccessary. + ** Note the buffer is always filled to the maximum, not just the + ** number of bytes neccessary for the lexer to continue. + ** + ** \param nbytes - the number of bytes + */ + + void Lexer::buffer_grow (size_t new_size) + { + char *new_buffer = new char[new_size]; + + std::copy (buffer, limit, new_buffer); + + token_start = new_buffer + (token_start - buffer); + cursor = new_buffer + (cursor - buffer); + limit = new_buffer + new_size; + + buffer_size = new_size; + + delete [] buffer; + buffer = new_buffer; + } + + void Lexer::read (size_t nbytes) + { + if (token_start + nbytes > limit) { // we need larger buffer + buffer_grow (token_start - buffer + nbytes); + } + + std::copy (token_start, limit, buffer); + cursor -= token_start - buffer; + char *old_limit = limit - (token_start - buffer); + token_start = buffer; + + file->read (old_limit, limit - old_limit); + if (file->eof ()) { + size_t bytes = file->gcount (); + std::fill (old_limit + bytes, limit, '\0'); + } + } + + void Lexer::buffer_init () + { + file->read (buffer, buffer_size); + if (file->eof ()) { + size_t bytes = file->gcount (); + std::fill (buffer + bytes, buffer + buffer_size, '\0'); + } + + cursor = marker = token_start = buffer; + limit = buffer + buffer_size; + } + + + } // namespace Lexer + + } // namespace ASM +} // namespace SpasmImpl + -- cgit v1.3.1-23-gd82d