-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
(define-grammar <operator> | ||
(var (let name identifier)) | ||
(ap (let target operator) | ||
(let arg-entries-group (one-or-more "(" arg-entries ")"))) | ||
(sequence-begin (let sequence sequence)) | ||
(car "car" "(" (let target exp) ")") | ||
(cdr "cdr" "(" (let target exp) ")") | ||
(dot-field (let target operator) "." (let name identifier)) | ||
(dot-method | ||
(let target operator) "." (let name identifier) | ||
(let arg-entries-group (one-or-more "(" arg-entries ")"))) | ||
(recursion | ||
"recursion" "(" (let target exp) ")" | ||
"{" (let case-entries (zero-or-more case-entry)) "}") | ||
(induction | ||
"induction" "(" (let target exp) ")" | ||
"{" "motive" (let motive "exp") | ||
(let case-entries (zero-or-more case-entry)) "}")) | ||
|
||
(define-grammar <operator> | ||
[var (let name <identifier>) => (Exp::Var (match-string name))] | ||
[ap (let target <operator>) | ||
(let arg-entries-group (one-or-more "(" <arg-entries> ")")) | ||
=> (Exp::Ap (match <exp> target) | ||
(match-list ...))] | ||
[sequence-begin (let sequence <sequence>) | ||
=> (Exp::Sequence (match <sequence> sequence))] | ||
[car "car" "(" (let target <exp>) ")" | ||
=> (Exp::Car (match <exp> target))] | ||
[cdr "cdr" "(" (let target <exp>) ")" | ||
=> (Exp::Cdr (match <exp> target))] | ||
[dot-field (let target <operator>) "." (let name <identifier>) | ||
=> (Exp::Dot (match <exp> target) (match <identifier> name))] | ||
[dot-method | ||
(let target <operator>) "." (let name <identifier>) | ||
(let arg-entries-group (one-or-more "(" <arg-entries> ")"))] | ||
[recursion | ||
"recursion" "(" (let target <exp>) ")" | ||
"{" (let case-entries (zero-or-more <case-entry>)) "}"] | ||
[induction | ||
"induction" "(" (let target exp) ")" | ||
"{" "motive" (let motive "exp") | ||
(let case-entries (zero-or-more <case-entry>)) "}"]) | ||
|
||
(define-grammar <operator> | ||
[var (let name <identifier>) => (Exp::Var name)] | ||
[ap (let target <operator>) | ||
(let arg-entries-group (one-or-more "(" <arg-entries> ")")) | ||
=> (Exp::Ap target | ||
(TODO arg-entries-group))] | ||
[sequence-begin (let sequence <sequence>) | ||
=> (Exp::Sequence sequence)] | ||
[car "car" "(" (let target <exp>) ")" | ||
=> (Exp::Car target)] | ||
[cdr "cdr" "(" (let target <exp>) ")" | ||
=> (Exp::Cdr target)] | ||
[dot-field (let target <operator>) "." (let name <identifier>) | ||
=> (Exp::Dot target name)] | ||
[dot-method | ||
(let target <operator>) "." (let name <identifier>) | ||
(let arg-entries-group (one-or-more "(" <arg-entries> ")"))] | ||
[recursion | ||
"recursion" "(" (let target <exp>) ")" | ||
"{" (let case-entries (zero-or-more <case-entry>)) "}"] | ||
[induction | ||
"induction" "(" (let target exp) ")" | ||
"{" "motive" (let motive "exp") | ||
(let case-entries (zero-or-more <case-entry>)) "}"]) |