UNB/ CS/ David Bremner/ teaching/ cs3613/ code/ doge-driver.rkt
#lang plai

(require "doge-grammar.rkt")
(require "doge-lexer.rkt")

(define (string->sexpr str)
  (syntax->datum (parse (tokenize-string str))))

(define (catch-parse-error str)
  (with-handlers ([exn:fail? (lambda (v) 'fail)])
    (string->sexpr str)))


(test
 (string->sexpr "wow. such language. very tricky. wow.") 
 '(doge "wow" "." "such" (subject "language") "." "very" (adjective "tricky") "." "wow" "."))

(test
 (string->sexpr "wow. such course. very tricky. wow.") 
 '(doge "wow" "." "such" (subject "course") "." "very" (adjective "tricky") "." "wow" "."))

(test
 (string->sexpr "wow. such course. very difficult. wow.") 
 '(doge "wow" "." "such" (subject "course") "." "very" (adjective "difficult") "." "wow" "."))

(test
 (string->sexpr "wow. such prof. very mean. wow.") 
 '(doge "wow" "." "such" (subject "prof") "." "very" (adjective "mean") "." "wow" "."))