git @ Cat's Eye Technologies SixtyPical / 9235c6e
Support line comments. Chris Pressey 6 years ago
5 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
55
66 * Added `byte table` type locations and indexed addressing (`+ x`, `+ y`).
77 * Integer literals may be given in hexadecimal.
8 * Line comments may be included in source code by prefixing them with `//`.
89
910 0.4
1011 ---
3232
3333 For 0.5:
3434
35 * source code comments.
36
3735 For 0.6:
3836
3937 * `interrupt` routines.
0 // Displays 256 hearts at the top of the Commodore 64's screen.
1
2 // Define where the screen starts in memory:
03 byte table screen @ 1024
14
25 routine main
6 // These are the values that will be written to by this routine:
37 trashes a, x, z, n, screen
48 {
59 ld x, 0
6 ld a, 83
10 ld a, 83 // 83 = screen code for heart
711 repeat {
812 st a, screen + x
913 inc x
10 } until z
14 } until z // this flag will be set when x wraps around from 255 to 0
1115 }
2828
2929 def scan(self):
3030 self.scan_pattern(r'[ \t\n\r]*', 'whitespace')
31 while self.scan_pattern(r'\/\/.*?[\n\r]', 'comment'):
32 self.scan_pattern(r'[ \t\n\r]*', 'whitespace')
3133 if not self.text:
3234 self.token = None
3335 self.type = 'EOF'
1515 | routine main {
1616 | ld a, 0
1717 | add a, 1
18 | }
19 = ok
20
21 Program with comments.
22
23 | // Welcome to my program.
24 |
25 | routine main {
26 | ld a, 0
27 | add a, 1 // We are adding the thing.
1828 | }
1929 = ok
2030