Added some simple symbol handling to the Parser.
This commit is contained in:
+5
-5
@@ -149,7 +149,6 @@ Token* ParseDirective(void) {
|
||||
|
||||
free(directive);
|
||||
|
||||
//Ignore the line
|
||||
IgnoreLine();
|
||||
|
||||
return NULL;
|
||||
@@ -164,9 +163,7 @@ Token* ParseString(void) {
|
||||
|
||||
int start = Position;
|
||||
|
||||
while(!ScannerAtEnd() && PeekScanner() != '"') {
|
||||
AdvanceScanner();
|
||||
}
|
||||
while(!ScannerAtEnd() && PeekScanner() != '"') AdvanceScanner();
|
||||
|
||||
int length = Position - start;
|
||||
|
||||
@@ -211,7 +208,10 @@ Token* ParseIdentifier(void) {
|
||||
|
||||
if (IsOpcode(lexeme, &type)) return CreateToken(lexeme, lexeme, Line, type);
|
||||
if (IsRegister(lexeme, &type)) return CreateToken(lexeme, lexeme, Line, type);
|
||||
if (lexeme[length - 1] == ':') return CreateToken(lexeme, lexeme, Line, LABEL);
|
||||
if (lexeme[length - 1] == ':') {
|
||||
lexeme[length - 1] = '\0'; //Bit hacky, but this makes the parser's job a bit easier.
|
||||
return CreateToken(lexeme, lexeme, Line, LABEL);
|
||||
}
|
||||
|
||||
return CreateToken(lexeme, lexeme, Line, IDENTIFIER);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user