Thank you for your comment

Beau­tiful Racket / tuto­rials

basic/parser.rkt
#lang brag
b-program : b-line (NEWLINE b-line)*
b-line :
1
2
3
#lang brag
b-program : b-line (NEWLINE b-line)*
b-line :
copy to clipboard
sample.rkt
#lang basic
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end
1
2
3
4
5
6
7
8
9
#lang basic
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line :
1
2
3
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num
       | b-line-num b-statement
       | b-line-num b-statement (":" b-statement)+
b-line-num : INTEGER
b-statement :
1
2
3
4
5
6
7
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num
       | b-line-num b-statement
       | b-line-num b-statement (":" b-statement)+
b-line-num : INTEGER
b-statement :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement (":" b-statement)*]
b-line-num : INTEGER
b-statement :
1
2
3
4
5
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement (":" b-statement)*]
b-line-num : INTEGER
b-statement :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])*
b-line-num : INTEGER
b-statement :
1
2
3
4
5
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])*
b-line-num : INTEGER
b-statement :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement :
b-rem : REM
1
2
3
4
5
6
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement :
b-rem : REM
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end :
b-print :
b-goto :
1
2
3
4
5
6
7
8
9
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end :
b-print :
b-goto :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print :
b-goto :
1
2
3
4
5
6
7
8
9
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print :
b-goto :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto :
b-expr :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto :
b-expr :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr :
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr :
b-sum :
b-number : INTEGER | DECIMAL
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr :
b-sum :
b-number : INTEGER | DECIMAL
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr :
b-sum : b-number ("+" b-number)*
b-number : INTEGER | DECIMAL
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr :
b-sum : b-number ("+" b-number)*
b-number : INTEGER | DECIMAL
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr : b-sum
b-sum : b-number ("+" b-number)*
b-number : INTEGER | DECIMAL
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#lang brag
b-program : [b-line] (NEWLINE [b-line])*
b-line : b-line-num [b-statement] (":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : "end"
b-print : "print" [b-printable] (";" [b-printable])*
b-printable : STRING | b-expr
b-goto : "goto" b-expr
b-expr : b-sum
b-sum : b-number ("+" b-number)*
b-number : INTEGER | DECIMAL
copy to clipboard
parser-test.rkt
#lang br
(require basic/parser basic/tokenizer brag/support)

(define str #<<HERE
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
HERE
)

(parse-to-datum (apply-tokenizer make-tokenizer str))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#lang br
(require basic/parser basic/tokenizer brag/support)

(define str #<<HERE
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
HERE
)

(parse-to-datum (apply-tokenizer make-tokenizer str))
copy to clipboard
sample.rkt
#lang basic
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end
1
2
3
4
5
6
7
8
9
#lang basic
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end
copy to clipboard
parser-test.rkt
#lang br
(require basic/parser basic/tokenizer brag/support)

(define str #<<HERE
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end
HERE
  )

(parse-to-datum (apply-tokenizer make-tokenizer str))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#lang br
(require basic/parser basic/tokenizer brag/support)

(define str #<<HERE
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end
HERE
  )

(parse-to-datum (apply-tokenizer make-tokenizer str))
copy to clipboard
test.rkt
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
1
2
3
4
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
copy to clipboard
basic/parse-only.rkt
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")

(define (read-syntax path port)
  (define parse-tree (parse path (make-tokenizer port path)))
  (strip-bindings
   #`(module basic-parser-mod basic/parse-only
       #,parse-tree)))
(module+ reader (provide read-syntax))

(define-macro (parser-only-mb PARSE-TREE)
  #'(#%module-begin
     'PARSE-TREE))
(provide (rename-out [parser-only-mb #%module-begin]))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")

(define (read-syntax path port)
  (define parse-tree (parse path (make-tokenizer port path)))
  (strip-bindings
   #`(module basic-parser-mod basic/parse-only
       #,parse-tree)))
(module+ reader (provide read-syntax))

(define-macro (parser-only-mb PARSE-TREE)
  #'(#%module-begin
     'PARSE-TREE))
(provide (rename-out [parser-only-mb #%module-begin]))
copy to clipboard
test.rkt
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
1
2
3
4
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
copy to clipboard
test.rkt
#lang basic-demo
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
1
2
3
4
#lang basic-demo
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
copy to clipboard
basic/tokenize-only.rkt
#lang br/quicklang
(require brag/support "tokenizer.rkt")

(define (read-syntax path port)
  (define tokens (apply-tokenizer make-tokenizer port))
  (strip-bindings
   #`(module basic-tokens-mod basic/tokenize-only
       #,@tokens)))
(module+ reader (provide read-syntax))

(define-macro (tokenize-only-mb TOKEN ...)
  #'(#%module-begin
     (list TOKEN ...)))
(provide (rename-out [tokenize-only-mb #%module-begin]))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#lang br/quicklang
(require brag/support "tokenizer.rkt")

(define (read-syntax path port)
  (define tokens (apply-tokenizer make-tokenizer port))
  (strip-bindings
   #`(module basic-tokens-mod basic/tokenize-only
       #,@tokens)))
(module+ reader (provide read-syntax))

(define-macro (tokenize-only-mb TOKEN ...)
  #'(#%module-begin
     (list TOKEN ...)))
(provide (rename-out [tokenize-only-mb #%module-begin]))
copy to clipboard
test.rkt
#lang basic/tokenize-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
1
2
3
4
#lang basic/tokenize-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
copy to clipboard
test.rkt
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
1
2
3
4
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
30 end
copy to clipboard
test.rkt
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
25 xyzzy
30 end
1
2
3
4
5
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
25 xyzzy
30 end
copy to clipboard
test.rkt
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
25 prinxyzzy
30 end
1
2
3
4
5
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
25 prinxyzzy
30 end
copy to clipboard
test.rkt
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
25 print goto
30 end
1
2
3
4
5
#lang basic/parse-only
10 print "hello" : print "world"
20 goto 9 + 10 + 11
25 print goto
30 end
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-expr : b-sum
b-sum : b-number (/"+" b-number)*
b-number : INTEGER | DECIMAL
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
b-line-num : INTEGER
b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-expr : b-sum
b-sum : b-number (/"+" b-number)*
b-number : INTEGER | DECIMAL
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
@b-line-num : INTEGER
@b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
@b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-expr : b-sum
b-sum : b-number (/"+" b-number)*
@b-number : INTEGER | DECIMAL
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
@b-line-num : INTEGER
@b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
@b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-expr : b-sum
b-sum : b-number (/"+" b-number)*
@b-number : INTEGER | DECIMAL
copy to clipboard
basic/parser.rkt
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
@b-line-num : INTEGER
@b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
@b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-expr : b-sum
b-sum : b-number (/"+" b-number)*
@b-number : INTEGER | DECIMAL
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
@b-line-num : INTEGER
@b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
@b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-expr : b-sum
b-sum : b-number (/"+" b-number)*
@b-number : INTEGER | DECIMAL
copy to clipboard
← prev next →