Support parsing '?' tokens, which is a shorthand for 'PRINT'.

This commit is contained in:
kris 2019-07-20 15:52:01 -05:00
parent 801ce68525
commit f7b5b050dd
3 changed files with 9 additions and 1 deletions

View File

@ -108,7 +108,12 @@ public class TokenReader {
.filter(t -> opt.get().parts.get(1).equals(t.text))
.orElseThrow(() -> new IOException("Expecting: " + opt.get().parts));
}
return Optional.of(Token.keyword(line, opt.get()));
ApplesoftKeyword outKeyword = opt.get();
// Special case - canonicalize '?' alternate form of 'PRINT'
if (opt.filter(kw -> kw == ApplesoftKeyword.questionmark).isPresent()) {
outKeyword = ApplesoftKeyword.PRINT;
}
return Optional.of(Token.keyword(line, outKeyword));
}
// Check if we found a directive
if (tokenizer.sval.startsWith("$")) {

View File

@ -71,6 +71,7 @@ public enum ApplesoftKeyword {
DEF(0xB8, "DEF"),
POKE(0xB9, "POKE"),
PRINT(0xBA, "PRINT"),
questionmark(0xBA, "?"), // Alternate form of PRINT
CONT(0xBB, "CONT"),
LIST(0xBC, "LIST"),
CLEAR(0xBD, "CLEAR"),
@ -178,6 +179,7 @@ public enum ApplesoftKeyword {
tokenizer.resetSyntax();
tokenizer.wordChars('a', 'z');
tokenizer.wordChars('A', 'Z');
tokenizer.wordChars('?', '?'); // For '?' form of PRINT
tokenizer.wordChars('$', '$'); // Experiment to pull in string marker
tokenizer.wordChars('%', '%'); // Experiment to pull in integer marker
tokenizer.wordChars(128 + 32, 255);

View File

@ -0,0 +1 @@
10 ? "PASS"