spec.scm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ;;; Brainfuck for GNU Guile.
  2. ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
  3. ;; This library is free software; you can redistribute it and/or
  4. ;; modify it under the terms of the GNU Lesser General Public
  5. ;; License as published by the Free Software Foundation; either
  6. ;; version 3 of the License, or (at your option) any later version.
  7. ;;
  8. ;; This library is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. ;; Lesser General Public License for more details.
  12. ;;
  13. ;; You should have received a copy of the GNU Lesser General Public
  14. ;; License along with this library; if not, write to the Free Software
  15. ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. ;; 02110-1301 USA
  17. ;;; Code:
  18. (define-module (language brainfuck spec)
  19. #:use-module (language brainfuck compile-tree-il)
  20. #:use-module (language brainfuck compile-scheme)
  21. #:use-module (language brainfuck parse)
  22. #:use-module (system base language)
  23. #:export (brainfuck))
  24. ; The new language is integrated into Guile via this (define-language)
  25. ; specification in the special module (language [lang] spec).
  26. ; Provided is a parser-routine in #:reader, a output routine in #:printer
  27. ; and one or more compiler routines (as target-language - routine pairs)
  28. ; in #:compilers. This is the basic set of fields needed to specify a new
  29. ; language.
  30. (define-language brainfuck
  31. #:title "Brainfuck"
  32. #:reader (lambda (port env) (read-brainfuck port))
  33. #:compilers `((tree-il . ,compile-tree-il)
  34. (scheme . ,compile-scheme))
  35. #:printer write
  36. )