|
|
|
@ -25,13 +25,39 @@
|
|
|
|
|
(lhs-id (p 1) (p 5) "expr" #f)
|
|
|
|
|
(pattern-token (p 8) (p 13) "COLON" #f))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : <COLON> COLON")))
|
|
|
|
|
(list (rule (p 1) (p 21)
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "!expr : COLON")))
|
|
|
|
|
(list (rule (p 1) (p 14)
|
|
|
|
|
(lhs-id (p 1) (p 6) "expr" ''hide)
|
|
|
|
|
(pattern-token (p 9) (p 14) "COLON" #f))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "@expr : COLON")))
|
|
|
|
|
(list (rule (p 1) (p 14)
|
|
|
|
|
(lhs-id (p 1) (p 6) "expr" ''splice)
|
|
|
|
|
(pattern-token (p 9) (p 14) "COLON" #f))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : !COLON COLON")))
|
|
|
|
|
(list (rule (p 1) (p 20)
|
|
|
|
|
(lhs-id (p 1) (p 5) "expr" #f)
|
|
|
|
|
(pattern-seq (p 8) (p 20)
|
|
|
|
|
(list
|
|
|
|
|
(pattern-token (p 8) (p 14) "COLON" 'hide)
|
|
|
|
|
(pattern-token (p 15) (p 20) "COLON" #f))))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : !thing COLON")))
|
|
|
|
|
(list (rule (p 1) (p 20)
|
|
|
|
|
(lhs-id (p 1) (p 5) "expr" #f)
|
|
|
|
|
(pattern-seq (p 8) (p 20)
|
|
|
|
|
(list
|
|
|
|
|
(pattern-id (p 8) (p 14) "thing" 'hide)
|
|
|
|
|
(pattern-token (p 15) (p 20) "COLON" #f))))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : @thing COLON")))
|
|
|
|
|
(list (rule (p 1) (p 20)
|
|
|
|
|
(lhs-id (p 1) (p 5) "expr" #f)
|
|
|
|
|
(pattern-seq (p 8) (p 21)
|
|
|
|
|
(pattern-seq (p 8) (p 20)
|
|
|
|
|
(list
|
|
|
|
|
(pattern-token (p 8) (p 15) "COLON" #t)
|
|
|
|
|
(pattern-token (p 16) (p 21) "COLON" #f))))))
|
|
|
|
|
(pattern-id (p 8) (p 14) "thing" 'splice)
|
|
|
|
|
(pattern-token (p 15) (p 20) "COLON" #f))))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : 'hello'*")))
|
|
|
|
|
(list (rule (p 1) (p 16)
|
|
|
|
@ -47,11 +73,11 @@
|
|
|
|
|
1
|
|
|
|
|
(pattern-lit (p 8) (p 15) "hello" #f)))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : [<'hello'>]")))
|
|
|
|
|
(list (rule (p 1) (p 19)
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : [!'hello']")))
|
|
|
|
|
(list (rule (p 1) (p 18)
|
|
|
|
|
(lhs-id (p 1) (p 5) "expr" #f)
|
|
|
|
|
(pattern-maybe (p 8) (p 19)
|
|
|
|
|
(pattern-lit (p 9) (p 18) "hello" #t)))))
|
|
|
|
|
(pattern-maybe (p 8) (p 18)
|
|
|
|
|
(pattern-lit (p 9) (p 17) "hello" 'hide)))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : COLON | BLAH")))
|
|
|
|
|
(list (rule (p 1) (p 20)
|
|
|
|
@ -70,13 +96,12 @@
|
|
|
|
|
(list (pattern-token (p 23) (p 26) "BAZ" #f)
|
|
|
|
|
(pattern-id (p 27) (p 31) "expr" #f))))))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : one two <three>")))
|
|
|
|
|
(list (rule (p 1) (p 23)
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : one two !three")))
|
|
|
|
|
(list (rule (p 1) (p 22)
|
|
|
|
|
(lhs-id (p 1) (p 5) "expr" #f)
|
|
|
|
|
(pattern-seq (p 8) (p 23) (list (pattern-id (p 8) (p 11) "one" #f)
|
|
|
|
|
(pattern-seq (p 8) (p 22) (list (pattern-id (p 8) (p 11) "one" #f)
|
|
|
|
|
(pattern-id (p 12) (p 15) "two" #f)
|
|
|
|
|
(pattern-id (p 16) (p 23) "three" #t))))))
|
|
|
|
|
|
|
|
|
|
(pattern-id (p 16) (p 22) "three" 'hide))))))
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : (one two three)")))
|
|
|
|
|
(list (rule (p 1) (p 23)
|
|
|
|
@ -85,7 +110,6 @@
|
|
|
|
|
(pattern-id (p 13) (p 16) "two" #f)
|
|
|
|
|
(pattern-id (p 17) (p 22) "three" #f))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(check-equal? (grammar-parser (tokenize (open-input-string "expr : one two* three")))
|
|
|
|
|
(list (rule (p 1) (p 22)
|
|
|
|
|
(lhs-id (p 1) (p 5) "expr" #f)
|
|
|
|
|