1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-29 18:49:22 +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`). * Added `byte table` type locations and indexed addressing (`+ x`, `+ y`).
* Integer literals may be given in hexadecimal. * Integer literals may be given in hexadecimal.
* Line comments may be included in source code by prefixing them with `//`.
0.4 0.4
--- ---

View File

@ -33,8 +33,6 @@ TODO
For 0.5: For 0.5:
* source code comments.
For 0.6: For 0.6:
* `interrupt` routines. * `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 byte table screen @ 1024
routine main routine main
// These are the values that will be written to by this routine:
trashes a, x, z, n, screen trashes a, x, z, n, screen
{ {
ld x, 0 ld x, 0
ld a, 83 ld a, 83 // 83 = screen code for heart
repeat { repeat {
st a, screen + x st a, screen + x
inc 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): def scan(self):
self.scan_pattern(r'[ \t\n\r]*', 'whitespace') 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: if not self.text:
self.token = None self.token = None
self.type = 'EOF' self.type = 'EOF'

View File

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