mirror of
https://github.com/AppleCommander/bastools.git
synced 2025-01-02 10:31:01 +00:00
Merge pull request #19 from KrisKennaway/master
Support parsing '?' tokens, which is a shorthand for 'PRINT'.
This commit is contained in:
commit
cc12f7ccba
@ -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("$")) {
|
||||
|
@ -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);
|
||||
|
2
tools/bt/src/test/resources/print.bas
Normal file
2
tools/bt/src/test/resources/print.bas
Normal file
@ -0,0 +1,2 @@
|
||||
10 REM Test case to validate that the '?' shorthand form of PRINT is accepted
|
||||
20 ? "PASS"
|
Loading…
Reference in New Issue
Block a user