More renaming

remotes/jackfirth/master
Jack Firth 2 years ago
parent 386052ac68
commit 6c73ec6f13

@ -48,7 +48,7 @@
[TOKEN (datum->syntax rules-stx 'token)] ; for repl
[RULE-IDS (map syntax-e rule-ids)]
[RULES-STX rules-stx])
;; this stx object represents the top level of a #lang brag module.
;; this stx object represents the top level of a #lang yaragg module.
;; so any `define`s are automatically available at the repl.
;; and only identifiers explicitly `provide`d are visible on import.
#'(#%module-begin

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
## Equal numbers of 0 and 1s in a string.
##

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
rule: "0"* "1"

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
rule-0n1n: ["0" rule-0n1n "1"]

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
expr : term (/'+' term)*
@term : factor (/'*' @factor)*

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;; Simple baby example of JSON structure
json ::= number | string

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;; Simple baby example of JSON structure
json: number

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
#:prefix-out my:
;; Simple baby example of JSON structure

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;; Simple baby example of JSON structure
json: number | string

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
## The following comes from: http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
start: A c def hello-world
A : "\"\101\\" ; A
c : '\'\U0063\\' ; c

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;; test the curly quantifier
start : a-rule | b-rule | c-rule | d-rule | e-rule
a-rule : "a"{2} ; exactly 2

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
top : w | x | y | z | a | b | c
w : /"w" ; atom
x : /("x") ; seq

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
top : expr (/"," expr)*
expr : "x" | list
list : "(" expr ("," expr)* ")"

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
top : xs | ys | zs
xs : () | "x" xs

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
top : x | y
/x : Ø | "x" @x
@y : Ø | "y" y

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;; Lua parser, adapted from:
;; http://www.lua.org/manual/5.1/manual.html#8

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
start : ( (X | X Y) A* )*

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
nested-word-list: WORD
| LEFT-PAREN nested-word-list* RIGHT-PAREN

@ -1,2 +1,2 @@
#lang brag
#lang yaragg
start: "a" "\"" "'" "\\" 'a' '"' '\'' '\\'

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
expr : term ('+' term)*
term : factor ('*' factor)*

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;;
;; See: http://stackoverflow.com/questions/12345647/rewrite-this-script-by-designing-an-interpreter-in-racket

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;;
;; See: http://stackoverflow.com/questions/12345647/rewrite-this-script-by-designing-an-interpreter-in-racket

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
top : ("start" | "atok")+

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
## Statlist grammar

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
start: next
next: "0"

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
/top : sub
sub : "x"

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
/top : sub
/sub : "x"

@ -1,3 +1,3 @@
#lang brag
#lang yaragg
/top : sub
@sub : "x"

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
start: (tab | space | newline | letter | return | all)*
tab: '\t'
space: " "

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;; A parser for a silly language
sentence: verb optional-adjective object
verb: greeting

@ -36,7 +36,7 @@
;; errors with position are sensitive to length of lang line
(define lang-line "#lang brag")
(define lang-line "#lang yaragg")
(check-compile-error (format "~a" lang-line)
"The grammar does not appear to have any rules")
@ -52,34 +52,34 @@
(check-compile-error "#lang brag\n x: NUMBER\nx:STRING"
(check-compile-error "#lang yaragg\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 brag\nx:y"
(check-compile-error "#lang yaragg\nx:y"
"Rule y has no definition")
(check-compile-error "#lang brag\nnumber : 1flarbl"
(check-compile-error "#lang yaragg\nnumber : 1flarbl"
"Rule 1flarbl has no definition")
(check-compile-error "#lang brag\nprogram: EOF"
(check-compile-error "#lang yaragg\nprogram: EOF"
"Token EOF is reserved and can not be used in a grammar")
;; Nontermination checks:
(check-compile-error "#lang brag\nx : x"
(check-compile-error "#lang yaragg\nx : x"
"Rule x has no finite derivation")
(check-compile-error #<<EOF
#lang brag
#lang yaragg
x : x y
y : "y"
EOF
@ -90,7 +90,7 @@ EOF
; This should be illegal too:
(check-compile-error #<<EOF
#lang brag
#lang yaragg
a : "a" b
b : a | b
EOF
@ -100,7 +100,7 @@ EOF
(check-compile-error #<<EOF
#lang brag
#lang yaragg
a : [b]
b : [c]
c : c
@ -109,7 +109,7 @@ EOF
(check-compile-error #<<EOF
#lang brag
#lang yaragg
a : [b]
b : c
c : c
@ -118,7 +118,7 @@ EOF
(check-compile-error #<<EOF
#lang brag
#lang yaragg
a : [a]
b : [b]
c : c

@ -1,4 +1,4 @@
#lang brag
#lang yaragg
;; This used to fail when we had the yacc-based backend, but
;; cfg-parser seems to be ok with it.

@ -3,7 +3,7 @@
racket/date
file/md5
(for-label racket
brag
yaragg
yaragg/support
(only-in yaragg-parser-tools/lex lexer-src-pos)
(only-in syntax/parse syntax-parse ~literal)))
@ -26,12 +26,12 @@
@title{brag: a better Racket AST generator}
@title{Yaragg: Yet Another Racket AST-Generator Generator}
@author["Danny Yoo (95%)" "Matthew Butterick (5%)"]
@defmodulelang[brag]
@defmodulelang[yaragg]
@margin-note{This is a fork of the @link["https://docs.racket-lang.org/ragg"]{@racket[ragg]} package. It has a variety of bugfixes and new features. Some of these features have required new notation that's not necessarily compatible with all existing @racket[ragg] files.
@ -77,11 +77,11 @@ This BNF description is also known as a @deftech{grammar}. Just as it does in a
Have we made progress? We have a valid grammar. But we're still missing a @emph{parser}: a function that can use that description to make structures out of a sequence of tokens.
Meanwhile, it's clear that we don't yet have a valid program because there's no @litchar{#lang} line. Let's add one: put @litchar{#lang brag} at the top of the grammar, and save it as a file called @filepath{nested-word-list.rkt}.
Meanwhile, it's clear that we don't yet have a valid program because there's no @litchar{#lang} line. Let's add one: put @litchar{#lang yaragg} at the top of the grammar, and save it as a file called @filepath{nested-word-list.rkt}.
@filebox["nested-word-list.rkt"]{
@verbatim{
#lang brag
#lang yaragg
nested-word-list: WORD
| LEFT-PAREN nested-word-list* RIGHT-PAREN
}}
@ -151,7 +151,7 @@ to use:
@itemize[
@item{It provides a @litchar{#lang} for writing BNF grammars.
A module written in @litchar{#lang brag} automatically generates a
A module written in @litchar{#lang yaragg} automatically generates a
parser. The grammar controls the structure of the syntax objects it generates.}
@item{The language uses a few conventions to simplify the expression of
@ -226,7 +226,7 @@ Here's a first pass at expressing the structure of these line-drawing programs.
@filebox["simple-line-drawing.rkt"]{
@verbatim|{
#lang brag
#lang yaragg
drawing: rows*
rows: repeat chunk+ ";"
repeat: INTEGER
@ -674,7 +674,7 @@ generates.
@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
@litchar{#lang yaragg}, followed by a collection of @tech{rule}s and
possibly @tech{line comment}s or @tech{multiline comment}s.
A @deftech{rule} is a sequence consisting of: a @tech{rule identifier}, a separator (either @litchar{":"} or @litchar{"::="}), and a @tech{pattern}.
@ -726,7 +726,7 @@ A @deftech{pattern} is one of the following:
For example, in the following program:
@nested[#:style 'inset
@verbatim|{
#lang brag
#lang yaragg
;; A parser for a silly language
sentence: verb optional-adjective object
verb: greeting
@ -749,7 +749,7 @@ More examples:
BNF for binary
strings that contain an equal number of zeros and ones.
@verbatim|{
#lang brag
#lang yaragg
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.
@ -759,7 +759,7 @@ More examples:
@item{A BNF for
@link["http://www.json.org/"]{JSON}-like structures.
@verbatim|{
#lang brag
#lang yaragg
json: number | string
| array | object
number: NUMBER
@ -784,7 +784,7 @@ If the cut is applied to a right-hand pattern element, then that element is omit
For instance, consider this simple grammar for arithmetic expressions:
@verbatim|{
#lang brag
#lang yaragg
expr : term ('+' term)*
term : factor ('*' factor)*
factor : ("0" | "1" | "2" | "3"
@ -803,7 +803,7 @@ We get this parse tree:
Suppose we felt the @litchar{+} and @litchar{*} characters were superfluous. We can add cuts to the grammar by prefixing these pattern elements with @litchar{/}:
@verbatim|{
#lang brag
#lang yaragg
expr : term (/'+' term)*
term : factor (/'*' factor)*
factor : ("0" | "1" | "2" | "3"
@ -818,7 +818,7 @@ Our parse tree changes accordingly:
Now suppose we apply a cut on the rule name, @racket[factor]:
@verbatim|{
#lang brag
#lang yaragg
expr : term (/'+' term)*
term : factor (/'*' factor)*
/factor : ("0" | "1" | "2" | "3"
@ -839,7 +839,7 @@ If the splice is applied to a right-hand pattern element, that element is splice
Suppose we remove the cut from the @racket[factor] rule name and instead splice the second appearance of @racket[factor] in the pattern for the @racket[term] rule:
@verbatim|{
#lang brag
#lang yaragg
expr : term (/'+' term)*
term : factor (/'*' @factor)*
factor : ("0" | "1" | "2" | "3"
@ -854,7 +854,7 @@ The @racket[factor] elements matching the first position of the @racket[term] pa
Finally, suppose we add a splice to the @racket[term] rule name:
@verbatim|{
#lang brag
#lang yaragg
expr : term (/'+' term)*
@term : factor (/'*' @factor)*
factor : ("0" | "1" | "2" | "3"
@ -875,7 +875,7 @@ Caveat for the top-level rule: though the rule name can have a cut, it cannot ha
@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 brag} will consider
are a few other classes of situations that @litchar{#lang yaragg} will consider
as syntax errors.
@tt{brag} will raise a syntax error if the grammar:
@ -888,7 +888,7 @@ as syntax errors.
following program:
@nested[#:style 'code-inset
@verbatim|{
#lang brag
#lang yaragg
foo: [bar]
}|
]
@ -904,7 +904,7 @@ as syntax errors.
program:
@nested[#:style 'code-inset
@verbatim|{
#lang brag
#lang yaragg
infinite-a: "a" infinite-a
}|
]
@ -918,7 +918,7 @@ grammars.
@subsection{Semantics}
A program written in @litchar{#lang brag} produces a module that provides a few
A program written in @litchar{#lang yaragg} produces a module that provides a few
bindings. The most important of these is @racket[parse]:
@defproc[(parse [source-path any/c #f]
@ -994,7 +994,7 @@ Thus, it's only the presence of @tech{rule identifier}s in a rule's
@filepath{simple-arithmetic-grammar.rkt}:
@filebox["simple-arithmetic-grammar.rkt"]{
@verbatim|{
#lang brag
#lang yaragg
expr : term ('+' term)*
term : factor ('*' factor)*
factor : INT

Loading…
Cancel
Save