From b55d290fe96376535a5cefb4af447ecb755a1c4f Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 5 May 2016 17:01:56 -0700 Subject: [PATCH] rename `br/ragg` as `brag` --- .travis.yml | 4 +- README.md | 3 + beautiful-racket-ragg/br/ragg.rkt | 5 - .../simple-line-drawing/examples/letter-i.rkt | 4 - beautiful-racket-ragg/br/ragg/info.rkt | 10 - beautiful-racket/br/demo/basic/parser.rkt | 2 +- beautiful-racket/br/demo/basic/tokenizer.rkt | 2 +- beautiful-racket/br/demo/bf/bf-parser.rkt | 2 +- beautiful-racket/br/demo/bf/bf-reader.rkt | 2 +- .../br/demo/bf/test-tokenizer.rkt | 2 +- beautiful-racket/br/demo/hdl-tst/parser.rkt | 2 +- .../br/demo/hdl-tst/tokenizer.rkt | 2 +- beautiful-racket/br/demo/hdl/parser.rkt | 2 +- beautiful-racket/br/demo/hdl/tokenizer.rkt | 2 +- beautiful-racket/br/demo/txtadv/parser.rkt | 2 +- beautiful-racket/br/demo/txtadv/tokenizer.rkt | 2 +- beautiful-racket/info.rkt | 2 +- {beautiful-racket-ragg => brag}/LICENSE | 0 {beautiful-racket-ragg => brag}/README.md | 0 .../br/ragg => brag/brag}/Makefile | 0 .../br-ragg.scrbl => brag/brag/brag.scrbl | 214 +++++------------- .../brag}/cfg-parser/cfg-parser.rkt | 0 .../br/ragg => brag/brag}/codegen/codegen.rkt | 10 +- .../br/ragg => brag/brag}/codegen/flatten.rkt | 2 +- .../br/ragg => brag/brag}/codegen/reader.rkt | 10 +- .../br/ragg => brag/brag}/codegen/runtime.rkt | 4 +- .../brag}/codegen/satisfaction.rkt | 0 .../brag}/codegen/sexp-based-lang.rkt | 4 +- .../brag}/elider/json-elider-toy.rkt | 2 +- .../ragg => brag/brag}/elider/json-elider.rkt | 2 +- .../brag}/elider/test-json-elider.rkt | 2 +- .../ragg => brag/brag}/examples/01-equal.rkt | 2 +- .../br/ragg => brag/brag}/examples/0n1.rkt | 2 +- .../br/ragg => brag/brag}/examples/0n1n.rkt | 2 +- .../ragg => brag/brag}/examples/baby-json.rkt | 2 +- .../br/ragg => brag/brag}/examples/bnf.rkt | 0 .../brag}/examples/lua-parser.rkt | 2 +- .../brag}/examples/nested-word-list.rkt | 2 +- .../brag}/examples/python-grammar.rkt | 2 +- .../examples/simple-arithmetic-grammar.rkt | 2 +- .../brag}/examples/simple-line-drawing.rkt | 2 +- .../simple-line-drawing/examples/letter-i.rkt | 4 + .../examples/simple-line-drawing/grammar.rkt | 2 +- .../simple-line-drawing/interpret.rkt | 0 .../simple-line-drawing/lang/reader.rkt | 6 +- .../examples/simple-line-drawing/lexer.rkt | 2 +- .../simple-line-drawing/semantics.rkt | 0 .../brag}/examples/statlist-grammar.rkt | 2 +- .../br/ragg => brag/brag}/examples/wordy.rkt | 2 +- brag/brag/info.rkt | 6 + brag/brag/main.rkt | 5 + .../brag}/private/internal-support.rkt | 2 +- .../br/ragg => brag/brag}/rules/lexer.rkt | 0 .../br/ragg => brag/brag}/rules/parser.rkt | 0 .../ragg => brag/brag}/rules/rule-structs.rkt | 0 .../br/ragg => brag/brag}/rules/runtime.rkt | 0 .../br/ragg => brag/brag}/rules/stx-types.rkt | 0 .../br/ragg => brag/brag}/rules/stx.rkt | 0 .../br/ragg => brag/brag}/support.rkt | 0 .../brag}/test/exercise-python-grammar.rkt | 4 +- .../ragg => brag/brag}/test/test-01-equal.rkt | 2 +- .../br/ragg => brag/brag}/test/test-0n1.rkt | 4 +- .../br/ragg => brag/brag}/test/test-0n1n.rkt | 4 +- .../br/ragg => brag/brag}/test/test-all.rkt | 2 +- .../brag}/test/test-baby-json.rkt | 4 +- .../ragg => brag/brag}/test/test-errors.rkt | 30 +-- .../ragg => brag/brag}/test/test-flatten.rkt | 4 +- .../br/ragg => brag/brag}/test/test-lexer.rkt | 2 +- .../brag}/test/test-old-token.rkt | 4 +- .../ragg => brag/brag}/test/test-parser.rkt | 6 +- .../test/test-simple-arithmetic-grammar.rkt | 4 +- .../brag}/test/test-simple-line-drawing.rkt | 4 +- .../brag}/test/test-weird-grammar.rkt | 0 .../br/ragg => brag/brag}/test/test-wordy.rkt | 4 +- .../ragg => brag/brag}/test/weird-grammar.rkt | 2 +- {beautiful-racket-ragg => brag}/info.rkt | 0 76 files changed, 166 insertions(+), 263 deletions(-) delete mode 100755 beautiful-racket-ragg/br/ragg.rkt delete mode 100755 beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/examples/letter-i.rkt delete mode 100755 beautiful-racket-ragg/br/ragg/info.rkt rename {beautiful-racket-ragg => brag}/LICENSE (100%) rename {beautiful-racket-ragg => brag}/README.md (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/Makefile (100%) rename beautiful-racket-ragg/br/ragg/br-ragg.scrbl => brag/brag/brag.scrbl (81%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/cfg-parser/cfg-parser.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/codegen/codegen.rkt (98%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/codegen/flatten.rkt (99%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/codegen/reader.rkt (94%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/codegen/runtime.rkt (99%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/codegen/satisfaction.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/codegen/sexp-based-lang.rkt (95%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/elider/json-elider-toy.rkt (81%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/elider/json-elider.rkt (94%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/elider/test-json-elider.rkt (95%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/01-equal.rkt (92%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/0n1.rkt (53%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/0n1n.rkt (69%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/baby-json.rkt (93%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/bnf.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/lua-parser.rkt (98%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/nested-word-list.rkt (85%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/python-grammar.rkt (99%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/simple-arithmetic-grammar.rkt (82%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/simple-line-drawing.rkt (93%) create mode 100755 brag/brag/examples/simple-line-drawing/examples/letter-i.rkt rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/simple-line-drawing/grammar.rkt (93%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/simple-line-drawing/interpret.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/simple-line-drawing/lang/reader.rkt (74%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/simple-line-drawing/lexer.rkt (95%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/simple-line-drawing/semantics.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/statlist-grammar.rkt (94%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/examples/wordy.rkt (93%) create mode 100755 brag/brag/info.rkt create mode 100755 brag/brag/main.rkt rename {beautiful-racket-ragg/br/ragg => brag/brag}/private/internal-support.rkt (98%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/rules/lexer.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/rules/parser.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/rules/rule-structs.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/rules/runtime.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/rules/stx-types.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/rules/stx.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/support.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/exercise-python-grammar.rkt (98%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-01-equal.rkt (96%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-0n1.rkt (96%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-0n1n.rkt (96%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-all.rkt (89%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-baby-json.rkt (91%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-errors.rkt (84%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-flatten.rkt (99%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-lexer.rkt (97%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-old-token.rkt (97%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-parser.rkt (98%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-simple-arithmetic-grammar.rkt (96%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-simple-line-drawing.rkt (97%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-weird-grammar.rkt (100%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/test-wordy.rkt (86%) rename {beautiful-racket-ragg/br/ragg => brag/brag}/test/weird-grammar.rkt (88%) rename {beautiful-racket-ragg => brag}/info.rkt (100%) diff --git a/.travis.yml b/.travis.yml index ebd025e..bd7fd1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ script: # don't rely on package server - travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket-lib - raco test -p beautiful-racket-lib - - travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket-ragg - - raco test -p beautiful-racket-ragg + - travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=brag + - raco test -p brag - travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket - raco test -p beautiful-racket diff --git a/README.md b/README.md index 610e14e..89fb7b3 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,15 @@ beautiful-racket [![Build Status](https://travis-ci.org/mbutterick/beautiful-rac Resources for the upcoming “Beautiful Racket” book, including: * `#lang br` teaching language + +* `#lang brag` parser generator language (a fork of Danny Yoo's [ragg](http://github.com/jbclements/ragg)) * supporting modules * sample languages + Installation: `raco pkg install beautiful-racket` diff --git a/beautiful-racket-ragg/br/ragg.rkt b/beautiful-racket-ragg/br/ragg.rkt deleted file mode 100755 index 35db95a..0000000 --- a/beautiful-racket-ragg/br/ragg.rkt +++ /dev/null @@ -1,5 +0,0 @@ -#lang racket/base - -(module+ reader - (require "ragg/codegen/reader.rkt") - (provide (all-from-out "ragg/codegen/reader.rkt"))) diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/examples/letter-i.rkt b/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/examples/letter-i.rkt deleted file mode 100755 index 7626fc8..0000000 --- a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/examples/letter-i.rkt +++ /dev/null @@ -1,4 +0,0 @@ -#lang br/ragg/examples/simple-line-drawing -3 9 X; -6 3 b 3 X 3 b; -3 9 X; diff --git a/beautiful-racket-ragg/br/ragg/info.rkt b/beautiful-racket-ragg/br/ragg/info.rkt deleted file mode 100755 index 8b0f69a..0000000 --- a/beautiful-racket-ragg/br/ragg/info.rkt +++ /dev/null @@ -1,10 +0,0 @@ -#lang setup/infotab -(define name "ragg") -(define categories '(devtools)) -(define can-be-loaded-with 'all) -(define version "1.0") -(define repositories '("4.x")) -(define scribblings '(("br-ragg.scrbl"))) -(define blurb '("ragg: a Racket AST Generator Generator. A design goal is to be easy for beginners to use. Given a grammar in EBNF, ragg produces a parser that generates Racket's native syntax objects with full source location.")) -(define release-notes '((p "First release."))) -(define deps (list)) diff --git a/beautiful-racket/br/demo/basic/parser.rkt b/beautiful-racket/br/demo/basic/parser.rkt index a4d0949..6830493 100644 --- a/beautiful-racket/br/demo/basic/parser.rkt +++ b/beautiful-racket/br/demo/basic/parser.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; recursive rules destucture easily in the expander program : [CR]* [line [CR line]*] [CR]* diff --git a/beautiful-racket/br/demo/basic/tokenizer.rkt b/beautiful-racket/br/demo/basic/tokenizer.rkt index dd9531b..b758743 100644 --- a/beautiful-racket/br/demo/basic/tokenizer.rkt +++ b/beautiful-racket/br/demo/basic/tokenizer.rkt @@ -1,6 +1,6 @@ #lang br (require parser-tools/lex parser-tools/lex-sre - br/ragg/support + brag/support racket/string) (provide tokenize) diff --git a/beautiful-racket/br/demo/bf/bf-parser.rkt b/beautiful-racket/br/demo/bf/bf-parser.rkt index ae0b593..ebfb9ba 100644 --- a/beautiful-racket/br/demo/bf/bf-parser.rkt +++ b/beautiful-racket/br/demo/bf/bf-parser.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag bf-program : (op | loop)* op : ">" | "<" | "+" | "-" | "." | "," loop : "[" (op | loop)* "]" \ No newline at end of file diff --git a/beautiful-racket/br/demo/bf/bf-reader.rkt b/beautiful-racket/br/demo/bf/bf-reader.rkt index 7d41d24..94ad072 100644 --- a/beautiful-racket/br/demo/bf/bf-reader.rkt +++ b/beautiful-racket/br/demo/bf/bf-reader.rkt @@ -1,5 +1,5 @@ #lang br -(require parser-tools/lex br/ragg/support) +(require parser-tools/lex brag/support) (define (tokenize input-port) (define (next-token) (define get-token diff --git a/beautiful-racket/br/demo/bf/test-tokenizer.rkt b/beautiful-racket/br/demo/bf/test-tokenizer.rkt index 4676bbf..e7c3adf 100644 --- a/beautiful-racket/br/demo/bf/test-tokenizer.rkt +++ b/beautiful-racket/br/demo/bf/test-tokenizer.rkt @@ -1,5 +1,5 @@ #lang br -(require parser-tools/lex br/ragg/support) +(require parser-tools/lex brag/support) (define+provide (tokenize ip) (define get-token diff --git a/beautiful-racket/br/demo/hdl-tst/parser.rkt b/beautiful-racket/br/demo/hdl-tst/parser.rkt index a451596..33e203f 100644 --- a/beautiful-racket/br/demo/hdl-tst/parser.rkt +++ b/beautiful-racket/br/demo/hdl-tst/parser.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag tst-program : header-expr test-expr* diff --git a/beautiful-racket/br/demo/hdl-tst/tokenizer.rkt b/beautiful-racket/br/demo/hdl-tst/tokenizer.rkt index 6bd2c1c..79a47c4 100644 --- a/beautiful-racket/br/demo/hdl-tst/tokenizer.rkt +++ b/beautiful-racket/br/demo/hdl-tst/tokenizer.rkt @@ -1,6 +1,6 @@ #lang br (require parser-tools/lex parser-tools/lex-sre - br/ragg/support + brag/support racket/string) (provide tokenize) diff --git a/beautiful-racket/br/demo/hdl/parser.rkt b/beautiful-racket/br/demo/hdl/parser.rkt index b059104..242ac90 100644 --- a/beautiful-racket/br/demo/hdl/parser.rkt +++ b/beautiful-racket/br/demo/hdl/parser.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; rule of thumb: use [optional] bits judiciously as they multiply the cases needed for a production rule ;; rule of thumb: for a set of related IDs, put each into the same grammar entity diff --git a/beautiful-racket/br/demo/hdl/tokenizer.rkt b/beautiful-racket/br/demo/hdl/tokenizer.rkt index bae1da2..1a1bc31 100644 --- a/beautiful-racket/br/demo/hdl/tokenizer.rkt +++ b/beautiful-racket/br/demo/hdl/tokenizer.rkt @@ -1,6 +1,6 @@ #lang br (require parser-tools/lex parser-tools/lex-sre - br/ragg/support + brag/support racket/string) (provide tokenize) diff --git a/beautiful-racket/br/demo/txtadv/parser.rkt b/beautiful-racket/br/demo/txtadv/parser.rkt index 9db0a93..afa8e0f 100644 --- a/beautiful-racket/br/demo/txtadv/parser.rkt +++ b/beautiful-racket/br/demo/txtadv/parser.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag txtadv-program : verb-section everywhere-section things-section places-section start-section diff --git a/beautiful-racket/br/demo/txtadv/tokenizer.rkt b/beautiful-racket/br/demo/txtadv/tokenizer.rkt index 016d1bf..d004f25 100644 --- a/beautiful-racket/br/demo/txtadv/tokenizer.rkt +++ b/beautiful-racket/br/demo/txtadv/tokenizer.rkt @@ -1,6 +1,6 @@ #lang br (require parser-tools/lex parser-tools/lex-sre - br/ragg/support + brag/support racket/string) (provide tokenize) diff --git a/beautiful-racket/info.rkt b/beautiful-racket/info.rkt index 42bfea9..b9e3dad 100644 --- a/beautiful-racket/info.rkt +++ b/beautiful-racket/info.rkt @@ -2,5 +2,5 @@ (define collection 'multi) (define version "0.01") -(define deps '("base" "sugar" "beautiful-racket-lib" "rackunit-lib" "beautiful-racket-ragg" "parser-tools-lib")) +(define deps '("base" "sugar" "beautiful-racket-lib" "rackunit-lib" "brag" "parser-tools-lib")) (define build-deps '("racket-doc")) diff --git a/beautiful-racket-ragg/LICENSE b/brag/LICENSE similarity index 100% rename from beautiful-racket-ragg/LICENSE rename to brag/LICENSE diff --git a/beautiful-racket-ragg/README.md b/brag/README.md similarity index 100% rename from beautiful-racket-ragg/README.md rename to brag/README.md diff --git a/beautiful-racket-ragg/br/ragg/Makefile b/brag/brag/Makefile similarity index 100% rename from beautiful-racket-ragg/br/ragg/Makefile rename to brag/brag/Makefile diff --git a/beautiful-racket-ragg/br/ragg/br-ragg.scrbl b/brag/brag/brag.scrbl similarity index 81% rename from beautiful-racket-ragg/br/ragg/br-ragg.scrbl rename to brag/brag/brag.scrbl index 9b90b9b..27613e9 100755 --- a/beautiful-racket-ragg/br/ragg/br-ragg.scrbl +++ b/brag/brag/brag.scrbl @@ -3,8 +3,8 @@ racket/date file/md5 (for-label racket - br/ragg/support - br/ragg/examples/nested-word-list + brag/support + brag/examples/nested-word-list (only-in parser-tools/lex lexer-src-pos) (only-in syntax/parse syntax-parse ~literal))) @@ -26,14 +26,15 @@ -@title{ragg: a Racket AST Generator Generator} -@author+email["Danny Yoo" "dyoo@hashcollision.org"] +@title{brag: the Beautiful Racket AST Generator} +@author["Danny Yoo" "Matthew Butterick"] +@defmodulelang[brag] @section{Informal quickstart} @(define my-eval (make-base-eval)) -@(my-eval '(require br/ragg/examples/nested-word-list +@(my-eval '(require brag/examples/nested-word-list racket/list racket/match)) @@ -66,11 +67,9 @@ or more repetitions of the previous thing, and we treat the uppercased @racket[LEFT-PAREN], @racket[RIGHT-PAREN], and @racket[WORD] as placeholders for atomic @emph{tokens}. -@margin-note{See @secref{install-ragg} for instructions on installing -@tt{ragg.}} Here are a few examples of tokens: @interaction[#:eval my-eval -(require br/ragg/support) +(require brag/support) (token 'LEFT-PAREN) (token 'WORD "crunchy" #:span 7) (token 'RIGHT-PAREN)] @@ -82,12 +81,12 @@ use it to make structures out of a sequence of tokens. It's clear that we don't yet have a program because there's no @litchar{#lang} -line. We should add one. Put @litchar{#lang br/ragg} at the top of the BNF +line. We should add one. Put @litchar{#lang brag} at the top of the BNF description, and save it as a file called @filepath{nested-word-list.rkt}. @filebox["nested-word-list.rkt"]{ @verbatim{ -#lang br/ragg +#lang brag nested-word-list: WORD | LEFT-PAREN nested-word-list* RIGHT-PAREN }} @@ -135,12 +134,11 @@ What happens if we pass it a more substantial source of tokens? (token 'WORD str)]))) @code:comment{For example:} -(define token-source (tokenize "(welcome (to (((ragg)) ())))")) (define v (parse token-source)) (syntax->datum v) ] -Welcome to @tt{ragg}. +Welcome to @tt{brag}. @@ -153,12 +151,12 @@ Welcome to @tt{ragg}. @section{Introduction} -@tt{ragg} is a parsing framework for Racket with the design goal to be easy +@tt{brag} is a parsing framework for Racket with the design goal to be easy to use. It includes the following features: @itemize[ @item{It provides a @litchar{#lang} for writing extended BNF grammars. -A module written in @litchar{#lang br/ragg} automatically generates a +A module written in @litchar{#lang brag} automatically generates a parser. The output of this parser tries to follow @link["http://en.wikipedia.org/wiki/How_to_Design_Programs"]{HTDP} doctrine; the structure of the grammar informs the structure of the @@ -170,7 +168,7 @@ starting production. Identifiers in uppercase are assumed to represent terminal tokens, and are otherwise the names of nonterminals.} @item{Tokenizers can be developed completely independently of parsers. -@tt{ragg} takes a liberal view on tokens: they can be strings, +@tt{brag} takes a liberal view on tokens: they can be strings, symbols, or instances constructed with @racket[token]. Furthermore, tokens can optionally provide location: if tokens provide location, the generated syntax objects will as well.} @@ -182,38 +180,13 @@ generated syntax objects will as well.} ] -@subsection[#:tag "install-ragg"]{Installation} - -@itemize[ - -@item{@margin-note{At the time of this writing, Racket 5.3.2 is in -@link["http://pre.racket-lang.org/"]{pre-release}.} If you are using a version -of Racket > 5.3.1, then follow the instructions on the -@link["https://plt-etc.byu.edu:9004/info/ragg"]{PLaneT2 page}.} - - - -@item{For those who are using Racket <= 5.3.1, you can download the following PLT package: - -@nested[#:style 'inset]{@link["ragg.plt"]{ragg.plt} [md5sum: @compute-md5sum["ragg.plt" "ab79038b40e510a5cf13363825c4aef4"]] - - Last updated: @lookup-date["ragg.plt" "Wednesday, January 16th, 2013"] - } - -Once downloaded, either use DrRacket's package installation features -(@link["http://docs.racket-lang.org/drracket/Menus.html#(idx._(gentag._57._(lib._scribblings/drracket/drracket..scrbl)))"]{Install -PLT File...} under DrRacket's File menu), or use the command line: -@nested[#:style 'inset]{@tt{raco setup -A ragg.plt}}} - -] - @subsection{Example: a small DSL for ASCII diagrams} @margin-note{This is a @link["http://stackoverflow.com/questions/12345647/rewrite-this-script-by-designing-an-interpreter-in-racket"]{restatement -of a question on Stack Overflow}.} To motivate @tt{ragg}'s design, let's look +of a question on Stack Overflow}.} To motivate @tt{brag}'s design, let's look at the following toy problem: we'd like to define a language for drawing simple ASCII diagrams. We'd like to be able write something like this: @@ -276,7 +249,7 @@ programs. @subsection{Parsing the concrete syntax} @filebox["simple-line-drawing.rkt"]{ @verbatim|{ -#lang br/ragg +#lang brag drawing: rows* rows: repeat chunk+ ";" repeat: INTEGER @@ -284,21 +257,21 @@ chunk: INTEGER STRING }| } -@margin-note{@secref{ragg-syntax} describes @tt{ragg}'s syntax in more detail.} -We write a @tt{ragg} program as an extended BNF grammar, where patterns can be: +@margin-note{@secref{brag-syntax} describes @tt{brag}'s syntax in more detail.} +We write a @tt{brag} program as an extended BNF grammar, where patterns can be: @itemize[ @item{the names of other rules (e.g. @racket[chunk])} @item{literal and symbolic token names (e.g. @racket[";"], @racket[INTEGER])} @item{quantified patterns (e.g. @litchar{+} to represent one-or-more repetitions)} ] -The result of a @tt{ragg} program is a module with a @racket[parse] function +The result of a @tt{brag} program is a module with a @racket[parse] function that can parse tokens and produce a syntax object as a result. Let's exercise this function: @interaction[#:eval my-eval -(require br/ragg/support) +(require brag/support) @eval:alts[(require "simple-line-drawing.rkt") - (require br/ragg/examples/simple-line-drawing)] + (require brag/examples/simple-line-drawing)] (define stx (parse (list (token 'INTEGER 6) (token 'INTEGER 2) @@ -553,7 +526,7 @@ Let's add one. @filebox["letter-i.rkt"]{ @verbatim|{ -#lang br/ragg/examples/simple-line-drawing +#lang brag/examples/simple-line-drawing 3 9 X; 6 3 b 3 X 3 b; 3 9 X; @@ -569,9 +542,9 @@ how to compile programs labeled with this @litchar{#lang} line. We'll do two things: @itemize[ -@item{Tell Racket to use the @tt{ragg}-generated parser and lexer we defined +@item{Tell Racket to use the @tt{brag}-generated parser and lexer we defined earlier whenever it sees a program written with -@litchar{#lang br/ragg/examples/simple-line-drawing}.} +@litchar{#lang brag/examples/simple-line-drawing}.} @item{Define transformation rules for @racket[drawing], @racket[rows], and @racket[chunk] to rewrite these into standard Racket forms.} @@ -591,18 +564,18 @@ reader} tells Racket how to parse and compile a file. Whenever Racket sees a @filepath{/lang/reader}. Here's the definition for -@filepath{br/ragg/examples/simple-line-drawing/lang/reader.rkt}: +@filepath{brag/examples/simple-line-drawing/lang/reader.rkt}: -@filebox["br/ragg/examples/simple-line-drawing/lang/reader.rkt"]{ +@filebox["brag/examples/simple-line-drawing/lang/reader.rkt"]{ @codeblock|{ #lang s-exp syntax/module-reader -br/ragg/examples/simple-line-drawing/semantics +brag/examples/simple-line-drawing/semantics #:read my-read #:read-syntax my-read-syntax #:whole-body-readers? #t -(require br/ragg/examples/simple-line-drawing/lexer - br/ragg/examples/simple-line-drawing/grammar) +(require brag/examples/simple-line-drawing/lexer + brag/examples/simple-line-drawing/grammar) (define (my-read in) (syntax->datum (my-read-syntax #f in))) @@ -614,11 +587,7 @@ br/ragg/examples/simple-line-drawing/semantics We use a helper module @racketmodname[syntax/module-reader], which provides utilities for creating a module reader. It uses the lexer and -@tt{ragg}-generated parser we defined earlier (saved into -@link["http://hashcollision.org/ragg/examples/simple-line-drawing/lexer.rkt"]{lexer.rkt} -and -@link["http://hashcollision.org/ragg/examples/simple-line-drawing/grammar.rkt"]{grammar.rkt} -modules), and also tells Racket that it should compile the forms in the syntax +@tt{brag}-generated parser we defined earlier, and also tells Racket that it should compile the forms in the syntax object using a module called @filepath{semantics.rkt}. @margin-note{For a systematic treatment on capturing the semantics of @@ -627,7 +596,7 @@ Interpretation}.} Let's look into @filepath{semantics.rkt} and see what's involved in compilation: -@filebox["br/ragg/examples/simple-line-drawing/semantics.rkt"]{ +@filebox["brag/examples/simple-line-drawing/semantics.rkt"]{ @codeblock|{ #lang racket/base (require (for-syntax racket/base syntax/parse)) @@ -692,7 +661,7 @@ There are a few things to note: @itemize[ -@item{@tt{ragg}'s native data structure is the syntax object because the +@item{@tt{brag}'s native data structure is the syntax object because the majority of Racket's language-processing infrastructure knows how to read and write this structured value.} @@ -718,12 +687,12 @@ the macro expansion system to do this: ] -Altogether, @tt{ragg}'s intent is to be a parser generator generator for Racket +Altogether, @tt{brag}'s intent is to be a parser generator generator for Racket that's easy and fun to use. It's meant to fit naturally with the other tools in the Racket language toolchain. Hopefully, it will reduce the friction in making new languages with alternative concrete syntaxes. -The rest of this document describes the @tt{ragg} language and the parsers it +The rest of this document describes the @tt{brag} language and the parsers it generates. @@ -732,9 +701,9 @@ generates. @section{The language} -@subsection[#:tag "ragg-syntax"]{Syntax and terminology} -A program in the @tt{ragg} language consists of the language line -@litchar{#lang br/ragg}, followed by a collection of @tech{rule}s and +@subsection[#:tag "brag-syntax"]{Syntax and terminology} +A program in the @tt{brag} language consists of the language line +@litchar{#lang brag}, followed by a collection of @tech{rule}s and @tech{line comment}s. A @deftech{rule} is a sequence consisting of: a @tech{rule identifier}, a colon @@ -767,7 +736,7 @@ continues till the end of the line. For example, in the following program: @nested[#:style 'inset @verbatim|{ -#lang br/ragg +#lang brag ;; A parser for a silly language sentence: verb optional-adjective object verb: greeting @@ -787,20 +756,20 @@ More examples: @itemize[ @item{A -@link["http://hashcollision.org/ragg/examples/01-equal.rkt"]{BNF} for binary +BNF for binary strings that contain an equal number of zeros and ones. @verbatim|{ -#lang br/ragg +#lang brag equal: [zero one | one zero] ;; equal number of "0"s and "1"s. zero: "0" equal | equal "0" ;; has an extra "0" in it. one: "1" equal | equal "1" ;; has an extra "1" in it. }| } -@item{A @link["http://hashcollision.org/ragg/examples/baby-json.rkt"]{BNF} for +@item{A BNF for @link["http://www.json.org/"]{JSON}-like structures. @verbatim|{ -#lang br/ragg +#lang brag json: number | string | array | object number: NUMBER @@ -812,20 +781,16 @@ kvpair: ID ":" json } ] -The @link["https://github.com/dyoo/ragg"]{ragg github source repository} -includes -@link["https://github.com/dyoo/ragg/tree/master/ragg/examples"]{several more -examples}. @subsection{Syntax errors} Besides the basic syntax errors that can occur with a malformed grammar, there -are a few other classes of situations that @litchar{#lang br/ragg} will consider +are a few other classes of situations that @litchar{#lang brag} will consider as syntax errors. -@tt{ragg} will raise a syntax error if the grammar: +@tt{brag} will raise a syntax error if the grammar: @itemize[ @item{doesn't have any rules.} @@ -835,7 +800,7 @@ as syntax errors. following program: @nested[#:style 'code-inset @verbatim|{ -#lang br/ragg +#lang brag foo: [bar] }| ] @@ -844,14 +809,14 @@ should raise an error because @tt{bar} has not been defined, even though @item{uses the token name @racket[EOF]; the end-of-file token type is reserved -for internal use by @tt{ragg}.} +for internal use by @tt{brag}.} @item{contains a rule that has no finite derivation. e.g. the following program: @nested[#:style 'code-inset @verbatim|{ -#lang br/ragg +#lang brag infinite-a: "a" infinite-a }| ] @@ -860,13 +825,13 @@ should raise an error because no finite sequence of tokens will satisfy ] -Otherwise, @tt{ragg} should be fairly tolerant and permit even ambiguous +Otherwise, @tt{brag} should be fairly tolerant and permit even ambiguous grammars. @subsection{Semantics} -@declare-exporting[br/ragg/examples/nested-word-list] +@declare-exporting[brag/examples/nested-word-list] -A program written in @litchar{#lang br/ragg} produces a module that provides a few +A program written in @litchar{#lang brag} produces a module that provides a few bindings. The most important of these is @racket[parse]: @defproc[(parse [source any/c #f] @@ -881,7 +846,7 @@ first rule as the start production. The parse must completely consume The @deftech{token source} can either be a sequence, or a 0-arity function that produces @tech{tokens}. -A @deftech{token} in @tt{ragg} can be any of the following values: +A @deftech{token} in @tt{brag} can be any of the following values: @itemize[ @item{a string} @item{a symbol} @@ -916,7 +881,7 @@ pattern that informs the parser to introduces nested structure into the syntax object. -If the grammar has ambiguity, @tt{ragg} will choose and return a parse, though +If the grammar has ambiguity, @tt{brag} will choose and return a parse, though it does not guarantee which one it chooses. @@ -927,7 +892,7 @@ If the parse cannot be performed successfully, or if a token in the It's often convenient to extract a parser for other non-terminal rules in the -grammar, and not just for the first rule. A @tt{ragg}-generated module also +grammar, and not just for the first rule. A @tt{brag}-generated module also provides a form called @racket[make-rule-parser] to extract a parser for the other non-terminals: @@ -936,11 +901,11 @@ other non-terminals: Constructs a parser for the @racket[name] of one of the non-terminals in the grammar. -For example, given the @tt{ragg} program +For example, given the @tt{brag} program @filepath{simple-arithmetic-grammar.rkt}: @filebox["simple-arithmetic-grammar.rkt"]{ @verbatim|{ -#lang br/ragg +#lang brag expr : term ('+' term)* term : factor ('*' factor)* factor : INT @@ -949,7 +914,7 @@ factor : INT the following interaction shows how to extract a parser for @racket[term]s. @interaction[#:eval my-eval @eval:alts[(require "simple-arithmetic-grammar.rkt") - (require br/ragg/examples/simple-arithmetic-grammar)] + (require brag/examples/simple-arithmetic-grammar)] (define term-parse (make-rule-parser term)) (define tokens (list (token 'INT 3) "*" @@ -977,7 +942,7 @@ A set of all the token types used in a grammar. For example: @interaction[#:eval my-eval @eval:alts[(require "simple-arithmetic-grammar.rkt") - (require br/ragg/examples/simple-arithmetic-grammar)] + (require brag/examples/simple-arithmetic-grammar)] all-token-types ] @@ -989,10 +954,10 @@ all-token-types @section{Support API} -@defmodule[br/ragg/support] +@defmodule[brag/support] -The @racketmodname[br/ragg/support] module provides functions to interact with -@tt{ragg} programs. The most useful is the @racket[token] function, which +The @racketmodname[brag/support] module provides functions to interact with +@tt{brag} programs. The most useful is the @racket[token] function, which produces tokens to be parsed. @defproc[(token [type (or/c string? symbol?)] @@ -1043,65 +1008,4 @@ DrRacket should highlight the offending locations in the source.} - - -@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -@section{Caveats and things to do} - -Here are a few caveats and future aims for @tt{ragg}. - -@itemize[ - -@item{@tt{ragg} doesn't currently have a good story about operator precedence. -Future versions of @tt{ragg} will support the specification of operator -precedence to deal with grammar ambiguity, probably by extending the BNF -grammar rules in @litchar{#lang br/ragg} with keyword arguments.} - - -@item{I currently depend on the lexer framework provided by -@racketmodname[parser-tools/lex], which has a steeper learning curve than I'd -like. A future version of @tt{ragg} will probably try to provide a nicer set -of tools for defining lexers.} - - -@item{The underlying parsing engine (an Earley-style parser) has not been fully -optimized, so it may exhibit degenerate parse times. A future version of -@tt{ragg} will guarantee @math{O(n^3)} time bounds so that at the very least, -parses will be polynomial-time.} - - -@item{@tt{ragg} doesn't yet have a good story on dealing with parser error -recovery. If a parse fails, it tries to provide the source location, but does -little else.} - -@item{@tt{ragg} is slightly misnamed: what it really builds is a concrete -syntax tree rather than an abstract syntax tree. A future version of @tt{ragg} -will probably support annotations on patterns so that they can be omitted or -transformed in the parser output.} - -] - - -@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -@section{Miscellaneous and thanks} - -Thanks to Matthew Flatt for pointing me to @racket[cfg-parser] from the -@racket[cfg-parser] library. Joe Politz gave me good advice and -feedback. Also, he suggested the name ``ragg''. Other alternatives I'd been -considering were ``autogrammar'' or ``chompy''. Thankfully, he is a better -Namer than me. Daniel Patterson provided feedback that led to -@racket[make-rule-parser]. Robby Findler and Guillaume Marceau provided -steadfast suggestions to look into other parsing frameworks like -@link["http://en.wikipedia.org/wiki/Syntax_Definition_Formalism"]{SDF} and -@link["http://sablecc.org/"]{SableCC}. Special thanks to Shriram -Krishnamurthi, who convinced me that other people might find this package -useful. - - @close-eval[my-eval] diff --git a/beautiful-racket-ragg/br/ragg/cfg-parser/cfg-parser.rkt b/brag/brag/cfg-parser/cfg-parser.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/cfg-parser/cfg-parser.rkt rename to brag/brag/cfg-parser/cfg-parser.rkt diff --git a/beautiful-racket-ragg/br/ragg/codegen/codegen.rkt b/brag/brag/codegen/codegen.rkt similarity index 98% rename from beautiful-racket-ragg/br/ragg/codegen/codegen.rkt rename to brag/brag/codegen/codegen.rkt index 11357b1..2b91fd3 100755 --- a/beautiful-racket-ragg/br/ragg/codegen/codegen.rkt +++ b/brag/brag/codegen/codegen.rkt @@ -5,11 +5,11 @@ racket/set racket/syntax syntax/srcloc - br/ragg/rules/stx-types + brag/rules/stx-types "flatten.rkt" syntax/id-table (prefix-in sat: "satisfaction.rkt") - (prefix-in support: br/ragg/support) + (prefix-in support: brag/support) (prefix-in stxparse: syntax/parse)) (provide rules-codegen) @@ -104,9 +104,9 @@ (begin (require parser-tools/lex parser-module - br/ragg/codegen/runtime - br/ragg/support - br/ragg/private/internal-support + brag/codegen/runtime + brag/support + brag/private/internal-support racket/set (for-syntax syntax/parse racket/base)) diff --git a/beautiful-racket-ragg/br/ragg/codegen/flatten.rkt b/brag/brag/codegen/flatten.rkt similarity index 99% rename from beautiful-racket-ragg/br/ragg/codegen/flatten.rkt rename to brag/brag/codegen/flatten.rkt index 780fbfd..a6a9fb6 100755 --- a/beautiful-racket-ragg/br/ragg/codegen/flatten.rkt +++ b/brag/brag/codegen/flatten.rkt @@ -1,5 +1,5 @@ #lang br -(require br/ragg/rules/stx-types +(require brag/rules/stx-types (for-syntax racket/base)) (provide flatten-rule diff --git a/beautiful-racket-ragg/br/ragg/codegen/reader.rkt b/brag/brag/codegen/reader.rkt similarity index 94% rename from beautiful-racket-ragg/br/ragg/codegen/reader.rkt rename to brag/brag/codegen/reader.rkt index b741674..6413225 100755 --- a/beautiful-racket-ragg/br/ragg/codegen/reader.rkt +++ b/brag/brag/codegen/reader.rkt @@ -1,14 +1,14 @@ #lang s-exp syntax/module-reader -br/ragg/codegen/sexp-based-lang +brag/codegen/sexp-based-lang #:read my-read #:read-syntax my-read-syntax #:info my-get-info #:whole-body-readers? #t -(require br/ragg/rules/parser - br/ragg/rules/lexer - br/ragg/rules/stx - br/ragg/rules/rule-structs) +(require brag/rules/parser + brag/rules/lexer + brag/rules/stx + brag/rules/rule-structs) (define (my-read in) (syntax->datum (my-read-syntax #f in))) diff --git a/beautiful-racket-ragg/br/ragg/codegen/runtime.rkt b/brag/brag/codegen/runtime.rkt similarity index 99% rename from beautiful-racket-ragg/br/ragg/codegen/runtime.rkt rename to brag/brag/codegen/runtime.rkt index 5efc7e9..eb220da 100755 --- a/beautiful-racket-ragg/br/ragg/codegen/runtime.rkt +++ b/brag/brag/codegen/runtime.rkt @@ -4,8 +4,8 @@ racket/list racket/generator (prefix-in lex: parser-tools/lex) - br/ragg/support - br/ragg/private/internal-support) + brag/support + brag/private/internal-support) (provide THE-ERROR-HANDLER diff --git a/beautiful-racket-ragg/br/ragg/codegen/satisfaction.rkt b/brag/brag/codegen/satisfaction.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/codegen/satisfaction.rkt rename to brag/brag/codegen/satisfaction.rkt diff --git a/beautiful-racket-ragg/br/ragg/codegen/sexp-based-lang.rkt b/brag/brag/codegen/sexp-based-lang.rkt similarity index 95% rename from beautiful-racket-ragg/br/ragg/codegen/sexp-based-lang.rkt rename to brag/brag/codegen/sexp-based-lang.rkt index 3919bb7..b72ed94 100755 --- a/beautiful-racket-ragg/br/ragg/codegen/sexp-based-lang.rkt +++ b/brag/brag/codegen/sexp-based-lang.rkt @@ -11,7 +11,7 @@ ;; The intended use of this language is as follows: ;; ;;;;; s-exp-grammar.rkt ;;;;;;;;; -;; #lang br/ragg +;; #lang brag ;; s-exp : "(" s-exp* ")" | ATOM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -91,6 +91,6 @@ #%top-interaction) (define-syntax (rules stx) - (rules-codegen #:parser-provider-module 'br/ragg/cfg-parser/cfg-parser ;; 'parser-tools/yacc + (rules-codegen #:parser-provider-module 'brag/cfg-parser/cfg-parser ;; 'parser-tools/yacc #:parser-provider-form 'cfg-parser ;; 'parser stx)) diff --git a/beautiful-racket-ragg/br/ragg/elider/json-elider-toy.rkt b/brag/brag/elider/json-elider-toy.rkt similarity index 81% rename from beautiful-racket-ragg/br/ragg/elider/json-elider-toy.rkt rename to brag/brag/elider/json-elider-toy.rkt index fcb1040..3d55a38 100644 --- a/beautiful-racket-ragg/br/ragg/elider/json-elider-toy.rkt +++ b/brag/brag/elider/json-elider-toy.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; Simple baby example of JSON structure json: ID <":"> ID diff --git a/beautiful-racket-ragg/br/ragg/elider/json-elider.rkt b/brag/brag/elider/json-elider.rkt similarity index 94% rename from beautiful-racket-ragg/br/ragg/elider/json-elider.rkt rename to brag/brag/elider/json-elider.rkt index ce2c05e..224acd4 100755 --- a/beautiful-racket-ragg/br/ragg/elider/json-elider.rkt +++ b/brag/brag/elider/json-elider.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; Simple baby example of JSON structure json: number diff --git a/beautiful-racket-ragg/br/ragg/elider/test-json-elider.rkt b/brag/brag/elider/test-json-elider.rkt similarity index 95% rename from beautiful-racket-ragg/br/ragg/elider/test-json-elider.rkt rename to brag/brag/elider/test-json-elider.rkt index aeaad4f..bbb7e4d 100755 --- a/beautiful-racket-ragg/br/ragg/elider/test-json-elider.rkt +++ b/brag/brag/elider/test-json-elider.rkt @@ -1,6 +1,6 @@ #lang br (require "json-elider.rkt" - br/ragg/support + brag/support rackunit) (check-equal? diff --git a/beautiful-racket-ragg/br/ragg/examples/01-equal.rkt b/brag/brag/examples/01-equal.rkt similarity index 92% rename from beautiful-racket-ragg/br/ragg/examples/01-equal.rkt rename to brag/brag/examples/01-equal.rkt index b975fd1..c53bd18 100755 --- a/beautiful-racket-ragg/br/ragg/examples/01-equal.rkt +++ b/brag/brag/examples/01-equal.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ## Equal numbers of 0 and 1s in a string. ## diff --git a/beautiful-racket-ragg/br/ragg/examples/0n1.rkt b/brag/brag/examples/0n1.rkt similarity index 53% rename from beautiful-racket-ragg/br/ragg/examples/0n1.rkt rename to brag/brag/examples/0n1.rkt index c3173bd..53beae0 100755 --- a/beautiful-racket-ragg/br/ragg/examples/0n1.rkt +++ b/brag/brag/examples/0n1.rkt @@ -1,3 +1,3 @@ -#lang br/ragg +#lang brag rule: "0"* "1" diff --git a/beautiful-racket-ragg/br/ragg/examples/0n1n.rkt b/brag/brag/examples/0n1n.rkt similarity index 69% rename from beautiful-racket-ragg/br/ragg/examples/0n1n.rkt rename to brag/brag/examples/0n1n.rkt index 8ac8f0b..25b0ea5 100755 --- a/beautiful-racket-ragg/br/ragg/examples/0n1n.rkt +++ b/brag/brag/examples/0n1n.rkt @@ -1,3 +1,3 @@ -#lang br/ragg +#lang brag rule-0n1n: ["0" rule-0n1n "1"] diff --git a/beautiful-racket-ragg/br/ragg/examples/baby-json.rkt b/brag/brag/examples/baby-json.rkt similarity index 93% rename from beautiful-racket-ragg/br/ragg/examples/baby-json.rkt rename to brag/brag/examples/baby-json.rkt index b4f5f56..491dfc8 100755 --- a/beautiful-racket-ragg/br/ragg/examples/baby-json.rkt +++ b/brag/brag/examples/baby-json.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; Simple baby example of JSON structure json: number | string diff --git a/beautiful-racket-ragg/br/ragg/examples/bnf.rkt b/brag/brag/examples/bnf.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/examples/bnf.rkt rename to brag/brag/examples/bnf.rkt diff --git a/beautiful-racket-ragg/br/ragg/examples/lua-parser.rkt b/brag/brag/examples/lua-parser.rkt similarity index 98% rename from beautiful-racket-ragg/br/ragg/examples/lua-parser.rkt rename to brag/brag/examples/lua-parser.rkt index da3192f..75781e9 100755 --- a/beautiful-racket-ragg/br/ragg/examples/lua-parser.rkt +++ b/brag/brag/examples/lua-parser.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; Lua parser, adapted from: ;; http://www.lua.org/manual/5.1/manual.html#8 diff --git a/beautiful-racket-ragg/br/ragg/examples/nested-word-list.rkt b/brag/brag/examples/nested-word-list.rkt similarity index 85% rename from beautiful-racket-ragg/br/ragg/examples/nested-word-list.rkt rename to brag/brag/examples/nested-word-list.rkt index 6df6687..b7489c4 100755 --- a/beautiful-racket-ragg/br/ragg/examples/nested-word-list.rkt +++ b/brag/brag/examples/nested-word-list.rkt @@ -1,3 +1,3 @@ -#lang br/ragg +#lang brag nested-word-list: WORD | LEFT-PAREN nested-word-list* RIGHT-PAREN diff --git a/beautiful-racket-ragg/br/ragg/examples/python-grammar.rkt b/brag/brag/examples/python-grammar.rkt similarity index 99% rename from beautiful-racket-ragg/br/ragg/examples/python-grammar.rkt rename to brag/brag/examples/python-grammar.rkt index 21daae0..9244845 100755 --- a/beautiful-racket-ragg/br/ragg/examples/python-grammar.rkt +++ b/brag/brag/examples/python-grammar.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag # Grammar for Python diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-arithmetic-grammar.rkt b/brag/brag/examples/simple-arithmetic-grammar.rkt similarity index 82% rename from beautiful-racket-ragg/br/ragg/examples/simple-arithmetic-grammar.rkt rename to brag/brag/examples/simple-arithmetic-grammar.rkt index 08442eb..69a5f2c 100755 --- a/beautiful-racket-ragg/br/ragg/examples/simple-arithmetic-grammar.rkt +++ b/brag/brag/examples/simple-arithmetic-grammar.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag expr : term ('+' term)* term : factor ('*' factor)* diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing.rkt b/brag/brag/examples/simple-line-drawing.rkt similarity index 93% rename from beautiful-racket-ragg/br/ragg/examples/simple-line-drawing.rkt rename to brag/brag/examples/simple-line-drawing.rkt index a22465f..b97bdf5 100755 --- a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing.rkt +++ b/brag/brag/examples/simple-line-drawing.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; ;; See: http://stackoverflow.com/questions/12345647/rewrite-this-script-by-designing-an-interpreter-in-racket diff --git a/brag/brag/examples/simple-line-drawing/examples/letter-i.rkt b/brag/brag/examples/simple-line-drawing/examples/letter-i.rkt new file mode 100755 index 0000000..41f6570 --- /dev/null +++ b/brag/brag/examples/simple-line-drawing/examples/letter-i.rkt @@ -0,0 +1,4 @@ +#lang brag/examples/simple-line-drawing +3 9 X; +6 3 b 3 X 3 b; +3 9 X; diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/grammar.rkt b/brag/brag/examples/simple-line-drawing/grammar.rkt similarity index 93% rename from beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/grammar.rkt rename to brag/brag/examples/simple-line-drawing/grammar.rkt index a22465f..b97bdf5 100755 --- a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/grammar.rkt +++ b/brag/brag/examples/simple-line-drawing/grammar.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; ;; See: http://stackoverflow.com/questions/12345647/rewrite-this-script-by-designing-an-interpreter-in-racket diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/interpret.rkt b/brag/brag/examples/simple-line-drawing/interpret.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/interpret.rkt rename to brag/brag/examples/simple-line-drawing/interpret.rkt diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/lang/reader.rkt b/brag/brag/examples/simple-line-drawing/lang/reader.rkt similarity index 74% rename from beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/lang/reader.rkt rename to brag/brag/examples/simple-line-drawing/lang/reader.rkt index 13c69c4..d900f99 100755 --- a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/lang/reader.rkt +++ b/brag/brag/examples/simple-line-drawing/lang/reader.rkt @@ -1,12 +1,12 @@ #lang s-exp syntax/module-reader -br/ragg/examples/simple-line-drawing/semantics +brag/examples/simple-line-drawing/semantics #:read my-read #:read-syntax my-read-syntax #:info my-get-info #:whole-body-readers? #t -(require br/ragg/examples/simple-line-drawing/lexer - br/ragg/examples/simple-line-drawing/grammar) +(require brag/examples/simple-line-drawing/lexer + brag/examples/simple-line-drawing/grammar) (define (my-read in) (syntax->datum (my-read-syntax #f in))) diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/lexer.rkt b/brag/brag/examples/simple-line-drawing/lexer.rkt similarity index 95% rename from beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/lexer.rkt rename to brag/brag/examples/simple-line-drawing/lexer.rkt index 6ef3cf4..0dd4515 100755 --- a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/lexer.rkt +++ b/brag/brag/examples/simple-line-drawing/lexer.rkt @@ -3,7 +3,7 @@ (provide tokenize) ;; A simple lexer for simple-line-drawing. -(require br/ragg/support +(require brag/support parser-tools/lex) (define (tokenize ip) diff --git a/beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/semantics.rkt b/brag/brag/examples/simple-line-drawing/semantics.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/examples/simple-line-drawing/semantics.rkt rename to brag/brag/examples/simple-line-drawing/semantics.rkt diff --git a/beautiful-racket-ragg/br/ragg/examples/statlist-grammar.rkt b/brag/brag/examples/statlist-grammar.rkt similarity index 94% rename from beautiful-racket-ragg/br/ragg/examples/statlist-grammar.rkt rename to brag/brag/examples/statlist-grammar.rkt index 026b76e..18b2561 100755 --- a/beautiful-racket-ragg/br/ragg/examples/statlist-grammar.rkt +++ b/brag/brag/examples/statlist-grammar.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ## Statlist grammar diff --git a/beautiful-racket-ragg/br/ragg/examples/wordy.rkt b/brag/brag/examples/wordy.rkt similarity index 93% rename from beautiful-racket-ragg/br/ragg/examples/wordy.rkt rename to brag/brag/examples/wordy.rkt index 7430770..66c9042 100755 --- a/beautiful-racket-ragg/br/ragg/examples/wordy.rkt +++ b/brag/brag/examples/wordy.rkt @@ -1,4 +1,4 @@ -#lang br/ragg +#lang brag ;; A parser for a silly language sentence: verb optional-adjective object verb: greeting diff --git a/brag/brag/info.rkt b/brag/brag/info.rkt new file mode 100755 index 0000000..26e22e0 --- /dev/null +++ b/brag/brag/info.rkt @@ -0,0 +1,6 @@ +#lang setup/infotab +(define name "brag") +(define version "1.0") +(define scribblings '(("brag.scrbl"))) +(define blurb '("brag: the Beautiful Racket AST Generator. A fork o fDanny Yoo's ragg. A design goal is to be easy for beginners to use. Given a grammar in EBNF, ragg produces a parser that generates Racket's native syntax objects with full source location.")) +(define deps (list)) diff --git a/brag/brag/main.rkt b/brag/brag/main.rkt new file mode 100755 index 0000000..6ae6606 --- /dev/null +++ b/brag/brag/main.rkt @@ -0,0 +1,5 @@ +#lang racket/base + +(module+ reader + (require "codegen/reader.rkt") + (provide (all-from-out "codegen/reader.rkt"))) diff --git a/beautiful-racket-ragg/br/ragg/private/internal-support.rkt b/brag/brag/private/internal-support.rkt similarity index 98% rename from beautiful-racket-ragg/br/ragg/private/internal-support.rkt rename to brag/brag/private/internal-support.rkt index abaf0ac..8ff5f7d 100755 --- a/beautiful-racket-ragg/br/ragg/private/internal-support.rkt +++ b/brag/brag/private/internal-support.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require br/ragg/support) +(require brag/support) (provide current-source current-parser-error-handler diff --git a/beautiful-racket-ragg/br/ragg/rules/lexer.rkt b/brag/brag/rules/lexer.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/rules/lexer.rkt rename to brag/brag/rules/lexer.rkt diff --git a/beautiful-racket-ragg/br/ragg/rules/parser.rkt b/brag/brag/rules/parser.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/rules/parser.rkt rename to brag/brag/rules/parser.rkt diff --git a/beautiful-racket-ragg/br/ragg/rules/rule-structs.rkt b/brag/brag/rules/rule-structs.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/rules/rule-structs.rkt rename to brag/brag/rules/rule-structs.rkt diff --git a/beautiful-racket-ragg/br/ragg/rules/runtime.rkt b/brag/brag/rules/runtime.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/rules/runtime.rkt rename to brag/brag/rules/runtime.rkt diff --git a/beautiful-racket-ragg/br/ragg/rules/stx-types.rkt b/brag/brag/rules/stx-types.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/rules/stx-types.rkt rename to brag/brag/rules/stx-types.rkt diff --git a/beautiful-racket-ragg/br/ragg/rules/stx.rkt b/brag/brag/rules/stx.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/rules/stx.rkt rename to brag/brag/rules/stx.rkt diff --git a/beautiful-racket-ragg/br/ragg/support.rkt b/brag/brag/support.rkt similarity index 100% rename from beautiful-racket-ragg/br/ragg/support.rkt rename to brag/brag/support.rkt diff --git a/beautiful-racket-ragg/br/ragg/test/exercise-python-grammar.rkt b/brag/brag/test/exercise-python-grammar.rkt similarity index 98% rename from beautiful-racket-ragg/br/ragg/test/exercise-python-grammar.rkt rename to brag/brag/test/exercise-python-grammar.rkt index 361c2ba..21d1c85 100755 --- a/beautiful-racket-ragg/br/ragg/test/exercise-python-grammar.rkt +++ b/brag/brag/test/exercise-python-grammar.rkt @@ -1,6 +1,6 @@ #lang racket -(require br/ragg/examples/python-grammar - br/ragg/support +(require brag/examples/python-grammar + brag/support python-tokenizer racket/generator parser-tools/lex diff --git a/beautiful-racket-ragg/br/ragg/test/test-01-equal.rkt b/brag/brag/test/test-01-equal.rkt similarity index 96% rename from beautiful-racket-ragg/br/ragg/test/test-01-equal.rkt rename to brag/brag/test/test-01-equal.rkt index d6284e7..dcb2138 100755 --- a/beautiful-racket-ragg/br/ragg/test/test-01-equal.rkt +++ b/brag/brag/test/test-01-equal.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require br/ragg/examples/01-equal +(require brag/examples/01-equal rackunit) (check-equal? (syntax->datum (parse "")) diff --git a/beautiful-racket-ragg/br/ragg/test/test-0n1.rkt b/brag/brag/test/test-0n1.rkt similarity index 96% rename from beautiful-racket-ragg/br/ragg/test/test-0n1.rkt rename to brag/brag/test/test-0n1.rkt index 520d5b9..5611f6e 100755 --- a/beautiful-racket-ragg/br/ragg/test/test-0n1.rkt +++ b/brag/brag/test/test-0n1.rkt @@ -1,7 +1,7 @@ #lang racket/base -(require br/ragg/examples/0n1 - br/ragg/support +(require brag/examples/0n1 + brag/support rackunit) (define (lex ip) diff --git a/beautiful-racket-ragg/br/ragg/test/test-0n1n.rkt b/brag/brag/test/test-0n1n.rkt similarity index 96% rename from beautiful-racket-ragg/br/ragg/test/test-0n1n.rkt rename to brag/brag/test/test-0n1n.rkt index 5d6e9b1..f7655d5 100755 --- a/beautiful-racket-ragg/br/ragg/test/test-0n1n.rkt +++ b/brag/brag/test/test-0n1n.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require br/ragg/examples/0n1n - br/ragg/support +(require brag/examples/0n1n + brag/support rackunit) (define (lex ip) diff --git a/beautiful-racket-ragg/br/ragg/test/test-all.rkt b/brag/brag/test/test-all.rkt similarity index 89% rename from beautiful-racket-ragg/br/ragg/test/test-all.rkt rename to brag/brag/test/test-all.rkt index 9a2277d..8917aec 100755 --- a/beautiful-racket-ragg/br/ragg/test/test-all.rkt +++ b/brag/brag/test/test-all.rkt @@ -15,4 +15,4 @@ "test-errors.rkt" "test-old-token.rkt" "test-weird-grammar.rkt" - (submod br/ragg/codegen/satisfaction test)) + (submod brag/codegen/satisfaction test)) diff --git a/beautiful-racket-ragg/br/ragg/test/test-baby-json.rkt b/brag/brag/test/test-baby-json.rkt similarity index 91% rename from beautiful-racket-ragg/br/ragg/test/test-baby-json.rkt rename to brag/brag/test/test-baby-json.rkt index b9c97f9..dff09f4 100755 --- a/beautiful-racket-ragg/br/ragg/test/test-baby-json.rkt +++ b/brag/brag/test/test-baby-json.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require br/ragg/examples/baby-json - br/ragg/support +(require brag/examples/baby-json + brag/support rackunit) (check-equal? diff --git a/beautiful-racket-ragg/br/ragg/test/test-errors.rkt b/brag/brag/test/test-errors.rkt similarity index 84% rename from beautiful-racket-ragg/br/ragg/test/test-errors.rkt rename to brag/brag/test/test-errors.rkt index d2e789a..b84ae34 100755 --- a/beautiful-racket-ragg/br/ragg/test/test-errors.rkt +++ b/brag/brag/test/test-errors.rkt @@ -36,50 +36,50 @@ ;; errors with position are sensitive to length of lang line -(define lang-line "#lang br/ragg") +(define lang-line "#lang brag") (check-compile-error (format "~a" lang-line) "The grammar does not appear to have any rules") (check-compile-error (format "~a\nfoo" lang-line) - "Error while parsing grammar near: foo [line=2, column=0, position=15]") + "Error while parsing grammar near: foo [line=2, column=0, position=12]") (check-compile-error (format "~a\nnumber : 42" lang-line) - "Error while parsing grammar near: 42 [line=2, column=9, position=24]") + "Error while parsing grammar near: 42 [line=2, column=9, position=21]") (check-compile-error (format "~a\nnumber : 1" lang-line) - "Error while parsing grammar near: 1 [line=2, column=9, position=24]") + "Error while parsing grammar near: 1 [line=2, column=9, position=21]") -(check-compile-error "#lang br/ragg\n x: NUMBER\nx:STRING" +(check-compile-error "#lang brag\n x: NUMBER\nx:STRING" "Rule x has a duplicate definition") ;; Check to see that missing definitions for rules also raise good syntax ;; errors: -(check-compile-error "#lang br/ragg\nx:y" +(check-compile-error "#lang brag\nx:y" "Rule y has no definition") -(check-compile-error "#lang br/ragg\nnumber : 1flarbl" +(check-compile-error "#lang brag\nnumber : 1flarbl" "Rule 1flarbl has no definition") -(check-compile-error "#lang br/ragg\nprogram: EOF" +(check-compile-error "#lang brag\nprogram: EOF" "Token EOF is reserved and can not be used in a grammar") ;; Nontermination checks: -(check-compile-error "#lang br/ragg\nx : x" +(check-compile-error "#lang brag\nx : x" "Rule x has no finite derivation") (check-compile-error #<