diff --git a/make.scm b/make.scm index 226c35b3..297f8076 100755 --- a/make.scm +++ b/make.scm @@ -551,6 +551,7 @@ exec ${GUILE-guile} --no-auto-compile -L . -L guile -C . -C guile -s "$0" ${1+"$ "module/nyacc/lalr.mes" "module/nyacc/lang/c99/cpp.mes" "module/nyacc/lang/c99/parser.mes" + "module/nyacc/lang/c99/pprint.mes" "module/nyacc/lang/calc/parser.mes" "module/nyacc/lang/util.mes" "module/nyacc/lex.mes" diff --git a/module/language/c99/info.mes b/module/language/c99/info.mes index 933a4ed5..510b738f 100644 --- a/module/language/c99/info.mes +++ b/module/language/c99/info.mes @@ -96,22 +96,24 @@ (cons continue))))) (define (make-type type size pointer description) - (list type size pointer description)) + (list 'type* type size pointer description)) +(define (type? o) (and (pair? o) (eq? (car o) 'type*))) +(define type:type cadr) +(define type:size caddr) +(define type:pointer cadddr) +(define caddddr (compose cadddr cdr)) +(define type:description caddddr) -(define type:type car) -(define type:size cadr) -(define type:pointer caddr) -(define type:description cadddr) - -(define (make-global name type pointer value) - (cons name (list type pointer value))) - -(define global:type car) -(define global:pointer cadr) -(define global:value caddr) +(define (make-global type pointer value) + (list 'global* type pointer value)) +(define (global? o) (and (pair? o) (eq? (car o) 'global*))) +(define global:type cadr) +(define global:pointer caddr) +(define global:value cadddr) (define (make-local type pointer id) - (list type pointer id)) -(define local:type car) -(define local:pointer cadr) -(define local:id caddr) + (list 'local* type pointer id)) +(define (local? o) (and (pair? o) (eq? (car o) 'local*))) +(define local:type cadr) +(define local:pointer caddr) +(define local:id cadddr) diff --git a/module/nyacc/lang/c99/pprint.mes b/module/nyacc/lang/c99/pprint.mes new file mode 100644 index 00000000..39ce15ff --- /dev/null +++ b/module/nyacc/lang/c99/pprint.mes @@ -0,0 +1,38 @@ +;;; -*-scheme-*- + +;;; Mes --- Maxwell Equations of Software +;;; Copyright © 2017 Jan Nieuwenhuizen +;;; +;;; This file is part of Mes. +;;; +;;; Mes is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; Mes is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Mes. If not, see . + +;;; Commentary: + +;;; Code: + +(mes-use-module (mes guile)) +(mes-use-module (mes optargs)) +;;(mes-use-module (srfi srfi-1)) +;;(mes-use-module (nyacc lang util)) +;;(mes-use-module (sxml match)) +;;(mes-use-module (mes pretty-print)) + +;;(include-from-path "nyacc/lang/c99/pprint.scm") + +;; mes does not have (sxml match), short-circuit me +(define* (pretty-print-c99 tree + #:optional (port (current-output-port)) + #:key ugly per-line-prefix (basic-offset 2)) + (write tree port))