Updated the way string symbols are handled, allowing the programmer to terminate a string with any byte or none at all.
This commit is contained in:
+30
-6
@@ -100,13 +100,34 @@ void HandleAssemblerDirective() {
|
||||
}
|
||||
else if (token->Class == CharacterClass) {
|
||||
Symbol* s = AddSymbolToTable(symbolname, StringSymbol, MachineState.SymbolsTable);
|
||||
char* string = token->Lemexe;
|
||||
|
||||
s->Value.Text = token->Lemexe;
|
||||
AdvanceParser();
|
||||
|
||||
IgnoreParserLine();
|
||||
if (PeekToken()->Class == PunctuationClass && PeekToken()->Value.Punctuation == Comma) {
|
||||
AdvanceParser();
|
||||
|
||||
token = PeekToken();
|
||||
|
||||
if (token->Class != NumberClass) {
|
||||
fprintf(stderr, "[Error] Line %d: Expected terminating byte.\n", token->LineNumber);
|
||||
IgnoreParserLine();
|
||||
return;
|
||||
}
|
||||
|
||||
if (token->Value.Number > 255) {
|
||||
fprintf(stderr, "[Error] Line %d: Number must fit within a byte.\n", token->LineNumber);
|
||||
IgnoreParserLine();
|
||||
return;
|
||||
}
|
||||
|
||||
s->Value.String = CreateSymbolString(string, 1);
|
||||
s->Value.String->TerminatingByte = token->Value.Number;
|
||||
}
|
||||
else s->Value.String = CreateSymbolString(string, 0);
|
||||
}
|
||||
else IgnoreParserLine();
|
||||
|
||||
|
||||
IgnoreParserLine();
|
||||
}
|
||||
|
||||
Parameter* GetParameterType() {
|
||||
@@ -273,10 +294,13 @@ void PrintSymbols(void) {
|
||||
printf("%s -> %s", symbol->Name, mn);
|
||||
break;
|
||||
case NumericSymbol:
|
||||
printf("[N] %s", symbol->Name);
|
||||
printf("[N] %s Value: %d", symbol->Name, symbol->Value.Number);
|
||||
break;
|
||||
case StringSymbol:
|
||||
printf("[S] %s", symbol->Name);
|
||||
if (symbol->Value.String->Terminated)
|
||||
printf("[S] %s, %d", symbol->Name, symbol->Value.String->TerminatingByte);
|
||||
else
|
||||
printf("[S] %s", symbol->Value.String->String);
|
||||
break;
|
||||
case UnresolvedSymbol:
|
||||
printf("[U] %s", symbol->Name);
|
||||
|
||||
Reference in New Issue
Block a user