1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-06 15:29:30 +00:00

Support line comments.

This commit is contained in:
Chris Pressey 2015-10-18 18:54:28 +01:00
parent a933c81768
commit 9235c6eacc
5 changed files with 19 additions and 4 deletions

View File

@ -6,6 +6,7 @@ History of SixtyPical
* Added `byte table` type locations and indexed addressing (`+ x`, `+ y`).
* Integer literals may be given in hexadecimal.
* Line comments may be included in source code by prefixing them with `//`.
0.4
---

View File

@ -33,8 +33,6 @@ TODO
For 0.5:
* source code comments.
For 0.6:
* `interrupt` routines.

View File

@ -1,12 +1,16 @@
// Displays 256 hearts at the top of the Commodore 64's screen.
// Define where the screen starts in memory:
byte table screen @ 1024
routine main
// These are the values that will be written to by this routine:
trashes a, x, z, n, screen
{
ld x, 0
ld a, 83
ld a, 83 // 83 = screen code for heart
repeat {
st a, screen + x
inc x
} until z
} until z // this flag will be set when x wraps around from 255 to 0
}

View File

@ -29,6 +29,8 @@ class Scanner(object):
def scan(self):
self.scan_pattern(r'[ \t\n\r]*', 'whitespace')
while self.scan_pattern(r'\/\/.*?[\n\r]', 'comment'):
self.scan_pattern(r'[ \t\n\r]*', 'whitespace')
if not self.text:
self.token = None
self.type = 'EOF'

View File

@ -19,6 +19,16 @@ Rudimentary program.
| }
= ok
Program with comments.
| // Welcome to my program.
|
| routine main {
| ld a, 0
| add a, 1 // We are adding the thing.
| }
= ok
Hex literals.
| routine main {