Use test submodules for yaragg lang tests
parent
5a90bb6551
commit
e7415fc690
@ -1,30 +1,31 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require yaragg/examples/01-equal
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/01-equal
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal? (syntax->datum (parse ""))
|
(check-equal? (syntax->datum (parse ""))
|
||||||
'(equal))
|
'(equal))
|
||||||
(check-equal? (syntax->datum (parse "01"))
|
(check-equal? (syntax->datum (parse "01"))
|
||||||
'(equal (zero (equal) "0")
|
'(equal (zero (equal) "0")
|
||||||
(one (equal) "1")))
|
(one (equal) "1")))
|
||||||
(check-equal? (syntax->datum (parse "10"))
|
(check-equal? (syntax->datum (parse "10"))
|
||||||
'(equal (one (equal) "1")
|
'(equal (one (equal) "1")
|
||||||
(zero (equal) "0")))
|
(zero (equal) "0")))
|
||||||
(check-equal? (syntax->datum (parse "0011"))
|
(check-equal? (syntax->datum (parse "0011"))
|
||||||
'(equal (zero (equal) "0")
|
'(equal (zero (equal) "0")
|
||||||
(one (equal (zero (equal) "0")
|
(one (equal (zero (equal) "0")
|
||||||
(one (equal) "1"))
|
(one (equal) "1"))
|
||||||
"1")))
|
"1")))
|
||||||
(check-equal? (syntax->datum (parse "0110"))
|
(check-equal? (syntax->datum (parse "0110"))
|
||||||
'(equal (one (equal (zero (equal) "0")
|
'(equal (one (equal (zero (equal) "0")
|
||||||
(one (equal) "1"))
|
(one (equal) "1"))
|
||||||
"1")
|
"1")
|
||||||
(zero (equal) "0")))
|
(zero (equal) "0")))
|
||||||
|
|
||||||
(check-equal? (syntax->datum (parse "1100"))
|
(check-equal? (syntax->datum (parse "1100"))
|
||||||
'(equal (one (equal) "1")
|
'(equal (one (equal) "1")
|
||||||
(zero (equal (one (equal) "1")
|
(zero (equal (one (equal) "1")
|
||||||
(zero (equal) "0"))
|
(zero (equal) "0"))
|
||||||
"0")))
|
"0"))))
|
||||||
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
#lang racket/base
|
|
||||||
|
|
||||||
(require yaragg/tests/test-0n1
|
|
||||||
yaragg/tests/test-0n1n
|
|
||||||
yaragg/tests/test-01-equal
|
|
||||||
yaragg/tests/test-baby-json
|
|
||||||
yaragg/tests/test-baby-json-hider
|
|
||||||
yaragg/tests/test-curly-quantifier
|
|
||||||
yaragg/tests/test-cutter
|
|
||||||
yaragg/tests/test-empty-symbol
|
|
||||||
yaragg/tests/test-errors
|
|
||||||
yaragg/tests/test-flatten
|
|
||||||
yaragg/tests/test-hide-and-splice
|
|
||||||
yaragg/tests/test-lexer
|
|
||||||
yaragg/tests/test-nested-repeats
|
|
||||||
yaragg/tests/test-old-token
|
|
||||||
yaragg/tests/test-parser
|
|
||||||
yaragg/tests/test-quotation-marks-and-backslashes
|
|
||||||
yaragg/tests/test-simple-arithmetic-grammar
|
|
||||||
yaragg/tests/test-simple-line-drawing
|
|
||||||
yaragg/tests/test-start-and-atok
|
|
||||||
yaragg/tests/test-top-level-cut
|
|
||||||
yaragg/tests/test-weird-grammar
|
|
||||||
yaragg/tests/test-whitespace
|
|
||||||
yaragg/tests/test-wordy
|
|
||||||
(submod yaragg/codegen/satisfaction test))
|
|
@ -1,10 +1,12 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require yaragg/examples/codepoints
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/codepoints
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal? (parse-to-datum '("\"A\\" "'c\\" "*d\\\"\\ef\"" "hello world"))
|
(check-equal? (parse-to-datum '("\"A\\" "'c\\" "*d\\\"\\ef\"" "hello world"))
|
||||||
'(start (A "\"A\\")
|
'(start (A "\"A\\")
|
||||||
(c "'c\\")
|
(c "'c\\")
|
||||||
(def "*d\\\"\\ef\"")
|
(def "*d\\\"\\ef\"")
|
||||||
(hello-world "hello world")))
|
(hello-world "hello world"))))
|
||||||
|
@ -1,28 +1,33 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/curly-quantifier
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/curly-quantifier
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-exn exn:fail:parsing? (λ () (parse-to-datum "a")))
|
(check-exn exn:fail:parsing? (λ () (parse-to-datum "a")))
|
||||||
(check-equal? (parse-to-datum "aa") '(start (a-rule "a" "a")))
|
(check-equal? (parse-to-datum "aa") '(start (a-rule "a" "a")))
|
||||||
(check-exn exn:fail:parsing? (λ () (parse-to-datum "aaa")))
|
(check-exn exn:fail:parsing? (λ () (parse-to-datum "aaa")))
|
||||||
|
|
||||||
(check-equal? (parse-to-datum "") '(start (b-rule)))
|
(check-equal? (parse-to-datum "") '(start (b-rule)))
|
||||||
(check-equal? (parse-to-datum "b") '(start (b-rule "b")))
|
(check-equal? (parse-to-datum "b") '(start (b-rule "b")))
|
||||||
(check-equal? (parse-to-datum "bb") '(start (b-rule "b" "b")))
|
(check-equal? (parse-to-datum "bb") '(start (b-rule "b" "b")))
|
||||||
(check-exn exn:fail:parsing? (λ () (parse-to-datum "bbb")))
|
(check-exn exn:fail:parsing? (λ () (parse-to-datum "bbb")))
|
||||||
|
|
||||||
(check-exn exn:fail:parsing? (λ () (parse-to-datum "c")))
|
(check-exn exn:fail:parsing? (λ () (parse-to-datum "c")))
|
||||||
(check-equal? (parse-to-datum "cc") '(start (c-rule "c" "c")))
|
(check-equal? (parse-to-datum "cc") '(start (c-rule "c" "c")))
|
||||||
(check-equal? (parse-to-datum "ccc") '(start (c-rule "c" "c" "c")))
|
(check-equal? (parse-to-datum "ccc") '(start (c-rule "c" "c" "c")))
|
||||||
(check-equal? (parse-to-datum "cccc") '(start (c-rule "c" "c" "c" "c")))
|
(check-equal? (parse-to-datum "cccc") '(start (c-rule "c" "c" "c" "c")))
|
||||||
|
|
||||||
(check-exn exn:fail:parsing? (λ () (parse-to-datum "d")))
|
(check-exn exn:fail:parsing? (λ () (parse-to-datum "d")))
|
||||||
(check-equal? (parse-to-datum "dd") '(start (d-rule "d" "d")))
|
(check-equal? (parse-to-datum "dd") '(start (d-rule "d" "d")))
|
||||||
(check-equal? (parse-to-datum "ddd") '(start (d-rule "d" "d" "d")))
|
(check-equal? (parse-to-datum "ddd") '(start (d-rule "d" "d" "d")))
|
||||||
(check-exn exn:fail:parsing? (λ () (parse-to-datum "dddd")))
|
(check-exn exn:fail:parsing? (λ () (parse-to-datum "dddd")))
|
||||||
|
|
||||||
(check-equal? (syntax->datum ((make-rule-parser e-rule) "")) '(e-rule)) ; to prevent ambiguity with b-rule while parsing empty string
|
; to prevent ambiguity with b-rule while parsing empty string
|
||||||
(check-equal? (parse-to-datum "e") '(start (e-rule "e")))
|
(check-equal? (syntax->datum ((make-rule-parser e-rule) "")) '(e-rule))
|
||||||
(check-equal? (parse-to-datum "ee") '(start (e-rule "e" "e")))
|
|
||||||
(check-equal? (parse-to-datum "eee") '(start (e-rule "e" "e" "e")))
|
(check-equal? (parse-to-datum "e") '(start (e-rule "e")))
|
||||||
|
(check-equal? (parse-to-datum "ee") '(start (e-rule "e" "e")))
|
||||||
|
(check-equal? (parse-to-datum "eee") '(start (e-rule "e" "e" "e"))))
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/cutter-another
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/cutter-another
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal? (parse-tree "w") '(top (w)))
|
(check-equal? (parse-tree "w") '(top (w)))
|
||||||
(check-equal? (parse-tree "x") '(top (x)))
|
(check-equal? (parse-tree "x") '(top (x)))
|
||||||
(check-equal? (parse-tree "yy") '(top (y)))
|
(check-equal? (parse-tree "yy") '(top (y)))
|
||||||
(check-equal? (parse-tree "z") '(top (z)))
|
(check-equal? (parse-tree "z") '(top (z)))
|
||||||
(check-equal? (parse-tree "a") '(top (a)))
|
(check-equal? (parse-tree "a") '(top (a)))
|
||||||
(check-equal? (parse-tree "bb") '(top (b)))
|
(check-equal? (parse-tree "bb") '(top (b)))
|
||||||
(check-equal? (parse-tree "c") '(top (c)))
|
(check-equal? (parse-tree "c") '(top (c))))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/cutter
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/cutter
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
;; related to rule-flattening problem
|
;; related to rule-flattening problem
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(parse-to-datum (list "(" "x" "," "x" ")"))
|
(parse-to-datum (list "(" "x" "," "x" ")"))
|
||||||
'(top (expr (list "(" (expr "x") "," (expr "x") ")"))))
|
'(top (expr (list "(" (expr "x") "," (expr "x") ")")))))
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/empty-symbol
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/empty-symbol
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-true (and (member (parse-to-datum "") (list '(top (xs)) '(top (ys)) '(top (zs)))) #t))
|
(check-true (and (member (parse-to-datum "") (list '(top (xs)) '(top (ys)) '(top (zs)))) #t))
|
||||||
|
|
||||||
;; x is normal
|
;; x is normal
|
||||||
(check-equal? (parse-to-datum "x") '(top (xs "x" (xs))))
|
(check-equal? (parse-to-datum "x") '(top (xs "x" (xs))))
|
||||||
(check-equal? (parse-to-datum "xx") '(top (xs "x" (xs "x" (xs)))))
|
(check-equal? (parse-to-datum "xx") '(top (xs "x" (xs "x" (xs)))))
|
||||||
(check-equal? (parse-to-datum "xxx") '(top (xs "x" (xs "x" (xs "x" (xs))))))
|
(check-equal? (parse-to-datum "xxx") '(top (xs "x" (xs "x" (xs "x" (xs))))))
|
||||||
|
|
||||||
;; y cuts
|
;; y cuts
|
||||||
(check-equal? (parse-to-datum "y") '(top (ys "y")))
|
(check-equal? (parse-to-datum "y") '(top (ys "y")))
|
||||||
(check-equal? (parse-to-datum "yy") '(top (ys "y")))
|
(check-equal? (parse-to-datum "yy") '(top (ys "y")))
|
||||||
(check-equal? (parse-to-datum "yyy") '(top (ys "y")))
|
(check-equal? (parse-to-datum "yyy") '(top (ys "y")))
|
||||||
|
|
||||||
;; z splices
|
;; z splices
|
||||||
(check-equal? (parse-to-datum "z") '(top (zs "z")))
|
(check-equal? (parse-to-datum "z") '(top (zs "z")))
|
||||||
(check-equal? (parse-to-datum "zz") '(top (zs "z" "z")))
|
(check-equal? (parse-to-datum "zz") '(top (zs "z" "z")))
|
||||||
(check-equal? (parse-to-datum "zzz") '(top (zs "z" "z" "z")))
|
(check-equal? (parse-to-datum "zzz") '(top (zs "z" "z" "z"))))
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/hide-and-splice
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/hide-and-splice
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
;; check that an id with both a splice and hide is handled correctly
|
;; check that an id with both a splice and hide is handled correctly
|
||||||
|
|
||||||
(check-equal? (parse-to-datum "xxx") '(top ("x" "x" "x")))
|
(check-equal? (parse-to-datum "xxx") '(top ("x" "x" "x")))
|
||||||
(check-equal? (parse-to-datum "yyy") '(top "y" "y" "y"))
|
(check-equal? (parse-to-datum "yyy") '(top "y" "y" "y")))
|
||||||
|
@ -1,75 +1,79 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/rules/lexer
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/rules/lexer
|
||||||
rackunit
|
rackunit
|
||||||
yaragg/parser-tools/lex)
|
yaragg/parser-tools/lex)
|
||||||
|
|
||||||
(define (l s)
|
(define (l s)
|
||||||
(define t (lex/1 (open-input-string s)))
|
(define t (lex/1 (open-input-string s)))
|
||||||
(list (token-name (position-token-token t))
|
(list (token-name (position-token-token t))
|
||||||
(token-value (position-token-token t))
|
(token-value (position-token-token t))
|
||||||
(position-offset (position-token-start-pos t))
|
(position-offset (position-token-start-pos t))
|
||||||
(position-offset (position-token-end-pos t))))
|
(position-offset (position-token-end-pos t))))
|
||||||
|
|
||||||
;; WARNING: the offsets are not in terms of file positions. So they
|
;; WARNING: the offsets are not in terms of file positions. So they
|
||||||
;; start counting at 1, not 0.
|
;; start counting at 1, not 0.
|
||||||
(check-equal? (l " hi")
|
(check-equal? (l " hi")
|
||||||
'(ID "hi" 2 4))
|
'(ID "hi" 2 4))
|
||||||
|
|
||||||
(check-equal? (l " hi")
|
(check-equal? (l " hi")
|
||||||
'(ID "hi" 3 5))
|
'(ID "hi" 3 5))
|
||||||
|
|
||||||
(check-equal? (l "hi")
|
(check-equal? (l "hi")
|
||||||
'(ID "hi" 1 3))
|
'(ID "hi" 1 3))
|
||||||
|
|
||||||
(check-equal? (l "# foobar\nhi")
|
(check-equal? (l "# foobar\nhi")
|
||||||
'(ID "hi" 10 12))
|
'(ID "hi" 10 12))
|
||||||
|
|
||||||
(check-equal? (l "# foobar\rhi")
|
(check-equal? (l "# foobar\rhi")
|
||||||
'(ID "hi" 10 12))
|
'(ID "hi" 10 12))
|
||||||
|
|
||||||
(check-equal? (l "# foobar\r\nhi")
|
(check-equal? (l "# foobar\r\nhi")
|
||||||
'(ID "hi" 11 13))
|
'(ID "hi" 11 13))
|
||||||
|
|
||||||
(check-equal? (l "hi:")
|
(check-equal? (l "hi:")
|
||||||
'(RULE_HEAD "hi:" 1 4))
|
'(RULE_HEAD "hi:" 1 4))
|
||||||
|
|
||||||
(check-equal? (l "hi :")
|
(check-equal? (l "hi :")
|
||||||
'(RULE_HEAD "hi :" 1 7))
|
'(RULE_HEAD "hi :" 1 7))
|
||||||
|
|
||||||
(check-equal? (l "|")
|
(check-equal? (l "|")
|
||||||
'(PIPE "|" 1 2))
|
'(PIPE "|" 1 2))
|
||||||
|
|
||||||
(check-equal? (l "(")
|
(check-equal? (l "(")
|
||||||
'(LPAREN "(" 1 2))
|
'(LPAREN "(" 1 2))
|
||||||
|
|
||||||
(check-equal? (l "[")
|
(check-equal? (l "[")
|
||||||
'(LBRACKET "[" 1 2))
|
'(LBRACKET "[" 1 2))
|
||||||
|
|
||||||
(check-equal? (l ")")
|
(check-equal? (l ")")
|
||||||
'(RPAREN ")" 1 2))
|
'(RPAREN ")" 1 2))
|
||||||
|
|
||||||
(check-equal? (l "]")
|
(check-equal? (l "]")
|
||||||
'(RBRACKET "]" 1 2))
|
'(RBRACKET "]" 1 2))
|
||||||
|
|
||||||
;; 220111: lexer now converts single-quoted lexemes
|
;; 220111: lexer now converts single-quoted lexemes
|
||||||
;; to standard Racket-style double-quoted string literal
|
;; to standard Racket-style double-quoted string literal
|
||||||
(check-equal? (l "'hello'")
|
(check-equal? (l "'hello'")
|
||||||
'(LIT "\"hello\"" 1 8))
|
'(LIT "\"hello\"" 1 8))
|
||||||
|
|
||||||
(check-equal? (l "'he\\'llo'")
|
(check-equal? (l "'he\\'llo'")
|
||||||
'(LIT "\"he'llo\"" 1 10))
|
'(LIT "\"he'llo\"" 1 10))
|
||||||
|
|
||||||
(check-equal? (l "/")
|
(check-equal? (l "/")
|
||||||
'(HIDE "/" 1 2))
|
'(HIDE "/" 1 2))
|
||||||
|
|
||||||
(check-equal? (l " /")
|
(check-equal? (l " /")
|
||||||
'(HIDE "/" 2 3))
|
'(HIDE "/" 2 3))
|
||||||
|
|
||||||
(check-equal? (l "@")
|
(check-equal? (l "@")
|
||||||
'(SPLICE "@" 1 2))
|
'(SPLICE "@" 1 2))
|
||||||
|
|
||||||
(check-equal? (l " @")
|
(check-equal? (l " @")
|
||||||
'(SPLICE "@" 2 3))
|
'(SPLICE "@" 2 3))
|
||||||
|
|
||||||
(check-equal? (l "#:prefix-out val:")
|
; lexer skips kwarg
|
||||||
(list 'EOF eof 18 18)) ; lexer skips kwarg
|
(check-equal? (l "#:prefix-out val:")
|
||||||
|
(list 'EOF eof 18 18)))
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require rackunit
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require rackunit
|
||||||
yaragg/support
|
yaragg/support
|
||||||
yaragg/examples/subrule)
|
yaragg/examples/subrule)
|
||||||
|
|
||||||
(define parse-next (make-rule-parser next))
|
(define parse-next (make-rule-parser next))
|
||||||
(define parse-start (make-rule-parser start))
|
(define parse-start (make-rule-parser start))
|
||||||
|
|
||||||
(check-equal? (syntax->datum (parse #f "0")) '(start (next "0")))
|
|
||||||
(check-equal? (syntax->datum (parse #f "0")) (syntax->datum (parse "0")))
|
|
||||||
|
|
||||||
(check-equal? (syntax->datum (parse-start #f "0")) '(start (next "0")))
|
(check-equal? (syntax->datum (parse #f "0")) '(start (next "0")))
|
||||||
(check-equal? (syntax->datum (parse-start #f "0")) (syntax->datum (parse-start "0")))
|
(check-equal? (syntax->datum (parse #f "0")) (syntax->datum (parse "0")))
|
||||||
|
|
||||||
(check-equal? (syntax->datum (parse-next #f "0")) '(next "0"))
|
(check-equal? (syntax->datum (parse-start #f "0")) '(start (next "0")))
|
||||||
(check-equal? (syntax->datum (parse-next #f "0")) (syntax->datum (parse-next "0")))
|
(check-equal? (syntax->datum (parse-start #f "0")) (syntax->datum (parse-start "0")))
|
||||||
|
|
||||||
|
(check-equal? (syntax->datum (parse-next #f "0")) '(next "0"))
|
||||||
|
(check-equal? (syntax->datum (parse-next #f "0")) (syntax->datum (parse-next "0"))))
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/nested-repeats
|
|
||||||
rackunit)
|
|
||||||
|
|
||||||
(check-equal?
|
(module+ test
|
||||||
(syntax->datum (parse (list "X" "Y" "X")))
|
|
||||||
'(start "X" "Y" "X"))
|
|
||||||
|
|
||||||
|
(require yaragg/examples/nested-repeats
|
||||||
|
rackunit)
|
||||||
|
|
||||||
|
(check-equal?
|
||||||
|
(syntax->datum (parse (list "X" "Y" "X")))
|
||||||
|
'(start "X" "Y" "X")))
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/quotation-marks-and-backslashes
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/quotation-marks-and-backslashes
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal? (parse-tree "a\"'\\a\"'\\") '(start "a" "\"" "'" "\\" "a" "\"" "'" "\\"))
|
(check-equal? (parse-tree "a\"'\\a\"'\\") '(start "a" "\"" "'" "\\" "a" "\"" "'" "\\")))
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require yaragg/examples/start-and-atok
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/start-and-atok
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
;; make sure that "start" and "atok" work as terminals.
|
;; make sure that "start" and "atok" work as terminals.
|
||||||
|
|
||||||
(check-equal? (parse-to-datum (list "start")) '(top "start"))
|
|
||||||
(check-equal? (parse-to-datum (list "atok")) '(top "atok"))
|
|
||||||
(check-equal? (parse-to-datum (list "start" "atok")) '(top "start" "atok"))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(check-equal? (parse-to-datum (list "start")) '(top "start"))
|
||||||
|
(check-equal? (parse-to-datum (list "atok")) '(top "atok"))
|
||||||
|
(check-equal? (parse-to-datum (list "start" "atok")) '(top "start" "atok")))
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require (prefix-in 1: yaragg/examples/top-level-cut-1)
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require (prefix-in 1: yaragg/examples/top-level-cut-1)
|
||||||
(prefix-in 2: yaragg/examples/top-level-cut-2)
|
(prefix-in 2: yaragg/examples/top-level-cut-2)
|
||||||
(prefix-in 3: yaragg/examples/top-level-cut-3)
|
(prefix-in 3: yaragg/examples/top-level-cut-3)
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal? (1:parse-to-datum "x") '((sub "x")))
|
(check-equal? (1:parse-to-datum "x") '((sub "x")))
|
||||||
(check-equal? (2:parse-to-datum "x") '(("x")))
|
(check-equal? (2:parse-to-datum "x") '(("x")))
|
||||||
(check-equal? (3:parse-to-datum "x") '("x"))
|
(check-equal? (3:parse-to-datum "x") '("x")))
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require yaragg/tests/weird-grammar
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/tests/weird-grammar
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal? (syntax->datum (parse '("foo")))
|
(check-equal? (syntax->datum (parse '("foo")))
|
||||||
'(foo "foo"))
|
'(foo "foo")))
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/whitespace
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/whitespace
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(parse-to-datum "\ty\n x\tz\r")
|
(parse-to-datum "\ty\n x\tz\r")
|
||||||
'(start (tab "\t") (letter "y") (newline "\n") (space " ") (letter "x") (tab "\t") (letter "z") (return "\r")))
|
'(start (tab "\t") (letter "y") (newline "\n") (space " ") (letter "x") (tab "\t") (letter "z") (return "\r")))
|
||||||
|
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(parse-to-datum "\t\n \t\r")
|
(parse-to-datum "\t\n \t\r")
|
||||||
'(start (tab "\t") (newline "\n") (space " ") (tab "\t") (return "\r")))
|
'(start (tab "\t") (newline "\n") (space " ") (tab "\t") (return "\r")))
|
||||||
|
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(parse-to-datum "\a\b\t\n\v\f\r\e")
|
(parse-to-datum "\a\b\t\n\v\f\r\e")
|
||||||
'(start (all "\a" "\b" "\t" "\n" "\v" "\f" "\r" "\e")))
|
'(start (all "\a" "\b" "\t" "\n" "\v" "\f" "\r" "\e"))))
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require yaragg/examples/wordy
|
|
||||||
|
(module+ test
|
||||||
|
|
||||||
|
(require yaragg/examples/wordy
|
||||||
yaragg/support
|
yaragg/support
|
||||||
rackunit)
|
rackunit)
|
||||||
|
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(syntax->datum
|
(syntax->datum
|
||||||
(parse (list "hello" "world")))
|
(parse (list "hello" "world")))
|
||||||
'(sentence (verb (greeting "hello")) (optional-adjective) (object "world")))
|
'(sentence (verb (greeting "hello")) (optional-adjective) (object "world")))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(syntax->datum
|
(syntax->datum
|
||||||
(parse (list "hola" "frumpy" (token 'WORLD "세계"))))
|
(parse (list "hola" "frumpy" (token 'WORLD "세계"))))
|
||||||
|
|
||||||
'(sentence (verb (greeting "hola")) (optional-adjective "frumpy") (object "세계")))
|
'(sentence (verb (greeting "hola")) (optional-adjective "frumpy") (object "세계"))))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue