From f5dd28cd0561c42b75871e19ba06099944f8dacf Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 28 Feb 2017 17:12:15 -0800 Subject: [PATCH] fix lexer --- beautiful-racket-demo/basic-demo-3/lexer.rkt | 3 ++- beautiful-racket-demo/basic-demo-3/sample-for.rkt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/beautiful-racket-demo/basic-demo-3/lexer.rkt b/beautiful-racket-demo/basic-demo-3/lexer.rkt index 9601ef0..90a950f 100644 --- a/beautiful-racket-demo/basic-demo-3/lexer.rkt +++ b/beautiful-racket-demo/basic-demo-3/lexer.rkt @@ -19,7 +19,8 @@ [(:or (:seq (:? digits) "." digits) (:seq digits ".")) (token 'DECIMAL (string->number lexeme))] - [(:+ (:~ id-kapu)) (token 'ID (string->symbol lexeme))] + [(:seq (:~ (:or "-" id-kapu)) (:* (:~ id-kapu))) + (token 'ID (string->symbol lexeme))] [(:or (from/to "\"" "\"") (from/to "'" "'")) (token 'STRING (substring lexeme diff --git a/beautiful-racket-demo/basic-demo-3/sample-for.rkt b/beautiful-racket-demo/basic-demo-3/sample-for.rkt index 6590ba1..1242f24 100644 --- a/beautiful-racket-demo/basic-demo-3/sample-for.rkt +++ b/beautiful-racket-demo/basic-demo-3/sample-for.rkt @@ -1,6 +1,6 @@ #lang basic-demo-3 10 for a = 1 to 3 21 for b = 9 to 7 step -1 -22 print a ; b +22 print a : print b 23 next b 30 next a \ No newline at end of file