stricter about line breaks, less finicky about blank statements

pull/10/head
Matthew Butterick 8 years ago
parent eab018a9a2
commit 8504cd4d80

@ -23,7 +23,7 @@
(define (LINE-NUMBER-ID #:srcloc? [srcloc #f])
(if srcloc
(syntax-srcloc #'ORIG-LOC)
(begin STATEMENT ...))))))
(begin (void) STATEMENT ...))))))
(define b-rem void)
(define (b-print [val ""]) (displayln val))

@ -6,8 +6,9 @@
(define basic-lexer
(lexer-srcloc
[(eof) (return-without-srcloc eof)]
[(from/stop-before "rem" "\n") (token 'REM lexeme)]
[(:seq "\n" digits) (token 'LINE-NUMBER (string->number (string-trim lexeme)))]
[whitespace (token lexeme #:skip? #t)]
[(from/to "rem" "\n") (token 'REM lexeme)]
[(:or "print" "goto" "end" "+" ":") lexeme]
[digits (token 'INTEGER (string->number lexeme))]
[(:or (:seq (:? digits) "." digits)

@ -1,7 +1,7 @@
#lang brag
b-program : b-line*
b-line : @b-line-number b-statement (/":" b-statement)*
b-line-number : INTEGER
b-line : @b-line-number [b-statement] (/":" [b-statement])*
b-line-number : LINE-NUMBER
@b-statement : b-rem
| b-print
| b-goto

@ -1,5 +1,6 @@
#lang basic-demo
30 rem print "ignored"
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3

Loading…
Cancel
Save