Rename project to `yaragg`.

remotes/jackfirth/master
Jack Firth 3 years ago
parent 36306b57d4
commit 386052ac68

@ -37,11 +37,11 @@ jobs:
variant: ${{ matrix.racket-variant }} variant: ${{ matrix.racket-variant }}
- name: Install packages - name: Install packages
run: raco pkg install --auto ./br-parser-tools-lib run: raco pkg install --auto ./yaragg-parser-tools-lib
run: raco pkg install --auto ./br-parser-tools-doc run: raco pkg install --auto ./yaragg-parser-tools-doc
run: raco pkg install --auto ./br-parser-tools run: raco pkg install --auto ./yaragg-parser-tools
run: raco pkg install --auto ./brag-lib run: raco pkg install --auto ./yaragg-lib
run: raco pkg install --auto ./brag run: raco pkg install --auto ./yaragg
- name: Run the br-parser-tools tests - name: Run the yaragg-parser-tools tests
run: xvfb-run raco test --drdr -p br-parser-tools-lib br-parser-tools-doc br-parser-tools brag-lib brag run: xvfb-run raco test --drdr -p yaragg-parser-tools-lib yaragg-parser-tools-doc yaragg-parser-tools yaragg-lib yaragg

19
.gitignore vendored

@ -1,19 +1,2 @@
# for Racket
compiled/ compiled/
*~ doc/
# for Mac OS X
.DS_Store
.AppleDouble
.LSOverride
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
brag/*.html
brag/*.css
brag/*.js

@ -1,9 +1,7 @@
MIT License for `brag` (code only) Copyright 2022 Jack Firth
© 2017-2020 Matthew Butterick Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1,18 +1,11 @@
## brag ![Build Status](https://github.com/jackfirth/brag/workflows/CI/badge.svg) ## yaragg ![Build Status](https://github.com/jackfirth/yaragg/workflows/CI/badge.svg)
Racket DSL for generating parsers from BNF grammars.
Yet Another Racket AST-Generator Generator. Racket DSL for generating parsers from BNF grammars. Fork of [`brag`](https://pkgs.racket-lang.org/package/brag), which is itself a fork of [`ragg`](https://pkgs.racket-lang.org/package/ragg).
## Install ## Install
`raco pkg install brag` `raco pkg install --auto yaragg`
## Documentation
http://docs.racket-lang.org/brag/
## License ## License

@ -0,0 +1,11 @@
`yaragg` contains substantial portions of the software [`brag`](https://github.com/mbutterick/brag)
MIT License for `brag` (code only)
© 2017-2020 Matthew Butterick
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1,4 +1,4 @@
`brag` contains substantial portions of the software [`ragg`](https://github.com/jbclements/ragg) `yaragg` contains substantial portions of the software [`ragg`](https://github.com/jbclements/ragg)
MIT License for `ragg` MIT License for `ragg`

@ -1,3 +0,0 @@
#lang info
(define scribblings '(("br-parser-tools.scrbl" (multi-page) (parsing-library))))

@ -1,12 +0,0 @@
#lang info
(define collection 'multi)
(define deps '("br-parser-tools-lib"
"br-parser-tools-doc"))
(define implies '("br-parser-tools-lib"
"br-parser-tools-doc"))
(define pkg-desc "Lex- and Yacc-style parsing tools")
(define pkg-authors '(mflatt))

@ -1,4 +0,0 @@
#lang brag/examples/simple-line-drawing
3 9 X;
6 3 b 3 X 3 b;
3 9 X;

@ -1,26 +0,0 @@
#lang racket/base
(require brag/test/test-0n1
brag/test/test-0n1n
brag/test/test-01-equal
brag/test/test-baby-json
brag/test/test-baby-json-hider
brag/test/test-curly-quantifier
brag/test/test-cutter
brag/test/test-empty-symbol
brag/test/test-errors
brag/test/test-flatten
brag/test/test-hide-and-splice
brag/test/test-lexer
brag/test/test-nested-repeats
brag/test/test-old-token
brag/test/test-parser
brag/test/test-quotation-marks-and-backslashes
brag/test/test-simple-arithmetic-grammar
brag/test/test-simple-line-drawing
brag/test/test-start-and-atok
brag/test/test-top-level-cut
brag/test/test-weird-grammar
brag/test/test-whitespace
brag/test/test-wordy
(submod brag/codegen/satisfaction test))

@ -1,11 +0,0 @@
#lang racket/base
(require (prefix-in 1: brag/examples/top-level-cut-1)
(prefix-in 2: brag/examples/top-level-cut-2)
(prefix-in 3: brag/examples/top-level-cut-3)
brag/support
rackunit)
(check-equal? (1:parse-to-datum "x") '((sub "x")))
(check-equal? (2:parse-to-datum "x") '(("x")))
(check-equal? (3:parse-to-datum "x") '("x"))

@ -1,4 +0,0 @@
#lang info
(define scribblings '(("brag.scrbl")))

@ -3,8 +3,8 @@
(define collection 'multi) (define collection 'multi)
(define deps '(["base" #:version "6.3"] (define deps '(["base" #:version "6.3"]
"br-parser-tools-lib" "yaragg-parser-tools-lib"
"rackunit-lib" "rackunit-lib"
"syntax-color-lib")) "syntax-color-lib"))
(define implies '("br-parser-tools-lib")) (define implies '("yaragg-parser-tools-lib"))

@ -1,16 +1,16 @@
#lang racket/base #lang racket/base
(require racket/list (require racket/list
racket/syntax racket/syntax
brag/rules/stx-types yaragg/rules/stx-types
syntax/id-table syntax/id-table
(prefix-in sat: brag/codegen/satisfaction) (prefix-in sat: yaragg/codegen/satisfaction)
(for-template racket/base (for-template racket/base
brag/codegen/runtime yaragg/codegen/runtime
brag/private/internal-support)) yaragg/private/internal-support))
(provide (all-defined-out) (provide (all-defined-out)
(for-template (all-from-out brag/codegen/runtime (for-template (all-from-out yaragg/codegen/runtime
brag/private/internal-support))) yaragg/private/internal-support)))
;; Given a flattened rule, returns a syntax for the code that ;; Given a flattened rule, returns a syntax for the code that
;; preserves as much source location as possible. ;; preserves as much source location as possible.

@ -1,12 +1,12 @@
#lang racket/base #lang racket/base
(require (for-syntax racket/base (require (for-syntax racket/base
racket/list racket/list
brag/codegen/codegen yaragg/codegen/codegen
brag/codegen/runtime yaragg/codegen/runtime
brag/codegen/flatten) yaragg/codegen/flatten)
br-parser-tools/lex yaragg-parser-tools/lex
br-parser-tools/cfg-parser yaragg-parser-tools/cfg-parser
(prefix-in bs: brag/support) (prefix-in bs: yaragg/support)
racket/set) racket/set)
(provide (except-out (all-from-out racket/base) #%module-begin) (provide (except-out (all-from-out racket/base) #%module-begin)
@ -39,7 +39,7 @@
[((TOKEN-TYPE . TOKEN-TYPE-CONSTRUCTOR) ...) [((TOKEN-TYPE . TOKEN-TYPE-CONSTRUCTOR) ...)
(for/list ([tt (in-list (rules->token-types rules))]) (for/list ([tt (in-list (rules->token-types rules))])
(cons tt (string->symbol (format "token-~a" tt))))] (cons tt (string->symbol (format "token-~a" tt))))]
;; Flatten rules to use the yacc-style ruleset that br-parser-tools supports ;; Flatten rules to use the yacc-style ruleset that yaragg-parser-tools supports
[GENERATED-RULE-CODES (map flat-rule->yacc-rule (flatten-rules rules))] [GENERATED-RULE-CODES (map flat-rule->yacc-rule (flatten-rules rules))]
;; main exports. Break hygiene so they're also available at top-level / repl ;; main exports. Break hygiene so they're also available at top-level / repl
[(PARSE PARSE-TO-DATUM PARSE-TREE MAKE-RULE-PARSER ALL-TOKEN-TYPES) [(PARSE PARSE-TO-DATUM PARSE-TREE MAKE-RULE-PARSER ALL-TOKEN-TYPES)
@ -54,7 +54,7 @@
#'(#%module-begin #'(#%module-begin
(provide PARSE PARSE-TO-DATUM PARSE-TREE MAKE-RULE-PARSER ALL-TOKEN-TYPES) (provide PARSE PARSE-TO-DATUM PARSE-TREE MAKE-RULE-PARSER ALL-TOKEN-TYPES)
;; handle brag/support `token` with special identifier ;; handle yaragg/support `token` with special identifier
;; so it doesn't conflict with brag's internal `token` macro ;; so it doesn't conflict with brag's internal `token` macro
;; defined but deliberately not provided so it's available at repl, but not on import ;; defined but deliberately not provided so it's available at repl, but not on import
(define TOKEN bs:token) (define TOKEN bs:token)

@ -1,5 +1,5 @@
#lang racket/base #lang racket/base
(require brag/rules/stx-types (require yaragg/rules/stx-types
racket/list racket/list
(for-syntax racket/base)) (for-syntax racket/base))
(provide flatten-rule (provide flatten-rule

@ -1,14 +1,14 @@
#lang s-exp syntax/module-reader #lang s-exp syntax/module-reader
brag/codegen/expander yaragg/codegen/expander
#:read my-read #:read my-read
#:read-syntax my-read-syntax #:read-syntax my-read-syntax
#:info my-get-info #:info my-get-info
#:whole-body-readers? #t #:whole-body-readers? #t
(require brag/rules/parser (require yaragg/rules/parser
brag/rules/lexer yaragg/rules/lexer
brag/rules/stx yaragg/rules/stx
brag/rules/rule-structs) yaragg/rules/rule-structs)
(define (my-read in) (syntax->datum (my-read-syntax #f in))) (define (my-read in) (syntax->datum (my-read-syntax #f in)))
@ -41,7 +41,7 @@ brag/codegen/expander
(define (my-get-info key default default-filter) (define (my-get-info key default default-filter)
(case key (case key
[(color-lexer) (dynamic-require 'brag/private/colorer 'color-brag (λ () #f))] [(color-lexer) (dynamic-require 'yaragg/private/colorer 'color-brag (λ () #f))]
[(drracket:indentation) (dynamic-require 'brag/private/indenter 'indent-brag (λ () #f))] [(drracket:indentation) (dynamic-require 'yaragg/private/indenter 'indent-brag (λ () #f))]
[else (default-filter key default)])) [else (default-filter key default)]))

@ -2,9 +2,9 @@
(require racket/match (require racket/match
racket/list racket/list
racket/generator racket/generator
(prefix-in lex: br-parser-tools/lex) (prefix-in lex: yaragg-parser-tools/lex)
brag/support yaragg/support
brag/private/internal-support) yaragg/private/internal-support)
(provide the-error-handler (provide the-error-handler

@ -0,0 +1,4 @@
#lang yaragg/examples/simple-line-drawing
3 9 X;
6 3 b 3 X 3 b;
3 9 X;

@ -1,12 +1,12 @@
#lang s-exp syntax/module-reader #lang s-exp syntax/module-reader
brag/examples/simple-line-drawing/semantics yaragg/examples/simple-line-drawing/semantics
#:read my-read #:read my-read
#:read-syntax my-read-syntax #:read-syntax my-read-syntax
#:info my-get-info #:info my-get-info
#:whole-body-readers? #t #:whole-body-readers? #t
(require brag/examples/simple-line-drawing/lexer (require yaragg/examples/simple-line-drawing/lexer
brag/examples/simple-line-drawing/grammar) yaragg/examples/simple-line-drawing/grammar)
(define (my-read in) (define (my-read in)
(syntax->datum (my-read-syntax #f in))) (syntax->datum (my-read-syntax #f in)))

@ -3,8 +3,8 @@
(provide tokenize) (provide tokenize)
;; A simple lexer for simple-line-drawing. ;; A simple lexer for simple-line-drawing.
(require brag/support (require yaragg/support
br-parser-tools/lex) yaragg-parser-tools/lex)
(define (tokenize ip) (define (tokenize ip)
(port-count-lines! ip) (port-count-lines! ip)

@ -1,8 +1,8 @@
#lang racket/base #lang racket/base
(module reader racket/base (module reader racket/base
(require brag/codegen/reader) (require yaragg/codegen/reader)
(provide (all-from-out brag/codegen/reader))) (provide (all-from-out yaragg/codegen/reader)))
;; this creates dummy identifiers ;; this creates dummy identifiers
;; so cross-refs in `brag` docs will work ;; so cross-refs in `brag` docs will work

@ -1,5 +1,5 @@
#lang racket/base #lang racket/base
(require brag/support (submod brag/rules/lexer lex-abbrevs) racket/match) (require yaragg/support (submod yaragg/rules/lexer lex-abbrevs) racket/match)
(provide color-brag) (provide color-brag)
(define brag-syntax-lexer (define brag-syntax-lexer

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/support) (require yaragg/support)
(provide current-source (provide current-source
current-parser-error-handler current-parser-error-handler

@ -1,10 +1,10 @@
#lang racket/base #lang racket/base
(require (for-syntax racket/base brag/rules/parser)) (require (for-syntax racket/base yaragg/rules/parser))
(require br-parser-tools/lex (require yaragg-parser-tools/lex
(prefix-in : br-parser-tools/lex-sre) (prefix-in : yaragg-parser-tools/lex-sre)
brag/rules/parser yaragg/rules/parser
brag/rules/rule-structs yaragg/rules/rule-structs
(only-in brag/support from/to) (only-in yaragg/support from/to)
racket/string racket/string
syntax-color/racket-lexer syntax-color/racket-lexer
racket/match) racket/match)
@ -163,7 +163,7 @@
(values "" end-pos)])) (values "" end-pos)]))
;; position->pos: position -> pos ;; position->pos: position -> pos
;; Converts position structures from br-parser-tools/lex to our own pos structures. ;; Converts position structures from yaragg-parser-tools/lex to our own pos structures.
(define (position->pos a-pos) (define (position->pos a-pos)
(pos (position-offset a-pos) (pos (position-offset a-pos)
(position-line a-pos) (position-line a-pos)

@ -1,9 +1,9 @@
#lang racket/base #lang racket/base
(require br-parser-tools/yacc (require yaragg-parser-tools/yacc
br-parser-tools/lex yaragg-parser-tools/lex
racket/list racket/list
racket/match racket/match
brag/rules/rule-structs) yaragg/rules/rule-structs)
;; A parser for grammars. ;; A parser for grammars.
@ -265,7 +265,7 @@
;; position->pos: position -> pos ;; position->pos: position -> pos
;; Coerses position structures from br-parser-tools/lex to our own pos structures. ;; Coerses position structures from yaragg-parser-tools/lex to our own pos structures.
(define (position->pos a-pos) (define (position->pos a-pos)
(pos (position-offset a-pos) (pos (position-offset a-pos)
(position-line a-pos) (position-line a-pos)

@ -2,7 +2,7 @@
(provide (all-defined-out)) (provide (all-defined-out))
;; We keep our own position structure because br-parser-tools/lex's position ;; We keep our own position structure because yaragg-parser-tools/lex's position
;; structure is non-transparent, hence highly resistant to unit testing. ;; structure is non-transparent, hence highly resistant to unit testing.
(struct pos (offset line col) (struct pos (offset line col)
#:transparent) #:transparent)

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require brag/rules/rule-structs (require yaragg/rules/rule-structs
br-parser-tools/lex yaragg-parser-tools/lex
racket/match racket/match
syntax/strip-context) syntax/strip-context)

@ -1,11 +1,11 @@
#lang racket/base #lang racket/base
(require br-parser-tools/lex (require yaragg-parser-tools/lex
racket/string racket/string
racket/struct racket/struct
(prefix-in : br-parser-tools/lex-sre) (prefix-in : yaragg-parser-tools/lex-sre)
(for-syntax racket/base)) (for-syntax racket/base))
(provide (all-from-out br-parser-tools/lex) (provide (all-from-out yaragg-parser-tools/lex)
(all-from-out br-parser-tools/lex-sre) (all-from-out yaragg-parser-tools/lex-sre)
[struct-out token-struct] [struct-out token-struct]
token token
[struct-out exn:fail:parsing]) [struct-out exn:fail:parsing])

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/01-equal (require yaragg/examples/01-equal
rackunit) rackunit)
(check-equal? (syntax->datum (parse "")) (check-equal? (syntax->datum (parse ""))

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require brag/examples/0n1 (require yaragg/examples/0n1
brag/support yaragg/support
rackunit) rackunit)
(define (lex ip) (define (lex ip)

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/0n1n (require yaragg/examples/0n1n
brag/support yaragg/support
rackunit) rackunit)
(define (lex ip) (define (lex ip)

@ -0,0 +1,26 @@
#lang racket/base
(require yaragg/test/test-0n1
yaragg/test/test-0n1n
yaragg/test/test-01-equal
yaragg/test/test-baby-json
yaragg/test/test-baby-json-hider
yaragg/test/test-curly-quantifier
yaragg/test/test-cutter
yaragg/test/test-empty-symbol
yaragg/test/test-errors
yaragg/test/test-flatten
yaragg/test/test-hide-and-splice
yaragg/test/test-lexer
yaragg/test/test-nested-repeats
yaragg/test/test-old-token
yaragg/test/test-parser
yaragg/test/test-quotation-marks-and-backslashes
yaragg/test/test-simple-arithmetic-grammar
yaragg/test/test-simple-line-drawing
yaragg/test/test-start-and-atok
yaragg/test/test-top-level-cut
yaragg/test/test-weird-grammar
yaragg/test/test-whitespace
yaragg/test/test-wordy
(submod yaragg/codegen/satisfaction test))

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/baby-json-hider (require yaragg/examples/baby-json-hider
brag/support yaragg/support
rackunit) rackunit)
(define parse-result (parse (list "{" (define parse-result (parse (list "{"

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require brag/examples/baby-json (require yaragg/examples/baby-json
(prefix-in alt: brag/examples/baby-json-alt) (prefix-in alt: yaragg/examples/baby-json-alt)
brag/support yaragg/support
rackunit) rackunit)
(let ([str (list "{" (let ([str (list "{"

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/codepoints (require yaragg/examples/codepoints
rackunit) rackunit)
(check-equal? (parse-to-datum '("\"A\\" "'c\\" "*d\\\"\\ef\"" "hello world")) (check-equal? (parse-to-datum '("\"A\\" "'c\\" "*d\\\"\\ef\"" "hello world"))

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/curly-quantifier (require yaragg/examples/curly-quantifier
brag/support yaragg/support
rackunit) rackunit)
(check-exn exn:fail:parsing? (λ () (parse-to-datum "a"))) (check-exn exn:fail:parsing? (λ () (parse-to-datum "a")))

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/cutter-another (require yaragg/examples/cutter-another
brag/support yaragg/support
rackunit) rackunit)
(check-equal? (parse-tree "w") '(top (w))) (check-equal? (parse-tree "w") '(top (w)))

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/cutter (require yaragg/examples/cutter
brag/support yaragg/support
rackunit) rackunit)
;; related to rule-flattening problem ;; related to rule-flattening problem

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/empty-symbol (require yaragg/examples/empty-symbol
brag/support yaragg/support
rackunit) rackunit)
(check-true (and (member (parse-to-datum "") (list '(top (xs)) '(top (ys)) '(top (zs)))) #t)) (check-true (and (member (parse-to-datum "") (list '(top (xs)) '(top (ys)) '(top (zs)))) #t))

@ -130,7 +130,7 @@ EOF
(check-compile-error #<<EOF (check-compile-error #<<EOF
#lang racket/base #lang racket/base
(require brag/examples/simple-line-drawing) (require yaragg/examples/simple-line-drawing)
(define bad-parser (make-rule-parser crunchy)) (define bad-parser (make-rule-parser crunchy))
EOF EOF
"Rule crunchy is not defined in the grammar" "Rule crunchy is not defined in the grammar"

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/rules/stx-types (require yaragg/rules/stx-types
brag/codegen/flatten yaragg/codegen/flatten
rackunit) rackunit)

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/hide-and-splice (require yaragg/examples/hide-and-splice
brag/support yaragg/support
rackunit) rackunit)
;; check that an id with both a splice and hide is handled correctly ;; check that an id with both a splice and hide is handled correctly

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require brag/rules/lexer (require yaragg/rules/lexer
rackunit rackunit
br-parser-tools/lex) yaragg-parser-tools/lex)
(define (l s) (define (l s)
(define t (lex/1 (open-input-string s))) (define t (lex/1 (open-input-string s)))

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require rackunit (require rackunit
brag/support yaragg/support
brag/examples/subrule) yaragg/examples/subrule)
(define parse-next (make-rule-parser next)) (define parse-next (make-rule-parser next))
(define parse-start (make-rule-parser start)) (define parse-start (make-rule-parser start))

@ -1,5 +1,5 @@
#lang racket/base #lang racket/base
(require brag/examples/nested-repeats (require yaragg/examples/nested-repeats
rackunit) rackunit)
(check-equal? (check-equal?

@ -2,11 +2,11 @@
;; Make sure the old token type also works fine. ;; Make sure the old token type also works fine.
(require brag/examples/simple-line-drawing (require yaragg/examples/simple-line-drawing
brag/support yaragg/support
racket/list racket/list
br-parser-tools/lex yaragg-parser-tools/lex
(prefix-in : br-parser-tools/lex-sre) (prefix-in : yaragg-parser-tools/lex-sre)
rackunit) rackunit)
(define-tokens tokens (INTEGER STRING |;| EOF)) (define-tokens tokens (INTEGER STRING |;| EOF))
@ -72,5 +72,5 @@ EOF
;; FIXME: add tests to make sure location is as we expect. ;; FIXME: add tests to make sure location is as we expect.
;; ;;
;; FIXME: handle the EOF issue better. Something in cfg-parser ;; FIXME: handle the EOF issue better. Something in cfg-parser
;; appears to deviate from br-parser-tools/yacc with regards to the stop ;; appears to deviate from yaragg-parser-tools/yacc with regards to the stop
;; token. ;; token.

@ -2,10 +2,10 @@
(require rackunit (require rackunit
br-parser-tools/lex yaragg-parser-tools/lex
brag/rules/parser yaragg/rules/parser
brag/rules/lexer yaragg/rules/lexer
brag/rules/rule-structs) yaragg/rules/rule-structs)
;; quick-and-dirty helper for pos construction. ;; quick-and-dirty helper for pos construction.

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/quotation-marks-and-backslashes (require yaragg/examples/quotation-marks-and-backslashes
brag/support yaragg/support
rackunit) rackunit)
(check-equal? (parse-tree "a\"'\\a\"'\\") '(start "a" "\"" "'" "\\" "a" "\"" "'" "\\")) (check-equal? (parse-tree "a\"'\\a\"'\\") '(start "a" "\"" "'" "\\" "a" "\"" "'" "\\"))

@ -1,8 +1,8 @@
#lang racket/base #lang racket/base
(require brag/examples/simple-arithmetic-grammar (require yaragg/examples/simple-arithmetic-grammar
brag/support yaragg/support
racket/set racket/set
br-parser-tools/lex yaragg-parser-tools/lex
racket/list racket/list
rackunit) rackunit)

@ -1,10 +1,10 @@
#lang racket/base #lang racket/base
(require brag/examples/simple-line-drawing (require yaragg/examples/simple-line-drawing
brag/support yaragg/support
racket/list racket/list
br-parser-tools/lex yaragg-parser-tools/lex
(prefix-in : br-parser-tools/lex-sre) (prefix-in : yaragg-parser-tools/lex-sre)
rackunit) rackunit)
(define (make-tokenizer ip) (define (make-tokenizer ip)
@ -68,5 +68,5 @@ EOF
;; FIXME: add tests to make sure location is as we expect. ;; FIXME: add tests to make sure location is as we expect.
;; ;;
;; FIXME: handle the EOF issue better. Something in cfg-parser ;; FIXME: handle the EOF issue better. Something in cfg-parser
;; appears to deviate from br-parser-tools/yacc with regards to the stop ;; appears to deviate from yaragg-parser-tools/yacc with regards to the stop
;; token. ;; token.

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require brag/examples/start-and-atok (require yaragg/examples/start-and-atok
brag/support yaragg/support
rackunit) rackunit)
;; make sure that "start" and "atok" work as terminals. ;; make sure that "start" and "atok" work as terminals.

@ -0,0 +1,11 @@
#lang racket/base
(require (prefix-in 1: yaragg/examples/top-level-cut-1)
(prefix-in 2: yaragg/examples/top-level-cut-2)
(prefix-in 3: yaragg/examples/top-level-cut-3)
yaragg/support
rackunit)
(check-equal? (1:parse-to-datum "x") '((sub "x")))
(check-equal? (2:parse-to-datum "x") '(("x")))
(check-equal? (3:parse-to-datum "x") '("x"))

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/test/weird-grammar (require yaragg/test/weird-grammar
rackunit) rackunit)
(check-equal? (syntax->datum (parse '("foo"))) (check-equal? (syntax->datum (parse '("foo")))

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/whitespace (require yaragg/examples/whitespace
brag/support yaragg/support
rackunit) rackunit)
(check-equal? (check-equal?

@ -1,6 +1,6 @@
#lang racket/base #lang racket/base
(require brag/examples/wordy (require yaragg/examples/wordy
brag/support yaragg/support
rackunit) rackunit)
(check-equal? (check-equal?

@ -5,10 +5,6 @@
(define build-deps '("scheme-lib" (define build-deps '("scheme-lib"
"racket-doc" "racket-doc"
"syntax-color-doc" "syntax-color-doc"
"br-parser-tools-lib" "yaragg-parser-tools-lib"
"scribble-lib")) "scribble-lib"))
(define update-implies '("br-parser-tools-lib")) (define update-implies '("yaragg-parser-tools-lib"))
(define pkg-desc "documentation part of \"br-parser-tools\"")
(define pkg-authors '(mflatt))

@ -2,10 +2,10 @@
@(require scribble/manual scribble/struct scribble/xref scribble/bnf @(require scribble/manual scribble/struct scribble/xref scribble/bnf
(for-label scheme/base (for-label scheme/base
scheme/contract scheme/contract
br-parser-tools/lex yaragg-parser-tools/lex
(prefix-in : br-parser-tools/lex-sre) (prefix-in : yaragg-parser-tools/lex-sre)
br-parser-tools/yacc yaragg-parser-tools/yacc
br-parser-tools/cfg-parser)) yaragg-parser-tools/cfg-parser))
@title{Parser Tools: @exec{lex} and @exec{yacc}-style Parsing (BR edition)} @title{Parser Tools: @exec{lex} and @exec{yacc}-style Parsing (BR edition)}
@ -26,7 +26,7 @@ This documentation assumes familiarity with @exec{lex}- and @exec{yacc}-style le
@section-index["scanning"] @section-index["scanning"]
@section-index["scanner"] @section-index["scanner"]
@defmodule[br-parser-tools/lex] @defmodule[yaragg-parser-tools/lex]
@; ---------------------------------------- @; ----------------------------------------
@ -61,7 +61,7 @@ This documentation assumes familiarity with @exec{lex}- and @exec{yacc}-style le
@margin-note{The implementation of @racketmodname[syntax-color/racket-lexer] @margin-note{The implementation of @racketmodname[syntax-color/racket-lexer]
contains a lexer for the @racketmodname[racket] language. contains a lexer for the @racketmodname[racket] language.
In addition, files in the @filepath{examples} sub-directory In addition, files in the @filepath{examples} sub-directory
of the @filepath{br-parser-tools} collection contain of the @filepath{yaragg-parser-tools} collection contain
simpler example lexers.} simpler example lexers.}
An @racket[re] is matched as follows: An @racket[re] is matched as follows:
@ -69,7 +69,7 @@ This documentation assumes familiarity with @exec{lex}- and @exec{yacc}-style le
@itemize[ @itemize[
@item{@racket[id] --- expands to the named @deftech{lexer abbreviation}; @item{@racket[id] --- expands to the named @deftech{lexer abbreviation};
abbreviations are defined via @racket[define-lex-abbrev] or supplied by modules abbreviations are defined via @racket[define-lex-abbrev] or supplied by modules
like @racketmodname[br-parser-tools/lex-sre].} like @racketmodname[yaragg-parser-tools/lex-sre].}
@item{@racket[string] --- matches the sequence of characters in @racket[string].} @item{@racket[string] --- matches the sequence of characters in @racket[string].}
@item{@racket[character] --- matches a literal @racket[character].} @item{@racket[character] --- matches a literal @racket[character].}
@item{@racket[(repetition lo hi re)] --- matches @racket[re] repeated between @racket[lo] @item{@racket[(repetition lo hi re)] --- matches @racket[re] repeated between @racket[lo]
@ -94,15 +94,15 @@ empty string, @racket[(union)] matches nothing,
The regular expression language is not designed to be used directly, The regular expression language is not designed to be used directly,
but rather as a basis for a user-friendly notation written with but rather as a basis for a user-friendly notation written with
regular expression macros. For example, regular expression macros. For example,
@racketmodname[br-parser-tools/lex-sre] supplies operators from Olin @racketmodname[yaragg-parser-tools/lex-sre] supplies operators from Olin
Shivers's SREs, and @racketmodname[br-parser-tools/lex-plt-v200] supplies Shivers's SREs, and @racketmodname[yaragg-parser-tools/lex-plt-v200] supplies
(deprecated) operators from the previous version of this library. (deprecated) operators from the previous version of this library.
Since those libraries provide operators whose names match other Racket Since those libraries provide operators whose names match other Racket
bindings, such as @racket[*] and @racket[+], they normally must be bindings, such as @racket[*] and @racket[+], they normally must be
imported using a prefix: imported using a prefix:
@racketblock[ @racketblock[
(require (prefix-in : br-parser-tools/lex-sre)) (require (prefix-in : yaragg-parser-tools/lex-sre))
] ]
The suggested prefix is @racket[:], so that @racket[:*] and The suggested prefix is @racket[:], so that @racket[:*] and
@ -360,14 +360,14 @@ characters, @racket[char-lower-case?] characters, etc.}
@subsection{Lexer SRE Operators} @subsection{Lexer SRE Operators}
@defmodule[br-parser-tools/lex-sre] @defmodule[yaragg-parser-tools/lex-sre]
@; Put the docs in a macro, so that we can bound the scope of @; Put the docs in a macro, so that we can bound the scope of
@; the import of `*', etc.: @; the import of `*', etc.:
@(define-syntax-rule (lex-sre-doc) @(define-syntax-rule (lex-sre-doc)
(... (...
(begin (begin
(require (for-label br-parser-tools/lex-sre)) (require (for-label yaragg-parser-tools/lex-sre))
@defform[(* re ...)]{ @defform[(* re ...)]{
@ -437,16 +437,16 @@ characters.}
@subsection{Lexer Legacy Operators} @subsection{Lexer Legacy Operators}
@defmodule[br-parser-tools/lex-plt-v200] @defmodule[yaragg-parser-tools/lex-plt-v200]
@(define-syntax-rule (lex-v200-doc) @(define-syntax-rule (lex-v200-doc)
(... (...
(begin (begin
(require (for-label br-parser-tools/lex-plt-v200)) (require (for-label yaragg-parser-tools/lex-plt-v200))
@t{The @racketmodname[br-parser-tools/lex-plt-v200] module re-exports @t{The @racketmodname[yaragg-parser-tools/lex-plt-v200] module re-exports
@racket[*], @racket[+], @racket[?], and @racket[&] from @racket[*], @racket[+], @racket[?], and @racket[&] from
@racketmodname[br-parser-tools/lex-sre]. It also re-exports @racketmodname[yaragg-parser-tools/lex-sre]. It also re-exports
@racket[:or] as @racket[:], @racket[::] as @racket[|@|], @racket[:~] @racket[:or] as @racket[:], @racket[::] as @racket[|@|], @racket[:~]
as @racket[^], and @racket[:/] as @racket[-].} as @racket[^], and @racket[:/] as @racket[-].}
@ -467,7 +467,7 @@ The same as @racket[(complement re ...)].})))
Each @racket[_action-expr] in a @racket[lexer] form can produce any Each @racket[_action-expr] in a @racket[lexer] form can produce any
kind of value, but for many purposes, producing a @deftech{token} kind of value, but for many purposes, producing a @deftech{token}
value is useful. Tokens are usually necessary for inter-operating with value is useful. Tokens are usually necessary for inter-operating with
a parser generated by @racket[br-parser-tools/parser], but tokens may not a parser generated by @racket[yaragg-parser-tools/parser], but tokens may not
be the right choice when using @racket[lexer] in other situations. be the right choice when using @racket[lexer] in other situations.
@defform[(define-tokens group-id (token-id ...))]{ @defform[(define-tokens group-id (token-id ...))]{
@ -513,7 +513,7 @@ be the right choice when using @racket[lexer] in other situations.
@section-index["yacc"] @section-index["yacc"]
@defmodule[br-parser-tools/yacc] @defmodule[yaragg-parser-tools/yacc]
@defform/subs[#:literals (grammar tokens start end precs src-pos @defform/subs[#:literals (grammar tokens start end precs src-pos
suppress debug yacc-output prec) suppress debug yacc-output prec)
@ -712,9 +712,9 @@ be the right choice when using @racket[lexer] in other situations.
@section-index["cfg-parser"] @section-index["cfg-parser"]
@defmodule[br-parser-tools/cfg-parser]{The @racketmodname[br-parser-tools/cfg-parser] @defmodule[yaragg-parser-tools/cfg-parser]{The @racketmodname[yaragg-parser-tools/cfg-parser]
library provides a parser generator that is an alternative to that of library provides a parser generator that is an alternative to that of
@racketmodname[br-parser-tools/yacc].} @racketmodname[yaragg-parser-tools/yacc].}
@defform/subs[#:literals (grammar tokens start end precs src-pos @defform/subs[#:literals (grammar tokens start end precs src-pos
suppress debug yacc-output prec) suppress debug yacc-output prec)
@ -731,7 +731,7 @@ library provides a parser generator that is an alternative to that of
Creates a parser similar to that of @racket[parser]. Unlike @racket[parser], Creates a parser similar to that of @racket[parser]. Unlike @racket[parser],
@racket[cfg-parser], can consume arbitrary and potentially ambiguous context-free @racket[cfg-parser], can consume arbitrary and potentially ambiguous context-free
grammars. Its interface is a subset of @racketmodname[br-parser-tools/yacc], with grammars. Its interface is a subset of @racketmodname[yaragg-parser-tools/yacc], with
the following differences: the following differences:
@itemize[ @itemize[
@ -751,7 +751,7 @@ library provides a parser generator that is an alternative to that of
@section{Converting @exec{yacc} or @exec{bison} Grammars} @section{Converting @exec{yacc} or @exec{bison} Grammars}
@defmodule[br-parser-tools/yacc-to-scheme] @defmodule[yaragg-parser-tools/yacc-to-scheme]
@defproc[(trans [file path-string?]) any/c]{ @defproc[(trans [file path-string?]) any/c]{
@ -765,7 +765,7 @@ conversion tool. It is not entirely robust. For example, if the C
actions in the original grammar have nested blocks, the tool will fail. actions in the original grammar have nested blocks, the tool will fail.
Annotated examples are in the @filepath{examples} subdirectory of the Annotated examples are in the @filepath{examples} subdirectory of the
@filepath{br-parser-tools} collection.} @filepath{yaragg-parser-tools} collection.}
@; ---------------------------------------------------------------------- @; ----------------------------------------------------------------------

@ -0,0 +1,3 @@
#lang info
(define scribblings '(("yaragg-parser-tools.scrbl" (multi-page) (parsing-library))))

@ -5,5 +5,3 @@
"base" "base"
"compatibility-lib")) "compatibility-lib"))
(define build-deps '("rackunit-lib")) (define build-deps '("rackunit-lib"))
(define pkg-desc "implementation (no documentation) part of \"br-parser-tools\"")

@ -1,5 +1,5 @@
#lang racket/base #lang racket/base
;; This module implements a parser form like the br-parser-tools's ;; This module implements a parser form like the yaragg-parser-tools's
;; `parser', except that it works on an arbitrary CFG (returning ;; `parser', except that it works on an arbitrary CFG (returning
;; the first sucecssful parse). ;; the first sucecssful parse).
@ -23,7 +23,7 @@
;; different lengths. (Otherwise, in the spirit of finding one ;; different lengths. (Otherwise, in the spirit of finding one
;; successful parse, only the first result is kept.) ;; successful parse, only the first result is kept.)
;; The br-parser-tools's `parse' is used to transform tokens in the ;; The yaragg-parser-tools's `parse' is used to transform tokens in the
;; grammar to tokens specific to this parser. In other words, this ;; grammar to tokens specific to this parser. In other words, this
;; parser uses `parser' so that it doesn't have to know anything about ;; parser uses `parser' so that it doesn't have to know anything about
;; tokens. ;; tokens.
@ -31,12 +31,12 @@
(require br-parser-tools/yacc (require yaragg-parser-tools/yacc
br-parser-tools/lex) yaragg-parser-tools/lex)
(require (for-syntax racket/base (require (for-syntax racket/base
syntax/boundmap syntax/boundmap
br-parser-tools/private-lex/token-syntax)) yaragg-parser-tools/private-lex/token-syntax))
(provide cfg-parser) (provide cfg-parser)
@ -752,7 +752,7 @@
(module* test racket/base (module* test racket/base
(require (submod "..") (require (submod "..")
br-parser-tools/lex yaragg-parser-tools/lex
racket/block racket/block
rackunit) rackunit)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save