mbutterick / brag

Racket DSL for generating parsers from BNF grammars [moved to https://git.matthewbutterick.com/mbutterick/brag]
https://git.matthewbutterick.com/mbutterick/brag
MIT License
61 stars 12 forks source link

Minor code correction in the Quick Start docs #21

Closed thelonious closed 5 years ago

thelonious commented 5 years ago

I tried using the following code from the Quick Start section in the docs:

(define (tokenize s)
  (for/list ([str (regexp-match* #px"\\(\|\\)\|\\w+" s)])
    (match str
      ["("
       (token 'LEFT-PAREN str)]
      [")"
       (token 'RIGHT-PAREN str)]
      [else
       (token 'WORD str)])))

Racket complained about the use of else in the last clause. I was able to change that to _ and then it worked fine.

mbutterick commented 5 years ago

Strange. What version of Racket? else is a little misleading in the context of match, but it should work the same way as _.

thelonious commented 5 years ago

Hmm, seems to be fine now. It must have been a copy/paste error on my part. My apologies.