Skip to content

Commit 227273c

Browse files
fix some over-wide lines
1 parent 8bcf191 commit 227273c

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

scribblings/reference/compiling.scrbl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ Here is an example for a @racket[match] DSL where pattern-bound variables cannot
4343
@;TODO host-interface/expression and racket-expr isn't getting linked
4444
@racketblock[
4545
(syntax-spec
46-
(binding-class pat-var #:reference-compiler (make-variable-like-reference-compiler (lambda (id) id)))
46+
(binding-class pat-var
47+
#:reference-compiler (make-variable-like-reference-compiler
48+
(lambda (id) id)))
4749
(host-interface/expression
4850
(match target:racket-expr c:clause ...)
4951
#'(let ([target-pv target])

scribblings/tutorial/basic-tutorial.scrbl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ Our initial specification with @racket[syntax-spec] supplies the grammar:
7171

7272
(nonterminal state-spec
7373
(state name:id transitions:transition-spec ...)
74-
(state name:id ((~datum on-enter) body:action-spec ...+) transitions:transition-spec ...))
74+
(state name:id
75+
((~datum on-enter) body:action-spec ...+)
76+
transitions:transition-spec ...))
7577

7678
(nonterminal transition-spec
7779
(on (event-name:id arg:id ...)
@@ -196,7 +198,9 @@ Now let's add binding rules for state names. We can't just use @racket[scope] an
196198
(error 'machine "compiler not yet implemented"))
197199

198200
(nonterminal/exporting state-spec
199-
(state name:state-name ((~datum on-enter) body:action-spec ...+) transition:transition-spec ...)
201+
(state name:state-name
202+
((~datum on-enter) body:action-spec ...+)
203+
transition:transition-spec ...)
200204
#:binding (export name)
201205

202206
(state name:state-name transition:transition-spec ...)
@@ -252,7 +256,9 @@ An action expression can only @racket[displayln] the value of a variable. What i
252256
...
253257

254258
(nonterminal/exporting state-spec
255-
(state name:state-name ((~datum on-enter) body:racket-body ...+) transition:transition-spec ...)
259+
(state name:state-name
260+
((~datum on-enter) body:racket-body ...+)
261+
transition:transition-spec ...)
256262
#:binding [(export name) (scope (import body) ...)]
257263

258264
(state name:state-name transition:transition-spec ...)
@@ -362,11 +368,12 @@ We'll create a class for the state machine, which acts as a context class, and a
362368

363369
The @racket[machine%] class stores the current state instance and delegates to it. Each state class has methods for each defined transition. Transition actions go in the transition's method and @racket[on-enter] actions go in the class body. When a state is entered, the @racket[machine%] class creates a fresh instance of it, which runs the class body, and sets the current state to that instance. Finally, we return an instance of the machine class.
364370

365-
Now Let's start to write the compiler:
371+
Now let's start to write the compiler:
366372

367373
@racketblock[
368374
(syntax-spec
369-
(binding-class event-var #:reference-compiler mutable-reference-compiler)
375+
(binding-class event-var
376+
#:reference-compiler mutable-reference-compiler)
370377
...
371378
(host-interface/expression
372379
(machine #:initial initial-state:state-name s:state-spec ...)
@@ -379,7 +386,8 @@ Now Let's start to write the compiler:
379386
#:datum-literals (machine state on-enter)
380387
[(_ initial-state
381388
(state state-name
382-
(~optional (on-enter action ...) #:defaults ([(action 1) '()]))
389+
(~optional (on-enter action ...)
390+
#:defaults ([(action 1) '()]))
383391
e ...)
384392
...)
385393
#'(let ()
@@ -495,8 +503,10 @@ In our language's compiler, we can use symbol set to raise an error when a state
495503
(define (check-for-inaccessible-states initial-state-id state-specs)
496504
(define accessible-states (get-accessible-states initial-state-id state-specs))
497505
(for/list ([state-spec state-specs]
498-
#:unless (symbol-set-member? accessible-states (state-spec-name state-spec)))
499-
(error 'machine "Inaccessible state: ~a" (syntax->datum (state-spec-name state-spec)))))
506+
#:unless (symbol-set-member? accessible-states
507+
(state-spec-name state-spec)))
508+
(error 'machine "Inaccessible state: ~a"
509+
(syntax->datum (state-spec-name state-spec)))))
500510

501511
(define (get-accessible-states initial-state-id state-specs)
502512
(define accessible-states (local-symbol-set))

scribblings/tutorial/multipass-tutorial.scrbl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Here is the syntax-spec of our language:
1717
@repl[
1818
#:hidden #t
1919
(module grammar racket
20-
(provide (all-defined-out) (for-space anf (all-defined-out)) (for-syntax (all-defined-out) (for-space anf (all-defined-out))))
20+
(provide (all-defined-out)
21+
(for-space anf (all-defined-out))
22+
(for-syntax (all-defined-out) (for-space anf (all-defined-out))))
2123
(require "main.rkt" (for-syntax syntax/parse racket))
2224
(require (for-syntax racket/match racket/syntax racket/list))
2325
(syntax-spec
@@ -80,7 +82,8 @@ Here is the syntax-spec of our language:
8082
(define bindings-rev '())
8183
; Identifier rhs-expr -> Void
8284
; ends up producing a let-binding of x to e in the result
83-
(define (lift-binding! x e) (set! bindings-rev (cons (list x e) bindings-rev)))
85+
(define (lift-binding! x e)
86+
(set! bindings-rev (cons (list x e) bindings-rev)))
8487
(define e^ (to-rhs! e lift-binding!))
8588
(wrap-lets e^ (reverse bindings-rev)))
8689

scribblings/tutorial/stlc-tutorial.scrbl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ Let's do it!
253253

254254
@racketblock[#:escape unracket
255255
(syntax-spec
256-
(binding-class typed-var #:reference-compiler typed-var-reference-compiler)
256+
(binding-class typed-var
257+
#:reference-compiler typed-var-reference-compiler)
257258
...
258259

259260
(nonterminal typed-expr
@@ -478,13 +479,17 @@ Now let's update the rest of our code:
478479

479480
(define-stlc-syntax let
480481
(syntax-parser
481-
[(_ ([x e] ...) body) #'(#%let ([x e] ...) body)]
482-
[(_ ([x e] ...) body ...+) #'(#%let ([x e] ...) (block body ...))]))
482+
[(_ ([x e] ...) body)
483+
#'(#%let ([x e] ...) body)]
484+
[(_ ([x e] ...) body ...+)
485+
#'(#%let ([x e] ...) (block body ...))]))
483486

484487
(define-stlc-syntax lambda
485488
(syntax-parser
486-
[(_ ([x (~datum :) t] ...) body) #'(#%lambda ([x : t] ...) body)]
487-
[(_ ([x (~datum :) t] ...) body ...+) #'(#%lambda ([x : t] ...) (block body ...))]))
489+
[(_ ([x (~datum :) t] ...) body)
490+
#'(#%lambda ([x : t] ...) body)]
491+
[(_ ([x (~datum :) t] ...) body ...+)
492+
#'(#%lambda ([x : t] ...) (block body ...))]))
488493

489494
(define-stlc-syntax let*
490495
(syntax-parser

0 commit comments

Comments
 (0)