; This function creates and tests DFAs built ; from regular grammars corresponding to ; the following regular expressions ; (where brackets are used for optionality): ; l(l+n)* ; ln* ; in + out + in_out ; dd* + dd*.d* ; [-](dd* + dd*.dd*e[-]dd) (define test-cases '( (build-DFA-from-grammar '((S #\l A) (S #\l) (A #\l A) (A #\l) (A #\n A) (A #\n))) (test-string "l") (test-string "ll") (test-string "ln") (test-string "lnnn") (test-string "llnnn") (test-string "lnnln") (test-string "lxnnn") (test-string "nnn") (test-string "nlnl") (build-DFA-from-grammar '((S #\l A) (S #\l) (A #\n A) (A #\n))) (test-string "l") (test-string "ln") (test-string "lnnn") (test-string "ll") (test-string "nnn") (test-string "llnnn") (test-string "lnnln") (test-string "lxnnn") (build-DFA-from-grammar '((S #\i A) (S #\o B) (A #\n C) (A #\n) (C #\_ D) (D #\o B) (B #\u E) (E #\t))) (test-string "in") (test-string "out") (test-string "in_out") (test-string "in_") (test-string "out_in") (test-string "i") (test-string "on") (build-DFA-from-grammar '((S #\d A) (S #\d) (A #\d A) (A #\d) (A #\. B) (A #\.) (B #\d B) (B #\d))) (test-string "d") (test-string "dd") (test-string "ddd") (test-string "dddd") (test-string "d.d") (test-string "d.dd") (test-string "dd.") (test-string ".dd") (test-string "d.d.d") (test-string "dd..dd") (build-DFA-from-grammar '((S #\d A) (S #\d) (S #\- B) (A #\d A) (A #\d) (B #\d A) (B #\d) (A #\. C) (B #\d) (C #\d D) (C #\d) (D #\d D) (D #\d) (D #\e E) (E #\- F) (E #\d H) (F #\d G) (G #\d) (H #\d) )) (test-string "d") (test-string "dd") (test-string "ddd") (test-string "dddd") (test-string "-d") (test-string "d.d") (test-string "-d.d") (test-string "d.dd") (test-string "-d.dd") (test-string "ddd.dd") (test-string "dd.dedd") (test-string "-ddd.dde-dd") (test-string "dd.") (test-string ".dd") (test-string "-.d") (test-string "d-dd") (test-string "d.d.d") (test-string "ddedd") (test-string "d.ded.d") (test-string "dd.de-d") (test-string "ddd.ddeddd") (test-string "dd.ded.dedd") )) ; This function merely takes the elements of ; the list test-cases and prints their ; values on separate lines (define (test) (for-each (lambda (x) (display (eval x)) (newline)) test-cases))