resume in parser

pull/10/head
Matthew Butterick 8 years ago
parent f5dd28cd05
commit d60ef52e2b

@ -8,6 +8,9 @@
(define-lex-abbrev id-kapu (define-lex-abbrev id-kapu
(:or whitespace (char-set "()[]{}\",'`;#|\\"))) (:or whitespace (char-set "()[]{}\",'`;#|\\")))
(define-lex-abbrev id
(:seq (:~ (:or "-" id-kapu)) (:* (:~ id-kapu))))
(define basic-lexer (define basic-lexer
(lexer-srcloc (lexer-srcloc
[(eof) (return-without-srcloc eof)] [(eof) (return-without-srcloc eof)]
@ -19,8 +22,7 @@
[(:or (:seq (:? digits) "." digits) [(:or (:seq (:? digits) "." digits)
(:seq digits ".")) (:seq digits "."))
(token 'DECIMAL (string->number lexeme))] (token 'DECIMAL (string->number lexeme))]
[(:seq (:~ (:or "-" id-kapu)) (:* (:~ id-kapu))) [id (token 'ID (string->symbol lexeme))]
(token 'ID (string->symbol lexeme))]
[(:or (from/to "\"" "\"") (from/to "'" "'")) [(:or (from/to "\"" "\"") (from/to "'" "'"))
(token 'STRING (token 'STRING
(substring lexeme (substring lexeme

@ -1,8 +1,7 @@
#lang basic-demo-3 #lang basic-demo-3
5 x = 5 10 import math/number-theory
10 def f(x, y) = x * y 20 print nth-prime(15)
20 print f(9, f(4,5)) : print x 30 print prime?(24)
30 print 42 : import math/number-theory 40 import racket/base
40 print prime?(15) 50 print max(f(1), f(2), f(5), f(4))
50 import racket/base 60 def f(x) = x + x
60 print max(2, 4, 10, 8)
Loading…
Cancel
Save