#!/usr/bin/env guile
!#
;; calc.scm - calculator
;;
;; Copyright (C) 2015,2017 Matthew R. Wette
;; 
;; Copying and distribution of this file, with or without modification,
;; are permitted in any medium without royalty provided the copyright
;; notice and this notice are preserved.  This file is offered as-is,
;; without any warranty.

(add-to-load-path (string-append (getcwd) "/../../../../module"))
(add-to-load-path (string-append (getcwd) "/../../../../examples"))

(use-modules (nyacc lalr))
(use-modules (nyacc lex))
(use-modules (nyacc parse))

(define simple-spec
  (lalr-spec
   (prec< (left "+" "-") (left "*" "/"))
   (start expr)
   (grammar
    (expr
     (expr "+" expr ($$ (+ $1 $3)))
     (expr "-" expr ($$ (- $1 $3)))
     (expr "*" expr ($$ (* $1 $3)))
     (expr "/" expr ($$ (/ $1 $3)))
     ("*" $error)
     ($fixed ($$ (string->number $1)))
     ($float ($$ (string->number $1)))
     ("(" expr ")" ($$ $2))))))

(define simple-mach (make-lalr-machine simple-spec))
(define match-table (assq-ref simple-mach 'mtab))
(define gen-lexer (make-lexer-generator match-table))
(define parse (make-lalr-ia-parser simple-mach))

(let iter ((cmd ""))
  (if 

;; --- last line ---
