|
|
@ -117,7 +117,7 @@ That's @racket[(some [pig])], essentially.
|
|
|
|
What happens if we pass our @racket[parse] function a bigger source of tokens?
|
|
|
|
What happens if we pass our @racket[parse] function a bigger source of tokens?
|
|
|
|
|
|
|
|
|
|
|
|
@interaction[#:eval my-eval
|
|
|
|
@interaction[#:eval my-eval
|
|
|
|
@code:comment{tokenize: string -> (sequence/c token-struct?)}
|
|
|
|
@code:comment{tokenize: string -> (sequenceof token-struct?)}
|
|
|
|
@code:comment{Generate tokens from a string:}
|
|
|
|
@code:comment{Generate tokens from a string:}
|
|
|
|
(define (tokenize s)
|
|
|
|
(define (tokenize s)
|
|
|
|
(for/list ([str (regexp-match* #px"\\(|\\)|\\w+" s)])
|
|
|
|
(for/list ([str (regexp-match* #px"\\(|\\)|\\w+" s)])
|
|
|
@ -689,8 +689,8 @@ continues till the end of the line.
|
|
|
|
A @deftech{multiline comment} begins with @litchar{(*} and ends with @litchar{*)}.
|
|
|
|
A @deftech{multiline comment} begins with @litchar{(*} and ends with @litchar{*)}.
|
|
|
|
|
|
|
|
|
|
|
|
An @deftech{identifier} is a sequence of letters, numbers, or
|
|
|
|
An @deftech{identifier} is a sequence of letters, numbers, or
|
|
|
|
characters in the set @racket["-.!$%&/<=>?^_~@"]. It must not contain
|
|
|
|
characters in the set @racket["-.!$%&/<=>^_~@"]. It must not contain
|
|
|
|
@litchar{*}, @litchar{+}, or @litchar|{{}| and @litchar|{}}|, as those characters are used to denote quantification.
|
|
|
|
@litchar{*}, @litchar{+}, @litchar{?}, or @litchar|{{}| and @litchar|{}}|, as those characters are used to denote quantification.
|
|
|
|
|
|
|
|
|
|
|
|
A @deftech{pattern} is one of the following:
|
|
|
|
A @deftech{pattern} is one of the following:
|
|
|
|
@itemize[
|
|
|
|
@itemize[
|
|
|
@ -922,7 +922,7 @@ A program written in @litchar{#lang brag} produces a module that provides a few
|
|
|
|
bindings. The most important of these is @racket[parse]:
|
|
|
|
bindings. The most important of these is @racket[parse]:
|
|
|
|
|
|
|
|
|
|
|
|
@defproc[(parse [source-path any/c #f]
|
|
|
|
@defproc[(parse [source-path any/c #f]
|
|
|
|
[token-source (or/c (sequence/c token)
|
|
|
|
[token-source (or/c (sequenceof token)
|
|
|
|
(-> token))])
|
|
|
|
(-> token))])
|
|
|
|
syntax?]{
|
|
|
|
syntax?]{
|
|
|
|
|
|
|
|
|
|
|
|