-
-
Save wilbowma/5054403 to your computer and use it in GitHub Desktop.
A demonstration of a merging nonterminals in define-union-language
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
#lang racket | |
(provide LMerge) | |
(require redex/reduction-semantics | |
(only-in redex/private/matcher compiled-lang-lang)) | |
(define-language LBase | |
(e (+ e e) | |
number)) | |
(define-extended-language L1 LBase | |
(e .... | |
(- e e))) | |
(define-extended-language L2 LBase | |
(e .... | |
(* e e))) | |
;; Untagged merge of two languages that define the same nonterminal | |
(define-union-language LMerge L1 L2) | |
;; Tagged merge of two extended languages that define the same | |
;; nonterminal | |
(define-union-language LMerge2 (f. L1) (d. L2)) | |
(redex-match? LBase e (term (+ 1 1))) | |
(redex-match? LMerge e (term (* 1 1))) | |
(redex-match? LMerge e (term (- 1 1))) | |
(redex-match? LMerge e (term (+ 1 1))) | |
(redex-match? LMerge e (term (^ 1 1))) | |
(compiled-lang-lang LMerge) | |
(compiled-lang-lang LMerge2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment