resume in parser

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

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

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