Add a SEMICOLON token

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-04-08 11:01:07 +02:00
parent 1d3046892f
commit 14b71906b7
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
3 changed files with 4 additions and 4 deletions

View File

@ -49,11 +49,11 @@ vector<tok> lex(const string& in)
} else goto insertToken;
}
case DEFINE: case RPAR: case COMMA:
case RBRACE: case RBRACKET:
case RBRACE: case RBRACKET: case SEMICOLON:
case PLUS: case HYPHEN: case LCOMP: case RCOMP:
case DOT: case DOLLAR_SIGN: case SQUOTE:
insertToken: resVal.emplace_back(static_cast<tok::type>(current), lineNumber);
[[likely]] case ' ': case '\t': case '\r': case ';': break;
[[likely]] case ' ': case '\t': case '\r': break;
[[likely]] case '\n': ++lineNumber; break;
default: {
const tok::type type = getIdentifierCharType(current);

View File

@ -11,7 +11,7 @@ struct tok {
typedef Yerbacon::Exception LexerException;
enum type: const unsigned short {
UNEXPECTED = std::numeric_limits<unsigned char>::max() + 1, IDENTIFIER, NUMBER, ALPHACHAR,
DEFINE = '=', TAG = '#', DOLLAR_SIGN = '$', DOT = '.', COMMA = ',',
DEFINE = '=', TAG = '#', DOLLAR_SIGN = '$', DOT = '.', COMMA = ',', SEMICOLON = ';',
LPAR = '(', LBRACE = '{', LBRACKET = '[', RPAR = ')',
RBRACE = '}', RBRACKET = ']',
PLUS = '+', HYPHEN = '-', DIVIDE = '/',

View File

@ -92,7 +92,7 @@ namespace Parser {
const unsigned increment = 2 + isFinalDefine;
const auto beginning = lexed.begin() + i + increment;
const auto end = find_if(beginning, lexed.end(), [&current](const tok& it){ // TODO Find another way of choosing the tokens to parse
return it.line != current.line;
return it.toktype == SEMICOLON || it.line != current.line;
});
parseTree << Define(isFinalDefine, current.toktext, parse(beginning, end));
i += 1 + isFinalDefine + distance(beginning, end);