From 5b05b64a2a658c0f7d4eb5b09fa342c7375a776e Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Thu, 11 Apr 2013 00:03:50 -0400 Subject: Init --- hw05_arith_scanner.scm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 hw05_arith_scanner.scm (limited to 'hw05_arith_scanner.scm') diff --git a/hw05_arith_scanner.scm b/hw05_arith_scanner.scm new file mode 100644 index 0000000..f15833f --- /dev/null +++ b/hw05_arith_scanner.scm @@ -0,0 +1,38 @@ +#lang eopl + +;; ::== { }* +;; ::== { }* +;; ::== +;; ::== ( ) +;; ::== + | - +;; ::== * | / + +(define arith-scanner + '( + (add-op (or "+" "-") symbol) + (mult-op (or "*" "/") symbol) + (number (digit (arbno digit)) number) + )) + +(define arith-grammar + '( + (expression (number) arith-factor) + ;(expression (number add-op number) arith-factor) + ;(expression (expression add-op expression) arith-factor) + )) + +(sllgen:make-define-datatypes arith-scanner arith-grammar) + +(define list-the-datatypes + (lambda () + (sllgen:list-define-datatypes arith-scanner arith-grammar))) + +(define just-scan + (sllgen:make-string-scanner arith-scanner '())) + +(define scan&parse + (sllgen:make-string-parser arith-scanner arith-grammar) ) + +(define read-eval-print + (sllgen:make-rep-loop "--> " stmt-evaluator + (sllgen:make-stream-parser arith-scanner arith-grammar) )) \ No newline at end of file -- cgit v1.2.3