generated from jackfirth/racket-package-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce refactoring rule grammar more rigorously
- Loading branch information
Showing
2 changed files
with
90 additions
and
10 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,77 @@ | ||
#lang racket/base | ||
|
||
|
||
(provide syntax-parse-option | ||
syntax-parse-pattern-directive) | ||
|
||
|
||
(require syntax/parse) | ||
|
||
|
||
;@---------------------------------------------------------------------------------------------------- | ||
|
||
|
||
(define-splicing-syntax-class syntax-parse-option | ||
(pattern (~seq #:context ~! context-expr:expr)) | ||
(pattern (~seq #:literals ~! (literal:syntax-parse-literal ...))) | ||
(pattern (~seq #:datum-literals ~! (datum-literal:syntax-parse-datum-literal ...))) | ||
(pattern (~seq #:literal-sets ~! (literal-set:syntax-parse-literal-set ...))) | ||
(pattern #:track-literals) | ||
(pattern (~seq #:conventions ~! (convention-id:id ...))) | ||
(pattern (~seq #:local-conventions ~! (convention-id:id ...))) | ||
(pattern #:disable-colon-notation)) | ||
|
||
|
||
(define-syntax-class syntax-parse-literal | ||
(pattern literal-id:id) | ||
(pattern (pattern-id:id literal-id:id)) | ||
(pattern (pattern-id:id literal-id:id #:phase phase-expr:expr))) | ||
|
||
|
||
(define-syntax-class syntax-parse-datum-literal | ||
(pattern literal-id:id) | ||
(pattern (pattern-id:id literal-id:id))) | ||
|
||
|
||
(define-syntax-class syntax-parse-literal-set | ||
(pattern literal-set-id:id) | ||
(pattern (literal-set-id:id literal-set-option:syntax-parse-literal-set-option ...))) | ||
|
||
|
||
(define-splicing-syntax-class syntax-parse-literal-set-option | ||
(pattern (~seq #:at context-id:id)) | ||
(pattern (~seq #:phase phase-expr:expr))) | ||
|
||
|
||
(define-splicing-syntax-class syntax-parse-pattern-directive | ||
(pattern (~seq #:declare ~! pvar-id:id | ||
(~or syntax-class-id:id (syntax-class-id:id arg ...)) | ||
(~optional (~seq #:role role-expr:expr)))) | ||
(pattern (~seq #:post ~! action-pattern:syntax-parse-action-pattern)) | ||
(pattern (~seq #:and ~! action-pattern:syntax-parse-action-pattern)) | ||
(pattern (~seq #:with ~! syntax-pattern stx-expr:expr)) | ||
(pattern (~seq #:attr ~! (~or attr-name-id:id (attr-name-id:id depth)) expr:expr)) | ||
(pattern (~seq #:fail-when ~! condition-expr:expr message-expr:expr)) | ||
(pattern (~seq #:fail-unless ~! condition-expr:expr message-expr:expr)) | ||
(pattern (~seq #:when ~! condition-expr:expr)) | ||
(pattern (~seq #:do ~! [defn-or-expr ...])) | ||
(pattern (~seq #:undo ~! [defn-or-expr ...])) | ||
(pattern #:cut)) | ||
|
||
|
||
(define-syntax-class syntax-parse-action-pattern | ||
#:literals (~! ~bind ~fail ~parse ~and ~do ~undo ~post) | ||
(pattern :~!) | ||
(pattern (:~bind [(~or attr-name-id:id (attr-name-id:id depth)) expr:expr] ...)) | ||
(pattern | ||
(:~fail (~optional fail-condition:syntax-parse-fail-condition) (~optional mesage-expr:expr))) | ||
(pattern (:~parse S-pattern stx-expr:expr)) | ||
(pattern (:~and A-pattern:syntax-parse-action-pattern ...+)) | ||
(pattern (:~do defn-or-expr ...)) | ||
(pattern (:~undo defn-or-expr ...)) | ||
(pattern (:~post A-pattern:syntax-parse-action-pattern))) | ||
|
||
|
||
(define-splicing-syntax-class syntax-parse-fail-condition | ||
(pattern (~seq #:when condition-expr:expr)) | ||
(pattern (~seq #:unless condition-expr:expr))) |
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