From b79059faa457243fdfdfa9a09e1040e6b2b5dee8 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Wed, 14 Mar 2018 09:51:24 +0000 Subject: [PATCH] Two seperate words looks better. --- src/sixtypical/parser.py | 7 ++++--- tests/SixtyPical Analysis.md | 20 ++++++++++---------- tests/SixtyPical Syntax.md | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/sixtypical/parser.py b/src/sixtypical/parser.py index 061ba03..ede7849 100644 --- a/src/sixtypical/parser.py +++ b/src/sixtypical/parser.py @@ -378,12 +378,13 @@ class Parser(object): return Repeat(self.scanner.line_number, src=src, block=block, inverted=inverted) elif self.scanner.consume('for'): dest = self.locexpr() - if self.scanner.consume('downto'): + if self.scanner.consume('down'): direction = -1 - elif self.scanner.consume('upto'): + elif self.scanner.consume('up'): direction = 1 else: - self.syntax_error('expected "upto" or "downto", found "%s"' % self.scanner.token) + self.syntax_error('expected "up" or "down", found "%s"' % self.scanner.token) + self.scanner.expect('to') final = self.literal_int() block = self.block() return For(self.scanner.line_number, dest=dest, direction=direction, final=final, block=block) diff --git a/tests/SixtyPical Analysis.md b/tests/SixtyPical Analysis.md index fadaa3f..47617db 100644 --- a/tests/SixtyPical Analysis.md +++ b/tests/SixtyPical Analysis.md @@ -1669,7 +1669,7 @@ In a "for" loop, we know the exact range the loop variable takes on. | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 0 - | for x upto 15 { + | for x up to 15 { | ld a, tab + x | } | } @@ -1679,7 +1679,7 @@ In a "for" loop, we know the exact range the loop variable takes on. | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 0 - | for x upto 15 { + | for x up to 15 { | ld a, tab + x | } | } @@ -1691,7 +1691,7 @@ You cannot modify the loop variable in a "for" loop. | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 0 - | for x upto 15 { + | for x up to 15 { | ld x, 0 | } | } @@ -1703,19 +1703,19 @@ If the range isn't known to be smaller than the final value, you can't go up to | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 16 - | for x upto 15 { + | for x up to 15 { | ld a, tab + x | } | } ? RangeExceededError -In a "for" loop (downto variant), we know the exact range the loop variable takes on. +In a "for" loop (downward-counting variant), we know the exact range the loop variable takes on. | byte table[16] tab | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 15 - | for x downto 0 { + | for x down to 0 { | ld a, tab + x | } | } @@ -1725,19 +1725,19 @@ In a "for" loop (downto variant), we know the exact range the loop variable take | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 15 - | for x downto 0 { + | for x down to 0 { | ld a, tab + x | } | } ? RangeExceededError -You cannot modify the loop variable in a "for" loop (downto variant). +You cannot modify the loop variable in a "for" loop (downward variant). | byte table[16] tab | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 15 - | for x downto 0 { + | for x down to 0 { | ld x, 0 | } | } @@ -1749,7 +1749,7 @@ If the range isn't known to be larger than the final value, you can't go down to | | define foo routine inputs tab trashes a, x, c, z, v, n { | ld x, 0 - | for x downto 0 { + | for x down to 0 { | ld a, tab + x | } | } diff --git a/tests/SixtyPical Syntax.md b/tests/SixtyPical Syntax.md index 29bd84b..2add5ea 100644 --- a/tests/SixtyPical Syntax.md +++ b/tests/SixtyPical Syntax.md @@ -137,11 +137,11 @@ Basic "open-faced for" loops, up and down. | | routine foo trashes a, x, c, z, v { | ld x, 0 - | for x upto 15 { + | for x up to 15 { | ld a, tab + x | } | ld x, 15 - | for x downto 0 { + | for x down to 0 { | ld a, tab + x | } | }