nyacc: Unbundle.
* configure (check-version): Use keyword parameters, add #:command parameter. (main): Check for Nyacc. * INSTALL: Mention Nyacc as dependency. * make/guile.make (all-go): Compile in guile dir. * module/module.make (SCM_FILES): Remove Nyacc filters. * module/nyacc/BUGS: Remove. * module/nyacc/ChangeLog: Remove. * module/nyacc/README: Remove. * module/nyacc/README.nyacc: Remove. * module/nyacc/bison.scm: Remove. * module/nyacc/export.scm: Remove. * module/nyacc/import.scm: Remove. * module/nyacc/lalr.scm: Remove. * module/nyacc/lalr2.scm: Remove. * module/nyacc/lang/c99/README: Remove. * module/nyacc/lang/c99/body.scm: Remove. * module/nyacc/lang/c99/cpp.scm: Remove. * module/nyacc/lang/c99/cppmach.scm: Remove. * module/nyacc/lang/c99/mach.d/c99act.scm: Remove. * module/nyacc/lang/c99/mach.d/c99tab.scm: Remove. * module/nyacc/lang/c99/mach.d/c99xact.scm: Remove. * module/nyacc/lang/c99/mach.d/c99xtab.scm: Remove. * module/nyacc/lang/c99/mach.d/cppact.scm: Remove. * module/nyacc/lang/c99/mach.d/cpptab.scm: Remove. * module/nyacc/lang/c99/mach.scm: Remove. * module/nyacc/lang/c99/parser.scm: Remove. * module/nyacc/lang/c99/pprint.scm: Remove. * module/nyacc/lang/c99/util1.scm: Remove. * module/nyacc/lang/c99/util2.scm: Remove. * module/nyacc/lang/c99/xparser.scm: Remove. * module/nyacc/lang/calc/parser.scm: Remove. * module/nyacc/lang/util.scm: Remove. * module/nyacc/lex.scm: Remove. * module/nyacc/parse.scm: Remove. * module/nyacc/util.scm: Remove.
This commit is contained in:
parent
ec935e5667
commit
c64691797b
4
INSTALL
4
INSTALL
|
@ -12,6 +12,9 @@ Building and Installing Mes
|
|||
guix environment --system=i686-linux -l guix.scm #32 bit only
|
||||
|
||||
** Other GNU/Linux
|
||||
*** Nyacc, 0.78.0 is known to work.
|
||||
Matt Wette's C99 LALR parser.
|
||||
|
||||
*** A C compiler, GNU Gcc 4.9.3 is known to work.
|
||||
The idea is to drop this requirement, of course.
|
||||
|
||||
|
@ -25,7 +28,6 @@ Not strictly necessary.
|
|||
*** /bin/sh, GNU Bash 4.3 is known to work.
|
||||
Let's just say for now that it gets awkward without a shell.
|
||||
|
||||
|
||||
*** Development (but see [[./guix.scm]])
|
||||
|
||||
*** GNU coreutils
|
||||
|
|
15
configure
vendored
15
configure
vendored
|
@ -17,7 +17,6 @@ Missing dependencies, run
|
|||
EOF
|
||||
exit 1
|
||||
fi
|
||||
unset GUILE_AUTO_COMPILE GUILE_LOAD_COMPILED_PATH
|
||||
exec ${GUILE} --no-auto-compile -L $(pwd) -e '(@@ (configure) main)' -s "$0" ${1+"$@"}
|
||||
!#
|
||||
|
||||
|
@ -119,12 +118,13 @@ exec ${GUILE} --no-auto-compile -L $(pwd) -e '(@@ (configure) main)' -s "$0" ${1
|
|||
(map string->number version)))
|
||||
|
||||
(define required '())
|
||||
(define* (check-version command expected
|
||||
#:optional
|
||||
(define* (check-version name expected
|
||||
#:key
|
||||
(deb #f)
|
||||
(version-option '--version)
|
||||
(compare tuple<=))
|
||||
(stderr "checking for ~a~a..." command
|
||||
(compare tuple<=)
|
||||
(command name))
|
||||
(stderr "checking for ~a~a..." name
|
||||
(if (null? expected) ""
|
||||
(format #f " [~a]" (version->string expected))))
|
||||
(let* ((output (gulp-pipe (format #f "~a ~a 2>&1" command version-option)))
|
||||
|
@ -133,8 +133,8 @@ exec ${GUILE} --no-auto-compile -L $(pwd) -e '(@@ (configure) main)' -s "$0" ${1
|
|||
(stderr "~a ~a\n" (if pass? (if (pair? actual) "" " yes")
|
||||
(if actual " no, found" "")) (version->string actual))
|
||||
(or pass?
|
||||
(if (not (pair? command)) (begin (set! required (cons (or deb command) required)) pass?)
|
||||
(check-version (cdr command) expected deb version-option compare)))))
|
||||
(if (not (pair? name)) (begin (set! required (cons (or deb name) required)) pass?)
|
||||
(check-version (cdr name) expected deb version-option compare)))))
|
||||
|
||||
(define* (check-pkg-config package expected #:optional (deb #f))
|
||||
(check-version (format #f "pkg-config --modversion ~a" package) expected deb))
|
||||
|
@ -205,6 +205,7 @@ Usage: ./configure [OPTION]...
|
|||
(check-version 'guile '(2 0))
|
||||
(check-version 'make '(4 0))
|
||||
(check-version 'perl '(5))
|
||||
(check-version 'nyacc '(0 78 0) #:command (string-append GUILE " -c '(use-modules (nyacc lalr)) (display *nyacc-version*)'"))
|
||||
|
||||
(when (pair? required)
|
||||
(stderr "\nMissing dependencies [~a], run\n\n" ((->string ", ") required))
|
||||
|
|
6
guix.scm
6
guix.scm
|
@ -50,6 +50,7 @@
|
|||
(gnu packages cross-base)
|
||||
(gnu packages gcc)
|
||||
(gnu packages guile)
|
||||
(gnu packages mes)
|
||||
(gnu packages package-management)
|
||||
(gnu packages perl)
|
||||
((guix build utils) #:select (with-directory-excursion))
|
||||
|
@ -93,11 +94,12 @@
|
|||
(url "https://gitlab.com/janneke/mes")
|
||||
(commit commit)))
|
||||
(file-name (string-append name "-" version))
|
||||
;; TODO: Unbundle nyacc.
|
||||
(sha256
|
||||
(base32 "1ynr0hc0k15307sgzv09k3y5rvy46h0wbh7zcblx1f9v7y8k90zv"))))
|
||||
(build-system gnu-build-system)
|
||||
(supported-systems '("x86_64-linux"))
|
||||
(propagated-inputs
|
||||
`(("nyacc" ,nyacc)))
|
||||
(native-inputs
|
||||
`(("guile" ,guile-2.2)
|
||||
;; Use cross-compiler rather than #:system "i686-linux" to get
|
||||
|
@ -126,7 +128,7 @@ prototype in C and a Nyacc-based C compiler in [Guile] Scheme.")
|
|||
(define-public mes.git
|
||||
(package
|
||||
(inherit mes)
|
||||
(name "mes.git")
|
||||
(name "mes")
|
||||
(version "git")
|
||||
(source (local-file %source-dir #:recursive? #t #:select? git-file?))))
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ all-go: SCM_FILES:=$(SCM_FILES)
|
|||
all-go: GUILE_FLAGS:=$(GUILE_FLAGS)
|
||||
all-go: $(SCM_FILES)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET)cd $(DIR) && srcdir=$(srcdir) host=$(host) $(GUILE) $(GUILE_FLAGS:guile=../guile) -s ../build-aux/compile-all.scm $(SCM_FILES:$(DIR)/%=%)
|
||||
$(QUIET)cd guile && srcdir=$(srcdir) host=$(host) $(GUILE) $(GUILE_FLAGS:guile=.) -s ../build-aux/compile-all.scm $(SCM_FILES:$(DIR)/%=%)
|
||||
|
||||
$(GO_FILES): all-go
|
||||
|
||||
|
|
|
@ -39,10 +39,6 @@ SCM_FILES:=$(filter-out %optargs.scm, $(SCM_FILES))
|
|||
SCM_FILES:=$(filter-out %pretty-print.scm, $(SCM_FILES))
|
||||
SCM_FILES:=$(filter-out %syntax.scm, $(SCM_FILES))
|
||||
SCM_FILES:=$(filter-out module/mes/peg/%.scm, $(SCM_FILES))
|
||||
SCM_FILES:=$(filter-out module/nyacc/lang/c99/body.scm, $(SCM_FILES))
|
||||
SCM_FILES:=$(filter-out module/nyacc/lang/c99/mach.d/%.scm, $(SCM_FILES))
|
||||
SCM_FILES:=$(filter-out module/nyacc/lang/c99/mach.scm, $(SCM_FILES))
|
||||
SCM_FILES:=$(filter-out module/nyacc/lang/c99/xparser.scm, $(SCM_FILES))
|
||||
include make/guile.make
|
||||
|
||||
# FIXME: https://gitlab.com/janneke/guile/commits/1.8
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
Copyright (C) 2016 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.
|
||||
|
||||
BUG-005 <= next bug id
|
||||
|
||||
BUG-004 Idea: use guile prompts to implement rollback parser
|
||||
|
||||
BUG-003 If using phony prec token then it ends up in match table.
|
||||
For example, "then" appears in the match table for lang/c99.
|
||||
|
||||
=fixed=
|
||||
|
||||
BUG-001 In lalr.scm, hashify-machine, if pat contains a rrconf then the output
|
||||
is unspecified
|
||||
todo I think this was already fixed
|
||||
|
||||
BUG-002 If mach has a conflict and hashify followed by pp-lalr-machine then
|
||||
error because hashify puts #f, not integer, for pat-v.
|
||||
fixed fixed pp-lalr-machine to check for #f
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
2017-05-06 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lalr.scm: updated write-lalr-tables and write-lalr-actions to
|
||||
accept a prefix string
|
||||
|
||||
2017-05-04 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/pprint.scm (pretty-print-c99): removed double spacing
|
||||
in printed declarations
|
||||
|
||||
* lang/util.scm (make-pp-formatter): fixed bug in column counting
|
||||
that prevented line-wrap to occur.
|
||||
|
||||
2017-04-12 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lex.scm (make-comm-reader): comments which end in newline can
|
||||
now also end in #<eof>
|
||||
|
||||
2017-03-11 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/parser.scm (parse-c99): added mode keyword argument to
|
||||
gen-c-lexer, file mode would not have been working ...
|
||||
|
||||
2017-03-03 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lalr.scm: added "keepers" keyword argument to compact-machine
|
||||
and also added $end as default
|
||||
|
||||
2017-02-28 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/pprint.scm: (binary 'd-del .. => (binary 'd-sel
|
||||
|
||||
2017-02-22 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/cpp.scm (rtokl->string): added handler for 'string
|
||||
|
||||
* lang/c99/body.scm: added 'skip state so that if skipping #if
|
||||
then no CPP if or elif arguments are evaluated
|
||||
|
||||
* lang/c99/cpp.scm: parse 0L numbers, convert c numbers (e.g.,
|
||||
123L) to scheme so that string->number works. I need to update
|
||||
cnumstr->snumstr in nyacc/lex.scm.
|
||||
|
||||
2017-02-16 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/cpp.scm (rtokl->string): now handled symb ## arg ## symb
|
||||
(scan-cpp-input): skip-il-ws after #\(
|
||||
|
||||
2017-01-18 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/parser.scm: check for EOF in end of CPP line
|
||||
|
||||
* lang/c99/mach.scm (c99-spec): decl for translation unit was
|
||||
updated to allow programs with no declarations or statements
|
||||
|
||||
2017-01-08 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* ../../test-suite/nyacc/lang/c99/exam.d/ex05.c: C99 does not
|
||||
allow lone `;' outside of functions. Removed.
|
||||
|
||||
2017-01-07 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/body.scm (read-cpp-line): cpp statement should not
|
||||
include newline? Changed to unread final newline.
|
||||
|
||||
* lang/util.scm: add report-error: prints msg w/ file, line
|
||||
|
||||
* parse.scm (make-lalr-parser): changed printout of parse error to
|
||||
(throw 'parse-error . args) and expect the full parser to catch
|
||||
the error
|
||||
|
||||
* lang/c99/mach.scm (c99-spec): from
|
||||
2017-01-07 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
mising unquote in output sx for goto: `(goto $2) => `(goto ,$2)
|
||||
|
||||
2017-01-06 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/parser.scm: default parser #:mode is now 'code; done
|
||||
since the CPP should now be working (??)
|
||||
|
||||
* lalr.scm (process-spec): in add-el changed memq to member since
|
||||
we are using strings for terminals
|
||||
|
||||
2017-01-02 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/mach.scm (c99-spec): added hooks (cpp-ok!, no-cpp!) to
|
||||
provide handshaking between parser and lexer wrt when the lexer
|
||||
can pass CPP statements to the parser
|
||||
|
||||
* lang/c99/cppbody.scm (expand-cpp-mref): skip ws between ident
|
||||
and left paren
|
||||
|
||||
2017-01-01 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/body.scm (gen-c-lexer): in code mode now expands includes
|
||||
|
||||
* lang/c99/pprint.scm (pretty-print-c99): added enum-dev w/o name
|
||||
|
||||
2016-11-25 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* added support for ellipsis to lang/c99/cpp.scm
|
||||
|
||||
2016-11-24 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* added (ellipsis) to lang/c99/pprint.scm
|
||||
|
||||
2016-04-09 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* bison.scm: new file providing make-lalr-machin/bison. It is
|
||||
similar to make-lalr-machine but uses external bison program
|
||||
instead of the default from-scratch lalr code.
|
||||
|
||||
2016-03-04 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lalr.scm: changed grammar parser to interpret $string as
|
||||
terminal. This saves typing a quote in front.
|
||||
|
||||
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.
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
nyacc/README
|
||||
|
||||
Copyright (C) 2016 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.
|
||||
|
||||
|
||||
strategy for generating parsers and other stuff
|
||||
|
||||
guile -s mach.scm -c '(@ (nyacc lang c99 mach) gen-mach-files)'
|
||||
=> .scm/{actions.scm,tables.scm}
|
||||
#guild compile
|
||||
|
||||
eval-when?
|
||||
|
||||
use-case: dist mach-files and parser
|
||||
|
||||
dist:
|
||||
mach.scm
|
||||
|
||||
|
||||
===============================================================================
|
||||
|
||||
dev-parser.scm: mach.scm pbody.scm mk-parser.scm
|
||||
parser.scm: mach.scm pbody.scm mk-parser.scm
|
||||
expr-parser.scm: mach.scm pbody.scm mk-parser.scm
|
||||
|
||||
$ guile -l cppmach.scm -c '(@ (nyacc lang c99 cppmach) gen-cpp-files)'
|
||||
> cppact.scm cpptab.scm
|
||||
|
||||
$ guile -l mach.scm -c '(@ (nyacc lang c99 mach) gen-c99-files)'
|
||||
> c99act.scm c99tab.scm
|
||||
|
||||
$ guile -l mach.scm -c '(@ (nyacc lang c99 mach) gen-c99x-files)'
|
||||
> c99xact.scm c99xtab.scm
|
||||
|
||||
===============================================================================
|
||||
|
||||
install:
|
||||
cpp.go
|
||||
mach.go
|
||||
parser.go
|
||||
xparser.go
|
||||
pprint.go
|
||||
util1.go
|
||||
util1.go
|
||||
|
||||
cpp.scm: cppmach.scm
|
||||
|
||||
#cppmach.scm (export-files
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
This is a version 0.76.5+jsdev of NYACC (Not Yet Another Compiler Compiler!).
|
||||
|
||||
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.
|
||||
|
||||
Full source distribution for NYACC is available at
|
||||
https://download.savannah.gnu.org/project/nyacc
|
||||
|
||||
This software package is covered by the following licenses:
|
||||
* GNU PUBLIC GENERAL LICENCE, version 3 (See COPYING.)
|
||||
* GNU LESSER PUBLIC GENERAL LICENCE, version 3 (See COPYING.LESSER.)
|
||||
* GNU Free Documentation License, version 1.3 (See doc/nyacc/COPYING.DOC.)
|
||||
|
||||
There is an incomplete manual in doc/nyacc/.
|
||||
|
||||
There is a demo program calc.scm in examples/nyacc/lang/calc. Easy starter:
|
||||
$ cd examples/nyacc/lang/calc
|
||||
$ ./calc
|
||||
2 + 2 => 4
|
||||
|
||||
The module code is in module/nyacc. Modules are imported as follows:
|
||||
(use-modules (nyacc lalr))
|
||||
(use-modules (nyacc lex))
|
||||
|
||||
If you have a personal guile directory then you can copy modules/nyacc
|
||||
to that directory. To install in the global guile distribution:
|
||||
user$ sudo -s
|
||||
root# cd module
|
||||
root# make -f Makefile.nyacc install
|
||||
root# exit
|
||||
user$
|
||||
|
||||
The syntax and nomenclature should be considered not stable.
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
;;; nyacc/bison.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2016 Matthew R. Wette
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library 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
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (nyacc bison)
|
||||
#:export (make-lalr-machine/bison)
|
||||
#:use-module (sxml simple)
|
||||
#:use-module (sxml match)
|
||||
#:use-module (sxml xpath)
|
||||
#:use-module (ice-9 pretty-print)
|
||||
#:use-module ((srfi srfi-1) #:select (fold))
|
||||
#:use-module ((srfi srfi-43) #:select (vector-for-each vector-map))
|
||||
#:use-module (nyacc export)
|
||||
#:use-module (nyacc lalr) ; gen-match-table
|
||||
)
|
||||
|
||||
;; @deffn chew-on-grammar tree lhs-v rhs-v terms => a-list
|
||||
;; Generate a-list that maps bison rule index to NYACC rule index.
|
||||
(define (chew-on-grammar tree lhs-v rhs-v terms) ;; bison-rule => nyacc-rule map
|
||||
|
||||
;; match rule index, if no match return @code{-1}
|
||||
;; could be improved by starting with last rule number and wrapping
|
||||
(define (match-rule lhs rhs)
|
||||
(let iter ((ix 0))
|
||||
(if (eqv? ix (vector-length lhs-v)) -1
|
||||
(if (and (equal? lhs (elt->bison (vector-ref lhs-v ix) terms))
|
||||
(equal? rhs (vector->list
|
||||
(vector-map
|
||||
(lambda (ix val) (elt->bison val terms))
|
||||
(vector-ref rhs-v ix)))))
|
||||
ix
|
||||
(iter (1+ ix))))))
|
||||
|
||||
;; this is a fold
|
||||
(define (rule->index-al tree seed)
|
||||
(sxml-match tree
|
||||
;; Skip first bison rule: always $accept.
|
||||
((rule (@ (number "0")) (lhs "$accept") . ,rest)
|
||||
(acons 0 0 seed))
|
||||
;; This matches all others.
|
||||
((rule (@ (number ,n)) (lhs ,lhs) (rhs (symbol ,rhs) ...))
|
||||
(acons (string->number n) (match-rule lhs rhs) seed))
|
||||
(,otherwise seed)))
|
||||
|
||||
(fold rule->index-al '() ((sxpath '(// rule)) tree)))
|
||||
|
||||
;; @deffn chew-on-automaton tree gx-al bs->ns => a-list
|
||||
;; This digests the automaton and generated the @code{pat-v} and @code{kis-v}
|
||||
;; vectors for the NYACC automaton.
|
||||
(define (chew-on-automaton tree gx-al bs->ns)
|
||||
|
||||
(define st-numb
|
||||
(let ((xsnum (sxpath '(@ number *text*))))
|
||||
(lambda (state)
|
||||
(string->number (car (xsnum state))))))
|
||||
|
||||
(define (do-state state)
|
||||
(let* ((b-items ((sxpath '(// item)) state))
|
||||
(n-items (fold
|
||||
(lambda (tree seed)
|
||||
(sxml-match tree
|
||||
((item (@ (rule-number ,rns) (point ,pts)) . ,rest)
|
||||
(let ((rn (string->number rns))
|
||||
(pt (string->number pts)))
|
||||
(if (and (positive? rn) (zero? pt)) seed
|
||||
(acons (assq-ref gx-al rn) pt seed))))
|
||||
(,otherwise (error "broken item")))) '() b-items))
|
||||
(b-trans ((sxpath '(// transition)) state))
|
||||
(n-trans (map
|
||||
(lambda (tree)
|
||||
(sxml-match tree
|
||||
((transition (@ (symbol ,symb) (state ,dest)))
|
||||
(cons* (bs->ns symb) 'shift (string->number dest)))
|
||||
(,otherwise (error "broken tran")))) b-trans))
|
||||
(b-redxs ((sxpath '(// reduction)) state))
|
||||
(n-redxs (map
|
||||
(lambda (tree)
|
||||
(sxml-match tree
|
||||
((reduction (@ (symbol ,symb) (rule "accept")))
|
||||
(cons* (bs->ns symb) 'accept 0))
|
||||
((reduction (@ (symbol ,symb) (rule ,rule)))
|
||||
(cons* (bs->ns symb) 'reduce
|
||||
(assq-ref gx-al (string->number rule))))
|
||||
(,otherwise (error "broken redx" tree)))) b-redxs))
|
||||
)
|
||||
(list
|
||||
(st-numb state)
|
||||
(cons 'kis n-items)
|
||||
(cons 'pat (append n-trans n-redxs)))))
|
||||
|
||||
(let ((xsf (sxpath '(itemset item (@ (rule-number (equal? "0"))
|
||||
(point (equal? "2")))))))
|
||||
(let iter ((data '()) (xtra #f) (states (cdr tree)))
|
||||
(cond
|
||||
((null? states) (cons xtra data))
|
||||
((pair? (xsf (car states)))
|
||||
(iter data (st-numb (car states)) (cdr states)))
|
||||
(else
|
||||
(iter (cons (do-state (car states)) data) xtra (cdr states)))))))
|
||||
|
||||
;; @deffn atomize symbol => string
|
||||
;; This is copied from the module @code{(nyacc lalr)}.
|
||||
(define (atomize terminal) ; from lalr.scm
|
||||
(if (string? terminal)
|
||||
(string->symbol (string-append "$:" terminal))
|
||||
terminal))
|
||||
|
||||
;; @deffn make-bison->nyacc-symbol-mapper terminals non-terminals => proc
|
||||
;; This generates a procedure to map bison symbol names, generated by the
|
||||
;; NYACC @code{lalr->bison} procedure, (back) to nyacc symbols names.
|
||||
(define (make-bison->nyacc-symbol-mapper terms non-ts)
|
||||
(let ((bs->ns-al
|
||||
(cons*
|
||||
'("$default" . $default)
|
||||
'("$end" . $end)
|
||||
(map (lambda (symb) (cons (elt->bison symb terms) symb))
|
||||
(append (map atomize terms) non-ts)))))
|
||||
(lambda (name) (assoc-ref bs->ns-al name))))
|
||||
|
||||
;; fix-pa
|
||||
;; fix parse action
|
||||
(define (fix-pa pa xs)
|
||||
(cond
|
||||
((and (eqv? 'shift (cadr pa))
|
||||
(> (cddr pa) xs))
|
||||
(cons* (car pa) (cadr pa) (1- (cddr pa))))
|
||||
((and (eqv? 'shift (cadr pa))
|
||||
(= (cddr pa) xs))
|
||||
(cons* (car pa) 'accept 0))
|
||||
(else pa)))
|
||||
|
||||
;; @deffn fix-is is xs rhs-v
|
||||
;; Convert xxx
|
||||
(define (fix-is is xs rhs-v)
|
||||
(let* ((gx (car is))
|
||||
(rx (cdr is))
|
||||
(gl (vector-length (vector-ref rhs-v gx))))
|
||||
(if (= rx gl) (cons gx -1) is)))
|
||||
|
||||
;; @deffn spec->mac-sxml spec
|
||||
;; Write bison-converted @var{spec} to file, run bison on it, and load
|
||||
;; the bison-generated automaton as a SXML tree using the @code{-x} option.
|
||||
(define (spec->mach-sxml spec)
|
||||
(let* ((basename (tmpnam))
|
||||
(bisname (string-append basename ".y"))
|
||||
(xmlname (string-append basename ".xml"))
|
||||
(tabname (string-append basename ".tab.c")))
|
||||
(with-output-to-file bisname
|
||||
(lambda () (lalr->bison spec)))
|
||||
(system (string-append "bison" " --xml=" xmlname " --output=" tabname
|
||||
" " bisname))
|
||||
(let ((sx (call-with-input-file xmlname
|
||||
(lambda (p) (xml->sxml p #:trim-whitespace? #t)))))
|
||||
(delete-file bisname)
|
||||
(delete-file xmlname)
|
||||
(delete-file tabname)
|
||||
sx)))
|
||||
|
||||
;; @deffn make-lalr-machine/bison spec => mach
|
||||
;; Make a LALR automaton, consistent with that from @code{make-lalr-machine}
|
||||
;; using external @code{bison} program.
|
||||
(define (make-lalr-machine/bison spec)
|
||||
(let* ((terminals (assq-ref spec 'terminals))
|
||||
(non-terms (assq-ref spec 'non-terms))
|
||||
(lhs-v (assq-ref spec 'lhs-v))
|
||||
(rhs-v (assq-ref spec 'rhs-v))
|
||||
(s0 (spec->mach-sxml spec))
|
||||
(sG ((sxpath '(bison-xml-report grammar)) s0))
|
||||
(sG (if (pair? sG) (car sG) sG))
|
||||
(sA ((sxpath '(bison-xml-report automaton)) s0))
|
||||
(sA (if (pair? sA) (car sA) sA))
|
||||
(pG (chew-on-grammar sG lhs-v rhs-v terminals))
|
||||
(bsym->nsym (make-bison->nyacc-symbol-mapper terminals non-terms))
|
||||
(pA (chew-on-automaton sA pG bsym->nsym))
|
||||
(xs (car pA))
|
||||
(ns (caadr pA))
|
||||
(pat-v (make-vector ns #f))
|
||||
(kis-v (make-vector ns #f))
|
||||
)
|
||||
;;(pretty-print sA)
|
||||
(for-each
|
||||
(lambda (state)
|
||||
(let* ((sx (car state))
|
||||
(sx (if (>= sx xs) (1- sx) sx))
|
||||
(pat (assq-ref (cdr state) 'pat))
|
||||
(pat (map (lambda (pa) (fix-pa pa xs)) pat))
|
||||
(kis (assq-ref (cdr state) 'kis))
|
||||
(kis (map (lambda (is) (fix-is is xs rhs-v)) kis)))
|
||||
(vector-set! pat-v sx pat)
|
||||
(vector-set! kis-v sx kis)))
|
||||
(cdr pA))
|
||||
(gen-match-table
|
||||
(cons*
|
||||
(cons 'pat-v pat-v)
|
||||
(cons 'kis-v kis-v)
|
||||
(cons 'len-v (vector-map (lambda (i v) (vector-length v)) rhs-v))
|
||||
(cons 'rto-v (vector-copy lhs-v))
|
||||
spec))))
|
||||
|
||||
|
||||
;; --- last line ---
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
;;; nyacc/export.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015,2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library 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
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (nyacc export)
|
||||
#:export (lalr->bison
|
||||
lalr->guile
|
||||
c-char token->bison elt->bison
|
||||
)
|
||||
#:use-module ((nyacc lalr) #:select (find-terminal pp-rule lalr-start))
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc util)
|
||||
#:use-module ((srfi srfi-1) #:select (fold))
|
||||
#:use-module ((srfi srfi-43) #:select (vector-for-each))
|
||||
#:use-module (ice-9 regex)
|
||||
)
|
||||
|
||||
;; The code below, for exporting to guile and bison, should be moved to
|
||||
;; an "export" module.
|
||||
|
||||
;; terminal:
|
||||
;; ident-like-string -> caps
|
||||
;; non-ident-like-string -> ChSeq_#_# ...
|
||||
;; symbol -> if $, use _, otherwise ???
|
||||
|
||||
;; breakdown:
|
||||
;; 1 terminal, or non-terminal:
|
||||
;; 2 if non-terminal,
|
||||
;; replace - with _, replace $ with _
|
||||
;; 3 if terminal, (output of @code{find-terminal})
|
||||
;; if symbol, use 2
|
||||
;; replace char with (c-char .)
|
||||
;; if length-1 string replace with (c-char .)
|
||||
;; if like-c-ident string, replace with CAPS
|
||||
;; otherwise use ChSeq
|
||||
|
||||
(define re/g regexp-substitute/global)
|
||||
|
||||
(define (chseq->name cs)
|
||||
(let* ((iseq (string-fold (lambda (c s) (cons* (char->integer c) s)) '() cs))
|
||||
(tail (string-join (map number->string iseq) "_"))
|
||||
(name (string-append "ChSeq_" tail)))
|
||||
name))
|
||||
|
||||
;; Convert char to string that works inside single quotes for C.
|
||||
(define (c-char ch)
|
||||
(case ch
|
||||
((#\') "'\\''")
|
||||
((#\\) "'\\\\'")
|
||||
((#\newline) "'\\n'")
|
||||
((#\tab) "'\\t'")
|
||||
((#\return) "\\r")
|
||||
(else (string #\' ch #\'))))
|
||||
|
||||
(define (token->bison tok)
|
||||
(cond
|
||||
((eqv? tok '$error) "error")
|
||||
((symbol? tok) (symbol->bison tok))
|
||||
((char? tok) (c-char tok))
|
||||
((string? tok)
|
||||
(cond
|
||||
((like-c-ident? tok) (string-upcase tok))
|
||||
((= 1 (string-length tok)) (c-char (string-ref tok 0)))
|
||||
(else (chseq->name tok))))
|
||||
(else (error "what?"))))
|
||||
|
||||
(define (symbol->bison symb)
|
||||
(let* ((str0 (symbol->string symb))
|
||||
(str1 (re/g #f "-" str0 'pre "_" 'post))
|
||||
(str2 (re/g #f "\\$" str1 'pre "_" 'post)))
|
||||
str2))
|
||||
|
||||
(define (elt->bison symb terms)
|
||||
(let ((term (find-terminal symb terms)))
|
||||
(if term
|
||||
(token->bison term)
|
||||
(symbol->bison symb))))
|
||||
|
||||
;; @deffn lalr->bison spec => to current output port
|
||||
;; needs cleanup: tokens working better but p-rules need fix.
|
||||
(define (lalr->bison spec . rest)
|
||||
|
||||
(define (setup-assc assc)
|
||||
(fold (lambda (al seed)
|
||||
(append (x-flip al) seed)) '() assc))
|
||||
|
||||
(let* ((port (if (pair? rest) (car rest) (current-output-port)))
|
||||
(lhs-v (assq-ref spec 'lhs-v))
|
||||
(rhs-v (assq-ref spec 'rhs-v))
|
||||
(prp-v (assq-ref spec 'prp-v))
|
||||
(assc (setup-assc (assq-ref spec 'assc)))
|
||||
(nrule (vector-length lhs-v))
|
||||
(terms (assq-ref spec 'terminals)))
|
||||
;; Generate copyright notice.
|
||||
(let* ((notice (assq-ref (assq-ref spec 'attr) 'notice))
|
||||
(lines (if notice (string-split notice #\newline) '())))
|
||||
(for-each (lambda (l) (fmt port "// ~A\n" l))
|
||||
lines))
|
||||
;; Write out the tokens.
|
||||
(for-each
|
||||
(lambda (term)
|
||||
(unless (eqv? term '$error)
|
||||
(fmt port "%token ~A\n" (token->bison term))))
|
||||
terms)
|
||||
;; Write the associativity and prececences.
|
||||
(let iter ((pl '()) (ppl (assq-ref spec 'prec)))
|
||||
(cond
|
||||
((pair? pl)
|
||||
(fmt port "%~A" (or (assq-ref assc (caar pl)) "precedence"))
|
||||
(let iter2 ((pl (car pl)))
|
||||
(unless (null? pl)
|
||||
(fmt port " ~A" (elt->bison (car pl) terms))
|
||||
(iter2 (cdr pl))))
|
||||
(fmt port "\n")
|
||||
(iter (cdr pl) ppl))
|
||||
((pair? ppl) (iter (car ppl) (cdr ppl)))))
|
||||
;; Don't compact tables.
|
||||
(fmt port "%define lr.default-reduction accepting\n")
|
||||
;; Provide start symbol.
|
||||
(fmt port "%start ~A\n%%\n" (elt->bison (lalr-start spec) terms))
|
||||
;;
|
||||
(do ((i 1 (1+ i))) ((= i nrule))
|
||||
(let* ((lhs (vector-ref lhs-v i)) (rhs (vector-ref rhs-v i)))
|
||||
(fmt port "~A:" (elt->bison lhs terms))
|
||||
(vector-for-each
|
||||
(lambda (ix e) (fmt port " ~A" (elt->bison e terms)))
|
||||
rhs)
|
||||
(if (zero? (vector-length rhs)) (fmt port " %empty"))
|
||||
(and=> (vector-ref prp-v i)
|
||||
(lambda (tok) (fmt port " %prec ~A" (elt->bison tok terms))))
|
||||
(fmt port " ;\n")))
|
||||
(newline port)
|
||||
(values)))
|
||||
|
||||
;; @item pp-guile-input spec => to current output port
|
||||
;; total hack right now
|
||||
(define (lalr->guile spec . rest)
|
||||
(let* ((port (if (pair? rest) (car rest) (current-output-port)))
|
||||
(lhs-v (assq-ref spec 'lhs-v))
|
||||
(rhs-v (assq-ref spec 'rhs-v))
|
||||
(act-v (assq-ref spec 'act-v))
|
||||
(nrule (vector-length lhs-v))
|
||||
(terms (assq-ref spec 'terminals))
|
||||
(lhsP #f))
|
||||
;;
|
||||
(fmt port "(use-modules (system base lalr))\n")
|
||||
(fmt port "(define parser\n")
|
||||
(fmt port " (lalr-parser\n (")
|
||||
(for-each
|
||||
(lambda (s)
|
||||
(if (> (port-column port) 60) (fmt port "\n "))
|
||||
(cond
|
||||
((equal? #\; s) (fmt port " C-semi"))
|
||||
((symbol? s) (fmt port " ~A" s))
|
||||
(else (fmt port " C-~A" s))))
|
||||
terms)
|
||||
(fmt port ")\n")
|
||||
;;
|
||||
(do ((i 1 (1+ i))) ((= i nrule))
|
||||
(let* ((lhs (vector-ref lhs-v i)) (rhs (vector-ref rhs-v i)))
|
||||
(if #f
|
||||
(pp-rule 0 i)
|
||||
(begin
|
||||
(if lhsP
|
||||
(if (not (eqv? lhs lhsP))
|
||||
(fmt port " )\n (~S\n" lhs))
|
||||
(fmt port " (~S\n" lhs))
|
||||
(fmt port " (")
|
||||
(do ((j 0 (1+ j) )) ((= j (vector-length rhs)))
|
||||
(let ((e (vector-ref rhs j)))
|
||||
(if (positive? j) (fmt port " "))
|
||||
(fmt
|
||||
port "~A"
|
||||
(cond
|
||||
((equal? #\; e) (fmtstr "C-semi"))
|
||||
((char? e) (fmtstr "C-~A" e))
|
||||
(else e)))
|
||||
))
|
||||
(fmt port ") ")
|
||||
(fmt port ": ~S" `(begin ,@(vector-ref act-v i)))
|
||||
(fmt port "\n")
|
||||
(set! lhsP lhs)))))
|
||||
(fmt port " ))\n")
|
||||
(fmt port " )\n")
|
||||
(values)))
|
||||
|
||||
;;; --- last line ---
|
|
@ -1,106 +0,0 @@
|
|||
;;; nyacc/import.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015 Matthew R. Wette
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library 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
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
;; Convert guile lalr grammar to nyacc grammar.
|
||||
|
||||
;; What is *eoi* for?
|
||||
|
||||
(define-module (nyacc import)
|
||||
#:export-syntax (lalr-parser)
|
||||
#:export (guile-lalr->nyacc-lalr)
|
||||
#:use-module ((srfi srfi-1) #:select (fold-right))
|
||||
)
|
||||
|
||||
(define (convert-tree spec0)
|
||||
(let* ((terms (cons '*eoi* (car spec0)))
|
||||
(start (caadr spec0))
|
||||
(wrap-symb
|
||||
(lambda (s) (cons (if (memq s terms) 'terminal 'non-terminal) s))))
|
||||
(let iter ((prl1 '()) ; new production rules
|
||||
(prl0 (cdr spec0)) ; old production rules
|
||||
(lhs #f) ; LHS
|
||||
(rhs1-l #f) ; new RHS list
|
||||
(rhs0-l #f)) ; old RHS list
|
||||
(cond
|
||||
((pair? rhs0-l) ;; convert RHS
|
||||
(iter prl1 prl0 lhs
|
||||
(cons
|
||||
(fold-right ;; s1 ... : a => (('terminal . s) ... ('$$ . a))
|
||||
(lambda (symb seed) (cons (wrap-symb symb) seed))
|
||||
(list (list '$$ (cdar rhs0-l)))
|
||||
(caar rhs0-l))
|
||||
rhs1-l)
|
||||
(cdr rhs0-l)))
|
||||
((null? rhs0-l) ;; roll up LHS+RHSs to new rule
|
||||
(iter (cons (cons lhs (reverse rhs1-l)) prl1) prl0 #f #f #f))
|
||||
((pair? prl0) ;; next production rule
|
||||
(iter prl1 (cdr prl0) (caar prl0) '() (cdar prl0)))
|
||||
(else ;; return spec in preliminary form
|
||||
(list
|
||||
'lalr-spec
|
||||
`(start ,start)
|
||||
`(grammar ,(reverse prl1))))))))
|
||||
|
||||
(define-syntax parse-rhs-list
|
||||
(syntax-rules (:)
|
||||
((_ (<rhs0sym> ...) : <rhs0act> <rhs1> ...)
|
||||
(cons (cons '(<rhs0sym> ...) '<rhs0act>)
|
||||
(parse-rhs-list <rhs1> ...)))
|
||||
((_) (list))))
|
||||
|
||||
(define-syntax parse-prod-list
|
||||
(syntax-rules ()
|
||||
((_ (<lhs> <rhs> ...) <prod1> ...)
|
||||
(cons (cons '<lhs> (parse-rhs-list <rhs> ...))
|
||||
(parse-prod-list <prod1> ...)))
|
||||
((_) (list))))
|
||||
|
||||
|
||||
(define-syntax lalr-parser
|
||||
(syntax-rules ()
|
||||
((_ <tokens> <prod0> ...)
|
||||
(convert-tree
|
||||
(cons '<tokens> (parse-prod-list <prod0> ...))))))
|
||||
|
||||
|
||||
(define (guile-lalr->nyacc-lalr match-table spec)
|
||||
(letrec
|
||||
((mark (lambda (s) (if (symbol? s) `(quote ,s) s)))
|
||||
(rmt (map (lambda (p) (cons (cdr p) (mark (car p)))) match-table))
|
||||
(clean
|
||||
(lambda (dt)
|
||||
(cond
|
||||
((null? dt) '())
|
||||
((pair? dt)
|
||||
(case (car dt)
|
||||
((non-terminal) (cdr dt))
|
||||
((terminal)
|
||||
(cond
|
||||
((assq-ref rmt (cdr dt)))
|
||||
((symbol? (cdr dt)) (simple-format #f "~A" (cdr dt)))
|
||||
(else (cdr dt))))
|
||||
((start) dt)
|
||||
(else
|
||||
(cons (clean (car dt)) (clean (cdr dt))))))
|
||||
(else
|
||||
dt))))
|
||||
)
|
||||
(clean spec)))
|
||||
|
||||
|
||||
;;; --- last line ---
|
File diff suppressed because it is too large
Load diff
|
@ -1,242 +0,0 @@
|
|||
(add-to-load-path "/Users/mwette/repo/sv/nyacc-master/module")
|
||||
;;; system/base/lalr2.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2014-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library 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
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public License
|
||||
;;; along with this library; if not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
;; I need to find way to preserve srconf, rrconf after hashify.
|
||||
;; compact needs to deal with it ...
|
||||
|
||||
;;(define-module (system base lalr2)
|
||||
(define-module (nyacc lalr2)
|
||||
#:export-syntax (lalr2-spec)
|
||||
#:export (*lalr2-version*
|
||||
)
|
||||
#:use-module ((srfi srfi-1) #:select (fold fold-right remove lset-union
|
||||
lset-intersection lset-difference))
|
||||
#:use-module ((srfi srfi-9) #:select (define-record-type))
|
||||
#:use-module ((srfi srfi-43) #:select (vector-map vector-for-each vector-any))
|
||||
#:use-module (nyacc util) ;; fmt fmtstr
|
||||
)
|
||||
(use-modules (ice-9 pretty-print))
|
||||
|
||||
(define *lalr2-version* "0.01.0")
|
||||
|
||||
(define (fmtstr fmt . args)
|
||||
(apply simple-format #f fmt args))
|
||||
(define (fmterr fmt . args)
|
||||
(apply simple-format #t fmt args))
|
||||
(define (fmtout fmt . args)
|
||||
(apply simple-format #t fmt args))
|
||||
(define fmt simple-format)
|
||||
|
||||
;; @deffn reserved? grammar-symbol
|
||||
;; Determine whether the syntax argument is a reserved symbol, that is.
|
||||
;; So instead of writing @code{'$fixed} for syntax one can write
|
||||
;; @code{$fixed}. We may want to change this to
|
||||
;; @example
|
||||
;; (reserved-terminal? grammar-symbol)
|
||||
;; (reserved-non-term? grammar-symbol)
|
||||
;; @end example
|
||||
(define (reserved? grammar-symbol)
|
||||
;; If the first character `$' then it's reserved.
|
||||
(eqv? #\$ (string-ref (symbol->string (syntax->datum grammar-symbol)) 0)))
|
||||
|
||||
;; @deffn {Syntax} lalr2-spec grammar => spec
|
||||
;; This routine reads a grammar in a scheme-like syntax and returns an a-list.
|
||||
;; @end deffn
|
||||
(define-syntax lalr2-spec
|
||||
(syntax-rules +++ ()
|
||||
((_ <expr> +++)
|
||||
(letrec-syntax
|
||||
((parse-rhs
|
||||
(lambda (x)
|
||||
;; The following is syntax-case because we use a fender.
|
||||
(syntax-case x (quote $$ $prec $empty)
|
||||
;; action specifications
|
||||
((_ ($$ <guts> ...) <e2> ...)
|
||||
#'(cons '(action #f <guts> ...) (parse-rhs <e2> ...)))
|
||||
;; other internal $-syntax
|
||||
((_ ($prec <tok>) <e2> ...)
|
||||
#'(cons (cons 'prec (tokenize <tok>)) (parse-rhs <e2> ...)))
|
||||
((_ $empty <e2> ...) ; TODO: propagate to processor
|
||||
#'(cons '(empty) (parse-rhs <e2> ...)))
|
||||
;; terminals and non-terminals
|
||||
((_ (quote <e1>) <e2> ...)
|
||||
#'(cons '(terminal . <e1>) (parse-rhs <e2> ...)))
|
||||
((_ (<f> ...) <e2> ...)
|
||||
#'(cons (<f> ...) (parse-rhs <e2> ...)))
|
||||
((_ <e1> <e2> ...)
|
||||
(identifier? (syntax <e1>)) ; fender to trap non-terminals
|
||||
(if (reserved? (syntax <e1>))
|
||||
#'(cons '(terminal . <e1>) (parse-rhs <e2> ...))
|
||||
#'(cons '(non-terminal . <e1>) (parse-rhs <e2> ...))))
|
||||
((_ <e1> <e2> ...)
|
||||
#'(cons '(terminal . <e1>) (parse-rhs <e2> ...)))
|
||||
((_) #'(list)))))
|
||||
(parse-rhs-list
|
||||
(syntax-rules ()
|
||||
((_ (<ex> ...) <rhs> ...)
|
||||
(cons (parse-rhs <ex> ...) (parse-rhs-list <rhs> ...)))
|
||||
((_) '())))
|
||||
(parse-grammar
|
||||
(syntax-rules ()
|
||||
((_ (<lhs> <rhs> ...) <prod> ...)
|
||||
(cons (cons '<lhs> (parse-rhs-list <rhs> ...))
|
||||
(parse-grammar <prod> ...)))
|
||||
((_) '())))
|
||||
(tokenize
|
||||
(lambda (x)
|
||||
(syntax-case x ()
|
||||
((_ <tk>) (identifier? (syntax <tk>)) #'(quote <tk>))
|
||||
((_ <tk>) #'<tk>))))
|
||||
(tokenize-list
|
||||
(syntax-rules ()
|
||||
((_ <tk1> <tk2> ...)
|
||||
(cons (tokenize <tk1>) (tokenize-list <tk2> ...)))
|
||||
((_) '())))
|
||||
(parse-precedence
|
||||
(syntax-rules (left right nonassoc)
|
||||
((_ (left <tk> ...) <ex> ...)
|
||||
(cons (cons 'left (tokenize-list <tk> ...))
|
||||
(parse-precedence <ex> ...)))
|
||||
((_ (right <tk> ...) <ex> ...)
|
||||
(cons (cons 'right (tokenize-list <tk> ...))
|
||||
(parse-precedence <ex> ...)))
|
||||
((_ (nonassoc <tk> ...) <ex> ...)
|
||||
(cons (cons 'nonassoc (tokenize-list <tk> ...))
|
||||
(parse-precedence <ex> ...)))
|
||||
((_ <tk> <ex> ...)
|
||||
(cons (list 'undecl (tokenize <tk>))
|
||||
(parse-precedence <ex> ...)))
|
||||
((_) '())))
|
||||
(lalr-spec-1
|
||||
(syntax-rules (start expect notice prec< prec> grammar)
|
||||
((_ (start <symb>) <e> ...)
|
||||
(cons (cons 'start '<symb>) (lalr-spec-1 <e> ...)))
|
||||
((_ (expect <n>) <e> ...)
|
||||
(cons (cons 'expect <n>) (lalr-spec-1 <e> ...)))
|
||||
((_ (notice <str>) <e> ...)
|
||||
(cons (cons 'notice <str>) (lalr-spec-1 <e> ...)))
|
||||
((_ (prec< <ex> ...) <e> ...)
|
||||
(cons (cons 'precedence (parse-precedence <ex> ...))
|
||||
(lalr-spec-1 <e> ...)))
|
||||
((_ (prec> <ex> ...) <e> ...)
|
||||
(cons (cons 'precedence (reverse (parse-precedence <ex> ...)))
|
||||
(lalr-spec-1 <e> ...)))
|
||||
((_ (grammar <prod> ...) <e> ...)
|
||||
(cons (cons 'grammar (parse-grammar <prod> ...))
|
||||
(lalr-spec-1 <e> ...)))
|
||||
((_) '()))))
|
||||
(identity (lalr-spec-1 <expr> +++))))))
|
||||
|
||||
;; @deffn atomize terminal => object
|
||||
;; Generate an atomic object for a terminal. Expected terminals are strings,
|
||||
;; characters and symbols. This will convert the strings @code{s} to symbols
|
||||
;; of the form @code{'$:s}.
|
||||
(define (atomize terminal)
|
||||
(if (string? terminal)
|
||||
(string->symbol (string-append "$:" terminal))
|
||||
terminal))
|
||||
|
||||
(define (process-spec tree)
|
||||
|
||||
;; Make a new symbol. This is a helper for proxies and mid-rule-actions.
|
||||
;; The counter here is the only @code{set!} in @code{process-spec}.
|
||||
;; Otherwise, I believe @code{process-spec} is referentially transparent.
|
||||
(define maksy
|
||||
(let ((cntr 1))
|
||||
(lambda ()
|
||||
(let ((c cntr))
|
||||
(set! cntr (1+ cntr))
|
||||
(string->symbol (string-append "$P" (number->string c)))))))
|
||||
|
||||
;; Canonicalize precedence and associativity. Precedence will appear
|
||||
;; as sets of equivalent items in increasing order of precedence
|
||||
;; (e.g., @code{((+ -) (* /)}). The input tree has nodes that look like
|
||||
;; @example
|
||||
;; '(precedence (left "+" "-") (left "*" "/"))
|
||||
;; '(precedence ('then "else")
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; =>
|
||||
;; @example
|
||||
;; (prec ((+ -) (* /)) ((then) (else)))
|
||||
;; @end example
|
||||
(define (prec-n-assc tree)
|
||||
;; prec-l; lt-assc-l rt-assc-l non-assc-l pspec
|
||||
(let iter ((pll '()) (pl '()) (la '()) (ra '()) (na '())
|
||||
(spec '()) (tree tree))
|
||||
(cond
|
||||
((pair? spec)
|
||||
;; item ~ ('left "+" "-") => a ~ 'left, tl ~ (#\+ #\-)
|
||||
(let* ((item (car spec)) (as (car item)) (tl (map atomize (cdr item))))
|
||||
(case as
|
||||
((left)
|
||||
(iter pll (cons tl pl) (append tl la) ra na (cdr spec) tree))
|
||||
((right)
|
||||
(iter pll (cons tl pl) la (append tl ra) na (cdr spec) tree))
|
||||
((nonassoc)
|
||||
(iter pll (cons tl pl) la ra (append tl na) (cdr spec) tree))
|
||||
((undecl)
|
||||
(iter pll (cons tl pl) la ra na (cdr spec) tree)))))
|
||||
((pair? pl)
|
||||
(iter (cons (reverse pl) pll) '() la ra na spec tree))
|
||||
((pair? tree)
|
||||
(iter pll pl la ra na
|
||||
(if (eqv? 'precedence (caar tree)) (cdar tree) '()) (cdr tree)))
|
||||
(else
|
||||
(list
|
||||
`(prec . ,(reverse pll))
|
||||
`(assc (left ,@la) (right ,@ra) (nonassoc ,@na)))))))
|
||||
|
||||
(let* ((gram (assq-ref tree 'grammar))
|
||||
(start-symbol (and=> (assq-ref tree 'start) atomize))
|
||||
(start-rule (lambda () (list start-symbol)))
|
||||
(add-el (lambda (e l) (if (member e l) l (cons e l))))
|
||||
(pna (prec-n-assc tree)))
|
||||
;; We sweep through the grammar to generate a canonical specification.
|
||||
;; Note: the local rhs is used to hold RHS terms, but a
|
||||
;; value of @code{'()} is used to signal "add rule", and a value of
|
||||
;; @code{#f} is used to signal ``done, proceed to next rule.''
|
||||
;; We use @code{tail} below to go through all remaining rules so that any
|
||||
;; like LHS get absorbed before proceeding: This keeps LHS in sequence.
|
||||
;; Note: code-comm and lone-comm are added to terminals so that they end
|
||||
;; up in the match-table. The parser will skip these if the automoton has
|
||||
;; no associated transitions for these. This allows users to parse for
|
||||
;; comments in some rules but skip the rest.
|
||||
(let iter ((tl '($error $end)) ; set of terminals
|
||||
(head gram) ; head of unprocessed productions
|
||||
(rhs-l '()) ; list of RHSs being processed
|
||||
(rhs #f)) ; RHS being processed
|
||||
(cond
|
||||
((pair? rhs)
|
||||
(case (caar rhs)
|
||||
((terminal)
|
||||
(iter (add-el (cdar rhs) tl) head rhs-l (cdr rhs)))
|
||||
(else
|
||||
(iter tl head rhs-l (cdr rhs)))))
|
||||
((pair? rhs-l)
|
||||
(iter tl head (cdr rhs-l) (car rhs-l)))
|
||||
((pair? head)
|
||||
(iter tl (cdr head) (car head) rhs-l))
|
||||
(else
|
||||
(simple-format #t "need to process terminals\n")
|
||||
(pretty-print pna)
|
||||
tl)))
|
||||
))
|
||||
|
||||
;; @end itemize
|
||||
;;; --- last line ---
|
|
@ -1,45 +0,0 @@
|
|||
nyacc/lang/c99/
|
||||
|
||||
Copyright (C) 2015,2016 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.
|
||||
|
||||
manifest:
|
||||
|
||||
cpp.scm C preprocessor using tables
|
||||
includes: cppbody.scm cppact.scm,cpptab.scm
|
||||
cppbody.scm eval-cpp-expr procedure
|
||||
cppmach.scm CPP expression grammer, machine and act/tab file generation
|
||||
|
||||
mach.scm C grammer, machine and act/tab file generation
|
||||
include: pbody.scm
|
||||
depends: cpp.scm
|
||||
parser.scm C file parser, using tables
|
||||
includes: body.scm, c99act.scm, c99tab.scm
|
||||
depends: cpp.scm
|
||||
xparser.scm C expression parser
|
||||
includes: body.scm, c99xact.scm, c99xtab.scm
|
||||
depends: cpp.scm
|
||||
|
||||
pprint.scm C pretty printer, from SXML output of above parsers
|
||||
|
||||
util1.scm utilities merge, remove trees from included files
|
||||
util2.scm utilities to process information in trees
|
||||
|
||||
mach.d/
|
||||
cppact.scm cpp expression parser actions, generated from cppmach.scm
|
||||
cpptab.scm cpp expression parser tables, generated from cppmach.scm
|
||||
|
||||
c99act.scm parser actions, generated from mach.scm
|
||||
c99tab.scm C99 parser tables, generated from mach.scm
|
||||
|
||||
c99xact.scm expression parser actions, generated from mach.scm
|
||||
c99xtab.scm C99 expression parser tables, generated from mach.scm
|
||||
|
||||
|
||||
==== cpp ================================
|
||||
|
||||
parse-cpp-line line => tree
|
|
@ -1,541 +0,0 @@
|
|||
;;; lang/c99/body.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; Notes on the code design may be found in doc/nyacc/lang/c99-hg.info
|
||||
|
||||
;; @section The C99 Parser Body
|
||||
;; This code provides the front end to the C99 parser, including the lexical
|
||||
;; analyzer and optional CPP processing. In @code{'file} mode the lex'er
|
||||
;; passes CPP statements to the parser; in @code{'code} mode the lex'er
|
||||
;; parses and evaluates the CPP statements. In the case of included files
|
||||
;; (e.g., via @code{#include <file.h>}) the include files are parsed if
|
||||
;; not in @code{inc-help}. The a-list @code{inc-help} maps
|
||||
;; include file names to typenames (e.g., @code{stdio.h} to @code{FILE}) and
|
||||
;; CPP defines (e.g., "INT_MAX=12344").
|
||||
|
||||
(use-modules ((srfi srfi-9) #:select (define-record-type)))
|
||||
(use-modules ((sxml xpath) #:select (sxpath)))
|
||||
(use-modules (ice-9 pretty-print)) ;; for debugging
|
||||
|
||||
(define-record-type cpi
|
||||
(make-cpi-1)
|
||||
cpi?
|
||||
(debug cpi-debug set-cpi-debug!) ; debug #t #f
|
||||
(defines cpi-defs set-cpi-defs!) ; #defines
|
||||
(incdirs cpi-incs set-cpi-incs!) ; #includes
|
||||
(inc-tynd cpi-itynd set-cpi-itynd!) ; a-l of incfile => typenames
|
||||
(inc-defd cpi-idefd set-cpi-idefd!) ; a-l of incfile => defines
|
||||
(ptl cpi-ptl set-cpi-ptl!) ; parent typename list
|
||||
(ctl cpi-ctl set-cpi-ctl!) ; current typename list
|
||||
;;(brlev cpi-brlev set-cpi-brlev! ; curr brace level (#includes)
|
||||
)
|
||||
|
||||
;;.@deffn Procedure split-cppdef defstr => (<name> . <repl>)| \
|
||||
;; (<name> <args> . <repl>)|#f
|
||||
;; Convert define string to a dict item. Examples:
|
||||
;; @example
|
||||
;; "ABC=123" => '("ABC" . "123")
|
||||
;; "MAX(X,Y)=((X)>(Y)?(X):(Y))" => ("MAX" ("X" "Y") . "((X)>(Y)?(X):(Y))")
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (split-cppdef defstr)
|
||||
(let ((x2st (string-index defstr #\()) ; start of args
|
||||
(x2nd (string-index defstr #\))) ; end of args
|
||||
(x3 (string-index defstr #\=))) ; start of replacement
|
||||
(cond
|
||||
((not x3) #f)
|
||||
((and x2st x3)
|
||||
;;(if (not (eq? (1+ x2nd) x3)) (c99-err "bad CPP def: ~S" defstr))
|
||||
(cons* (substring defstr 0 x2st)
|
||||
(string-split
|
||||
(string-delete #\space (substring defstr (1+ x2st) x2nd))
|
||||
#\,)
|
||||
(substring defstr (1+ x3))))
|
||||
(else
|
||||
(cons (substring defstr 0 x3) (substring defstr (1+ x3)))))))
|
||||
#|
|
||||
(use-modules (ice-9 regex))
|
||||
(define split-cppdef
|
||||
(let ((rx1 (make-regexp "^([A-Za-z0-9_]+)\\(([^)]*)\\)=(.*)$"))
|
||||
(rx2 (make-regexp "^([A-Za-z0-9_]+)=(.*)$")))
|
||||
(lambda (defstr)
|
||||
(let* ()
|
||||
(cond
|
||||
((regexp-exec rx1 defstr) =>
|
||||
(lambda (m1)
|
||||
(let* ((s1 (match:substring m1 1))
|
||||
(s2 (match:substring m1 2))
|
||||
(s3 (match:substring m1 3)))
|
||||
(cons* s1 (string-split s2 #\,) s3))))
|
||||
((regexp-exec rx2 defstr) =>
|
||||
(lambda (m2)
|
||||
(let* ((s1 (match:substring m2 1))
|
||||
(s2 (match:substring m2 2)))
|
||||
(cons s1 s2))))
|
||||
(else #f)))))))
|
||||
|#
|
||||
|
||||
;; @deffn Procedure make-cpi debug defines incdirs inchelp
|
||||
;; @end deffn
|
||||
(define (make-cpi debug defines incdirs inchelp)
|
||||
;; convert inchelp into inc-file->typenames and inc-file->defines
|
||||
;; Any entry for an include file which contains `=' is considered
|
||||
;; a define; otherwise, the entry is a typename.
|
||||
|
||||
(define (split-helper helper)
|
||||
(let ((file (car helper)))
|
||||
(let iter ((tyns '()) (defs '()) (ents (cdr helper)))
|
||||
(cond
|
||||
((null? ents) (values (cons file tyns) (cons file defs)))
|
||||
((split-cppdef (car ents)) =>
|
||||
(lambda (def) (iter tyns (cons def defs) (cdr ents))))
|
||||
(else (iter (cons (car ents) tyns) defs (cdr ents)))))))
|
||||
|
||||
(let* ((cpi (make-cpi-1)))
|
||||
(set-cpi-debug! cpi debug) ; print states debug
|
||||
(set-cpi-defs! cpi (map split-cppdef defines)) ; list of define strings
|
||||
(set-cpi-incs! cpi incdirs) ; list of include dir's
|
||||
(set-cpi-ptl! cpi '()) ; list of lists of typenames
|
||||
(set-cpi-ctl! cpi '()) ; list of typenames
|
||||
;; Break up the helpers into typenames and defines.
|
||||
(let iter ((itynd '()) (idefd '()) (helpers inchelp))
|
||||
(cond ((null? helpers)
|
||||
(set-cpi-itynd! cpi itynd)
|
||||
(set-cpi-idefd! cpi idefd))
|
||||
(else
|
||||
(call-with-values
|
||||
(lambda () (split-helper (car helpers)))
|
||||
(lambda (ityns idefs)
|
||||
(iter (cons ityns itynd) (cons idefs idefd) (cdr helpers)))))))
|
||||
;; Assign builtins.
|
||||
(and=> (assoc-ref (cpi-itynd cpi) "__builtin")
|
||||
(lambda (tl) (set-cpi-ctl! cpi (append tl (cpi-ctl cpi)))))
|
||||
(and=> (assoc-ref (cpi-idefd cpi) "__builtin")
|
||||
(lambda (tl) (set-cpi-defs! cpi (append tl (cpi-defs cpi)))))
|
||||
;; Return the populated info.
|
||||
cpi))
|
||||
|
||||
(define *info* (make-fluid #f))
|
||||
|
||||
;; @deffn {Procedure} typename? name
|
||||
;; Called by lexer to determine if symbol is a typename.
|
||||
;; Check current sibling for each generation.
|
||||
;; @end deffn
|
||||
(define (typename? name)
|
||||
(let ((cpi (fluid-ref *info*)))
|
||||
(if (member name (cpi-ctl cpi)) #t
|
||||
(let iter ((ptl (cpi-ptl cpi)))
|
||||
(if (null? ptl) #f
|
||||
(if (member name (car ptl)) #t
|
||||
(iter (cdr ptl))))))))
|
||||
|
||||
;; @deffn {Procedure} add-typename name
|
||||
;; Helper for @code{save-typenames}.
|
||||
;; @end deffn
|
||||
(define (add-typename name)
|
||||
(let ((cpi (fluid-ref *info*)))
|
||||
(set-cpi-ctl! cpi (cons name (cpi-ctl cpi)))))
|
||||
|
||||
(define (cpi-push) ;; on #if
|
||||
(let ((cpi (fluid-ref *info*)))
|
||||
(set-cpi-ptl! cpi (cons (cpi-ctl cpi) (cpi-ptl cpi)))
|
||||
(set-cpi-ctl! cpi '())))
|
||||
|
||||
(define (cpi-shift) ;; on #elif #else
|
||||
(set-cpi-ctl! (fluid-ref *info*) '()))
|
||||
|
||||
(define (cpi-pop) ;; on #endif
|
||||
(let ((cpi (fluid-ref *info*)))
|
||||
(set-cpi-ctl! cpi (append (cpi-ctl cpi) (car (cpi-ptl cpi))))
|
||||
(set-cpi-ptl! cpi (cdr (cpi-ptl cpi)))))
|
||||
|
||||
;; @deffn {Procedure} find-new-typenames decl
|
||||
;; Helper for @code{save-typenames}.
|
||||
;; Given declaration return a list of new typenames (via @code{typedef}).
|
||||
;; @end deffn
|
||||
(define (find-new-typenames decl)
|
||||
|
||||
;; like declr->ident in util2.scm
|
||||
(define (declr->id-name declr)
|
||||
(case (car declr)
|
||||
((ident) (sx-ref declr 1))
|
||||
((init-declr) (declr->id-name (sx-ref declr 1)))
|
||||
((comp-declr) (declr->id-name (sx-ref declr 1)))
|
||||
((array-of) (declr->id-name (sx-ref declr 1)))
|
||||
((ptr-declr) (declr->id-name (sx-ref declr 2)))
|
||||
((ftn-declr) (declr->id-name (sx-ref declr 1)))
|
||||
((scope) (declr->id-name (sx-ref declr 1)))
|
||||
(else (error "coding bug: " declr))))
|
||||
|
||||
(let* ((spec (sx-ref decl 1))
|
||||
(stor (sx-find 'stor-spec spec))
|
||||
(id-l (sx-ref decl 2)))
|
||||
(if (and stor (eqv? 'typedef (caadr stor)))
|
||||
(let iter ((res '()) (idl (cdr id-l)))
|
||||
(if (null? idl) res
|
||||
(iter (cons (declr->id-name (sx-ref (car idl) 1)) res)
|
||||
(cdr idl))))
|
||||
'())))
|
||||
|
||||
;; @deffn {Procedure} save-typenames decl
|
||||
;; Save the typenames for the lexical analyzer and return the decl.
|
||||
;; @end deffn
|
||||
(define (save-typenames decl)
|
||||
;; This finds typenames using @code{find-new-typenames} and adds via
|
||||
;; @code{add-typename}. Then return the decl.
|
||||
(for-each add-typename (find-new-typenames decl))
|
||||
decl)
|
||||
|
||||
;; ------------------------------------------------------------------------
|
||||
|
||||
(define (c99-err . args)
|
||||
(apply throw 'c99-error args))
|
||||
|
||||
;; @deffn {Procedure} read-cpp-line ch => #f | (cpp-xxxx)??
|
||||
;; Given if ch is #\# read a cpp-statement.
|
||||
;; The standard implies that comments are tossed here but we keep them
|
||||
;; so that they can end up in the pretty-print output.
|
||||
;; @end deffn
|
||||
(define (read-cpp-line ch)
|
||||
(if (not (eq? ch #\#)) #f
|
||||
(let iter ((cl '()) (ch (read-char)))
|
||||
(cond
|
||||
((eof-object? ch) (throw 'cpp-error "CPP lines must end in newline"))
|
||||
((eq? ch #\newline) (unread-char ch) (list->string (reverse cl)))
|
||||
((eq? ch #\\)
|
||||
(let ((c2 (read-char)))
|
||||
(if (eq? c2 #\newline)
|
||||
(iter cl (read-char))
|
||||
(iter (cons* c2 ch cl) (read-char)))))
|
||||
((eq? ch #\/) ;; swallow comments, event w/ newlines
|
||||
(let ((c2 (read-char)))
|
||||
(cond
|
||||
((eqv? c2 #\*)
|
||||
(let iter2 ((cl2 (cons* #\* #\/ cl)) (ch (read-char)))
|
||||
(cond
|
||||
((eq? ch #\*)
|
||||
(let ((c2 (read-char)))
|
||||
(if (eqv? c2 #\/)
|
||||
(iter (cons* #\/ #\* cl2) (read-char)) ;; keep comment
|
||||
(iter2 (cons #\* cl2) c2))))
|
||||
(else
|
||||
(iter2 (cons ch cl2) (read-char))))))
|
||||
(else
|
||||
(iter (cons #\/ cl) c2)))))
|
||||
(else (iter (cons ch cl) (read-char)))))))
|
||||
|
||||
;; @deffn {Procedure} find-file-in-dirl file dirl => path
|
||||
;; @end deffn
|
||||
(define (find-file-in-dirl file dirl)
|
||||
(let iter ((dirl dirl))
|
||||
(if (null? dirl) #f
|
||||
(let ((p (string-append (car dirl) "/" file)))
|
||||
(if (access? p R_OK) p (iter (cdr dirl)))))))
|
||||
|
||||
(define (def-xdef? name mode)
|
||||
(not (eqv? mode 'file)))
|
||||
|
||||
;; @deffn {Procedure} gen-c-lexer [#:mode mode] [#:xdef? proc] => procedure
|
||||
;; Generate a context-sensitive lexer for the C99 language. The generated
|
||||
;; lexical analyzer reads and passes comments and optionally CPP statements
|
||||
;; to the parser. The keyword argument @var{mode} will determine if CPP
|
||||
;; statements are passed (@code{'file} mode) or parsed and executed
|
||||
;; (@code{'file} mode) as described above. Comments will be passed as
|
||||
;; ``line'' comments or ``lone'' comments: lone comments appear on a line
|
||||
;; without code. The @code{xdef?} keyword argument allows user to pass
|
||||
;; a predicate which determines whether CPP symbols in code are expanded.
|
||||
;; The default predicate is
|
||||
;; @example
|
||||
;; (define (def-xdef? mode name) (eqv? mode 'code))
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define gen-c-lexer
|
||||
;; This gets ugly in order to handle cpp.
|
||||
;;.need to add support for num's w/ letters like @code{14L} and @code{1.3f}.
|
||||
;; todo: I think there is a bug wrt the comment reader because // ... \n
|
||||
;; will end up in same mode... so after
|
||||
;; int x; // comment
|
||||
;; the lexer will think we are not at BOL.
|
||||
(let* ((match-table c99-mtab)
|
||||
(read-ident read-c-ident)
|
||||
(read-comm read-c-comm)
|
||||
;;
|
||||
(ident-like? (make-ident-like-p read-ident))
|
||||
;;
|
||||
(strtab (filter-mt string? match-table)) ; strings in grammar
|
||||
(kwstab (filter-mt ident-like? strtab)) ; keyword strings =>
|
||||
(keytab (map-mt string->symbol kwstab)) ; keywords in grammar
|
||||
(chrseq (remove-mt ident-like? strtab)) ; character sequences
|
||||
(symtab (filter-mt symbol? match-table)) ; symbols in grammar
|
||||
(chrtab (filter-mt char? match-table)) ; characters in grammar
|
||||
;;
|
||||
(read-chseq (make-chseq-reader chrseq))
|
||||
(assc-$ (lambda (pair) (cons (assq-ref symtab (car pair)) (cdr pair))))
|
||||
;;
|
||||
(t-ident (assq-ref symtab '$ident))
|
||||
(t-typename (assq-ref symtab 'typename))
|
||||
(xp1 (sxpath '(cpp-stmt define)))
|
||||
(xp2 (sxpath '(decl))))
|
||||
;; mode: 'code|'file|'decl
|
||||
;; xdef?: (proc name mode) => #t|#f : do we expand #define?
|
||||
(lambda* (#:key (mode 'code) (xdef? #f))
|
||||
(let ((bol #t) ; begin-of-line condition
|
||||
(xtxt #f) ; parsing cpp expanded text (kludge?)
|
||||
(ppxs (list 'keep)) ; CPP execution state stack
|
||||
(info (fluid-ref *info*)) ; info shared w/ parser
|
||||
(brlev 0) ; brace level
|
||||
(x-def? (or xdef? def-xdef?))
|
||||
)
|
||||
;; Return the first (tval . lval) pair not excluded by the CPP.
|
||||
(lambda ()
|
||||
|
||||
(define (add-define tree)
|
||||
(let* ((tail (cdr tree))
|
||||
(name (car (assq-ref tail 'name)))
|
||||
(args (assq-ref tail 'args))
|
||||
(repl (car (assq-ref tail 'repl)))
|
||||
(cell (cons name (if args (cons args repl) repl))))
|
||||
(set-cpi-defs! info (cons cell (cpi-defs info)))))
|
||||
|
||||
(define (rem-define name)
|
||||
(set-cpi-defs! info (delete name (cpi-defs info))))
|
||||
|
||||
(define (apply-helper file)
|
||||
(let* ((tyns (assoc-ref (cpi-itynd info) file))
|
||||
(defs (assoc-ref (cpi-idefd info) file)))
|
||||
;;(simple-format #t "apply-helper ~S => ~S\n" file tyns)
|
||||
;;(simple-format #t " itynd= ~S\n" (cpi-itynd info))
|
||||
(when tyns
|
||||
(for-each add-typename tyns)
|
||||
(set-cpi-defs! info (append defs (cpi-defs info))))
|
||||
tyns))
|
||||
|
||||
(define (inc-stmt->file stmt)
|
||||
(let* ((arg (cadr stmt)) (len (string-length arg)))
|
||||
(substring arg 1 (1- len))))
|
||||
|
||||
(define (inc-file->path file)
|
||||
(find-file-in-dirl file (cpi-incs info)))
|
||||
|
||||
(define (code-if stmt)
|
||||
;;(simple-format #t "code-if: ppxs=~S\n" ppxs)
|
||||
(case (car ppxs)
|
||||
((skip-look skip-done skip) ;; don't eval if excluded
|
||||
;;(simple-format #t "code-if: SKIP\n")
|
||||
(set! ppxs (cons 'skip ppxs)))
|
||||
(else
|
||||
;;(simple-format #t "code-if: KEEP\n")
|
||||
;;(simple-format #t " text=~S\n" (cadr stmt))
|
||||
;;(simple-format #t " defs=~S\n" (cpi-defs info))
|
||||
(let* ((defs (cpi-defs info))
|
||||
(val (eval-cpp-cond-text (cadr stmt) defs)))
|
||||
(if (not val) (c99-err "unresolved: ~S" (cadr stmt)))
|
||||
(if (eq? 'keep (car ppxs))
|
||||
(if (zero? val)
|
||||
(set! ppxs (cons 'skip-look ppxs))
|
||||
(set! ppxs (cons 'keep ppxs)))
|
||||
(set! ppxs (cons 'skip-done ppxs))))))
|
||||
stmt)
|
||||
|
||||
(define (code-elif stmt)
|
||||
(case (car ppxs)
|
||||
((skip) #t) ;; don't eval if excluded
|
||||
(else
|
||||
(let* ((defs (cpi-defs info))
|
||||
(val (eval-cpp-cond-text (cadr stmt) defs)))
|
||||
(if (not val) (c99-err "unresolved: ~S" (cadr stmt)))
|
||||
(case (car ppxs)
|
||||
((skip-look) (if (not (zero? val)) (set-car! ppxs 'keep)))
|
||||
((keep) (set-car! ppxs 'skip-done))))))
|
||||
stmt)
|
||||
|
||||
(define (code-else stmt)
|
||||
(case (car ppxs)
|
||||
((skip-look) (set-car! ppxs 'keep))
|
||||
((keep) (set-car! ppxs 'skip-done)))
|
||||
stmt)
|
||||
|
||||
(define (code-endif stmt)
|
||||
(set! ppxs (cdr ppxs))
|
||||
stmt)
|
||||
|
||||
(define (eval-cpp-incl/here stmt) ;; => stmt
|
||||
;; include file inplace
|
||||
(let* ((file (inc-stmt->file stmt))
|
||||
(path (inc-file->path file)))
|
||||
(cond
|
||||
((apply-helper file))
|
||||
((not path) (c99-err "not found: ~S" file)) ; file not found
|
||||
(else (set! bol #t) (push-input (open-input-file path))))
|
||||
stmt))
|
||||
|
||||
(define (eval-cpp-incl/tree stmt) ;; => stmt
|
||||
;; include file as a new tree
|
||||
(let* ((file (inc-stmt->file stmt))
|
||||
(path (inc-file->path file)))
|
||||
(cond
|
||||
((apply-helper file) stmt) ; use helper
|
||||
((not path) (c99-err "not found: ~S" file)) ; file not found
|
||||
((with-input-from-file path run-parse) => ; add tree to stmt
|
||||
(lambda (tree)
|
||||
;;(pretty-print tree (current-error-port))
|
||||
;;(pretty-print (xp1 tree))
|
||||
(for-each add-define (xp1 tree))
|
||||
(append stmt tree))))))
|
||||
|
||||
(define (eval-cpp-stmt/code stmt) ;; => stmt
|
||||
(case (car stmt)
|
||||
((if) (code-if stmt))
|
||||
((elif) (code-elif stmt))
|
||||
((else) (code-else stmt))
|
||||
((endif) (code-endif stmt))
|
||||
(else
|
||||
(if (eqv? 'keep (car ppxs))
|
||||
(case (car stmt)
|
||||
((include) (eval-cpp-incl/here stmt))
|
||||
((define) (add-define stmt) stmt)
|
||||
((undef) (rem-define (cadr stmt)) stmt)
|
||||
((error) (c99-err "error: #error ~A" (cadr stmt)))
|
||||
((pragma) stmt) ;; ignore for now
|
||||
(else (error "bad cpp flow stmt")))))))
|
||||
|
||||
(define (eval-cpp-stmt/decl stmt) ;; => stmt
|
||||
(case (car stmt)
|
||||
((if) (code-if stmt))
|
||||
((elif) (code-elif stmt))
|
||||
((else) (code-else stmt))
|
||||
((endif) (code-endif stmt))
|
||||
(else
|
||||
(if (eqv? 'keep (car ppxs))
|
||||
(case (car stmt)
|
||||
((include) ; use tree unless inside braces
|
||||
(if (zero? brlev)
|
||||
(eval-cpp-incl/tree stmt)
|
||||
(eval-cpp-incl/here stmt)))
|
||||
((define) (add-define stmt) stmt)
|
||||
((undef) (rem-define (cadr stmt)) stmt)
|
||||
((error) (c99-err "error: #error ~A" (cadr stmt)))
|
||||
((pragma) stmt) ;; ignore for now
|
||||
(else (error "bad cpp flow stmt")))
|
||||
stmt))))
|
||||
|
||||
(define (eval-cpp-stmt/file stmt) ;; => stmt
|
||||
(case (car stmt)
|
||||
((if) (cpi-push) stmt)
|
||||
((elif else) (cpi-shift) stmt)
|
||||
((endif) (cpi-pop) stmt)
|
||||
((include) (eval-cpp-incl/tree stmt))
|
||||
((define) (add-define stmt) stmt)
|
||||
((undef) (rem-define (cadr stmt)) stmt)
|
||||
((error) stmt)
|
||||
((pragma) stmt) ;; need to work this
|
||||
(else (error "bad cpp flow stmt"))))
|
||||
|
||||
;; Maybe evaluate the CPP statement.
|
||||
(define (eval-cpp-stmt stmt)
|
||||
(with-throw-handler
|
||||
'cpp-error
|
||||
(lambda ()
|
||||
(case mode
|
||||
((code) (eval-cpp-stmt/code stmt))
|
||||
((decl) (eval-cpp-stmt/decl stmt))
|
||||
((file) (eval-cpp-stmt/file stmt))
|
||||
(else (error "lang/c99 coding error"))))
|
||||
(lambda (key fmt . rest)
|
||||
(report-error fmt rest)
|
||||
(throw 'c99-error "CPP error"))))
|
||||
|
||||
;; Predicate to determine if we pass the cpp-stmt to the parser.
|
||||
;; @itemize
|
||||
;; If code mode, never
|
||||
;; If file mode, all except includes between { }
|
||||
;; If decl mode, only defines and includes outside {}
|
||||
;; @end itemize
|
||||
(define (pass-cpp-stmt? stmt)
|
||||
(case mode
|
||||
((code) #f)
|
||||
((decl) (and (zero? brlev) (memq (car stmt) '(include define))))
|
||||
((file) (or (zero? brlev) (not (eqv? (car stmt) 'include))))
|
||||
(else (error "lang/c99 coding error"))))
|
||||
|
||||
;; Composition of @code{read-cpp-line} and @code{eval-cpp-line}.
|
||||
(define (read-cpp-stmt ch)
|
||||
(and=> (read-cpp-line ch) cpp-line->stmt))
|
||||
|
||||
(define (read-token)
|
||||
(let iter ((ch (read-char)))
|
||||
(cond
|
||||
((eof-object? ch)
|
||||
(set! xtxt #f)
|
||||
(if (pop-input) (iter (read-char)) (assc-$ '($end . ""))))
|
||||
((eq? ch #\newline) (set! bol #t) (iter (read-char)))
|
||||
((char-set-contains? c:ws ch) (iter (read-char)))
|
||||
(bol
|
||||
(set! bol #f)
|
||||
(cond ;; things that depend on bol only
|
||||
((read-comm ch #t) => assc-$)
|
||||
((read-cpp-stmt ch) =>
|
||||
(lambda (stmt)
|
||||
(let ((stmt (eval-cpp-stmt stmt))) ; eval can add tree
|
||||
(if (pass-cpp-stmt? stmt)
|
||||
(assc-$ `(cpp-stmt . ,stmt))
|
||||
(iter (read-char))))))
|
||||
(else (iter ch))))
|
||||
((read-ident ch) =>
|
||||
(lambda (name)
|
||||
(let ((symb (string->symbol name)))
|
||||
;;(simple-format #t "id: name=~S xtxt=~S\n" name xtxt)
|
||||
(cond
|
||||
((and (not xtxt)
|
||||
(if (procedure? x-def?) (x-def? name mode) x-def?)
|
||||
(expand-cpp-macro-ref name (cpi-defs info)))
|
||||
=> (lambda (st)
|
||||
;;(simple-format #t "repl=~S\n" st)
|
||||
(set! xtxt #t) ; so we don't re-expand
|
||||
(push-input (open-input-string st))
|
||||
(iter (read-char))))
|
||||
((assq-ref keytab symb)
|
||||
=> (lambda (t) (cons t name)))
|
||||
((typename? name)
|
||||
(cons (assq-ref symtab 'typename) name))
|
||||
(else
|
||||
(cons (assq-ref symtab '$ident) name))))))
|
||||
((read-c-num ch) => assc-$)
|
||||
((read-c-string ch) => assc-$)
|
||||
((read-c-chlit ch) => assc-$)
|
||||
((read-comm ch #f) => assc-$)
|
||||
((and (char=? ch #\{) (set! brlev (1+ brlev)) #f) #f)
|
||||
((and (char=? ch #\}) (set! brlev (1- brlev)) #f) #f)
|
||||
((read-chseq ch) => identity)
|
||||
((assq-ref chrtab ch) => (lambda (t) (cons t (string ch))))
|
||||
((eqv? ch #\\) ;; C allows \ at end of line to continue
|
||||
(let ((ch (read-char)))
|
||||
(cond ((eqv? #\newline ch) (iter (read-char))) ;; extend line
|
||||
(else (unread-char ch) (cons #\\ "\\"))))) ;; parse err
|
||||
(else (cons ch (string ch))))))
|
||||
|
||||
;; Loop between reading tokens and skipping tokens via CPP logic.
|
||||
(let iter ((pair (read-token)))
|
||||
(case (car ppxs)
|
||||
((keep) ;;(simple-format #t "lx=>~S\n" pair)
|
||||
pair)
|
||||
((skip-done skip-look skip)
|
||||
(iter (read-token)))
|
||||
(else (error "coding error"))))
|
||||
)))))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,505 +0,0 @@
|
|||
;;; lang/c/cpp.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; C preprocessor macro expansion and condition text parse-and-eval
|
||||
;; ref: https://gcc.gnu.org/onlinedocs/gcc-3.0.1/cpp_3.html
|
||||
|
||||
(define-module (nyacc lang c99 cpp)
|
||||
#:export (
|
||||
cpp-line->stmt
|
||||
eval-cpp-cond-text
|
||||
expand-cpp-macro-ref)
|
||||
#:use-module (nyacc parse)
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module (rnrs arithmetic bitwise)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (system base pmatch)
|
||||
)
|
||||
|
||||
(define c99-std-defs
|
||||
'("__DATE__" "__FILE__" "__LINE__" "__STDC__" "__STDC_HOSTED__"
|
||||
"__STDC_VERSION__" "__TIME__"))
|
||||
|
||||
(define (c99-std-def? str)
|
||||
(let iter ((defs c99-std-defs))
|
||||
(cond
|
||||
((null? defs) #f)
|
||||
((string=? (car defs) str) #t)
|
||||
(else (iter (cdr defs))))))
|
||||
|
||||
(define (c99-std-val str)
|
||||
(cond
|
||||
((string=? str "__DATE__") "M01 01 2001")
|
||||
((string=? str "__FILE__") "(unknown)")
|
||||
((string=? str "__LINE__") "0")
|
||||
((string=? str "__STDC__") "1")
|
||||
((string=? str "__STDC_HOSTED__") "0")
|
||||
((string=? str "__STDC_VERSION__") "201701")
|
||||
((string=? str "__TIME__") "00:00:00")
|
||||
(else #f)))
|
||||
|
||||
(define inline-whitespace (list->char-set '(#\space #\tab)))
|
||||
|
||||
;;.@deffn {Procedure} skip-il-ws ch
|
||||
;; Skip in-line whitespace
|
||||
;; @end deffn
|
||||
(define (skip-il-ws ch)
|
||||
(cond
|
||||
((eof-object? ch) ch)
|
||||
((char-set-contains? inline-whitespace ch) (skip-il-ws (read-char)))
|
||||
(else ch)))
|
||||
|
||||
;; @deffn {Procedure} read-ellipsis ch
|
||||
;; read ellipsis
|
||||
;; @end deffn
|
||||
(define (read-ellipsis ch)
|
||||
(cond
|
||||
((eof-object? ch) #f)
|
||||
((char=? ch #\.) (read-char) (read-char) "...") ; assumes correct syntax
|
||||
(else #f)))
|
||||
|
||||
;; @deffn {Procedure} cpp-define
|
||||
;; Reads CPP define from current input and generates a cooresponding sxml
|
||||
;; expression.
|
||||
;; @example
|
||||
;; (define (name "ABC") (repl "123"))
|
||||
;; OR
|
||||
;; (define (name "ABC") (args "X" "Y") (repl "X+Y"))
|
||||
;; @example
|
||||
;; @end deffn
|
||||
(define (cpp-define)
|
||||
|
||||
(define (p-args la) ;; parse args
|
||||
(if (eq? la #\()
|
||||
(let iter ((args '()) (la (skip-il-ws (read-char))))
|
||||
(cond
|
||||
((eq? la #\)) (reverse args))
|
||||
((read-c-ident la) =>
|
||||
(lambda (arg) (iter (cons arg args) (skip-il-ws (read-char)))))
|
||||
((read-ellipsis la) =>
|
||||
(lambda (arg) (iter (cons arg args) (skip-il-ws (read-char)))))
|
||||
((eq? la #\,) (iter args (skip-il-ws (read-char))))))
|
||||
(begin (if (char? la) (unread-char la)) #f)))
|
||||
|
||||
(define (p-rest la) ;; parse rest
|
||||
(cond ((eof-object? la) "")
|
||||
(else (unread-char la) (drain-input (current-input-port)))))
|
||||
|
||||
(let* ((name (read-c-ident (skip-il-ws (read-char))))
|
||||
(args (or (p-args (read-char)) '()))
|
||||
(repl (p-rest (skip-il-ws (read-char)))))
|
||||
(if (pair? args)
|
||||
`(define (name ,name) (args . ,args) (repl ,repl))
|
||||
`(define (name ,name) (repl ,repl)))))
|
||||
|
||||
|
||||
;; @deffn {Procedure} cpp-include
|
||||
;; Parse CPP include statement.
|
||||
(define (cpp-include)
|
||||
(let* ((beg-ch (skip-il-ws (read-char)))
|
||||
(end-ch (if (eq? beg-ch #\<) #\> #\"))
|
||||
(path (let iter ((cl (list beg-ch)) (ch (read-char)))
|
||||
(if (eq? ch end-ch) (list->string (reverse (cons ch cl)))
|
||||
(iter (cons ch cl) (read-char))))))
|
||||
`(include ,path)))
|
||||
|
||||
;; @deffn {Procedure} cpp-line->stmt line defs => (stmt-type text)
|
||||
;; Parse a line from a CPP statement and return a parse tree.
|
||||
;; @example
|
||||
;; (parse-cpp-stmt "define X 123") => (define "X" "123")
|
||||
;; (parse-cpp-stmt "if defined(A) && defined(B) && defined(C)"
|
||||
;; => (if "defined(A) && defined(B) && defined(C)")
|
||||
;; @end example
|
||||
;; To evaluate the @code{if} statements use @code{parse-cpp-expr} and
|
||||
;; @code{eval-cpp-expr}.
|
||||
;; @end deffn
|
||||
(define (cpp-line->stmt line)
|
||||
(define (rd-ident) (read-c-ident (skip-il-ws (read-char))))
|
||||
(define (rd-num) (and=> (read-c-num (skip-il-ws (read-char))) cdr))
|
||||
(define (rd-rest) (let ((ch (skip-il-ws (read-char))))
|
||||
(if (not (eof-object? ch)) (unread-char ch))
|
||||
(drain-input (current-input-port))))
|
||||
(with-input-from-string line
|
||||
(lambda ()
|
||||
(let ((cmd (string->symbol (read-c-ident (skip-il-ws (read-char))))))
|
||||
(case cmd
|
||||
((include) (cpp-include))
|
||||
((define) (cpp-define))
|
||||
((undef) `(undef ,(rd-ident)))
|
||||
((ifdef)
|
||||
`(if ,(string-append "defined(" (rd-ident) ")" (rd-rest))))
|
||||
((ifndef)
|
||||
`(if ,(string-append "!defined(" (rd-ident) ")" (rd-rest))))
|
||||
((if elif else endif line error pragma) (list cmd (rd-rest)))
|
||||
(else '(unknown "")))))))
|
||||
|
||||
(include-from-path "nyacc/lang/c99/mach.d/cpptab.scm")
|
||||
(include-from-path "nyacc/lang/c99/mach.d/cppact.scm")
|
||||
|
||||
(define raw-parser
|
||||
(make-lalr-parser
|
||||
(list (cons 'len-v cpp-len-v) (cons 'pat-v cpp-pat-v) (cons 'rto-v cpp-rto-v)
|
||||
(cons 'mtab cpp-mtab) (cons 'act-v cpp-act-v))))
|
||||
|
||||
(define (cpp-err fmt . args)
|
||||
(apply throw 'cpp-error fmt args))
|
||||
|
||||
;; Since we want to be able to get CPP statements with comment in tact
|
||||
;; (e.g., for passing to @code{pretty-print-c99}) we need to remove
|
||||
;; comments when parsing CPP expressions. We convert a comm-reader
|
||||
;; into a comm-skipper here. And from that generate a lexer generator.
|
||||
(define cpp-comm-skipper
|
||||
(let ((reader (make-comm-reader '(("/*" . "*/")))))
|
||||
(lambda (ch)
|
||||
(reader ch #f))))
|
||||
|
||||
;; generate a lexical analyzer per string
|
||||
(define gen-cpp-lexer
|
||||
(make-lexer-generator cpp-mtab #:comm-skipper cpp-comm-skipper))
|
||||
|
||||
;; @deffn {Procedure} parse-cpp-expr text => tree
|
||||
;; Given a string returns a cpp parse tree. This is called by
|
||||
;; @code{eval-cpp-expr}. The text will have had all CPP defined symbols
|
||||
;; expanded already so no identifiers should appear in the text.
|
||||
;; A @code{cpp-error} will be thrown if a parse error occurs.
|
||||
;; @end deffn
|
||||
(define (parse-cpp-expr text)
|
||||
(with-throw-handler
|
||||
'nyacc-error
|
||||
(lambda ()
|
||||
(with-input-from-string text
|
||||
(lambda () (raw-parser (gen-cpp-lexer)))))
|
||||
(lambda (key fmt . args)
|
||||
(apply throw 'cpp-error fmt args))))
|
||||
|
||||
;; @deffn {Procedure} eval-cpp-expr tree dict => datum
|
||||
;; Evaluate a tree produced from @code{parse-cpp-expr}.
|
||||
;; The tree passed to this routine is
|
||||
;; @end deffn
|
||||
(define (eval-cpp-expr tree dict)
|
||||
(letrec
|
||||
((tx (lambda (tr ix) (list-ref tr ix)))
|
||||
(tx1 (lambda (tr) (tx tr 1)))
|
||||
(ev (lambda (ex ix) (eval-expr (list-ref ex ix))))
|
||||
(ev1 (lambda (ex) (ev ex 1))) ; eval expr in arg 1
|
||||
(ev2 (lambda (ex) (ev ex 2))) ; eval expr in arg 2
|
||||
(ev3 (lambda (ex) (ev ex 3))) ; eval expr in arg 3
|
||||
(eval-expr
|
||||
(lambda (tree)
|
||||
(case (car tree)
|
||||
((fixed) (string->number (cnumstr->scm (tx1 tree))))
|
||||
((char) (char->integer (tx1 tree)))
|
||||
((defined) (if (assoc-ref dict (tx1 tree)) 1 0))
|
||||
((pre-inc post-inc) (1+ (ev1 tree)))
|
||||
((pre-dec post-dec) (1- (ev1 tree)))
|
||||
((pos) (ev1 tree))
|
||||
((neg) (- (ev1 tree)))
|
||||
((bw-not) (bitwise-not (ev1 tree)))
|
||||
((not) (if (zero? (ev1 tree)) 1 0))
|
||||
((mul) (* (ev1 tree) (ev2 tree)))
|
||||
((div) (/ (ev1 tree) (ev2 tree)))
|
||||
((mod) (modulo (ev1 tree) (ev2 tree)))
|
||||
((add) (+ (ev1 tree) (ev2 tree)))
|
||||
((sub) (- (ev1 tree) (ev2 tree)))
|
||||
((lshift) (bitwise-arithmetic-shift-left (ev1 tree) (ev2 tree)))
|
||||
((rshift) (bitwise-arithmetic-shift-right (ev1 tree) (ev2 tree)))
|
||||
((lt) (if (< (ev1 tree) (ev2 tree)) 1 0))
|
||||
((le) (if (<= (ev1 tree) (ev2 tree)) 1 0))
|
||||
((gt) (if (> (ev1 tree) (ev2 tree)) 1 0))
|
||||
((ge) (if (>= (ev1 tree) (ev2 tree)) 1 0))
|
||||
((equal) (if (= (ev1 tree) (ev2 tree)) 1 0))
|
||||
((noteq) (if (= (ev1 tree) (ev2 tree)) 0 1))
|
||||
((bw-or) (bitwise-ior (ev1 tree) (ev2 tree)))
|
||||
((bw-xor) (bitwise-xor (ev1 tree) (ev2 tree)))
|
||||
((bw-and) (bitwise-and (ev1 tree) (ev2 tree)))
|
||||
((or) (if (and (zero? (ev1 tree)) (zero? (ev2 tree))) 0 1))
|
||||
((and) (if (or (zero? (ev1 tree)) (zero? (ev2 tree))) 0 1))
|
||||
((cond-expr) (if (zero? (ev1 tree)) (ev3 tree) (ev2 tree)))
|
||||
((ident) (cpp-err "undefined identifier: ~S" (cadr tree)))
|
||||
(else (error "incomplete implementation"))))))
|
||||
(eval-expr tree)))
|
||||
|
||||
;;.@deffn {Procedure} rtokl->string reverse-token-list => string
|
||||
;; Convert reverse token-list to string.
|
||||
;; @end deffn
|
||||
(define (rtokl->string tokl)
|
||||
|
||||
;; Turn reverse chl into a string and insert it into the string list stl.
|
||||
(define (add-chl chl stl)
|
||||
(if (null? chl) stl (cons (list->string chl) stl)))
|
||||
|
||||
;;(simple-format #t "\nused=~S\n" used)
|
||||
;; Works like this: Scan through the list of tokens (key-val pairs or
|
||||
;; lone characters). Lone characters are collected in a list (@code{chl});
|
||||
;; pairs are converted into strings and combined with list of characters
|
||||
;; into a list of strings. When done the list of strings is combined to
|
||||
;; one string. (The token 'argval is expansion of argument.)
|
||||
(let iter ((stl '()) ; list of strings to reverse-append
|
||||
(chl '()) ; char list
|
||||
(nxt #f) ; next string to add after chl
|
||||
(tkl tokl)) ; input token list
|
||||
(cond
|
||||
(nxt
|
||||
(iter (cons nxt (add-chl chl stl)) '() #f tkl))
|
||||
((null? tkl)
|
||||
(apply string-append (add-chl chl stl)))
|
||||
((char? (car tkl))
|
||||
(iter stl (cons (car tkl) chl) nxt (cdr tkl)))
|
||||
(else
|
||||
(pmatch tkl
|
||||
(((ident . ,rval) dhash (ident . ,lval) . ,rest)
|
||||
(iter stl chl nxt
|
||||
(acons 'ident (string-append lval rval) (list-tail tkl 3))))
|
||||
(((ident . ,arg) hash . ,rest)
|
||||
(iter stl chl (string-append "\"" arg "\"") (list-tail tkl 2)))
|
||||
(((ident . ,iden) (ident . ,lval) . ,rest)
|
||||
(iter stl chl iden rest))
|
||||
(((ident . ,iden) . ,rest)
|
||||
(iter stl chl iden rest))
|
||||
(((string . ,val) . ,rest)
|
||||
(iter stl (cons #\" chl) val (cons #\" rest)))
|
||||
(((defined . ,val) . ,rest)
|
||||
(iter stl chl val rest))
|
||||
((space space . ,rest)
|
||||
(iter stl chl nxt rest))
|
||||
((space . ,rest)
|
||||
(iter stl (cons #\space chl) nxt rest))
|
||||
((,asis . ,rest)
|
||||
(iter stl chl asis rest))
|
||||
(,otherwise
|
||||
(error "no match" tkl)))))))
|
||||
|
||||
;; We just scanned "defined", now need to scan the arg to inhibit expansion.
|
||||
;; For example, we have scanned "defined"; we now scan "(FOO)" or "FOO", and
|
||||
;; return "defined(FOO)" or "defined FOO".
|
||||
(define (scan-defined-arg)
|
||||
(let* ((ch (skip-il-ws (read-char))) (no-ec (not (char=? ch #\())))
|
||||
(let iter ((chl (list ch)) (ch (skip-il-ws (read-char))))
|
||||
(cond
|
||||
((eof-object? ch)
|
||||
(if no-ec
|
||||
(string-append "defined " (list->string (reverse chl)))
|
||||
(cpp-err "illegal argument to `defined'")))
|
||||
((char-set-contains? c:ir ch)
|
||||
(iter (cons ch chl) (read-char)))
|
||||
(no-ec
|
||||
(unread-char ch)
|
||||
(string-append "defined " (list->string (reverse chl))))
|
||||
((char=? #\) (skip-il-ws ch))
|
||||
(string-append "defined" (list->string (reverse (cons #\) chl)))))
|
||||
(else
|
||||
(cpp-err "illegal argument to `defined'"))))))
|
||||
|
||||
(define (scan-cpp-input defs used end-tok)
|
||||
;; Works like this: scan for tokens (comments, parens, strings, char's, etc).
|
||||
;; Tokens are collected in a (reverse ordered) list (tkl) and merged together
|
||||
;; to a string on return using @code{rtokl->string}. Keep track of expanded
|
||||
;; identifiers and rerun if something got expanded. Also, keep track of
|
||||
;; ## and spaces so that we can parse ID /* foo */ ## /* bar */ 123
|
||||
;; as well as ABC/*foo*/(123,456).
|
||||
|
||||
(define (trim-spaces tkl)
|
||||
(if (and (pair? tkl) (eqv? 'space (car tkl)))
|
||||
(trim-spaces (cdr tkl))
|
||||
tkl))
|
||||
|
||||
(define (finish rr tkl)
|
||||
(let* ((tkl (if end-tok (trim-spaces tkl) tkl))
|
||||
(repl (rtokl->string tkl)))
|
||||
;;(if (null? rr) (simple-format #t "finish ~S\n" tkl))
|
||||
(if (pair? rr)
|
||||
(expand-cpp-repl repl defs (append rr used)) ;; re-run
|
||||
repl)))
|
||||
|
||||
;;(simple-format #t "scan-cpp-input end-tok=~S\n" end-tok)
|
||||
(let iter ((rr '()) ; list symbols resolved
|
||||
(tkl '()) ; token list of
|
||||
(lv 0) ; level
|
||||
(ch (skip-il-ws (read-char)))) ; next character
|
||||
;;(unless end-tok (simple-format #t "tkl=~S ch=~S\n" tkl ch))
|
||||
(cond
|
||||
((eof-object? ch) (finish rr tkl))
|
||||
((and (eqv? end-tok ch) (zero? lv))
|
||||
(unread-char ch) (finish rr tkl))
|
||||
((and end-tok (char=? #\) ch) (zero? lv))
|
||||
(unread-char ch) (finish rr tkl))
|
||||
((or (char-set-contains? c:ws ch) ; whitespace
|
||||
(read-c-comm ch #f)) ; comment
|
||||
(iter rr (cons 'space tkl) lv (skip-il-ws (read-char))))
|
||||
((read-c-ident ch) =>
|
||||
(lambda (iden)
|
||||
(if (equal? iden "defined")
|
||||
(iter rr (acons 'defined (scan-defined-arg) tkl) lv (read-char))
|
||||
(let ((rval (expand-cpp-macro-ref iden defs used)))
|
||||
(if rval
|
||||
(iter #t (cons rval tkl) lv (read-char))
|
||||
(iter rr (acons 'ident iden tkl) lv (read-char)))))))
|
||||
((read-c-string ch) =>
|
||||
(lambda (st) (iter rr (acons 'string (cdr st) tkl) lv (read-char))))
|
||||
((char=? #\( ch) (iter rr (cons ch tkl) (1+ lv) (read-char)))
|
||||
((char=? #\) ch) (iter rr (cons ch tkl) (1- lv) (read-char)))
|
||||
(else
|
||||
(iter rr (cons ch tkl) lv (read-char))))))
|
||||
|
||||
;; @deffn {Procedure} collect-args arglargd defs used => argd
|
||||
;; Collect arguments to a macro which appears in C code. If not looking at
|
||||
;; @code{(} return @code{#f}, else scan and eat up to closing @code{)}.
|
||||
;; If multiple whitespace characters are skipped at the front then only
|
||||
;; one @code{#\space} is re-inserted.
|
||||
;; @end deffn
|
||||
(define (collect-args argl defs used)
|
||||
(let iter1 ((sp #f) (ch (read-char)))
|
||||
(cond
|
||||
((eof-object? ch) (if sp (unread-char #\space)) #f)
|
||||
((char-set-contains? inline-whitespace ch) (iter1 #t (read-char)))
|
||||
((char=? #\( ch)
|
||||
(let iter2 ((argl argl) (argv '()) (ch ch))
|
||||
(cond
|
||||
((eqv? ch #\)) (reverse argv))
|
||||
((null? argl) (cpp-err "arg count"))
|
||||
((and (null? (cdr argl)) (string=? (car argl) "..."))
|
||||
(let ((val (scan-cpp-input defs used #\))))
|
||||
(iter2 (cdr argl) (acons "__VA_ARGS__" val argv) (read-char))))
|
||||
((or (char=? ch #\() (char=? ch #\,))
|
||||
(let* ((val (scan-cpp-input defs used #\,)))
|
||||
(iter2 (cdr argl) (acons (car argl) val argv) (read-char))))
|
||||
(else
|
||||
(error "cpp.scm, collect-args: coding error")))))
|
||||
(else (if sp (unread-char #\space)) #f))))
|
||||
|
||||
;; @deffn {Procedure} px-cpp-ftn-repl argd repl => string
|
||||
;; pre-expand CPP function where @var{argd} is an a-list of arg name
|
||||
;; and replacement and repl is the defined replacement
|
||||
;;
|
||||
;; argd is alist of arguments and token lists
|
||||
;; if end-tok == #f ignore levels
|
||||
;; ident space fixed float chseq hash dhash arg
|
||||
;; need to decide if we should use `(space ,tkl) or `((space) ,tkl)
|
||||
;; This should replace args and execute hash and double-hash ??
|
||||
;; @end deffn
|
||||
(define (px-cpp-ftn argd repl)
|
||||
(with-input-from-string repl
|
||||
(lambda ()
|
||||
;;(simple-format #t "px-cpp-ftn argd=~S repl=~S\n" argd repl)
|
||||
(px-cpp-ftn-1 argd))))
|
||||
|
||||
(define (px-cpp-ftn-1 argd)
|
||||
|
||||
;; Turn reverse chl into a string and insert it into the token stream.
|
||||
(define (ins-chl chl stl)
|
||||
(if (null? chl) stl (cons (list->string (reverse chl)) stl)))
|
||||
|
||||
(define (rem-space chl)
|
||||
(let iter ((chl chl))
|
||||
(cond
|
||||
((null? chl) chl)
|
||||
((char-set-contains? c:ws (car chl)) (iter (cdr chl)))
|
||||
(else chl))))
|
||||
|
||||
(define (mk-string str) (string-append "\"" str "\""))
|
||||
|
||||
(let iter ((stl '()) ; string list
|
||||
(chl '()) ; character list
|
||||
(nxt #f) ; next string after char list
|
||||
(ch (read-char))) ; next character
|
||||
;;(simple-format #t "px-1: stl=~S chl=~S nxt=~S ch=~S\n" stl chl nxt ch)
|
||||
(cond
|
||||
(nxt (iter (cons nxt (ins-chl chl stl)) '() #f ch))
|
||||
((eof-object? ch)
|
||||
(apply string-append (reverse (ins-chl chl stl))))
|
||||
((char-set-contains? c:ws ch)
|
||||
(iter stl (cons #\space chl) nxt (skip-il-ws (read-char))))
|
||||
((read-c-comm ch #f) (iter stl (cons #\space chl) nxt (read-char)))
|
||||
((read-c-string ch) =>
|
||||
(lambda (st) (iter stl chl (mk-string (cdr st)) (read-char))))
|
||||
((char=? #\( ch) (iter stl (cons ch chl) nxt (read-char)))
|
||||
((char=? #\) ch) (iter stl (cons ch chl) nxt (read-char)))
|
||||
((read-c-ident ch) => ; replace if aval
|
||||
(lambda (iden)
|
||||
(iter stl chl (or (assoc-ref argd iden) iden) (read-char))))
|
||||
((char=? #\# ch)
|
||||
(let ((ch (read-char)))
|
||||
(if (eqv? ch #\#)
|
||||
(iter stl (rem-space chl) nxt (skip-il-ws (read-char)))
|
||||
(let* ((aref (read-c-ident (skip-il-ws ch)))
|
||||
(aval (assoc-ref argd aref)))
|
||||
(if (not aref) (cpp-err "expecting arg-ref"))
|
||||
(if (not aval) (cpp-err "expecting arg-val"))
|
||||
(iter stl chl (mk-string aval) (read-char))))))
|
||||
(else (iter stl (cons ch chl) nxt (read-char))))))
|
||||
|
||||
;; @deffn {Procedure} cpp-expand-text text defs [used] => string
|
||||
;; Expand the string @var{text} using the provided CPP @var{defs} a-list.
|
||||
;; Identifiers in the list of strings @var{used} will not be expanded.
|
||||
;; @end deffn
|
||||
(define* (cpp-expand-text text defs #:optional (used '()))
|
||||
;;(simple-format #t "cpp-expand-text ~S\n" text)
|
||||
(with-input-from-string text
|
||||
(lambda () (scan-cpp-input defs used #f))))
|
||||
|
||||
;; @deffn {Procedure} expand-cpp-repl
|
||||
;; to be documented
|
||||
;; @end deffn
|
||||
(define (expand-cpp-repl text defs used)
|
||||
;;(simple-format #t "expand-cpp-repl text=~S used=~S\n" text used)
|
||||
(with-input-from-string text
|
||||
(lambda () (scan-cpp-input defs used #f))))
|
||||
|
||||
;; === exports =======================
|
||||
|
||||
;; @deffn {Procedure} eval-cpp-cond-text text defs => string
|
||||
;; Evaluate CPP condition expression (text).
|
||||
;; @end deffn
|
||||
(define (eval-cpp-cond-text text defs)
|
||||
(with-throw-handler
|
||||
'cpp-error
|
||||
(lambda ()
|
||||
(let* ((rhs (cpp-expand-text text defs))
|
||||
(exp (parse-cpp-expr rhs)))
|
||||
(eval-cpp-expr exp defs)))
|
||||
(lambda (key fmt . args)
|
||||
(report-error fmt args)
|
||||
(throw 'c99-error "CPP error"))))
|
||||
|
||||
;; @deffn {Procedure} expand-cpp-macro-ref ident defs [used] => repl|#f
|
||||
;; Given an identifier seen in the current input, this checks for associated
|
||||
;; definition in @var{defs} (generated from CPP defines). If found as simple
|
||||
;; macro, the expansion is returned as a string. If @var{ident} refers
|
||||
;; to a macro with arguments, then the arguments will be read from the
|
||||
;; current input. The format of the @code{defs} entries are
|
||||
;; @example
|
||||
;; ("ABC" . "123")
|
||||
;; ("MAX" ("X" "Y") . "((X)>(Y)?(X):(Y))")
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define* (expand-cpp-macro-ref ident defs #:optional (used '()))
|
||||
(let ((rval (assoc-ref defs ident)))
|
||||
;;(simple-format #t "ex-mac-ref rval=~S\n" rval)
|
||||
(cond
|
||||
((member ident used) #f)
|
||||
((string? rval) (expand-cpp-repl rval defs (cons ident used)))
|
||||
((pair? rval)
|
||||
;;(simple-format #t "rval = ~S\n" rval)
|
||||
(and=> (collect-args (car rval) defs used)
|
||||
(lambda (argd)
|
||||
(expand-cpp-repl (px-cpp-ftn argd (cdr rval))
|
||||
defs (cons ident used)))))
|
||||
((c99-std-val ident) => identity)
|
||||
(else #f))))
|
||||
|
||||
;;; --- last line ---
|
|
@ -1,131 +0,0 @@
|
|||
;;; lang/c99/cppmach.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015,2016 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; C preprocessor expression parser generator
|
||||
|
||||
(define-module (nyacc lang c99 cppmach)
|
||||
#:export (cpp-spec cpp-mach gen-cpp-files)
|
||||
#:use-module (nyacc lalr)
|
||||
#:use-module (nyacc parse)
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module ((srfi srfi-43) #:select (vector-map))
|
||||
#:use-module (rnrs arithmetic bitwise)
|
||||
)
|
||||
|
||||
(define cpp-spec
|
||||
(lalr-spec
|
||||
(notice (string-append "Copyright (C) 2016,2017 Matthew R. Wette"
|
||||
lang-crn-lic))
|
||||
(expect 0)
|
||||
(start conditional-expression)
|
||||
(grammar
|
||||
(conditional-expression
|
||||
(logical-or-expression)
|
||||
(logical-or-expression "?" logical-or-expression ":" conditional-expression
|
||||
($$ `(cond-expr ,$1 ,$3 ,$5))))
|
||||
(logical-or-expression
|
||||
(logical-and-expression)
|
||||
(logical-or-expression "||" logical-and-expression ($$ `(or ,$1 ,$3))))
|
||||
(logical-and-expression
|
||||
(bitwise-or-expression)
|
||||
(logical-and-expression "&&" bitwise-or-expression ($$ `(and ,$1 ,$3))))
|
||||
(bitwise-or-expression
|
||||
(bitwise-xor-expression)
|
||||
(bitwise-or-expression "|" bitwise-xor-expression
|
||||
($$ `(bitwise-or ,$1 ,$3))))
|
||||
(bitwise-xor-expression
|
||||
(bitwise-and-expression)
|
||||
(bitwise-xor-expression "^" bitwise-and-expression
|
||||
($$ `(bitwise-xor ,$1 ,$3))))
|
||||
(bitwise-and-expression
|
||||
(equality-expression)
|
||||
(bitwise-and-expression "&" equality-expression
|
||||
($$ `(bitwise-and ,$1 ,$3))))
|
||||
(equality-expression
|
||||
(relational-expression)
|
||||
(equality-expression "==" relational-expression ($$ `(equal ,$1 ,$3)))
|
||||
(equality-expression "!=" relational-expression ($$ `(noteq ,$1 ,$3))))
|
||||
(relational-expression
|
||||
(shift-expression)
|
||||
(relational-expression "<" shift-expression ($$ `(lt ,$1 ,$3)))
|
||||
(relational-expression "<=" shift-expression ($$ `(le ,$1 ,$3)))
|
||||
(relational-expression ">" shift-expression ($$ `(gt ,$1 ,$3)))
|
||||
(relational-expression ">=" shift-expression ($$ `(ge ,$1 ,$3))))
|
||||
(shift-expression
|
||||
(additive-expression)
|
||||
(shift-expression "<<" additive-expression ($$ `(lshift ,$1 ,$3)))
|
||||
(shift-expression ">>" additive-expression ($$ `(rshift ,$1 ,$3))))
|
||||
(additive-expression
|
||||
(multiplicative-expression)
|
||||
(additive-expression "+" multiplicative-expression ($$ `(add ,$1 ,$3)))
|
||||
(additive-expression "-" multiplicative-expression ($$ `(sub ,$1 ,$3))))
|
||||
(multiplicative-expression
|
||||
(unary-expression)
|
||||
(multiplicative-expression "*" unary-expression ($$ `(mul ,$1 ,$3)))
|
||||
(multiplicative-expression "/" unary-expression ($$ `(div ,$1 ,$3)))
|
||||
(multiplicative-expression "%" unary-expression ($$ `(mod ,$1 ,$3))))
|
||||
(unary-expression
|
||||
(postfix-expression)
|
||||
("-" unary-expression ($$ `(neg ,$2)))
|
||||
("+" unary-expression ($$ `(pos ,$2)))
|
||||
("!" unary-expression ($$ `(not ,$2)))
|
||||
("~" unary-expression ($$ `(bitwise-not ,$2)))
|
||||
("++" unary-expression ($$ `(pre-inc ,$2)))
|
||||
("--" unary-expression ($$ `(pre-dec ,$2))))
|
||||
(postfix-expression
|
||||
(primary-expression)
|
||||
(postfix-expression "++" ($$ `(post-inc ,$1)))
|
||||
(postfix-expression "--" ($$ `(post-dec ,$1))))
|
||||
(primary-expression
|
||||
($ident ($$ `(ident ,$1)))
|
||||
($fixed ($$ `(fixed ,$1))) ; integer-constant
|
||||
($chlit ($$ `(char ,$1))) ; char-constant
|
||||
("defined" "(" $ident ")" ($$ `(defined ,$3)))
|
||||
("defined" $ident ($$ `(defined ,$2)))
|
||||
("(" expression-list ")" ($$ $2)))
|
||||
(expression-list
|
||||
(conditional-expression)
|
||||
(expression-list "," conditional-expression ($$ $3)))
|
||||
)))
|
||||
|
||||
(define cpp-mach
|
||||
(compact-machine
|
||||
(hashify-machine
|
||||
(make-lalr-machine cpp-spec))))
|
||||
|
||||
;;; =====================================
|
||||
|
||||
;; @item gen-cpp-files [dir] => #t
|
||||
;; Update or generate the files @quot{cppact.scm} and @quot{cpptab.scm}.
|
||||
;; If there are no changes to existing files, no update occurs.
|
||||
(define (gen-cpp-files . rest)
|
||||
(define (lang-dir path)
|
||||
(if (pair? rest) (string-append (car rest) "/" path) path))
|
||||
(define (xtra-dir path)
|
||||
(lang-dir (string-append "mach.d/" path)))
|
||||
|
||||
(write-lalr-actions cpp-mach (xtra-dir "cppact.scm.new") #:prefix "cpp-")
|
||||
(write-lalr-tables cpp-mach (xtra-dir "cpptab.scm.new") #:prefix "cpp-")
|
||||
(let ((a (move-if-changed (xtra-dir "cppact.scm.new")
|
||||
(xtra-dir "cppact.scm")))
|
||||
(b (move-if-changed (xtra-dir "cpptab.scm.new")
|
||||
(xtra-dir "cpptab.scm"))))
|
||||
(when (or a b)
|
||||
(system (string-append "touch " (lang-dir "cpp.scm"))))))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,770 +0,0 @@
|
|||
;; ./mach.d/c99act.scm
|
||||
|
||||
;; Copyright (C) 2016,2017 Matthew R. Wette
|
||||
;;
|
||||
;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
;; or any later version published by the Free Software Foundation. See
|
||||
;; the file COPYING included with the this distribution.
|
||||
|
||||
(define c99-act-v
|
||||
(vector
|
||||
;; $start => translation-unit
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; primary-expression => identifier
|
||||
(lambda ($1 . $rest) `(p-expr ,$1))
|
||||
;; primary-expression => constant
|
||||
(lambda ($1 . $rest) `(p-expr ,$1))
|
||||
;; primary-expression => string-literal
|
||||
(lambda ($1 . $rest) `(p-expr ,(tl->list $1)))
|
||||
;; primary-expression => "(" expression ")"
|
||||
(lambda ($3 $2 $1 . $rest) $2)
|
||||
;; postfix-expression => primary-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; postfix-expression => postfix-expression "[" expression "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-ref ,$3 ,$1))
|
||||
;; postfix-expression => postfix-expression "(" argument-expression-list...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(fctn-call ,$1 ,(tl->list $3)))
|
||||
;; postfix-expression => postfix-expression "(" ")"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(fctn-call ,$1 (expr-list)))
|
||||
;; postfix-expression => postfix-expression "." identifier
|
||||
(lambda ($3 $2 $1 . $rest) `(d-sel ,$3 ,$1))
|
||||
;; postfix-expression => postfix-expression "->" identifier
|
||||
(lambda ($3 $2 $1 . $rest) `(i-sel ,$3 ,$1))
|
||||
;; postfix-expression => postfix-expression "++"
|
||||
(lambda ($2 $1 . $rest) `(post-inc ,$1))
|
||||
;; postfix-expression => postfix-expression "--"
|
||||
(lambda ($2 $1 . $rest) `(post-dec ,$1))
|
||||
;; postfix-expression => "(" type-name ")" "{" initializer-list "}"
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(comp-lit ,$2 ,(tl->list $5)))
|
||||
;; postfix-expression => "(" type-name ")" "{" initializer-list "," "}"
|
||||
(lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(comp-lit ,$2 ,(tl->list $5)))
|
||||
;; argument-expression-list => assignment-expression
|
||||
(lambda ($1 . $rest) (make-tl 'expr-list $1))
|
||||
;; argument-expression-list => argument-expression-list "," assignment-e...
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; argument-expression-list => arg-expr-hack
|
||||
(lambda ($1 . $rest) (make-tl 'expr-list $1))
|
||||
;; argument-expression-list => argument-expression-list "," arg-expr-hack
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; arg-expr-hack => declaration-specifiers abstract-declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(param-decl ,(tl->list $1) $2))
|
||||
;; arg-expr-hack => declaration-specifiers
|
||||
(lambda ($1 . $rest)
|
||||
`(param-decl ,(tl->list $1)))
|
||||
;; unary-expression => postfix-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; unary-expression => "++" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(pre-inc ,$2))
|
||||
;; unary-expression => "--" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(pre-dec ,$2))
|
||||
;; unary-expression => unary-operator cast-expression
|
||||
(lambda ($2 $1 . $rest) (list $1 $2))
|
||||
;; unary-expression => "sizeof" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(sizeof-expr ,$2))
|
||||
;; unary-expression => "sizeof" "(" type-name ")"
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(sizeof-type ,$3))
|
||||
;; unary-operator => "&"
|
||||
(lambda ($1 . $rest) 'ref-to)
|
||||
;; unary-operator => "*"
|
||||
(lambda ($1 . $rest) 'de-ref)
|
||||
;; unary-operator => "+"
|
||||
(lambda ($1 . $rest) 'pos)
|
||||
;; unary-operator => "-"
|
||||
(lambda ($1 . $rest) 'neg)
|
||||
;; unary-operator => "~"
|
||||
(lambda ($1 . $rest) 'bitwise-not)
|
||||
;; unary-operator => "!"
|
||||
(lambda ($1 . $rest) 'not)
|
||||
;; cast-expression => unary-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; cast-expression => "(" type-name ")" cast-expression
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(cast ,$2 ,$4))
|
||||
;; multiplicative-expression => cast-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; multiplicative-expression => multiplicative-expression "*" cast-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(mul ,$1 ,$3))
|
||||
;; multiplicative-expression => multiplicative-expression "/" cast-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(div ,$1 ,$3))
|
||||
;; multiplicative-expression => multiplicative-expression "%" cast-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(mod ,$1 ,$3))
|
||||
;; additive-expression => multiplicative-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; additive-expression => additive-expression "+" multiplicative-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(add ,$1 ,$3))
|
||||
;; additive-expression => additive-expression "-" multiplicative-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(sub ,$1 ,$3))
|
||||
;; shift-expression => additive-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; shift-expression => shift-expression "<<" additive-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(lshift ,$1 ,$3))
|
||||
;; shift-expression => shift-expression ">>" additive-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(rshift ,$1 ,$3))
|
||||
;; relational-expression => shift-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; relational-expression => relational-expression "<" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(lt ,$1 ,$3))
|
||||
;; relational-expression => relational-expression ">" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(gt ,$1 ,$3))
|
||||
;; relational-expression => relational-expression "<=" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(le ,$1 ,$3))
|
||||
;; relational-expression => relational-expression ">=" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(ge ,$1 ,$3))
|
||||
;; equality-expression => relational-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; equality-expression => equality-expression "==" relational-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(eq ,$1 ,$3))
|
||||
;; equality-expression => equality-expression "!=" relational-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(ne ,$1 ,$3))
|
||||
;; bitwise-and-expression => equality-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-and-expression => bitwise-and-expression "&" equality-expression
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(bitwise-and ,$1 ,$3))
|
||||
;; bitwise-xor-expression => bitwise-and-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-xor-expression => bitwise-xor-expression "^" bitwise-and-expr...
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(bitwise-xor ,$1 ,$3))
|
||||
;; bitwise-or-expression => bitwise-xor-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-or-expression => bitwise-or-expression "|" bitwise-xor-expres...
|
||||
(lambda ($3 $2 $1 . $rest) `(bitwise-or ,$1 ,$3))
|
||||
;; logical-and-expression => bitwise-or-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; logical-and-expression => logical-and-expression "&&" bitwise-or-expr...
|
||||
(lambda ($3 $2 $1 . $rest) `(and ,$1 ,$3))
|
||||
;; logical-or-expression => logical-and-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; logical-or-expression => logical-or-expression "||" logical-and-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(or ,$1 ,$3))
|
||||
;; conditional-expression => logical-or-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; conditional-expression => logical-or-expression "?" expression ":" co...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(cond-expr ,$1 ,$3 ,$5))
|
||||
;; assignment-expression => conditional-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-expression => unary-expression assignment-operator assignm...
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(assn-expr ,$1 (op ,$2) ,$3))
|
||||
;; assignment-operator => "="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "+="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "-="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "*="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "/="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "%="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "<<="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => ">>="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "&="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "^="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "|="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; expression => assignment-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; expression => expression "," assignment-expression
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
(if (eqv? 'comma-expr (sx-tag $1))
|
||||
(append $1 (list $3))
|
||||
`(comma-expr ,$1 ,$3)))
|
||||
;; constant-expression => conditional-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; declaration => declaration-specifiers init-declarator-list $P1 ";" op...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
(if (pair? $5) (append $3 (list $5)) $3))
|
||||
;; declaration => declaration-specifiers ";" opt-code-comment
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
(if (pair? $3)
|
||||
`(decl ,(tl->list $1) ,(list $3))
|
||||
`(decl ,(tl->list $1))))
|
||||
;; $P1 =>
|
||||
(lambda ($2 $1 . $rest)
|
||||
(save-typenames
|
||||
`(decl ,(tl->list $1) ,(tl->list $2))))
|
||||
;; declaration-specifiers => storage-class-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => storage-class-specifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; declaration-specifiers => type-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => type-specifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; declaration-specifiers => type-qualifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => type-qualifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; declaration-specifiers => function-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => function-specifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; init-declarator-list => init-declarator
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'init-declr-list $1))
|
||||
;; init-declarator-list => init-declarator-list "," init-declarator
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; init-declarator => declarator
|
||||
(lambda ($1 . $rest) `(init-declr ,$1))
|
||||
;; init-declarator => declarator "=" initializer
|
||||
(lambda ($3 $2 $1 . $rest) `(init-declr ,$1 ,$3))
|
||||
;; storage-class-specifier => "auto"
|
||||
(lambda ($1 . $rest) '(stor-spec (auto)))
|
||||
;; storage-class-specifier => "extern"
|
||||
(lambda ($1 . $rest) '(stor-spec (extern)))
|
||||
;; storage-class-specifier => "register"
|
||||
(lambda ($1 . $rest) '(stor-spec (register)))
|
||||
;; storage-class-specifier => "static"
|
||||
(lambda ($1 . $rest) '(stor-spec (static)))
|
||||
;; storage-class-specifier => "typedef"
|
||||
(lambda ($1 . $rest) '(stor-spec (typedef)))
|
||||
;; type-specifier => "void"
|
||||
(lambda ($1 . $rest) '(type-spec (void)))
|
||||
;; type-specifier => fixed-type-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => float-type-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => "_Bool"
|
||||
(lambda ($1 . $rest)
|
||||
'(type-spec (fixed-type "_Bool")))
|
||||
;; type-specifier => complex-type-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => struct-or-union-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => enum-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => typedef-name
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; fixed-type-specifier => "short"
|
||||
(lambda ($1 . $rest) '(fixed-type "short"))
|
||||
;; fixed-type-specifier => "short" "int"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "short int"))
|
||||
;; fixed-type-specifier => "signed" "short"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed short"))
|
||||
;; fixed-type-specifier => "signed" "short" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "signed short int"))
|
||||
;; fixed-type-specifier => "int"
|
||||
(lambda ($1 . $rest) '(fixed-type "int"))
|
||||
;; fixed-type-specifier => "signed"
|
||||
(lambda ($1 . $rest) '(fixed-type "signed"))
|
||||
;; fixed-type-specifier => "signed" "int"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed int"))
|
||||
;; fixed-type-specifier => "long"
|
||||
(lambda ($1 . $rest) '(fixed-type "long"))
|
||||
;; fixed-type-specifier => "long" "int"
|
||||
(lambda ($2 $1 . $rest) '(fixed-type "long int"))
|
||||
;; fixed-type-specifier => "signed" "long"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed long"))
|
||||
;; fixed-type-specifier => "signed" "long" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "signed long int"))
|
||||
;; fixed-type-specifier => "long" "long"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "long long"))
|
||||
;; fixed-type-specifier => "long" "long" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "long long int"))
|
||||
;; fixed-type-specifier => "signed" "long" "long"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "signed long long"))
|
||||
;; fixed-type-specifier => "signed" "long" "long" "int"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
'(fixed-type "signed long long int"))
|
||||
;; fixed-type-specifier => "unsigned" "short" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned short int"))
|
||||
;; fixed-type-specifier => "unsigned" "short"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned short"))
|
||||
;; fixed-type-specifier => "unsigned" "int"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned int"))
|
||||
;; fixed-type-specifier => "unsigned"
|
||||
(lambda ($1 . $rest) '(fixed-type "unsigned"))
|
||||
;; fixed-type-specifier => "unsigned" "long" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned long"))
|
||||
;; fixed-type-specifier => "unsigned" "long"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned long"))
|
||||
;; fixed-type-specifier => "unsigned" "long" "long" "int"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned long long int"))
|
||||
;; fixed-type-specifier => "unsigned" "long" "long"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned long long"))
|
||||
;; fixed-type-specifier => "char"
|
||||
(lambda ($1 . $rest) '(fixed-type "char"))
|
||||
;; fixed-type-specifier => "signed" "char"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed char"))
|
||||
;; fixed-type-specifier => "unsigned" "char"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned char"))
|
||||
;; float-type-specifier => "float"
|
||||
(lambda ($1 . $rest) '(float-type "float"))
|
||||
;; float-type-specifier => "double"
|
||||
(lambda ($1 . $rest) '(float-type "double"))
|
||||
;; float-type-specifier => "long" "double"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(float-type "long double"))
|
||||
;; complex-type-specifier => "_Complex"
|
||||
(lambda ($1 . $rest) '(complex-type "_Complex"))
|
||||
;; complex-type-specifier => "float" "_Complex"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(complex-type "float _Complex"))
|
||||
;; complex-type-specifier => "double" "_Complex"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(complex-type "double _Complex"))
|
||||
;; complex-type-specifier => "long" "double" "_Complex"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(complex-type "long double _Complex"))
|
||||
;; struct-or-union-specifier => "struct" ident-like "{" struct-declarati...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(struct-def ,$2 ,(tl->list $4)))
|
||||
;; struct-or-union-specifier => "struct" "{" struct-declaration-list "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(struct-def ,(tl->list $3)))
|
||||
;; struct-or-union-specifier => "struct" ident-like
|
||||
(lambda ($2 $1 . $rest) `(struct-ref ,$2))
|
||||
;; struct-or-union-specifier => "union" ident-like "{" struct-declaratio...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(union-def ,$2 ,(tl->list $4)))
|
||||
;; struct-or-union-specifier => "union" "{" struct-declaration-list "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(union-def ,(tl->list $3)))
|
||||
;; struct-or-union-specifier => "union" ident-like
|
||||
(lambda ($2 $1 . $rest) `(union-ref ,$2))
|
||||
;; ident-like => identifier
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; ident-like => typedef-name
|
||||
(lambda ($1 . $rest) `(ident ,(cdr $1)))
|
||||
;; struct-declaration-list => struct-declaration
|
||||
(lambda ($1 . $rest) (make-tl 'field-list $1))
|
||||
;; struct-declaration-list => lone-comment
|
||||
(lambda ($1 . $rest) (make-tl 'field-list $1))
|
||||
;; struct-declaration-list => struct-declaration-list struct-declaration
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; struct-declaration-list => struct-declaration-list lone-comment
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; struct-declaration => specifier-qualifier-list struct-declarator-list...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
(if (pair? $4)
|
||||
`(comp-decl ,(tl->list $1) ,(tl->list $2) ,$4)
|
||||
`(comp-decl ,(tl->list $1) ,(tl->list $2))))
|
||||
;; specifier-qualifier-list => type-specifier specifier-qualifier-list
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; specifier-qualifier-list => type-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; specifier-qualifier-list => type-qualifier specifier-qualifier-list
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; specifier-qualifier-list => type-qualifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; struct-declarator-list => struct-declarator
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'comp-declr-list $1))
|
||||
;; struct-declarator-list => struct-declarator-list "," struct-declarator
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; struct-declarator => declarator
|
||||
(lambda ($1 . $rest) `(comp-declr ,$1))
|
||||
;; struct-declarator => declarator ":" constant-expression
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(comp-declr (bit-field ,$1 ,$3)))
|
||||
;; struct-declarator => ":" constant-expression
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(comp-declr (bit-field ,$2)))
|
||||
;; enum-specifier => "enum" ident-like "{" enumerator-list "}"
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,$2 ,(tl->list $4)))
|
||||
;; enum-specifier => "enum" ident-like "{" enumerator-list "," "}"
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,$2 ,(tl->list $4)))
|
||||
;; enum-specifier => "enum" "{" enumerator-list "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,(tl->list $3)))
|
||||
;; enum-specifier => "enum" "{" enumerator-list "," "}"
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,(tl->list $3)))
|
||||
;; enum-specifier => "enum" ident-like
|
||||
(lambda ($2 $1 . $rest) `(enum-ref ,$2))
|
||||
;; enumerator-list => enumerator
|
||||
(lambda ($1 . $rest) (make-tl 'enum-def-list $1))
|
||||
;; enumerator-list => enumerator-list "," enumerator
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; enumerator => identifier
|
||||
(lambda ($1 . $rest) `(enum-defn ,$1))
|
||||
;; enumerator => identifier "=" constant-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(enum-defn ,$1 ,$3))
|
||||
;; type-qualifier => "const"
|
||||
(lambda ($1 . $rest) `(type-qual ,$1))
|
||||
;; type-qualifier => "volatile"
|
||||
(lambda ($1 . $rest) `(type-qual ,$1))
|
||||
;; type-qualifier => "restrict"
|
||||
(lambda ($1 . $rest) `(type-qual ,$1))
|
||||
;; function-specifier => "inline"
|
||||
(lambda ($1 . $rest) `(fctn-spec ,$1))
|
||||
;; declarator => pointer direct-declarator
|
||||
(lambda ($2 $1 . $rest) `(ptr-declr ,$1 ,$2))
|
||||
;; declarator => direct-declarator
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; direct-declarator => identifier
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; direct-declarator => "(" declarator ")"
|
||||
(lambda ($3 $2 $1 . $rest) `(scope ,$2))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list assign...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3 ,$4))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3))
|
||||
;; direct-declarator => direct-declarator "[" assignment-expression "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3))
|
||||
;; direct-declarator => direct-declarator "[" "]"
|
||||
(lambda ($3 $2 $1 . $rest) `(array-of ,$1))
|
||||
;; direct-declarator => direct-declarator "[" "static" type-qualifier-li...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $4))
|
||||
,$5))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list "stati...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))
|
||||
,$5))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list "*" "]"
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3 (var-len)))
|
||||
;; direct-declarator => direct-declarator "[" "*" "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 (var-len)))
|
||||
;; direct-declarator => direct-declarator "(" parameter-type-list ")"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(ftn-declr ,$1 ,(tl->list $3)))
|
||||
;; direct-declarator => direct-declarator "(" identifier-list ")"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(ftn-declr ,$1 ,(tl->list $3)))
|
||||
;; direct-declarator => direct-declarator "(" ")"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(ftn-declr ,$1 (param-list)))
|
||||
;; pointer => "*" type-qualifier-list
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(pointer ,(tl->list $2)))
|
||||
;; pointer => "*"
|
||||
(lambda ($1 . $rest) '(pointer))
|
||||
;; pointer => "*" type-qualifier-list pointer
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(pointer ,(tl->list $2) ,$3))
|
||||
;; pointer => "*" pointer
|
||||
(lambda ($2 $1 . $rest) `(pointer ,$2))
|
||||
;; type-qualifier-list => type-qualifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; type-qualifier-list => type-qualifier-list type-qualifier
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; parameter-type-list => parameter-list
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; parameter-type-list => parameter-list "," "..."
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
(tl-append $1 '(ellipsis)))
|
||||
;; parameter-list => parameter-declaration
|
||||
(lambda ($1 . $rest) (make-tl 'param-list $1))
|
||||
;; parameter-list => parameter-list "," parameter-declaration
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; parameter-declaration => declaration-specifiers declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(param-decl ,(tl->list $1) (param-declr ,$2)))
|
||||
;; parameter-declaration => declaration-specifiers abstract-declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(param-decl ,(tl->list $1) (param-declr ,$2)))
|
||||
;; parameter-declaration => declaration-specifiers
|
||||
(lambda ($1 . $rest)
|
||||
`(param-decl ,(tl->list $1)))
|
||||
;; identifier-list => identifier
|
||||
(lambda ($1 . $rest) (make-tl 'ident-list $1))
|
||||
;; identifier-list => identifier-list "," identifier
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; type-name => specifier-qualifier-list abstract-declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(type-name ,(tl->list $1) ,$2))
|
||||
;; type-name => declaration-specifiers
|
||||
(lambda ($1 . $rest) `(type-name ,(tl->list $1)))
|
||||
;; abstract-declarator => pointer
|
||||
(lambda ($1 . $rest) `(abs-declr ,$1))
|
||||
;; abstract-declarator => pointer direct-abstract-declarator
|
||||
(lambda ($2 $1 . $rest) `(abs-declr ,$1 ,$2))
|
||||
;; abstract-declarator => direct-abstract-declarator
|
||||
(lambda ($1 . $rest) `(abs-declr ,$1))
|
||||
;; direct-abstract-declarator => "(" abstract-declarator ")"
|
||||
(lambda ($3 $2 $1 . $rest) `(declr-scope ,$2))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array ,$3 ,$4))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-array ,$1 ,$3))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" assignme...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-array ,$1 ,$3))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "]"
|
||||
(lambda ($3 $2 $1 . $rest) `(declr-array ,$1))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "static"...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $4))
|
||||
,$5))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "static"...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $4))))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))
|
||||
,$5))
|
||||
;; direct-abstract-declarator => "[" type-qualifier-list assignment-expr...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array ,$2 ,$3))
|
||||
;; direct-abstract-declarator => "[" type-qualifier-list "]"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(declr-anon-array ,$2))
|
||||
;; direct-abstract-declarator => "[" assignment-expression "]"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(declr-anon-array ,$2))
|
||||
;; direct-abstract-declarator => "[" "]"
|
||||
(lambda ($2 $1 . $rest) `(declr-anon-array))
|
||||
;; direct-abstract-declarator => "[" "static" type-qualifier-list assign...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))
|
||||
,$4))
|
||||
;; direct-abstract-declarator => "[" "static" type-qualifier-list "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))))
|
||||
;; direct-abstract-declarator => "[" type-qualifier-list "static" assign...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $2))
|
||||
,$4))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "*" "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(declr-STAR ,$1))
|
||||
;; direct-abstract-declarator => "[" "*" "]"
|
||||
(lambda ($3 $2 $1 . $rest) '(declr-STAR))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "(" paramete...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-fctn ,$1 ,(tl->list $3)))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "(" ")"
|
||||
(lambda ($3 $2 $1 . $rest) `(declr-fctn ,$1))
|
||||
;; direct-abstract-declarator => "(" parameter-type-list ")"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(declr-anon-fctn ,(tl->list $2)))
|
||||
;; direct-abstract-declarator => "(" ")"
|
||||
(lambda ($2 $1 . $rest) '(declr-anon-fctn))
|
||||
;; typedef-name => 'typename
|
||||
(lambda ($1 . $rest) `(typename ,$1))
|
||||
;; initializer => assignment-expression
|
||||
(lambda ($1 . $rest) `(initzer ,$1))
|
||||
;; initializer => "{" initializer-list "}"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(initzer ,(tl->list $2)))
|
||||
;; initializer => "{" initializer-list "," "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(initzer ,(tl->list $2)))
|
||||
;; initializer-list => designation initializer
|
||||
(lambda ($2 $1 . $rest)
|
||||
(make-tl 'initzer-list $1 $2))
|
||||
;; initializer-list => initializer
|
||||
(lambda ($1 . $rest) (make-tl 'initzer-list $1))
|
||||
;; initializer-list => initializer-list "," designation initializer
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
(tl-append $1 $3 $4))
|
||||
;; initializer-list => initializer-list "," initializer
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; designation => designator-list "="
|
||||
(lambda ($2 $1 . $rest) `(desig ,$1))
|
||||
;; designator-list => designator
|
||||
(lambda ($1 . $rest) (make-tl 'desgr-list $1))
|
||||
;; designator-list => designator-list designator
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; designator => "[" constant-expression "]"
|
||||
(lambda ($3 $2 $1 . $rest) (list 'array-dsgr $2))
|
||||
;; designator => "." identifier
|
||||
(lambda ($2 $1 . $rest) (list 'sel-dsgr $2))
|
||||
;; statement => labeled-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => compound-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => expression-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => selection-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => iteration-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => jump-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => cpp-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; labeled-statement => identifier ":" statement
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(labeled-stmt ,$1 ,$3))
|
||||
;; labeled-statement => "case" constant-expression ":" statement
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(case ,$2 ,$4))
|
||||
;; labeled-statement => "default" ":" statement
|
||||
(lambda ($3 $2 $1 . $rest) `(default ,$3))
|
||||
;; compound-statement => "{" block-item-list "}"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(compd-stmt ,(tl->list $2)))
|
||||
;; compound-statement => "{" "}"
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(compd-stmt (block-item-list)))
|
||||
;; block-item-list => block-item
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'block-item-list $1))
|
||||
;; block-item-list => block-item-list block-item
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; block-item => declaration
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; block-item => statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; expression-statement => expression ";"
|
||||
(lambda ($2 $1 . $rest) `(expr-stmt ,$1))
|
||||
;; expression-statement => ";"
|
||||
(lambda ($1 . $rest) '(expr-stmt))
|
||||
;; selection-statement => "if" "(" expression ")" statement
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest) `(if ,$3 ,$5))
|
||||
;; selection-statement => "if" "(" expression ")" statement "else" state...
|
||||
(lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(if ,$3 ,$5 ,$7))
|
||||
;; selection-statement => "switch" "(" expression ")" statement
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(switch ,$3 ,$5))
|
||||
;; iteration-statement => "while" "(" expression ")" statement
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(while ,$3 ,$5))
|
||||
;; iteration-statement => "do" statement "while" "(" expression ")" ";"
|
||||
(lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(do-while ,$2 ,$5))
|
||||
;; iteration-statement => "for" "(" initial-clause opt-expression ";" op...
|
||||
(lambda ($8 $7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(for ,$3 ,$4 ,$6 ,$8))
|
||||
;; initial-clause => expression ";"
|
||||
(lambda ($2 $1 . $rest) $1)
|
||||
;; initial-clause => ";"
|
||||
(lambda ($1 . $rest) '(expr))
|
||||
;; initial-clause => declaration
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; opt-expression =>
|
||||
(lambda $rest '(expr))
|
||||
;; opt-expression => expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; jump-statement => "goto" identifier ";"
|
||||
(lambda ($3 $2 $1 . $rest) `(goto ,$2))
|
||||
;; jump-statement => "continue" ";"
|
||||
(lambda ($2 $1 . $rest) '(continue))
|
||||
;; jump-statement => "break" ";"
|
||||
(lambda ($2 $1 . $rest) '(break))
|
||||
;; jump-statement => "return" expression ";"
|
||||
(lambda ($3 $2 $1 . $rest) `(return ,$2))
|
||||
;; jump-statement => "return" ";"
|
||||
(lambda ($2 $1 . $rest) `(return (expr)))
|
||||
;; translation-unit => external-declaration-list
|
||||
(lambda ($1 . $rest) (tl->list $1))
|
||||
;; external-declaration-list =>
|
||||
(lambda $rest (make-tl 'trans-unit))
|
||||
;; external-declaration-list => external-declaration-list external-decla...
|
||||
(lambda ($2 $1 . $rest)
|
||||
(if (eqv? (sx-tag $2) 'extern-block)
|
||||
(tl-extend $1 (sx-tail $2 1))
|
||||
(tl-append $1 $2)))
|
||||
;; external-declaration => function-definition
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => declaration
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => lone-comment
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => cpp-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => pragma
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => "extern" '$string "{" external-declaration-li...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(extern-block
|
||||
(extern-begin ,$2)
|
||||
,@(sx-tail (tl->list $4) 1)
|
||||
(extern-end)))
|
||||
;; external-declaration => ";"
|
||||
(lambda ($1 . $rest)
|
||||
`(decl (@ (extension . "GNU C"))))
|
||||
;; function-definition => declaration-specifiers declarator declaration-...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(knr-fctn-defn
|
||||
,(tl->list $1)
|
||||
,$2
|
||||
,(tl->list $3)
|
||||
,$4))
|
||||
;; function-definition => declaration-specifiers declarator compound-sta...
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(fctn-defn ,(tl->list $1) ,$2 ,$3))
|
||||
;; declaration-list => declaration
|
||||
(lambda ($1 . $rest) (make-tl $1))
|
||||
;; declaration-list => declaration-list declaration
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; opt-code-comment =>
|
||||
(lambda $rest (list))
|
||||
;; opt-code-comment => code-comment
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; identifier => '$ident
|
||||
(lambda ($1 . $rest) `(ident ,$1))
|
||||
;; identifier => 'cpp-ident
|
||||
(lambda ($1 . $rest) `(ident ,$1))
|
||||
;; constant => '$fixed
|
||||
(lambda ($1 . $rest) `(fixed ,$1))
|
||||
;; constant => '$float
|
||||
(lambda ($1 . $rest) `(float ,$1))
|
||||
;; constant => '$chlit
|
||||
(lambda ($1 . $rest) `(char ,$1))
|
||||
;; string-literal => '$string
|
||||
(lambda ($1 . $rest) (make-tl 'string $1))
|
||||
;; string-literal => string-literal '$string
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; code-comment => '$code-comm
|
||||
(lambda ($1 . $rest) `(comment ,$1))
|
||||
;; lone-comment => '$lone-comm
|
||||
(lambda ($1 . $rest) `(comment ,$1))
|
||||
;; cpp-statement => 'cpp-stmt
|
||||
(lambda ($1 . $rest) `(cpp-stmt ,$1))
|
||||
;; pragma => 'cpp-pragma
|
||||
(lambda ($1 . $rest) $1)
|
||||
))
|
||||
|
||||
;;; end tables
|
|
@ -1,808 +0,0 @@
|
|||
;; ./mach.d/c99tab.scm
|
||||
|
||||
;; Copyright (C) 2016,2017 Matthew R. Wette
|
||||
;;
|
||||
;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
;; or any later version published by the Free Software Foundation. See
|
||||
;; the file COPYING included with the this distribution.
|
||||
|
||||
(define c99-len-v
|
||||
#(1 1 1 1 3 1 4 4 3 3 3 2 2 6 7 1 3 1 3 2 1 1 2 2 2 2 4 1 1 1 1 1 1 1 4 1
|
||||
3 3 3 1 3 3 1 3 3 1 3 3 3 3 1 3 3 1 3 1 3 1 3 1 3 1 3 1 5 1 3 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 3 1 5 3 0 1 2 1 2 1 2 1 2 1 3 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
2 2 3 1 1 2 1 2 2 3 2 3 3 4 3 2 2 1 3 2 4 3 1 2 2 1 1 2 1 2 2 3 5 4 2 5 4
|
||||
2 1 1 1 1 2 2 4 2 1 2 1 1 3 1 3 2 5 6 4 5 2 1 3 1 3 1 1 1 1 2 1 1 3 5 4 4
|
||||
3 6 6 5 4 4 4 3 2 1 3 2 1 2 1 3 1 3 2 2 1 1 3 2 1 1 2 1 3 5 4 4 3 6 5 6 4
|
||||
3 3 2 5 4 5 4 3 4 3 3 2 1 1 3 4 2 1 4 3 2 1 2 3 2 1 1 1 1 1 1 1 3 4 3 3 2
|
||||
1 2 1 1 2 1 5 7 5 5 7 8 2 1 1 0 1 3 2 2 3 2 1 0 2 1 1 1 1 1 5 1 4 3 1 2 0
|
||||
1 1 1 1 1 1 1 2 1 1 1 1))
|
||||
|
||||
(define c99-pat-v
|
||||
#(((103 . 1) (182 . 2) (97 . -281) (95 . -281) (-1 . -281)) ((22 . 3) (28
|
||||
. 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36
|
||||
. 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17) (26 . 18) (27 . 19
|
||||
) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 .
|
||||
26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (47 . 31) (147 . 32) (148 . 33
|
||||
) (149 . 34) (150 . 35) (1 . 36) (2 . 37) (95 . 38) (170 . 39) (48 . 40) (
|
||||
46 . 41) (100 . 42) (110 . 43) (134 . 44) (106 . 45) (101 . 46) (102 . 47)
|
||||
(97 . -280)) ((97 . 0)) ((-1 . -233)) ((85 . 85) (6 . 52) (7 . 53) (22 .
|
||||
3) (138 . 80) (181 . 81) (137 . 86)) ((85 . 83) (6 . 52) (7 . 53) (22 . 3)
|
||||
(138 . 80) (181 . 81) (137 . 84)) ((85 . 79) (6 . 52) (7 . 53) (22 . 3) (
|
||||
138 . 80) (181 . 81) (137 . 82)) ((-1 . -138)) ((31 . 78) (-1 . -136)) ((
|
||||
31 . 77) (-1 . -135)) ((-1 . -132)) ((40 . 73) (38 . 74) (36 . 75) (34 .
|
||||
76) (-1 . -127)) ((38 . 70) (36 . 71) (32 . 72) (-1 . -116)) ((-1 . -113))
|
||||
((40 . 66) (38 . 67) (36 . 68) (34 . 69) (-1 . -114)) ((38 . 65) (-1 .
|
||||
-109)) ((-1 . -176)) ((-1 . -175)) ((-1 . -174)) ((-1 . -173)) ((-1 . -108
|
||||
)) ((-1 . -107)) ((-1 . -106)) ((-1 . -105)) ((-1 . -104)) ((-1 . -103)) (
|
||||
(-1 . -102)) ((-1 . -101)) ((-1 . -100)) ((-1 . -99)) ((-1 . -98)) ((-1 .
|
||||
-96)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34
|
||||
. 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17
|
||||
) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24
|
||||
) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60)
|
||||
(47 . 31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (170 . 64) (-1 . -90
|
||||
)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 .
|
||||
10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17)
|
||||
(26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24)
|
||||
(142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (
|
||||
47 . 31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (170 . 63) (-1 . -88)
|
||||
) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10
|
||||
) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17) (
|
||||
26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (
|
||||
142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47
|
||||
. 31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (170 . 62) (-1 . -86))
|
||||
((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10)
|
||||
(35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17) (26
|
||||
. 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142
|
||||
. 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47 .
|
||||
31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (170 . 61) (-1 . -84)) ((
|
||||
95 . -306) (97 . -306) (-1 . -306)) ((95 . -305) (97 . -305) (-1 . -305))
|
||||
((95 . -304) (97 . -304) (-1 . -304)) ((146 . 49) (153 . 50) (48 . 51) (6
|
||||
. 52) (7 . 53) (80 . 54) (93 . 55) (181 . 56) (126 . 57) (127 . 58) (145
|
||||
. 59)) ((95 . -289) (97 . -289) (-1 . -289)) ((8 . 48) (-1 . -97)) ((95 .
|
||||
-287) (97 . -287) (-1 . -287)) ((95 . -286) (97 . -286) (-1 . -286)) ((95
|
||||
. -285) (97 . -285) (-1 . -285)) ((95 . -284) (97 . -284) (-1 . -284)) ((
|
||||
95 . -283) (97 . -283) (-1 . -283)) ((95 . -282) (97 . -282) (-1 . -282))
|
||||
((85 . 126)) ((48 . -92) (83 . -92)) ((152 . 124) (83 . 125) (48 . -83)) (
|
||||
(94 . 121) (98 . 122) (151 . 123) (97 . -294) (95 . -294) (-1 . -294)) ((
|
||||
-1 . -297)) ((-1 . -296)) ((25 . 17) (26 . 18) (27 . 19) (148 . 118) (125
|
||||
. 119) (80 . 54) (127 . 120) (-1 . -193)) ((6 . 52) (7 . 53) (80 . 54) (93
|
||||
. 55) (181 . 56) (126 . 57) (127 . 58) (145 . 117)) ((-1 . -179)) ((91 .
|
||||
115) (93 . 116) (-1 . -178)) ((6 . 52) (7 . 53) (93 . 55) (181 . 56) (126
|
||||
. 114)) ((85 . 108) (115 . 109) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 .
|
||||
7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40
|
||||
. 15) (24 . 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140
|
||||
. 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44
|
||||
. 29) (45 . 30) (46 . 60) (47 . 31) (147 . 32) (148 . 33) (149 . 34) (150
|
||||
. 35) (170 . 110) (106 . 111) (99 . 112) (59 . 113) (48 . -94) (83 . -94))
|
||||
((-1 . -97)) ((-1 . -85)) ((-1 . -87)) ((-1 . -89)) ((-1 . -91)) ((-1 .
|
||||
-110)) ((38 . 107) (-1 . -111)) ((-1 . -115)) ((36 . 105) (38 . 106) (-1
|
||||
. -118)) ((-1 . -133)) ((-1 . -117)) ((38 . 104) (-1 . -120)) ((31 . 103)
|
||||
(-1 . -137)) ((38 . 102) (-1 . -125)) ((-1 . -126)) ((36 . 100) (38 . 101)
|
||||
(-1 . -129)) ((-1 . -134)) ((-1 . -139)) ((-1 . -140)) ((22 . 3) (28 . 4)
|
||||
(29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12
|
||||
) (38 . 13) (37 . 14) (40 . 15) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (
|
||||
139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27)
|
||||
(148 . 92) (149 . 93) (95 . 38) (133 . 94) (134 . 95) (135 . 96) (136 . 99
|
||||
)) ((-1 . -149)) ((-1 . -148)) ((85 . 98) (-1 . -144)) ((22 . 3) (28 . 4)
|
||||
(29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12)
|
||||
(38 . 13) (37 . 14) (40 . 15) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (
|
||||
139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27)
|
||||
(148 . 92) (149 . 93) (95 . 38) (133 . 94) (134 . 95) (135 . 96) (136 . 97
|
||||
)) ((85 . 91) (-1 . -147)) ((6 . 52) (7 . 53) (181 . 88) (128 . 89) (129
|
||||
. 90)) ((85 . 87) (-1 . -168)) ((6 . 52) (7 . 53) (181 . 88) (128 . 89) (
|
||||
129 . 228)) ((59 . 227) (84 . -171) (83 . -171)) ((84 . -169) (83 . -169))
|
||||
((84 . 225) (83 . 226)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32
|
||||
. 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15)
|
||||
(25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23)
|
||||
(41 . 24) (142 . 25) (143 . 26) (42 . 27) (148 . 92) (149 . 93) (95 . 38)
|
||||
(133 . 94) (134 . 95) (135 . 96) (136 . 224)) ((22 . 3) (28 . 4) (29 . 5)
|
||||
(30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 .
|
||||
13) (37 . 14) (40 . 15) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21
|
||||
) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (148 .
|
||||
92) (149 . 93) (133 . 223) (-1 . -158)) ((22 . 3) (28 . 4) (29 . 5) (30 .
|
||||
6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37
|
||||
. 14) (40 . 15) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140
|
||||
. 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (148 . 92) (149
|
||||
. 93) (133 . 222) (-1 . -156)) ((6 . 52) (7 . 53) (80 . 54) (93 . 55) (
|
||||
181 . 56) (126 . 57) (127 . 58) (60 . 218) (145 . 219) (131 . 220) (132 .
|
||||
221)) ((95 . -151) (-1 . -151)) ((95 . -150) (-1 . -150)) ((84 . 217) (22
|
||||
. 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35
|
||||
. 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (25 . 17) (26 . 18) (27 . 19
|
||||
) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 .
|
||||
26) (42 . 27) (148 . 92) (149 . 93) (133 . 94) (135 . 214) (95 . 38) (134
|
||||
. 215)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (
|
||||
34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (25 . 17) (26
|
||||
. 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142
|
||||
. 25) (143 . 26) (42 . 27) (148 . 92) (149 . 93) (95 . 38) (133 . 94) (
|
||||
134 . 95) (135 . 96) (136 . 216)) ((84 . 213) (22 . 3) (28 . 4) (29 . 5) (
|
||||
30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13)
|
||||
(37 . 14) (40 . 15) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (
|
||||
140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (148 . 92)
|
||||
(149 . 93) (133 . 94) (135 . 214) (95 . 38) (134 . 215)) ((38 . 212) (-1
|
||||
. -131)) ((-1 . -128)) ((-1 . -124)) ((-1 . -141)) ((-1 . -121)) ((38 .
|
||||
211) (-1 . -122)) ((-1 . -119)) ((-1 . -112)) ((166 . 143) (165 . 144) (
|
||||
164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 .
|
||||
165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171)
|
||||
(87 . 172) (176 . 173) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 .
|
||||
8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (
|
||||
168 . 174) (155 . 175) (6 . 52) (7 . 53) (24 . 16) (25 . 17) (26 . 18) (27
|
||||
. 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (
|
||||
143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47 . 31) (172
|
||||
. 184) (2 . 37) (9 . 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14
|
||||
. 190) (15 . 191) (16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108)
|
||||
(20 . 196) (21 . 197) (181 . 198) (147 . 32) (148 . 33) (149 . 34) (150
|
||||
. 35) (110 . 199) (111 . 200) (112 . 201) (113 . 202) (114 . 203) (115 .
|
||||
204) (116 . 205) (170 . 110) (109 . 206) (106 . 207) (107 . 208) (108 .
|
||||
209) (84 . 210)) ((95 . -291) (97 . -291) (-1 . -291)) ((6 . 52) (7 . 53)
|
||||
(80 . 54) (93 . 55) (181 . 56) (126 . 57) (127 . 58) (145 . 128) (146 . 49
|
||||
) (153 . 50) (48 . 51)) ((-1 . -292)) ((85 . 108) (115 . 182) (22 . 3) (28
|
||||
. 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36
|
||||
. 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17) (26 . 18) (27 .
|
||||
19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143
|
||||
. 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47 . 31) (147 .
|
||||
32) (148 . 33) (149 . 34) (150 . 35) (170 . 110) (106 . 183)) ((166 . 143)
|
||||
(165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (
|
||||
8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158
|
||||
. 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 .
|
||||
161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (
|
||||
156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168
|
||||
. 174) (155 . 175) (85 . 179) (172 . 180) (144 . 181)) ((91 . 115) (93 .
|
||||
116) (-1 . -177)) ((44 . 141) (90 . 142) (166 . 143) (165 . 144) (164 .
|
||||
145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (
|
||||
4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (
|
||||
180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 .
|
||||
163) (80 . 164) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (
|
||||
167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172
|
||||
. 176) (25 . 17) (26 . 18) (27 . 19) (148 . 118) (125 . 177)) ((92 . 134)
|
||||
(6 . 52) (7 . 53) (181 . 135) (123 . 136) (22 . 3) (28 . 4) (29 . 5) (30
|
||||
. 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (
|
||||
37 . 14) (40 . 15) (24 . 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139
|
||||
. 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (43
|
||||
. 28) (44 . 29) (45 . 30) (46 . 60) (47 . 31) (147 . 32) (148 . 33) (149
|
||||
. 34) (150 . 35) (170 . 137) (121 . 138) (122 . 139) (124 . 140)) ((92 .
|
||||
133)) ((-1 . -196)) ((80 . 54) (127 . 131) (25 . 17) (26 . 18) (27 . 19) (
|
||||
148 . 132) (-1 . -192)) ((-1 . -195)) ((95 . -303) (97 . -303) (-1 . -303)
|
||||
) ((95 . -295) (97 . -295) (-1 . -295)) ((95 . -82) (97 . -82) (-1 . -82))
|
||||
((48 . 130)) ((6 . 52) (7 . 53) (80 . 54) (93 . 55) (181 . 56) (126 . 57)
|
||||
(127 . 58) (145 . 128) (146 . 129)) ((103 . 127) (95 . -281) (-1 . -281))
|
||||
((84 . 334) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9
|
||||
) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (
|
||||
25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (
|
||||
41 . 24) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (47
|
||||
. 31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (1 . 36) (2 . 37) (95
|
||||
. 38) (170 . 39) (48 . 40) (46 . 41) (100 . 42) (110 . 43) (134 . 44) (106
|
||||
. 45) (101 . 46) (102 . 47)) ((59 . 113) (48 . -94) (83 . -94)) ((48 .
|
||||
-93) (83 . -93)) ((94 . 121) (98 . 122) (151 . 333) (97 . -294) (95 . -294
|
||||
) (-1 . -294)) ((-1 . -194)) ((-1 . -197)) ((-1 . -180)) ((-1 . -191)) ((
|
||||
92 . -205) (83 . -205)) ((92 . 331) (83 . 332)) ((6 . 52) (7 . 53) (181 .
|
||||
56) (126 . 57) (145 . 325) (91 . 326) (93 . 327) (80 . 54) (120 . 328) (
|
||||
127 . 329) (169 . 330) (92 . -204) (83 . -204)) ((83 . -200) (92 . -200))
|
||||
((83 . 324) (92 . -198)) ((92 . 323)) ((25 . 17) (26 . 18) (27 . 19) (148
|
||||
. 118) (125 . 322)) ((-1 . -184)) ((-1 . -35)) ((80 . 319) (75 . 320) (74
|
||||
. 321) (-1 . -39)) ((79 . 317) (78 . 318) (-1 . -42)) ((73 . 315) (72 .
|
||||
316) (-1 . -45)) ((71 . 311) (70 . 312) (69 . 313) (68 . 314) (-1 . -50))
|
||||
((67 . 309) (66 . 310) (-1 . -53)) ((81 . 308) (-1 . -55)) ((-1 . -301)) (
|
||||
(-1 . -300)) ((-1 . -299)) ((-1 . -298)) ((65 . 307) (-1 . -57)) ((64 .
|
||||
306) (-1 . -59)) ((8 . 305) (-1 . -3)) ((-1 . -2)) ((-1 . -1)) ((63 . 304)
|
||||
(-1 . -61)) ((-1 . -32)) ((-1 . -31)) ((-1 . -30)) ((-1 . -29)) ((90 .
|
||||
303) (-1 . -28)) ((-1 . -27)) ((166 . 143) (165 . 144) (164 . 145) (163 .
|
||||
146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5
|
||||
. 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170)
|
||||
(86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172 . 184) (178
|
||||
. 297) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34
|
||||
. 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 .
|
||||
17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 .
|
||||
24) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60
|
||||
) (47 . 31) (147 . 32) (148 . 298) (149 . 299) (150 . 35) (170 . 300) (133
|
||||
. 301) (174 . 302)) ((-1 . -5)) ((61 . 295) (62 . 296) (-1 . -63)) ((8 .
|
||||
150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 .
|
||||
157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (
|
||||
81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 .
|
||||
173) (168 . 293) (93 . 294)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6
|
||||
. 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77 . 161) (
|
||||
78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 . 169) (167 .
|
||||
170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231) (166 . 292))
|
||||
((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (
|
||||
180 . 157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (93 . 289) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (
|
||||
87 . 172) (176 . 173) (168 . 291)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153
|
||||
) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77 .
|
||||
161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 289) (177 . 167) (
|
||||
82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 290)) ((91
|
||||
. 283) (93 . 284) (89 . 285) (88 . 286) (87 . 287) (86 . 288) (-1 . -21))
|
||||
((49 . 271) (50 . 272) (51 . 273) (52 . 274) (53 . 275) (54 . 276) (55 .
|
||||
277) (56 . 278) (57 . 279) (58 . 280) (59 . 281) (154 . 282) (-1 . -33)) (
|
||||
(-1 . -65)) ((90 . 270)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146)
|
||||
(162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153
|
||||
) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (181
|
||||
. 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (81 . 165)
|
||||
(93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87
|
||||
. 172) (176 . 173) (168 . 174) (155 . 175) (172 . 266) (25 . 17) (26 . 18)
|
||||
(27 . 19) (148 . 132) (90 . 267) (44 . 268) (80 . 269)) ((-1 . -28)) ((
|
||||
166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (
|
||||
160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159
|
||||
. 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (
|
||||
177 . 167) (89 . 259) (91 . 260) (156 . 168) (82 . 169) (167 . 170) (86 .
|
||||
171) (87 . 172) (176 . 173) (117 . 261) (168 . 174) (155 . 175) (118 . 262
|
||||
) (85 . 179) (172 . 180) (144 . 263) (119 . 264) (173 . 265)) ((83 . -234)
|
||||
(84 . -234) (48 . -234)) ((48 . -95) (83 . -95)) ((95 . -290) (97 . -290)
|
||||
(-1 . -290)) ((-1 . -293)) ((-1 . -78)) ((166 . 143) (165 . 144) (164 .
|
||||
145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (
|
||||
4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (
|
||||
180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 .
|
||||
163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (
|
||||
167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172
|
||||
. 184) (178 . 257) (48 . 258)) ((48 . 256)) ((48 . 255)) ((6 . 52) (7 . 53
|
||||
) (181 . 254)) ((93 . 253)) ((166 . 143) (165 . 144) (164 . 145) (163 .
|
||||
146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5
|
||||
. 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (
|
||||
177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176
|
||||
. 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (172 . 184) (2 . 37) (9
|
||||
. 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14 . 190) (15 . 191) (
|
||||
16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108) (20 . 196) (21 .
|
||||
197) (181 . 198) (110 . 199) (111 . 200) (112 . 201) (113 . 202) (114 .
|
||||
203) (115 . 204) (116 . 205) (109 . 252)) ((93 . 251)) ((93 . 250)) ((93
|
||||
. 249)) ((-1 . -263)) ((48 . 247) (83 . 248)) ((60 . 246)) ((8 . 150) (3
|
||||
. 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181
|
||||
. 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (
|
||||
177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 .
|
||||
166) (168 . 231) (166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 .
|
||||
147) (161 . 148) (160 . 149) (159 . 154) (158 . 155) (157 . 159) (156 .
|
||||
168) (155 . 232) (130 . 245)) ((60 . 244) (-1 . -1)) ((-1 . -252)) ((-1 .
|
||||
-251)) ((-1 . -250)) ((-1 . -249)) ((-1 . -248)) ((-1 . -247)) ((-1 . -246
|
||||
)) ((-1 . -261)) ((-1 . -260)) ((-1 . -258)) ((84 . 242) (166 . 143) (165
|
||||
. 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 .
|
||||
150) (3 . 151) (4 . 152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (
|
||||
180 . 157) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170)
|
||||
(86 . 171) (87 . 172) (176 . 173) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31
|
||||
. 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (
|
||||
40 . 15) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (24 . 16) (25 . 17) (26
|
||||
. 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (
|
||||
142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47
|
||||
. 31) (172 . 184) (2 . 37) (9 . 185) (10 . 186) (11 . 187) (12 . 188) (13
|
||||
. 189) (14 . 190) (15 . 191) (16 . 192) (19 . 193) (48 . 194) (178 . 195)
|
||||
(85 . 108) (20 . 196) (21 . 197) (181 . 198) (147 . 32) (148 . 33) (149
|
||||
. 34) (150 . 35) (110 . 199) (111 . 200) (112 . 201) (113 . 202) (114 .
|
||||
203) (115 . 204) (116 . 205) (170 . 110) (109 . 206) (106 . 207) (107 .
|
||||
243)) ((95 . -257) (97 . -257) (-1 . -257)) ((-1 . -123)) ((-1 . -130)) ((
|
||||
-1 . -143)) ((95 . -152) (-1 . -152)) ((95 . -153) (-1 . -153)) ((84 . 241
|
||||
) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10)
|
||||
(35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (25 . 17) (26 . 18) (27
|
||||
. 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (
|
||||
143 . 26) (42 . 27) (148 . 92) (149 . 93) (133 . 94) (135 . 214) (95 . 38)
|
||||
(134 . 215)) ((-1 . -146)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 .
|
||||
52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77 . 161) (78
|
||||
. 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 . 169) (167 . 170
|
||||
) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231) (166 . 143) (
|
||||
165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (
|
||||
159 . 154) (158 . 155) (157 . 159) (156 . 168) (155 . 232) (130 . 240)) ((
|
||||
60 . 239) (48 . -161) (83 . -161)) ((48 . -159) (83 . -159)) ((48 . 237) (
|
||||
83 . 238)) ((-1 . -155)) ((-1 . -157)) ((84 . 236) (22 . 3) (28 . 4) (29
|
||||
. 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38
|
||||
. 13) (37 . 14) (40 . 15) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139
|
||||
. 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (148
|
||||
. 92) (149 . 93) (133 . 94) (135 . 214) (95 . 38) (134 . 215)) ((-1 .
|
||||
-166)) ((84 . 234) (6 . 52) (7 . 53) (181 . 88) (128 . 235)) ((8 . 150) (3
|
||||
. 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181
|
||||
. 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165)
|
||||
(177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93
|
||||
. 166) (168 . 231) (166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 .
|
||||
147) (161 . 148) (160 . 149) (159 . 154) (158 . 155) (157 . 159) (156 .
|
||||
168) (155 . 232) (130 . 233)) ((83 . 229) (84 . 230)) ((6 . 52) (7 . 53) (
|
||||
181 . 88) (128 . 235) (84 . 412)) ((-1 . -164)) ((-1 . -33)) ((-1 . -80))
|
||||
((84 . -172) (83 . -172)) ((-1 . -167)) ((84 . -170) (83 . -170)) ((-1 .
|
||||
-145)) ((94 . 121) (98 . 122) (151 . 411) (95 . -294) (-1 . -294)) ((6 .
|
||||
52) (7 . 53) (80 . 54) (93 . 55) (181 . 56) (126 . 57) (127 . 58) (60 .
|
||||
218) (145 . 219) (131 . 410)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6
|
||||
. 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77 . 161) (
|
||||
78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 . 169) (167 .
|
||||
170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231) (166 . 143)
|
||||
(165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (
|
||||
159 . 154) (158 . 155) (157 . 159) (156 . 168) (155 . 232) (130 . 409)) ((
|
||||
48 . -163) (83 . -163)) ((-1 . -142)) ((95 . -256) (97 . -256) (-1 . -256)
|
||||
) ((-1 . -259)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 .
|
||||
147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (159
|
||||
. 154) (158 . 155) (179 . 156) (180 . 157) (157 . 159) (76 . 160) (77 .
|
||||
161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (
|
||||
156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168
|
||||
. 174) (155 . 175) (6 . 52) (7 . 53) (172 . 184) (2 . 37) (9 . 185) (10 .
|
||||
186) (11 . 187) (12 . 188) (13 . 189) (14 . 190) (15 . 191) (16 . 192) (19
|
||||
. 193) (48 . 194) (178 . 195) (85 . 108) (20 . 196) (21 . 197) (181 . 198
|
||||
) (110 . 199) (111 . 200) (112 . 201) (113 . 202) (114 . 203) (115 . 204)
|
||||
(116 . 205) (109 . 408)) ((60 . 407)) ((166 . 143) (165 . 144) (164 . 145)
|
||||
(163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 .
|
||||
152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (157 . 159)
|
||||
(76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 .
|
||||
166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172)
|
||||
(176 . 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (172 . 184) (2 . 37)
|
||||
(9 . 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14 . 190) (15 .
|
||||
191) (16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108) (20 . 196) (
|
||||
21 . 197) (181 . 198) (110 . 199) (111 . 200) (112 . 201) (113 . 202) (114
|
||||
. 203) (115 . 204) (116 . 205) (109 . 406)) ((-1 . -262)) ((166 . 143) (
|
||||
165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8
|
||||
. 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 .
|
||||
155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161)
|
||||
(78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156
|
||||
. 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174
|
||||
) (155 . 175) (172 . 405)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146
|
||||
) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 .
|
||||
153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170)
|
||||
(86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172 . 184) (178
|
||||
. 404)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161
|
||||
. 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 .
|
||||
53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159
|
||||
) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 .
|
||||
166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172)
|
||||
(176 . 173) (168 . 174) (155 . 175) (172 . 184) (178 . 403)) ((166 . 143)
|
||||
(165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8
|
||||
. 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158
|
||||
. 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 .
|
||||
161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (
|
||||
156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168
|
||||
. 174) (155 . 175) (172 . 184) (178 . 402)) ((15 . 401)) ((166 . 143) (165
|
||||
. 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 .
|
||||
150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 .
|
||||
155) (179 . 156) (180 . 157) (181 . 158) (22 . 3) (28 . 4) (29 . 5) (30 .
|
||||
6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37
|
||||
. 14) (40 . 15) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (
|
||||
80 . 178) (81 . 165) (93 . 166) (177 . 167) (24 . 16) (25 . 17) (26 . 18)
|
||||
(27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142 . 25)
|
||||
(143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47 . 31) (
|
||||
156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (147
|
||||
. 32) (148 . 33) (149 . 34) (150 . 35) (168 . 174) (155 . 175) (170 . 110)
|
||||
(172 . 184) (106 . 397) (48 . 398) (178 . 399) (105 . 400)) ((48 . 396))
|
||||
((-1 . -276)) ((-1 . -277)) ((48 . 395) (83 . 248)) ((-1 . -279)) ((6 . 52
|
||||
) (7 . 53) (181 . 394)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52)
|
||||
(7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77 . 161) (78 .
|
||||
162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 . 169) (167 . 170) (
|
||||
86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231) (166 . 143) (165
|
||||
. 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (159 .
|
||||
154) (158 . 155) (157 . 159) (156 . 168) (155 . 232) (130 . 393)) ((59 .
|
||||
-242) (89 . -242) (91 . -242)) ((59 . 391) (89 . 259) (91 . 260) (117 .
|
||||
392)) ((83 . -238) (84 . -238)) ((166 . 143) (165 . 144) (164 . 145) (163
|
||||
. 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (
|
||||
5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157)
|
||||
(181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80
|
||||
. 178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170
|
||||
) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (85 . 179) (
|
||||
172 . 180) (144 . 390)) ((83 . 388) (84 . 389)) ((90 . 387)) ((-1 . -182))
|
||||
((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148)
|
||||
(160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159
|
||||
. 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (
|
||||
177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176
|
||||
. 173) (168 . 174) (155 . 175) (172 . 386)) ((90 . 385) (-1 . -28)) ((-1
|
||||
. -183)) ((-1 . -77)) ((-1 . -76)) ((-1 . -75)) ((-1 . -74)) ((-1 . -73))
|
||||
((-1 . -72)) ((-1 . -71)) ((-1 . -70)) ((-1 . -69)) ((-1 . -68)) ((-1 .
|
||||
-67)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 .
|
||||
148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53)
|
||||
(159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (
|
||||
76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166
|
||||
) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (
|
||||
176 . 173) (168 . 174) (155 . 175) (172 . 384)) ((166 . 143) (165 . 144) (
|
||||
164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 .
|
||||
156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162)
|
||||
(79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 .
|
||||
169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175)
|
||||
(172 . 184) (178 . 383)) ((92 . 378) (166 . 143) (165 . 144) (164 . 145)
|
||||
(163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 .
|
||||
152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (22 . 3) (28 . 4) (29 . 5) (
|
||||
30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13)
|
||||
(37 . 14) (40 . 15) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (24
|
||||
. 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141
|
||||
. 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 .
|
||||
30) (46 . 60) (47 . 31) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79
|
||||
. 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (147 . 32) (148 . 33)
|
||||
(149 . 34) (150 . 35) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 .
|
||||
172) (176 . 173) (168 . 174) (155 . 175) (170 . 379) (171 . 380) (172 .
|
||||
381) (175 . 382)) ((6 . 52) (7 . 53) (181 . 377)) ((6 . 52) (7 . 53) (181
|
||||
. 376)) ((-1 . -11)) ((-1 . -12)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31
|
||||
. 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14)
|
||||
(40 . 15) (24 . 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (
|
||||
140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (
|
||||
44 . 29) (45 . 30) (46 . 60) (47 . 31) (147 . 32) (148 . 298) (149 . 299)
|
||||
(150 . 35) (170 . 300) (133 . 301) (174 . 375) (166 . 143) (165 . 144) (
|
||||
164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 .
|
||||
156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162)
|
||||
(79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 .
|
||||
169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175)
|
||||
(172 . 184) (178 . 297)) ((-1 . -22)) ((-1 . -23)) ((-1 . -24)) ((-1 .
|
||||
-25)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34
|
||||
. 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17
|
||||
) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24
|
||||
) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60)
|
||||
(47 . 31) (147 . 32) (148 . 298) (149 . 299) (150 . 35) (170 . 300) (133
|
||||
. 301) (174 . 374) (166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 .
|
||||
147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 .
|
||||
52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (
|
||||
157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 .
|
||||
165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171)
|
||||
(87 . 172) (176 . 173) (168 . 174) (155 . 175) (172 . 184) (178 . 297)) ((
|
||||
166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (
|
||||
160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159
|
||||
. 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (
|
||||
177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176
|
||||
. 173) (168 . 174) (155 . 175) (172 . 184) (178 . 373)) ((8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 .
|
||||
158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (
|
||||
177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 .
|
||||
166) (168 . 231) (166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 .
|
||||
147) (161 . 148) (160 . 149) (159 . 154) (158 . 155) (157 . 372)) ((92 .
|
||||
371) (83 . 248)) ((24 . 16) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47 .
|
||||
31) (147 . 32) (150 . 35) (170 . 63) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (
|
||||
31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14
|
||||
) (40 . 15) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22)
|
||||
(141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (148 . 298) (149 .
|
||||
299) (133 . 223) (92 . -88) (80 . -158) (91 . -158) (93 . -158)) ((24 . 16
|
||||
) (43 . 28) (44 . 29) (45 . 30) (46 . 60) (47 . 31) (147 . 32) (150 . 35)
|
||||
(170 . 62) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9)
|
||||
(34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (25 . 17) (26
|
||||
. 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24) (142
|
||||
. 25) (143 . 26) (42 . 27) (148 . 298) (149 . 299) (133 . 222) (92 . -86)
|
||||
(80 . -156) (91 . -156) (93 . -156)) ((92 . -208)) ((91 . 326) (93 . 368)
|
||||
(80 . 54) (120 . 328) (127 . 369) (169 . 370)) ((92 . 367)) ((-1 . -188))
|
||||
((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (
|
||||
180 . 157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (
|
||||
176 . 173) (93 . 166) (168 . 231) (166 . 143) (165 . 144) (164 . 145) (163
|
||||
. 146) (162 . 147) (161 . 148) (160 . 149) (159 . 154) (158 . 366)) ((-1
|
||||
. -302)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179
|
||||
. 156) (180 . 157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163)
|
||||
(80 . 178) (81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87
|
||||
. 172) (176 . 173) (93 . 166) (168 . 231) (166 . 143) (165 . 144) (164 .
|
||||
145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (159 . 365)) ((8 .
|
||||
150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 .
|
||||
157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (
|
||||
81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 .
|
||||
173) (93 . 166) (168 . 231) (166 . 143) (165 . 144) (164 . 145) (163 . 146
|
||||
) (162 . 147) (161 . 148) (160 . 364)) ((8 . 150) (3 . 151) (4 . 152) (5
|
||||
. 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (
|
||||
77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 .
|
||||
169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231)
|
||||
(166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 363)) (
|
||||
(8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180
|
||||
. 157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178)
|
||||
(81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176
|
||||
. 173) (93 . 166) (168 . 231) (166 . 143) (165 . 144) (164 . 145) (163 .
|
||||
146) (162 . 362)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 .
|
||||
53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (
|
||||
79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 .
|
||||
171) (87 . 172) (176 . 173) (93 . 166) (168 . 231) (166 . 143) (165 . 144)
|
||||
(164 . 145) (163 . 146) (162 . 361)) ((8 . 150) (3 . 151) (4 . 152) (5 .
|
||||
153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77
|
||||
. 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 . 169)
|
||||
(167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231) (166
|
||||
. 143) (165 . 144) (164 . 145) (163 . 360)) ((8 . 150) (3 . 151) (4 . 152)
|
||||
(5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160
|
||||
) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82
|
||||
. 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231
|
||||
) (166 . 143) (165 . 144) (164 . 145) (163 . 359)) ((8 . 150) (3 . 151) (4
|
||||
. 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (
|
||||
76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 .
|
||||
167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (
|
||||
168 . 231) (166 . 143) (165 . 144) (164 . 145) (163 . 358)) ((8 . 150) (3
|
||||
. 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181
|
||||
. 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (
|
||||
177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 .
|
||||
166) (168 . 231) (166 . 143) (165 . 144) (164 . 145) (163 . 357)) ((8 .
|
||||
150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 .
|
||||
157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (
|
||||
81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 .
|
||||
173) (93 . 166) (168 . 231) (166 . 143) (165 . 144) (164 . 356)) ((8 . 150
|
||||
) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157)
|
||||
(181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 .
|
||||
165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173)
|
||||
(93 . 166) (168 . 231) (166 . 143) (165 . 144) (164 . 355)) ((8 . 150) (3
|
||||
. 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181
|
||||
. 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (
|
||||
177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 .
|
||||
166) (168 . 231) (166 . 143) (165 . 354)) ((8 . 150) (3 . 151) (4 . 152) (
|
||||
5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160)
|
||||
(77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 .
|
||||
169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231)
|
||||
(166 . 143) (165 . 353)) ((8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52)
|
||||
(7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (77 . 161) (78 .
|
||||
162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 . 169) (167 . 170) (
|
||||
86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231) (166 . 352)) ((8
|
||||
. 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 .
|
||||
157) (181 . 158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (
|
||||
81 . 165) (177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 .
|
||||
173) (93 . 166) (168 . 231) (166 . 351)) ((8 . 150) (3 . 151) (4 . 152) (5
|
||||
. 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160) (
|
||||
77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 .
|
||||
169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231)
|
||||
(166 . 350)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147)
|
||||
(161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (
|
||||
7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157
|
||||
. 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (
|
||||
93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 .
|
||||
172) (176 . 173) (168 . 174) (155 . 175) (172 . 349) (25 . 17) (26 . 18) (
|
||||
27 . 19) (148 . 132)) ((-1 . -189)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (
|
||||
31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14
|
||||
) (40 . 15) (24 . 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21)
|
||||
(140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (43 . 28)
|
||||
(44 . 29) (45 . 30) (46 . 60) (47 . 31) (147 . 32) (148 . 33) (149 . 34) (
|
||||
150 . 35) (170 . 137) (121 . 347) (23 . 348)) ((92 . -202) (83 . -202)) ((
|
||||
166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (
|
||||
160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159
|
||||
. 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (81 . 165) (93 . 166) (177 . 167) (
|
||||
156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168
|
||||
. 174) (155 . 175) (172 . 342) (90 . 343) (44 . 344) (25 . 17) (26 . 18) (
|
||||
27 . 19) (148 . 118) (125 . 345) (80 . 346)) ((91 . 326) (120 . 328) (169
|
||||
. 339) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34
|
||||
. 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25 . 17
|
||||
) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41 . 24
|
||||
) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46 . 60)
|
||||
(47 . 31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (170 . 137) (121 .
|
||||
138) (122 . 139) (124 . 340) (92 . 341) (6 . 52) (7 . 53) (80 . 54) (93 .
|
||||
327) (181 . 56) (126 . 57) (127 . 329) (145 . 117)) ((91 . 337) (93 . 338)
|
||||
(92 . -211) (83 . -211)) ((91 . 326) (120 . 336) (6 . 52) (7 . 53) (93 .
|
||||
327) (181 . 56) (126 . 114) (92 . -209) (83 . -209)) ((92 . -203) (83 .
|
||||
-203)) ((-1 . -190)) ((6 . 52) (7 . 53) (181 . 335)) ((95 . -81) (97 . -81
|
||||
) (-1 . -81)) ((95 . -288) (97 . -288) (-1 . -288)) ((92 . -206) (83 .
|
||||
-206)) ((91 . 337) (93 . 338) (92 . -210) (83 . -210)) ((44 . 446) (90 .
|
||||
447) (166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 .
|
||||
148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53)
|
||||
(159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (
|
||||
76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 448) (81 . 165) (93 . 166
|
||||
) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (
|
||||
176 . 173) (168 . 174) (155 . 175) (172 . 449) (25 . 17) (26 . 18) (27 .
|
||||
19) (148 . 118) (125 . 450)) ((92 . 444) (22 . 3) (28 . 4) (29 . 5) (30 .
|
||||
6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37
|
||||
. 14) (40 . 15) (24 . 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 .
|
||||
21) (140 . 22) (141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (43 .
|
||||
28) (44 . 29) (45 . 30) (46 . 60) (47 . 31) (147 . 32) (148 . 33) (149 .
|
||||
34) (150 . 35) (170 . 137) (121 . 138) (122 . 139) (124 . 445)) ((92 . 443
|
||||
)) ((92 . 442)) ((-1 . -232)) ((90 . 441)) ((-1 . -223)) ((25 . 17) (26 .
|
||||
18) (27 . 19) (148 . 118) (125 . 440)) ((44 . 437) (25 . 17) (26 . 18) (27
|
||||
. 19) (148 . 132) (90 . 438) (166 . 143) (165 . 144) (164 . 145) (163 .
|
||||
146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5
|
||||
. 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170)
|
||||
(86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172 . 439)) ((
|
||||
90 . 436) (-1 . -28)) ((83 . -201) (92 . -201)) ((92 . -199)) ((90 . 435))
|
||||
((-1 . -38)) ((-1 . -37)) ((-1 . -36)) ((80 . 319) (75 . 320) (74 . 321)
|
||||
(-1 . -41)) ((80 . 319) (75 . 320) (74 . 321) (-1 . -40)) ((79 . 317) (78
|
||||
. 318) (-1 . -44)) ((79 . 317) (78 . 318) (-1 . -43)) ((73 . 315) (72 .
|
||||
316) (-1 . -49)) ((73 . 315) (72 . 316) (-1 . -48)) ((73 . 315) (72 . 316)
|
||||
(-1 . -47)) ((73 . 315) (72 . 316) (-1 . -46)) ((71 . 311) (70 . 312) (69
|
||||
. 313) (68 . 314) (-1 . -52)) ((71 . 311) (70 . 312) (69 . 313) (68 . 314
|
||||
) (-1 . -51)) ((67 . 309) (66 . 310) (-1 . -54)) ((81 . 308) (-1 . -56)) (
|
||||
(65 . 307) (-1 . -58)) ((64 . 306) (-1 . -60)) ((85 . 433) (8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 .
|
||||
158) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (
|
||||
177 . 167) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 .
|
||||
166) (168 . 231) (166 . 434)) ((91 . 326) (93 . 368) (80 . 54) (120 . 328)
|
||||
(127 . 369) (169 . 339) (22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32
|
||||
. 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15)
|
||||
(24 . 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (
|
||||
141 . 23) (41 . 24) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (
|
||||
45 . 30) (46 . 60) (47 . 31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (
|
||||
170 . 137) (121 . 138) (122 . 139) (124 . 340) (92 . 341)) ((91 . 326) (93
|
||||
. 368) (120 . 336) (92 . -209) (83 . -209)) ((92 . -207)) ((-1 . -4)) ((
|
||||
63 . 304) (-1 . -62)) ((60 . 432) (83 . 248)) ((92 . 431)) ((92 . 430)) ((
|
||||
-1 . -10)) ((-1 . -9)) ((-1 . -8)) ((91 . 326) (93 . 368) (80 . 54) (120
|
||||
. 328) (127 . 369) (169 . 429) (92 . -20) (83 . -20)) ((92 . -17) (83 .
|
||||
-17)) ((92 . -15) (83 . -15)) ((92 . 427) (83 . 428)) ((90 . 426) (83 .
|
||||
248)) ((-1 . -66)) ((-1 . -187)) ((90 . 425)) ((-1 . -181)) ((166 . 143) (
|
||||
165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8
|
||||
. 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 .
|
||||
155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161)
|
||||
(78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156
|
||||
. 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174
|
||||
) (155 . 175) (85 . 179) (172 . 180) (144 . 422) (89 . 259) (91 . 260) (
|
||||
117 . 261) (118 . 262) (119 . 423) (84 . 424)) ((83 . -235) (84 . -235) (
|
||||
48 . -235)) ((83 . -237) (84 . -237)) ((-1 . -241)) ((59 . -243) (89 .
|
||||
-243) (91 . -243)) ((90 . 421)) ((59 . -245) (91 . -245) (89 . -245)) ((-1
|
||||
. -278)) ((-1 . -275)) ((-1 . -272)) ((-1 . -271)) ((48 . 420) (83 . 248)
|
||||
) ((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148)
|
||||
(160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (
|
||||
159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76
|
||||
. 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166)
|
||||
(177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176
|
||||
. 173) (168 . 174) (155 . 175) (172 . 184) (178 . 418) (104 . 419) (48 .
|
||||
-273)) ((93 . 417)) ((92 . 416) (83 . 248)) ((92 . 415) (83 . 248)) ((83
|
||||
. 248) (92 . 414)) ((-1 . -79)) ((-1 . -255)) ((166 . 143) (165 . 144) (
|
||||
164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 .
|
||||
165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171)
|
||||
(87 . 172) (176 . 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (172 .
|
||||
184) (2 . 37) (9 . 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14 .
|
||||
190) (15 . 191) (16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108) (
|
||||
20 . 196) (21 . 197) (181 . 198) (110 . 199) (111 . 200) (112 . 201) (113
|
||||
. 202) (114 . 203) (115 . 204) (116 . 205) (109 . 413)) ((-1 . -253)) ((48
|
||||
. -162) (83 . -162)) ((48 . -160) (83 . -160)) ((95 . -154) (-1 . -154))
|
||||
((-1 . -165)) ((-1 . -254)) ((166 . 143) (165 . 144) (164 . 145) (163 .
|
||||
146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5
|
||||
. 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (
|
||||
177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176
|
||||
. 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (172 . 184) (2 . 37) (9
|
||||
. 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14 . 190) (15 . 191) (
|
||||
16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108) (20 . 196) (21 .
|
||||
197) (181 . 198) (110 . 199) (111 . 200) (112 . 201) (113 . 202) (114 .
|
||||
203) (115 . 204) (116 . 205) (109 . 471)) ((166 . 143) (165 . 144) (164 .
|
||||
145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (
|
||||
4 . 152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (157 .
|
||||
159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93
|
||||
. 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 .
|
||||
172) (176 . 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (172 . 184) (2
|
||||
. 37) (9 . 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14 . 190) (15
|
||||
. 191) (16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108) (20 . 196)
|
||||
(21 . 197) (181 . 198) (110 . 199) (111 . 200) (112 . 201) (113 . 202) (
|
||||
114 . 203) (115 . 204) (116 . 205) (109 . 470)) ((166 . 143) (165 . 144) (
|
||||
164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 .
|
||||
165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171)
|
||||
(87 . 172) (176 . 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (172 .
|
||||
184) (2 . 37) (9 . 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14 .
|
||||
190) (15 . 191) (16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108) (
|
||||
20 . 196) (21 . 197) (181 . 198) (110 . 199) (111 . 200) (112 . 201) (113
|
||||
. 202) (114 . 203) (115 . 204) (116 . 205) (109 . 469)) ((166 . 143) (165
|
||||
. 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 .
|
||||
150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 .
|
||||
155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161)
|
||||
(78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156
|
||||
. 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174
|
||||
) (155 . 175) (172 . 184) (178 . 468)) ((83 . 248) (48 . -274) (92 . -274)
|
||||
) ((48 . 467)) ((-1 . -270)) ((59 . -244) (91 . -244) (89 . -244)) ((83 .
|
||||
-240) (84 . -240)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162
|
||||
. 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6
|
||||
. 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158)
|
||||
(157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 .
|
||||
165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171)
|
||||
(87 . 172) (176 . 173) (168 . 174) (155 . 175) (85 . 179) (172 . 180) (144
|
||||
. 466)) ((83 . -236) (84 . -236) (48 . -236)) ((-1 . -186)) ((-1 . -6)) (
|
||||
(-1 . -7)) ((22 . 3) (28 . 4) (29 . 5) (30 . 6) (31 . 7) (32 . 8) (33 . 9)
|
||||
(34 . 10) (35 . 11) (36 . 12) (38 . 13) (37 . 14) (40 . 15) (24 . 16) (25
|
||||
. 17) (26 . 18) (27 . 19) (138 . 20) (139 . 21) (140 . 22) (141 . 23) (41
|
||||
. 24) (142 . 25) (143 . 26) (42 . 27) (43 . 28) (44 . 29) (45 . 30) (46
|
||||
. 60) (47 . 31) (147 . 32) (148 . 33) (149 . 34) (150 . 35) (170 . 379) (
|
||||
171 . 464) (166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (
|
||||
161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7
|
||||
. 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 .
|
||||
159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93
|
||||
. 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 .
|
||||
172) (176 . 173) (168 . 174) (155 . 175) (172 . 465)) ((92 . -19) (83 .
|
||||
-19)) ((85 . 433)) ((85 . 433) (-1 . -26)) ((8 . 150) (3 . 151) (4 . 152)
|
||||
(5 . 153) (6 . 52) (7 . 53) (179 . 156) (180 . 157) (181 . 158) (76 . 160)
|
||||
(77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (177 . 167) (82 .
|
||||
169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (93 . 166) (168 . 231)
|
||||
(166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (
|
||||
160 . 149) (159 . 154) (158 . 155) (157 . 159) (156 . 168) (155 . 463)) ((
|
||||
166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (
|
||||
160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159
|
||||
. 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (
|
||||
177 . 167) (89 . 259) (91 . 260) (156 . 168) (82 . 169) (167 . 170) (86 .
|
||||
171) (87 . 172) (176 . 173) (117 . 261) (168 . 174) (155 . 175) (118 . 262
|
||||
) (85 . 179) (172 . 180) (144 . 263) (119 . 264) (173 . 462)) ((-1 . -34))
|
||||
((-1 . -185)) ((-1 . -228)) ((166 . 143) (165 . 144) (164 . 145) (163 .
|
||||
146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5
|
||||
. 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170)
|
||||
(86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172 . 461)) ((
|
||||
-1 . -221)) ((90 . 460)) ((166 . 143) (165 . 144) (164 . 145) (163 . 146)
|
||||
(162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153
|
||||
) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (181
|
||||
. 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178)
|
||||
(81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86
|
||||
. 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172 . 458) (25 . 17
|
||||
) (26 . 18) (27 . 19) (148 . 132) (90 . 459)) ((-1 . -222)) ((-1 . -231))
|
||||
((-1 . -212)) ((-1 . -230)) ((92 . 457)) ((25 . 17) (26 . 18) (27 . 19) (
|
||||
148 . 118) (125 . 456)) ((-1 . -216)) ((90 . 455) (-1 . -28)) ((90 . 454))
|
||||
((166 . 143) (165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148)
|
||||
(160 . 149) (8 . 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159
|
||||
. 154) (158 . 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 .
|
||||
160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (
|
||||
177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176
|
||||
. 173) (168 . 174) (155 . 175) (172 . 451) (25 . 17) (26 . 18) (27 . 19) (
|
||||
148 . 132) (90 . 452) (44 . 453)) ((90 . 482)) ((-1 . -214)) ((166 . 143)
|
||||
(165 . 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8
|
||||
. 150) (3 . 151) (4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158
|
||||
. 155) (179 . 156) (180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 .
|
||||
161) (78 . 162) (79 . 163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (
|
||||
156 . 168) (82 . 169) (167 . 170) (86 . 171) (87 . 172) (176 . 173) (168
|
||||
. 174) (155 . 175) (172 . 481)) ((-1 . -215)) ((-1 . -227)) ((90 . 479) (
|
||||
25 . 17) (26 . 18) (27 . 19) (148 . 132) (166 . 143) (165 . 144) (164 .
|
||||
145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (
|
||||
4 . 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (
|
||||
180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 .
|
||||
163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (
|
||||
167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172
|
||||
. 480)) ((-1 . -229)) ((90 . 478)) ((-1 . -225)) ((-1 . -220)) ((90 . 477)
|
||||
) ((84 . 475) (83 . 476)) ((-1 . -64)) ((92 . -18) (83 . -18)) ((92 . -16)
|
||||
(83 . -16)) ((83 . -239) (84 . -239)) ((166 . 143) (165 . 144) (164 . 145
|
||||
) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4
|
||||
. 152) (5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (
|
||||
180 . 157) (181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 .
|
||||
163) (80 . 178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (
|
||||
167 . 170) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (172
|
||||
. 184) (178 . 418) (104 . 474) (92 . -273)) ((92 . 473) (83 . 248)) ((-1
|
||||
. -267)) ((-1 . -266)) ((17 . 472) (-1 . -264)) ((166 . 143) (165 . 144) (
|
||||
164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 .
|
||||
151) (4 . 152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (180 . 157) (
|
||||
157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 . 178) (81 .
|
||||
165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170) (86 . 171)
|
||||
(87 . 172) (176 . 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53) (172 .
|
||||
184) (2 . 37) (9 . 185) (10 . 186) (11 . 187) (12 . 188) (13 . 189) (14 .
|
||||
190) (15 . 191) (16 . 192) (19 . 193) (48 . 194) (178 . 195) (85 . 108) (
|
||||
20 . 196) (21 . 197) (181 . 198) (110 . 199) (111 . 200) (112 . 201) (113
|
||||
. 202) (114 . 203) (115 . 204) (116 . 205) (109 . 488)) ((48 . 487)) ((92
|
||||
. 486)) ((-1 . -13)) ((84 . 485) (166 . 143) (165 . 144) (164 . 145) (163
|
||||
. 146) (162 . 147) (161 . 148) (160 . 149) (8 . 150) (3 . 151) (4 . 152) (
|
||||
5 . 153) (6 . 52) (7 . 53) (159 . 154) (158 . 155) (179 . 156) (180 . 157)
|
||||
(181 . 158) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80
|
||||
. 178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170
|
||||
) (86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (85 . 179) (
|
||||
172 . 180) (144 . 422) (89 . 259) (91 . 260) (117 . 261) (118 . 262) (119
|
||||
. 423)) ((-1 . -226)) ((-1 . -224)) ((-1 . -218)) ((90 . 484)) ((90 . 483)
|
||||
) ((-1 . -213)) ((-1 . -219)) ((-1 . -217)) ((-1 . -14)) ((166 . 143) (165
|
||||
. 144) (164 . 145) (163 . 146) (162 . 147) (161 . 148) (160 . 149) (8 .
|
||||
150) (3 . 151) (4 . 152) (5 . 153) (159 . 154) (158 . 155) (179 . 156) (
|
||||
180 . 157) (157 . 159) (76 . 160) (77 . 161) (78 . 162) (79 . 163) (80 .
|
||||
178) (81 . 165) (93 . 166) (177 . 167) (156 . 168) (82 . 169) (167 . 170)
|
||||
(86 . 171) (87 . 172) (176 . 173) (168 . 174) (155 . 175) (6 . 52) (7 . 53
|
||||
) (172 . 184) (2 . 37) (9 . 185) (10 . 186) (11 . 187) (12 . 188) (13 .
|
||||
189) (14 . 190) (15 . 191) (16 . 192) (19 . 193) (48 . 194) (178 . 195) (
|
||||
85 . 108) (20 . 196) (21 . 197) (181 . 198) (110 . 199) (111 . 200) (112
|
||||
. 201) (113 . 202) (114 . 203) (115 . 204) (116 . 205) (109 . 489)) ((-1
|
||||
. -268)) ((-1 . -265)) ((-1 . -269))))
|
||||
|
||||
(define c99-rto-v
|
||||
#(#f 177 177 177 177 176 176 176 176 176 176 176 176 176 176 175 175 175
|
||||
175 171 171 168 168 168 168 168 168 167 167 167 167 167 167 166 166 165
|
||||
165 165 165 164 164 164 163 163 163 162 162 162 162 162 161 161 161 160
|
||||
160 159 159 158 158 157 157 156 156 155 155 172 172 154 154 154 154 154
|
||||
154 154 154 154 154 154 178 178 130 106 106 152 170 170 170 170 170 170
|
||||
170 170 153 153 146 146 150 150 150 150 150 149 149 149 149 149 149 149
|
||||
149 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143
|
||||
143 143 143 143 143 143 143 143 143 142 142 142 141 141 141 141 140 140
|
||||
140 140 140 140 137 137 136 136 136 136 135 133 133 133 133 132 132 131
|
||||
131 131 139 139 139 139 139 129 129 128 128 148 148 148 147 145 145 126
|
||||
126 126 126 126 126 126 126 126 126 126 126 126 127 127 127 127 125 125
|
||||
124 124 122 122 121 121 121 123 123 174 174 169 169 169 120 120 120 120
|
||||
120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 138
|
||||
144 144 144 173 173 173 173 119 118 118 117 117 109 109 109 109 109 109
|
||||
109 116 116 116 115 115 108 108 107 107 114 114 113 113 113 112 112 112
|
||||
105 105 105 104 104 111 111 111 111 111 182 103 103 102 102 102 102 102
|
||||
102 102 101 101 99 99 151 151 181 181 180 180 180 179 179 98 134 110 100))
|
||||
|
||||
(define c99-mtab
|
||||
'((cpp-pragma . 1) (cpp-stmt . 2) ($chlit . 3) ($float . 4) ($fixed . 5) (
|
||||
cpp-ident . 6) ($ident . 7) ($string . 8) ("return" . 9) ("break" . 10) (
|
||||
"continue" . 11) ("goto" . 12) ("for" . 13) ("do" . 14) ("while" . 15) (
|
||||
"switch" . 16) ("else" . 17) (then . 18) ("if" . 19) ("default" . 20) (
|
||||
"case" . 21) (typename . 22) ("..." . 23) ("inline" . 24) ("restrict" . 25
|
||||
) ("volatile" . 26) ("const" . 27) ("enum" . 28) ("union" . 29) ("struct"
|
||||
. 30) ("_Complex" . 31) ("double" . 32) ("float" . 33) ("char" . 34) (
|
||||
"unsigned" . 35) ("long" . 36) ("signed" . 37) ("int" . 38) (imp . 39) (
|
||||
"short" . 40) ("_Bool" . 41) ("void" . 42) ("typedef" . 43) ("static" . 44
|
||||
) ("register" . 45) ("extern" . 46) ("auto" . 47) (";" . 48) ("|=" . 49) (
|
||||
"^=" . 50) ("&=" . 51) (">>=" . 52) ("<<=" . 53) ("%=" . 54) ("/=" . 55) (
|
||||
"*=" . 56) ("-=" . 57) ("+=" . 58) ("=" . 59) (":" . 60) ("?" . 61) ("||"
|
||||
. 62) ("&&" . 63) ("|" . 64) ("^" . 65) ("!=" . 66) ("==" . 67) (">=" . 68
|
||||
) ("<=" . 69) (">" . 70) ("<" . 71) (">>" . 72) ("<<" . 73) ("%" . 74) (
|
||||
"/" . 75) ("!" . 76) ("~" . 77) ("-" . 78) ("+" . 79) ("*" . 80) ("&" . 81
|
||||
) ("sizeof" . 82) ("," . 83) ("}" . 84) ("{" . 85) ("--" . 86) ("++" . 87)
|
||||
("->" . 88) ("." . 89) ("]" . 90) ("[" . 91) (")" . 92) ("(" . 93) (
|
||||
$code-comm . 94) ($lone-comm . 95) ($error . 96) ($end . 97)))
|
||||
|
||||
;;; end tables
|
|
@ -1,770 +0,0 @@
|
|||
;; ./mach.d/c99xact.scm
|
||||
|
||||
;; Copyright (C) 2016,2017 Matthew R. Wette
|
||||
;;
|
||||
;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
;; or any later version published by the Free Software Foundation. See
|
||||
;; the file COPYING included with the this distribution.
|
||||
|
||||
(define c99x-act-v
|
||||
(vector
|
||||
;; $start => expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; primary-expression => identifier
|
||||
(lambda ($1 . $rest) `(p-expr ,$1))
|
||||
;; primary-expression => constant
|
||||
(lambda ($1 . $rest) `(p-expr ,$1))
|
||||
;; primary-expression => string-literal
|
||||
(lambda ($1 . $rest) `(p-expr ,(tl->list $1)))
|
||||
;; primary-expression => "(" expression ")"
|
||||
(lambda ($3 $2 $1 . $rest) $2)
|
||||
;; postfix-expression => primary-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; postfix-expression => postfix-expression "[" expression "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-ref ,$3 ,$1))
|
||||
;; postfix-expression => postfix-expression "(" argument-expression-list...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(fctn-call ,$1 ,(tl->list $3)))
|
||||
;; postfix-expression => postfix-expression "(" ")"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(fctn-call ,$1 (expr-list)))
|
||||
;; postfix-expression => postfix-expression "." identifier
|
||||
(lambda ($3 $2 $1 . $rest) `(d-sel ,$3 ,$1))
|
||||
;; postfix-expression => postfix-expression "->" identifier
|
||||
(lambda ($3 $2 $1 . $rest) `(i-sel ,$3 ,$1))
|
||||
;; postfix-expression => postfix-expression "++"
|
||||
(lambda ($2 $1 . $rest) `(post-inc ,$1))
|
||||
;; postfix-expression => postfix-expression "--"
|
||||
(lambda ($2 $1 . $rest) `(post-dec ,$1))
|
||||
;; postfix-expression => "(" type-name ")" "{" initializer-list "}"
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(comp-lit ,$2 ,(tl->list $5)))
|
||||
;; postfix-expression => "(" type-name ")" "{" initializer-list "," "}"
|
||||
(lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(comp-lit ,$2 ,(tl->list $5)))
|
||||
;; argument-expression-list => assignment-expression
|
||||
(lambda ($1 . $rest) (make-tl 'expr-list $1))
|
||||
;; argument-expression-list => argument-expression-list "," assignment-e...
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; argument-expression-list => arg-expr-hack
|
||||
(lambda ($1 . $rest) (make-tl 'expr-list $1))
|
||||
;; argument-expression-list => argument-expression-list "," arg-expr-hack
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; arg-expr-hack => declaration-specifiers abstract-declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(param-decl ,(tl->list $1) $2))
|
||||
;; arg-expr-hack => declaration-specifiers
|
||||
(lambda ($1 . $rest)
|
||||
`(param-decl ,(tl->list $1)))
|
||||
;; unary-expression => postfix-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; unary-expression => "++" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(pre-inc ,$2))
|
||||
;; unary-expression => "--" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(pre-dec ,$2))
|
||||
;; unary-expression => unary-operator cast-expression
|
||||
(lambda ($2 $1 . $rest) (list $1 $2))
|
||||
;; unary-expression => "sizeof" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(sizeof-expr ,$2))
|
||||
;; unary-expression => "sizeof" "(" type-name ")"
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(sizeof-type ,$3))
|
||||
;; unary-operator => "&"
|
||||
(lambda ($1 . $rest) 'ref-to)
|
||||
;; unary-operator => "*"
|
||||
(lambda ($1 . $rest) 'de-ref)
|
||||
;; unary-operator => "+"
|
||||
(lambda ($1 . $rest) 'pos)
|
||||
;; unary-operator => "-"
|
||||
(lambda ($1 . $rest) 'neg)
|
||||
;; unary-operator => "~"
|
||||
(lambda ($1 . $rest) 'bitwise-not)
|
||||
;; unary-operator => "!"
|
||||
(lambda ($1 . $rest) 'not)
|
||||
;; cast-expression => unary-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; cast-expression => "(" type-name ")" cast-expression
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(cast ,$2 ,$4))
|
||||
;; multiplicative-expression => cast-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; multiplicative-expression => multiplicative-expression "*" cast-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(mul ,$1 ,$3))
|
||||
;; multiplicative-expression => multiplicative-expression "/" cast-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(div ,$1 ,$3))
|
||||
;; multiplicative-expression => multiplicative-expression "%" cast-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(mod ,$1 ,$3))
|
||||
;; additive-expression => multiplicative-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; additive-expression => additive-expression "+" multiplicative-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(add ,$1 ,$3))
|
||||
;; additive-expression => additive-expression "-" multiplicative-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(sub ,$1 ,$3))
|
||||
;; shift-expression => additive-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; shift-expression => shift-expression "<<" additive-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(lshift ,$1 ,$3))
|
||||
;; shift-expression => shift-expression ">>" additive-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(rshift ,$1 ,$3))
|
||||
;; relational-expression => shift-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; relational-expression => relational-expression "<" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(lt ,$1 ,$3))
|
||||
;; relational-expression => relational-expression ">" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(gt ,$1 ,$3))
|
||||
;; relational-expression => relational-expression "<=" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(le ,$1 ,$3))
|
||||
;; relational-expression => relational-expression ">=" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(ge ,$1 ,$3))
|
||||
;; equality-expression => relational-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; equality-expression => equality-expression "==" relational-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(eq ,$1 ,$3))
|
||||
;; equality-expression => equality-expression "!=" relational-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(ne ,$1 ,$3))
|
||||
;; bitwise-and-expression => equality-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-and-expression => bitwise-and-expression "&" equality-expression
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(bitwise-and ,$1 ,$3))
|
||||
;; bitwise-xor-expression => bitwise-and-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-xor-expression => bitwise-xor-expression "^" bitwise-and-expr...
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(bitwise-xor ,$1 ,$3))
|
||||
;; bitwise-or-expression => bitwise-xor-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-or-expression => bitwise-or-expression "|" bitwise-xor-expres...
|
||||
(lambda ($3 $2 $1 . $rest) `(bitwise-or ,$1 ,$3))
|
||||
;; logical-and-expression => bitwise-or-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; logical-and-expression => logical-and-expression "&&" bitwise-or-expr...
|
||||
(lambda ($3 $2 $1 . $rest) `(and ,$1 ,$3))
|
||||
;; logical-or-expression => logical-and-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; logical-or-expression => logical-or-expression "||" logical-and-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(or ,$1 ,$3))
|
||||
;; conditional-expression => logical-or-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; conditional-expression => logical-or-expression "?" expression ":" co...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(cond-expr ,$1 ,$3 ,$5))
|
||||
;; assignment-expression => conditional-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-expression => unary-expression assignment-operator assignm...
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(assn-expr ,$1 (op ,$2) ,$3))
|
||||
;; assignment-operator => "="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "+="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "-="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "*="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "/="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "%="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "<<="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => ">>="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "&="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "^="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; assignment-operator => "|="
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; expression => assignment-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; expression => expression "," assignment-expression
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
(if (eqv? 'comma-expr (sx-tag $1))
|
||||
(append $1 (list $3))
|
||||
`(comma-expr ,$1 ,$3)))
|
||||
;; constant-expression => conditional-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; declaration => declaration-specifiers init-declarator-list $P1 ";" op...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
(if (pair? $5) (append $3 (list $5)) $3))
|
||||
;; declaration => declaration-specifiers ";" opt-code-comment
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
(if (pair? $3)
|
||||
`(decl ,(tl->list $1) ,(list $3))
|
||||
`(decl ,(tl->list $1))))
|
||||
;; $P1 =>
|
||||
(lambda ($2 $1 . $rest)
|
||||
(save-typenames
|
||||
`(decl ,(tl->list $1) ,(tl->list $2))))
|
||||
;; declaration-specifiers => storage-class-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => storage-class-specifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; declaration-specifiers => type-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => type-specifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; declaration-specifiers => type-qualifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => type-qualifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; declaration-specifiers => function-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; declaration-specifiers => function-specifier declaration-specifiers
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; init-declarator-list => init-declarator
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'init-declr-list $1))
|
||||
;; init-declarator-list => init-declarator-list "," init-declarator
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; init-declarator => declarator
|
||||
(lambda ($1 . $rest) `(init-declr ,$1))
|
||||
;; init-declarator => declarator "=" initializer
|
||||
(lambda ($3 $2 $1 . $rest) `(init-declr ,$1 ,$3))
|
||||
;; storage-class-specifier => "auto"
|
||||
(lambda ($1 . $rest) '(stor-spec (auto)))
|
||||
;; storage-class-specifier => "extern"
|
||||
(lambda ($1 . $rest) '(stor-spec (extern)))
|
||||
;; storage-class-specifier => "register"
|
||||
(lambda ($1 . $rest) '(stor-spec (register)))
|
||||
;; storage-class-specifier => "static"
|
||||
(lambda ($1 . $rest) '(stor-spec (static)))
|
||||
;; storage-class-specifier => "typedef"
|
||||
(lambda ($1 . $rest) '(stor-spec (typedef)))
|
||||
;; type-specifier => "void"
|
||||
(lambda ($1 . $rest) '(type-spec (void)))
|
||||
;; type-specifier => fixed-type-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => float-type-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => "_Bool"
|
||||
(lambda ($1 . $rest)
|
||||
'(type-spec (fixed-type "_Bool")))
|
||||
;; type-specifier => complex-type-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => struct-or-union-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => enum-specifier
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; type-specifier => typedef-name
|
||||
(lambda ($1 . $rest) `(type-spec ,$1))
|
||||
;; fixed-type-specifier => "short"
|
||||
(lambda ($1 . $rest) '(fixed-type "short"))
|
||||
;; fixed-type-specifier => "short" "int"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "short int"))
|
||||
;; fixed-type-specifier => "signed" "short"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed short"))
|
||||
;; fixed-type-specifier => "signed" "short" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "signed short int"))
|
||||
;; fixed-type-specifier => "int"
|
||||
(lambda ($1 . $rest) '(fixed-type "int"))
|
||||
;; fixed-type-specifier => "signed"
|
||||
(lambda ($1 . $rest) '(fixed-type "signed"))
|
||||
;; fixed-type-specifier => "signed" "int"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed int"))
|
||||
;; fixed-type-specifier => "long"
|
||||
(lambda ($1 . $rest) '(fixed-type "long"))
|
||||
;; fixed-type-specifier => "long" "int"
|
||||
(lambda ($2 $1 . $rest) '(fixed-type "long int"))
|
||||
;; fixed-type-specifier => "signed" "long"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed long"))
|
||||
;; fixed-type-specifier => "signed" "long" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "signed long int"))
|
||||
;; fixed-type-specifier => "long" "long"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "long long"))
|
||||
;; fixed-type-specifier => "long" "long" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "long long int"))
|
||||
;; fixed-type-specifier => "signed" "long" "long"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "signed long long"))
|
||||
;; fixed-type-specifier => "signed" "long" "long" "int"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
'(fixed-type "signed long long int"))
|
||||
;; fixed-type-specifier => "unsigned" "short" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned short int"))
|
||||
;; fixed-type-specifier => "unsigned" "short"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned short"))
|
||||
;; fixed-type-specifier => "unsigned" "int"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned int"))
|
||||
;; fixed-type-specifier => "unsigned"
|
||||
(lambda ($1 . $rest) '(fixed-type "unsigned"))
|
||||
;; fixed-type-specifier => "unsigned" "long" "int"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned long"))
|
||||
;; fixed-type-specifier => "unsigned" "long"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned long"))
|
||||
;; fixed-type-specifier => "unsigned" "long" "long" "int"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned long long int"))
|
||||
;; fixed-type-specifier => "unsigned" "long" "long"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(fixed-type "unsigned long long"))
|
||||
;; fixed-type-specifier => "char"
|
||||
(lambda ($1 . $rest) '(fixed-type "char"))
|
||||
;; fixed-type-specifier => "signed" "char"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "signed char"))
|
||||
;; fixed-type-specifier => "unsigned" "char"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(fixed-type "unsigned char"))
|
||||
;; float-type-specifier => "float"
|
||||
(lambda ($1 . $rest) '(float-type "float"))
|
||||
;; float-type-specifier => "double"
|
||||
(lambda ($1 . $rest) '(float-type "double"))
|
||||
;; float-type-specifier => "long" "double"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(float-type "long double"))
|
||||
;; complex-type-specifier => "_Complex"
|
||||
(lambda ($1 . $rest) '(complex-type "_Complex"))
|
||||
;; complex-type-specifier => "float" "_Complex"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(complex-type "float _Complex"))
|
||||
;; complex-type-specifier => "double" "_Complex"
|
||||
(lambda ($2 $1 . $rest)
|
||||
'(complex-type "double _Complex"))
|
||||
;; complex-type-specifier => "long" "double" "_Complex"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
'(complex-type "long double _Complex"))
|
||||
;; struct-or-union-specifier => "struct" ident-like "{" struct-declarati...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(struct-def ,$2 ,(tl->list $4)))
|
||||
;; struct-or-union-specifier => "struct" "{" struct-declaration-list "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(struct-def ,(tl->list $3)))
|
||||
;; struct-or-union-specifier => "struct" ident-like
|
||||
(lambda ($2 $1 . $rest) `(struct-ref ,$2))
|
||||
;; struct-or-union-specifier => "union" ident-like "{" struct-declaratio...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(union-def ,$2 ,(tl->list $4)))
|
||||
;; struct-or-union-specifier => "union" "{" struct-declaration-list "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(union-def ,(tl->list $3)))
|
||||
;; struct-or-union-specifier => "union" ident-like
|
||||
(lambda ($2 $1 . $rest) `(union-ref ,$2))
|
||||
;; ident-like => identifier
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; ident-like => typedef-name
|
||||
(lambda ($1 . $rest) `(ident ,(cdr $1)))
|
||||
;; struct-declaration-list => struct-declaration
|
||||
(lambda ($1 . $rest) (make-tl 'field-list $1))
|
||||
;; struct-declaration-list => lone-comment
|
||||
(lambda ($1 . $rest) (make-tl 'field-list $1))
|
||||
;; struct-declaration-list => struct-declaration-list struct-declaration
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; struct-declaration-list => struct-declaration-list lone-comment
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; struct-declaration => specifier-qualifier-list struct-declarator-list...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
(if (pair? $4)
|
||||
`(comp-decl ,(tl->list $1) ,(tl->list $2) ,$4)
|
||||
`(comp-decl ,(tl->list $1) ,(tl->list $2))))
|
||||
;; specifier-qualifier-list => type-specifier specifier-qualifier-list
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; specifier-qualifier-list => type-specifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; specifier-qualifier-list => type-qualifier specifier-qualifier-list
|
||||
(lambda ($2 $1 . $rest) (tl-insert $2 $1))
|
||||
;; specifier-qualifier-list => type-qualifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; struct-declarator-list => struct-declarator
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'comp-declr-list $1))
|
||||
;; struct-declarator-list => struct-declarator-list "," struct-declarator
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; struct-declarator => declarator
|
||||
(lambda ($1 . $rest) `(comp-declr ,$1))
|
||||
;; struct-declarator => declarator ":" constant-expression
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(comp-declr (bit-field ,$1 ,$3)))
|
||||
;; struct-declarator => ":" constant-expression
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(comp-declr (bit-field ,$2)))
|
||||
;; enum-specifier => "enum" ident-like "{" enumerator-list "}"
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,$2 ,(tl->list $4)))
|
||||
;; enum-specifier => "enum" ident-like "{" enumerator-list "," "}"
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,$2 ,(tl->list $4)))
|
||||
;; enum-specifier => "enum" "{" enumerator-list "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,(tl->list $3)))
|
||||
;; enum-specifier => "enum" "{" enumerator-list "," "}"
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(enum-def ,(tl->list $3)))
|
||||
;; enum-specifier => "enum" ident-like
|
||||
(lambda ($2 $1 . $rest) `(enum-ref ,$2))
|
||||
;; enumerator-list => enumerator
|
||||
(lambda ($1 . $rest) (make-tl 'enum-def-list $1))
|
||||
;; enumerator-list => enumerator-list "," enumerator
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; enumerator => identifier
|
||||
(lambda ($1 . $rest) `(enum-defn ,$1))
|
||||
;; enumerator => identifier "=" constant-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(enum-defn ,$1 ,$3))
|
||||
;; type-qualifier => "const"
|
||||
(lambda ($1 . $rest) `(type-qual ,$1))
|
||||
;; type-qualifier => "volatile"
|
||||
(lambda ($1 . $rest) `(type-qual ,$1))
|
||||
;; type-qualifier => "restrict"
|
||||
(lambda ($1 . $rest) `(type-qual ,$1))
|
||||
;; function-specifier => "inline"
|
||||
(lambda ($1 . $rest) `(fctn-spec ,$1))
|
||||
;; declarator => pointer direct-declarator
|
||||
(lambda ($2 $1 . $rest) `(ptr-declr ,$1 ,$2))
|
||||
;; declarator => direct-declarator
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; direct-declarator => identifier
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; direct-declarator => "(" declarator ")"
|
||||
(lambda ($3 $2 $1 . $rest) `(scope ,$2))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list assign...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3 ,$4))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3))
|
||||
;; direct-declarator => direct-declarator "[" assignment-expression "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3))
|
||||
;; direct-declarator => direct-declarator "[" "]"
|
||||
(lambda ($3 $2 $1 . $rest) `(array-of ,$1))
|
||||
;; direct-declarator => direct-declarator "[" "static" type-qualifier-li...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $4))
|
||||
,$5))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list "stati...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))
|
||||
,$5))
|
||||
;; direct-declarator => direct-declarator "[" type-qualifier-list "*" "]"
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 ,$3 (var-len)))
|
||||
;; direct-declarator => direct-declarator "[" "*" "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(array-of ,$1 (var-len)))
|
||||
;; direct-declarator => direct-declarator "(" parameter-type-list ")"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(ftn-declr ,$1 ,(tl->list $3)))
|
||||
;; direct-declarator => direct-declarator "(" identifier-list ")"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(ftn-declr ,$1 ,(tl->list $3)))
|
||||
;; direct-declarator => direct-declarator "(" ")"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(ftn-declr ,$1 (param-list)))
|
||||
;; pointer => "*" type-qualifier-list
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(pointer ,(tl->list $2)))
|
||||
;; pointer => "*"
|
||||
(lambda ($1 . $rest) '(pointer))
|
||||
;; pointer => "*" type-qualifier-list pointer
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(pointer ,(tl->list $2) ,$3))
|
||||
;; pointer => "*" pointer
|
||||
(lambda ($2 $1 . $rest) `(pointer ,$2))
|
||||
;; type-qualifier-list => type-qualifier
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'decl-spec-list $1))
|
||||
;; type-qualifier-list => type-qualifier-list type-qualifier
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; parameter-type-list => parameter-list
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; parameter-type-list => parameter-list "," "..."
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
(tl-append $1 '(ellipsis)))
|
||||
;; parameter-list => parameter-declaration
|
||||
(lambda ($1 . $rest) (make-tl 'param-list $1))
|
||||
;; parameter-list => parameter-list "," parameter-declaration
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; parameter-declaration => declaration-specifiers declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(param-decl ,(tl->list $1) (param-declr ,$2)))
|
||||
;; parameter-declaration => declaration-specifiers abstract-declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(param-decl ,(tl->list $1) (param-declr ,$2)))
|
||||
;; parameter-declaration => declaration-specifiers
|
||||
(lambda ($1 . $rest)
|
||||
`(param-decl ,(tl->list $1)))
|
||||
;; identifier-list => identifier
|
||||
(lambda ($1 . $rest) (make-tl 'ident-list $1))
|
||||
;; identifier-list => identifier-list "," identifier
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; type-name => specifier-qualifier-list abstract-declarator
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(type-name ,(tl->list $1) ,$2))
|
||||
;; type-name => declaration-specifiers
|
||||
(lambda ($1 . $rest) `(type-name ,(tl->list $1)))
|
||||
;; abstract-declarator => pointer
|
||||
(lambda ($1 . $rest) `(abs-declr ,$1))
|
||||
;; abstract-declarator => pointer direct-abstract-declarator
|
||||
(lambda ($2 $1 . $rest) `(abs-declr ,$1 ,$2))
|
||||
;; abstract-declarator => direct-abstract-declarator
|
||||
(lambda ($1 . $rest) `(abs-declr ,$1))
|
||||
;; direct-abstract-declarator => "(" abstract-declarator ")"
|
||||
(lambda ($3 $2 $1 . $rest) `(declr-scope ,$2))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array ,$3 ,$4))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-array ,$1 ,$3))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" assignme...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-array ,$1 ,$3))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "]"
|
||||
(lambda ($3 $2 $1 . $rest) `(declr-array ,$1))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "static"...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $4))
|
||||
,$5))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "static"...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $4))))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
|
||||
(lambda ($6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-array
|
||||
,$1
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))
|
||||
,$5))
|
||||
;; direct-abstract-declarator => "[" type-qualifier-list assignment-expr...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array ,$2 ,$3))
|
||||
;; direct-abstract-declarator => "[" type-qualifier-list "]"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(declr-anon-array ,$2))
|
||||
;; direct-abstract-declarator => "[" assignment-expression "]"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(declr-anon-array ,$2))
|
||||
;; direct-abstract-declarator => "[" "]"
|
||||
(lambda ($2 $1 . $rest) `(declr-anon-array))
|
||||
;; direct-abstract-declarator => "[" "static" type-qualifier-list assign...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))
|
||||
,$4))
|
||||
;; direct-abstract-declarator => "[" "static" type-qualifier-list "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3))))
|
||||
;; direct-abstract-declarator => "[" type-qualifier-list "static" assign...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $2))
|
||||
,$4))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "[" "*" "]"
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(declr-STAR ,$1))
|
||||
;; direct-abstract-declarator => "[" "*" "]"
|
||||
(lambda ($3 $2 $1 . $rest) '(declr-STAR))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "(" paramete...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(declr-fctn ,$1 ,(tl->list $3)))
|
||||
;; direct-abstract-declarator => direct-abstract-declarator "(" ")"
|
||||
(lambda ($3 $2 $1 . $rest) `(declr-fctn ,$1))
|
||||
;; direct-abstract-declarator => "(" parameter-type-list ")"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(declr-anon-fctn ,(tl->list $2)))
|
||||
;; direct-abstract-declarator => "(" ")"
|
||||
(lambda ($2 $1 . $rest) '(declr-anon-fctn))
|
||||
;; typedef-name => 'typename
|
||||
(lambda ($1 . $rest) `(typename ,$1))
|
||||
;; initializer => assignment-expression
|
||||
(lambda ($1 . $rest) `(initzer ,$1))
|
||||
;; initializer => "{" initializer-list "}"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(initzer ,(tl->list $2)))
|
||||
;; initializer => "{" initializer-list "," "}"
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(initzer ,(tl->list $2)))
|
||||
;; initializer-list => designation initializer
|
||||
(lambda ($2 $1 . $rest)
|
||||
(make-tl 'initzer-list $1 $2))
|
||||
;; initializer-list => initializer
|
||||
(lambda ($1 . $rest) (make-tl 'initzer-list $1))
|
||||
;; initializer-list => initializer-list "," designation initializer
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
(tl-append $1 $3 $4))
|
||||
;; initializer-list => initializer-list "," initializer
|
||||
(lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
|
||||
;; designation => designator-list "="
|
||||
(lambda ($2 $1 . $rest) `(desig ,$1))
|
||||
;; designator-list => designator
|
||||
(lambda ($1 . $rest) (make-tl 'desgr-list $1))
|
||||
;; designator-list => designator-list designator
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; designator => "[" constant-expression "]"
|
||||
(lambda ($3 $2 $1 . $rest) (list 'array-dsgr $2))
|
||||
;; designator => "." identifier
|
||||
(lambda ($2 $1 . $rest) (list 'sel-dsgr $2))
|
||||
;; statement => labeled-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => compound-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => expression-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => selection-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => iteration-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => jump-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; statement => cpp-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; labeled-statement => identifier ":" statement
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(labeled-stmt ,$1 ,$3))
|
||||
;; labeled-statement => "case" constant-expression ":" statement
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(case ,$2 ,$4))
|
||||
;; labeled-statement => "default" ":" statement
|
||||
(lambda ($3 $2 $1 . $rest) `(default ,$3))
|
||||
;; compound-statement => "{" block-item-list "}"
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(compd-stmt ,(tl->list $2)))
|
||||
;; compound-statement => "{" "}"
|
||||
(lambda ($2 $1 . $rest)
|
||||
`(compd-stmt (block-item-list)))
|
||||
;; block-item-list => block-item
|
||||
(lambda ($1 . $rest)
|
||||
(make-tl 'block-item-list $1))
|
||||
;; block-item-list => block-item-list block-item
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; block-item => declaration
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; block-item => statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; expression-statement => expression ";"
|
||||
(lambda ($2 $1 . $rest) `(expr-stmt ,$1))
|
||||
;; expression-statement => ";"
|
||||
(lambda ($1 . $rest) '(expr-stmt))
|
||||
;; selection-statement => "if" "(" expression ")" statement
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest) `(if ,$3 ,$5))
|
||||
;; selection-statement => "if" "(" expression ")" statement "else" state...
|
||||
(lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(if ,$3 ,$5 ,$7))
|
||||
;; selection-statement => "switch" "(" expression ")" statement
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(switch ,$3 ,$5))
|
||||
;; iteration-statement => "while" "(" expression ")" statement
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(while ,$3 ,$5))
|
||||
;; iteration-statement => "do" statement "while" "(" expression ")" ";"
|
||||
(lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(do-while ,$2 ,$5))
|
||||
;; iteration-statement => "for" "(" initial-clause opt-expression ";" op...
|
||||
(lambda ($8 $7 $6 $5 $4 $3 $2 $1 . $rest)
|
||||
`(for ,$3 ,$4 ,$6 ,$8))
|
||||
;; initial-clause => expression ";"
|
||||
(lambda ($2 $1 . $rest) $1)
|
||||
;; initial-clause => ";"
|
||||
(lambda ($1 . $rest) '(expr))
|
||||
;; initial-clause => declaration
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; opt-expression =>
|
||||
(lambda $rest '(expr))
|
||||
;; opt-expression => expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; jump-statement => "goto" identifier ";"
|
||||
(lambda ($3 $2 $1 . $rest) `(goto ,$2))
|
||||
;; jump-statement => "continue" ";"
|
||||
(lambda ($2 $1 . $rest) '(continue))
|
||||
;; jump-statement => "break" ";"
|
||||
(lambda ($2 $1 . $rest) '(break))
|
||||
;; jump-statement => "return" expression ";"
|
||||
(lambda ($3 $2 $1 . $rest) `(return ,$2))
|
||||
;; jump-statement => "return" ";"
|
||||
(lambda ($2 $1 . $rest) `(return (expr)))
|
||||
;; translation-unit => external-declaration-list
|
||||
(lambda ($1 . $rest) (tl->list $1))
|
||||
;; external-declaration-list =>
|
||||
(lambda $rest (make-tl 'trans-unit))
|
||||
;; external-declaration-list => external-declaration-list external-decla...
|
||||
(lambda ($2 $1 . $rest)
|
||||
(if (eqv? (sx-tag $2) 'extern-block)
|
||||
(tl-extend $1 (sx-tail $2 1))
|
||||
(tl-append $1 $2)))
|
||||
;; external-declaration => function-definition
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => declaration
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => lone-comment
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => cpp-statement
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => pragma
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; external-declaration => "extern" '$string "{" external-declaration-li...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(extern-block
|
||||
(extern-begin ,$2)
|
||||
,@(sx-tail (tl->list $4) 1)
|
||||
(extern-end)))
|
||||
;; external-declaration => ";"
|
||||
(lambda ($1 . $rest)
|
||||
`(decl (@ (extension . "GNU C"))))
|
||||
;; function-definition => declaration-specifiers declarator declaration-...
|
||||
(lambda ($4 $3 $2 $1 . $rest)
|
||||
`(knr-fctn-defn
|
||||
,(tl->list $1)
|
||||
,$2
|
||||
,(tl->list $3)
|
||||
,$4))
|
||||
;; function-definition => declaration-specifiers declarator compound-sta...
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(fctn-defn ,(tl->list $1) ,$2 ,$3))
|
||||
;; declaration-list => declaration
|
||||
(lambda ($1 . $rest) (make-tl $1))
|
||||
;; declaration-list => declaration-list declaration
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; opt-code-comment =>
|
||||
(lambda $rest (list))
|
||||
;; opt-code-comment => code-comment
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; identifier => '$ident
|
||||
(lambda ($1 . $rest) `(ident ,$1))
|
||||
;; identifier => 'cpp-ident
|
||||
(lambda ($1 . $rest) `(ident ,$1))
|
||||
;; constant => '$fixed
|
||||
(lambda ($1 . $rest) `(fixed ,$1))
|
||||
;; constant => '$float
|
||||
(lambda ($1 . $rest) `(float ,$1))
|
||||
;; constant => '$chlit
|
||||
(lambda ($1 . $rest) `(char ,$1))
|
||||
;; string-literal => '$string
|
||||
(lambda ($1 . $rest) (make-tl 'string $1))
|
||||
;; string-literal => string-literal '$string
|
||||
(lambda ($2 $1 . $rest) (tl-append $1 $2))
|
||||
;; code-comment => '$code-comm
|
||||
(lambda ($1 . $rest) `(comment ,$1))
|
||||
;; lone-comment => '$lone-comm
|
||||
(lambda ($1 . $rest) `(comment ,$1))
|
||||
;; cpp-statement => 'cpp-stmt
|
||||
(lambda ($1 . $rest) `(cpp-stmt ,$1))
|
||||
;; pragma => 'cpp-pragma
|
||||
(lambda ($1 . $rest) $1)
|
||||
))
|
||||
|
||||
;;; end tables
|
|
@ -1,569 +0,0 @@
|
|||
;; ./mach.d/c99xtab.scm
|
||||
|
||||
;; Copyright (C) 2016,2017 Matthew R. Wette
|
||||
;;
|
||||
;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
;; or any later version published by the Free Software Foundation. See
|
||||
;; the file COPYING included with the this distribution.
|
||||
|
||||
(define c99x-len-v
|
||||
#(1 1 1 1 3 1 4 4 3 3 3 2 2 6 7 1 3 1 3 2 1 1 2 2 2 2 4 1 1 1 1 1 1 1 4 1
|
||||
3 3 3 1 3 3 1 3 3 1 3 3 3 3 1 3 3 1 3 1 3 1 3 1 3 1 3 1 5 1 3 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 3 1 5 3 0 1 2 1 2 1 2 1 2 1 3 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
2 2 3 1 1 2 1 2 2 3 2 3 3 4 3 2 2 1 3 2 4 3 1 2 2 1 1 2 1 2 2 3 5 4 2 5 4
|
||||
2 1 1 1 1 2 2 4 2 1 2 1 1 3 1 3 2 5 6 4 5 2 1 3 1 3 1 1 1 1 2 1 1 3 5 4 4
|
||||
3 6 6 5 4 4 4 3 2 1 3 2 1 2 1 3 1 3 2 2 1 1 3 2 1 1 2 1 3 5 4 4 3 6 5 6 4
|
||||
3 3 2 5 4 5 4 3 4 3 3 2 1 1 3 4 2 1 4 3 2 1 2 3 2 1 1 1 1 1 1 1 3 4 3 3 2
|
||||
1 2 1 1 2 1 5 7 5 5 7 8 2 1 1 0 1 3 2 2 3 2 1 0 2 1 1 1 1 1 5 1 4 3 1 2 0
|
||||
1 1 1 1 1 1 1 2 1 1 1 1))
|
||||
|
||||
(define c99x-pat-v
|
||||
#(((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (
|
||||
8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (
|
||||
179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (
|
||||
79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (82 . 29) (
|
||||
167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (172 . 36)
|
||||
(178 . 37)) ((97 . -35) (-1 . -35)) ((80 . 119) (75 . 120) (74 . 121) (97
|
||||
. -39) (-1 . -39)) ((79 . 117) (78 . 118) (97 . -42) (-1 . -42)) ((73 .
|
||||
115) (72 . 116) (97 . -45) (-1 . -45)) ((71 . 111) (70 . 112) (69 . 113) (
|
||||
68 . 114) (97 . -50) (-1 . -50)) ((67 . 109) (66 . 110) (97 . -53) (-1 .
|
||||
-53)) ((81 . 108) (97 . -55) (-1 . -55)) ((97 . -301) (-1 . -301)) ((97 .
|
||||
-300) (-1 . -300)) ((97 . -299) (-1 . -299)) ((97 . -298) (-1 . -298)) ((
|
||||
97 . -297) (-1 . -297)) ((97 . -296) (-1 . -296)) ((65 . 107) (97 . -57) (
|
||||
-1 . -57)) ((64 . 106) (97 . -59) (-1 . -59)) ((8 . 105) (97 . -3) (-1 .
|
||||
-3)) ((97 . -2) (-1 . -2)) ((97 . -1) (-1 . -1)) ((63 . 104) (97 . -61) (
|
||||
-1 . -61)) ((-1 . -32)) ((-1 . -31)) ((-1 . -30)) ((-1 . -29)) ((-1 . -28)
|
||||
) ((-1 . -27)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6
|
||||
) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14)
|
||||
(158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21
|
||||
) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28)
|
||||
(82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35)
|
||||
(172 . 36) (178 . 66) (22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (
|
||||
32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40
|
||||
. 79) (24 . 80) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140
|
||||
. 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (43 . 92) (44
|
||||
. 93) (45 . 94) (46 . 95) (47 . 96) (147 . 97) (148 . 98) (149 . 99) (150
|
||||
. 100) (170 . 101) (133 . 102) (174 . 103)) ((97 . -5) (-1 . -5)) ((61 .
|
||||
64) (62 . 65) (97 . -63) (-1 . -63)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6
|
||||
. 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78
|
||||
. 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 .
|
||||
31) (87 . 32) (176 . 33) (168 . 62) (93 . 63)) ((8 . 8) (3 . 9) (4 . 10) (
|
||||
5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20) (77
|
||||
. 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (167 .
|
||||
30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 61)) ((8 .
|
||||
8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181
|
||||
. 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 57
|
||||
) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 59
|
||||
)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 .
|
||||
17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25)
|
||||
(93 . 57) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33)
|
||||
(168 . 58)) ((91 . 51) (93 . 52) (89 . 53) (88 . 54) (87 . 55) (86 . 56) (
|
||||
97 . -21) (-1 . -21)) ((49 . 39) (50 . 40) (51 . 41) (52 . 42) (53 . 43) (
|
||||
54 . 44) (55 . 45) (56 . 46) (57 . 47) (58 . 48) (59 . 49) (154 . 50) (97
|
||||
. -33) (-1 . -33)) ((97 . -65) (-1 . -65)) ((97 . -78) (-1 . -78)) ((83 .
|
||||
38) (97 . 0)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6)
|
||||
(160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14)
|
||||
(158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21)
|
||||
(78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (
|
||||
82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (
|
||||
172 . 190)) ((-1 . -77)) ((-1 . -76)) ((-1 . -75)) ((-1 . -74)) ((-1 . -73
|
||||
)) ((-1 . -72)) ((-1 . -71)) ((-1 . -70)) ((-1 . -69)) ((-1 . -68)) ((-1
|
||||
. -67)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160
|
||||
. 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (158
|
||||
. 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21) (78
|
||||
. 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (82 .
|
||||
29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (172
|
||||
. 189)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160
|
||||
. 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (158
|
||||
. 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21) (78
|
||||
. 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (82 .
|
||||
29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (172
|
||||
. 36) (178 . 188)) ((92 . 183) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (
|
||||
162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7
|
||||
. 13) (159 . 14) (22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 .
|
||||
72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79)
|
||||
(158 . 15) (179 . 16) (180 . 17) (181 . 18) (24 . 80) (25 . 81) (26 . 82)
|
||||
(27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89)
|
||||
(143 . 90) (42 . 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (
|
||||
157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93
|
||||
. 26) (177 . 27) (147 . 97) (148 . 146) (149 . 147) (150 . 100) (156 . 28)
|
||||
(82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35)
|
||||
(170 . 184) (171 . 185) (172 . 186) (175 . 187)) ((6 . 12) (7 . 13) (181
|
||||
. 182)) ((6 . 12) (7 . 13) (181 . 181)) ((97 . -11) (-1 . -11)) ((97 . -12
|
||||
) (-1 . -12)) ((22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72)
|
||||
(33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (24
|
||||
. 80) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (141
|
||||
. 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (43 . 92) (44 . 93) (45
|
||||
. 94) (46 . 95) (47 . 96) (147 . 97) (148 . 98) (149 . 99) (150 . 100) (
|
||||
170 . 101) (133 . 102) (174 . 180) (166 . 1) (165 . 2) (164 . 3) (163 . 4)
|
||||
(162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12)
|
||||
(7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19)
|
||||
(76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (
|
||||
177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
168 . 34) (155 . 35) (172 . 36) (178 . 66)) ((97 . -22) (-1 . -22)) ((97
|
||||
. -23) (-1 . -23)) ((97 . -33) (-1 . -33)) ((97 . -24) (-1 . -24)) ((97 .
|
||||
-25) (-1 . -25)) ((22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 .
|
||||
72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79)
|
||||
(24 . 80) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (
|
||||
141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (43 . 92) (44 . 93) (
|
||||
45 . 94) (46 . 95) (47 . 96) (147 . 97) (148 . 98) (149 . 99) (150 . 100)
|
||||
(170 . 101) (133 . 102) (174 . 179) (166 . 1) (165 . 2) (164 . 3) (163 . 4
|
||||
) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12)
|
||||
(7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19
|
||||
) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (
|
||||
177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
168 . 34) (155 . 35) (172 . 36) (178 . 66)) ((166 . 1) (165 . 2) (164 . 3)
|
||||
(163 . 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11)
|
||||
(6 . 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18)
|
||||
(157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93
|
||||
. 26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176
|
||||
. 33) (168 . 34) (155 . 35) (172 . 36) (178 . 178)) ((8 . 8) (3 . 9) (4
|
||||
. 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20
|
||||
) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (
|
||||
167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 1) (
|
||||
165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (159 . 14) (158
|
||||
. 15) (157 . 177)) ((92 . 176) (83 . 38)) ((-1 . -233)) ((85 . 174) (6 .
|
||||
12) (7 . 13) (22 . 67) (138 . 169) (181 . 170) (137 . 175)) ((85 . 172) (6
|
||||
. 12) (7 . 13) (22 . 67) (138 . 169) (181 . 170) (137 . 173)) ((85 . 168)
|
||||
(6 . 12) (7 . 13) (22 . 67) (138 . 169) (181 . 170) (137 . 171)) ((-1 .
|
||||
-138)) ((31 . 167) (-1 . -136)) ((31 . 166) (-1 . -135)) ((-1 . -132)) ((
|
||||
40 . 162) (38 . 163) (36 . 164) (34 . 165) (-1 . -127)) ((38 . 159) (36 .
|
||||
160) (32 . 161) (-1 . -116)) ((-1 . -113)) ((40 . 155) (38 . 156) (36 .
|
||||
157) (34 . 158) (-1 . -114)) ((38 . 154) (-1 . -109)) ((-1 . -176)) ((-1
|
||||
. -175)) ((-1 . -174)) ((-1 . -173)) ((-1 . -108)) ((-1 . -107)) ((-1 .
|
||||
-106)) ((-1 . -105)) ((-1 . -104)) ((-1 . -103)) ((-1 . -102)) ((-1 . -101
|
||||
)) ((-1 . -100)) ((-1 . -99)) ((-1 . -98)) ((-1 . -97)) ((-1 . -96)) ((22
|
||||
. 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74
|
||||
) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (24 . 80) (25 . 81) (
|
||||
26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (
|
||||
142 . 89) (143 . 90) (42 . 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47
|
||||
. 96) (147 . 97) (148 . 146) (149 . 147) (150 . 100) (170 . 153) (-1 .
|
||||
-90)) ((24 . 80) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (147 .
|
||||
97) (150 . 100) (170 . 151) (22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 .
|
||||
71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78)
|
||||
(40 . 79) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (
|
||||
141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (148 . 98) (149 . 99)
|
||||
(133 . 152) (92 . -88) (80 . -158) (91 . -158) (93 . -158)) ((24 . 80) (43
|
||||
. 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (147 . 97) (150 . 100) (170
|
||||
. 149) (22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33 .
|
||||
73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (25 . 81)
|
||||
(26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88)
|
||||
(142 . 89) (143 . 90) (42 . 91) (148 . 98) (149 . 99) (133 . 150) (92 .
|
||||
-86) (80 . -156) (91 . -156) (93 . -156)) ((22 . 67) (28 . 68) (29 . 69) (
|
||||
30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38
|
||||
. 77) (37 . 78) (40 . 79) (24 . 80) (25 . 81) (26 . 82) (27 . 83) (138 .
|
||||
84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42
|
||||
. 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (147 . 97) (148 .
|
||||
146) (149 . 147) (150 . 100) (170 . 148) (-1 . -84)) ((92 . -208)) ((91 .
|
||||
140) (93 . 141) (80 . 142) (120 . 143) (127 . 144) (169 . 145)) ((92 . 139
|
||||
)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 .
|
||||
17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25)
|
||||
(177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26)
|
||||
(168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (
|
||||
160 . 7) (159 . 14) (158 . 138)) ((97 . -302) (-1 . -302)) ((8 . 8) (3 . 9
|
||||
) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76
|
||||
. 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 .
|
||||
29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 .
|
||||
1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (159 . 137)
|
||||
) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 .
|
||||
17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25)
|
||||
(177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26)
|
||||
(168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (
|
||||
160 . 136)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16
|
||||
) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24)
|
||||
(81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
93 . 26) (168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161
|
||||
. 135)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (
|
||||
180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81
|
||||
. 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93
|
||||
. 26) (168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 134)) ((8
|
||||
. 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (
|
||||
181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177
|
||||
. 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168
|
||||
. 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 133)) ((8 . 8) (3 . 9
|
||||
) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76
|
||||
. 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 .
|
||||
29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 .
|
||||
1) (165 . 2) (164 . 3) (163 . 132)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6
|
||||
. 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 .
|
||||
22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31
|
||||
) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 1) (165 . 2) (164 . 3)
|
||||
(163 . 131)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 .
|
||||
16) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24
|
||||
) (81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33)
|
||||
(93 . 26) (168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 130)) ((8 . 8)
|
||||
(3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 .
|
||||
18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27)
|
||||
(82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60)
|
||||
(166 . 1) (165 . 2) (164 . 3) (163 . 129)) ((8 . 8) (3 . 9) (4 . 10) (5 .
|
||||
11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20) (77 . 21)
|
||||
(78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (167 . 30) (
|
||||
86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 1) (165 . 2) (
|
||||
164 . 128)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16
|
||||
) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24)
|
||||
(81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
93 . 26) (168 . 60) (166 . 1) (165 . 2) (164 . 127)) ((8 . 8) (3 . 9) (4
|
||||
. 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20
|
||||
) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (
|
||||
167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 1) (
|
||||
165 . 126)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16
|
||||
) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24)
|
||||
(81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
93 . 26) (168 . 60) (166 . 1) (165 . 125)) ((8 . 8) (3 . 9) (4 . 10) (5 .
|
||||
11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20) (77 . 21)
|
||||
(78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (167 . 30) (
|
||||
86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 124)) ((8 . 8) (
|
||||
3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18
|
||||
) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (
|
||||
82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (
|
||||
166 . 123)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16
|
||||
) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24)
|
||||
(81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
93 . 26) (168 . 60) (166 . 122)) ((97 . -38) (-1 . -38)) ((97 . -37) (-1
|
||||
. -37)) ((97 . -36) (-1 . -36)) ((80 . 119) (75 . 120) (74 . 121) (97 .
|
||||
-41) (-1 . -41)) ((80 . 119) (75 . 120) (74 . 121) (97 . -40) (-1 . -40))
|
||||
((79 . 117) (78 . 118) (97 . -44) (-1 . -44)) ((79 . 117) (78 . 118) (97
|
||||
. -43) (-1 . -43)) ((73 . 115) (72 . 116) (97 . -49) (-1 . -49)) ((73 .
|
||||
115) (72 . 116) (97 . -48) (-1 . -48)) ((73 . 115) (72 . 116) (97 . -47) (
|
||||
-1 . -47)) ((73 . 115) (72 . 116) (97 . -46) (-1 . -46)) ((71 . 111) (70
|
||||
. 112) (69 . 113) (68 . 114) (97 . -52) (-1 . -52)) ((71 . 111) (70 . 112)
|
||||
(69 . 113) (68 . 114) (97 . -51) (-1 . -51)) ((67 . 109) (66 . 110) (97
|
||||
. -54) (-1 . -54)) ((81 . 108) (97 . -56) (-1 . -56)) ((65 . 107) (97 .
|
||||
-58) (-1 . -58)) ((64 . 106) (97 . -60) (-1 . -60)) ((85 . 237) (8 . 8) (3
|
||||
. 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18)
|
||||
(76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (
|
||||
82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (
|
||||
166 . 238)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (
|
||||
160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (
|
||||
158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21)
|
||||
(78 . 22) (79 . 23) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (82 . 29) (
|
||||
167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (172 . 232)
|
||||
(90 . 233) (44 . 234) (25 . 81) (26 . 82) (27 . 83) (148 . 223) (125 .
|
||||
235) (80 . 236)) ((91 . 140) (93 . 141) (80 . 142) (120 . 143) (127 . 144)
|
||||
(169 . 226) (22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (
|
||||
33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (24
|
||||
. 80) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (141
|
||||
. 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (43 . 92) (44 . 93) (45 .
|
||||
94) (46 . 95) (47 . 96) (147 . 97) (148 . 146) (149 . 147) (150 . 100) (
|
||||
170 . 227) (121 . 228) (122 . 229) (124 . 230) (92 . 231)) ((25 . 81) (26
|
||||
. 82) (27 . 83) (148 . 223) (125 . 224) (80 . 142) (127 . 225) (-1 . -193)
|
||||
) ((91 . 221) (93 . 222) (92 . -211) (83 . -211)) ((91 . 140) (93 . 141) (
|
||||
120 . 220) (92 . -209) (83 . -209)) ((92 . -207)) ((22 . 67) (28 . 68) (29
|
||||
. 69) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 .
|
||||
76) (38 . 77) (37 . 78) (40 . 79) (24 . 80) (25 . 81) (26 . 82) (27 . 83)
|
||||
(138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90
|
||||
) (42 . 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (147 . 97) (
|
||||
148 . 146) (149 . 147) (150 . 100) (170 . 151) (-1 . -88)) ((22 . 67) (28
|
||||
. 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75
|
||||
) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (24 . 80) (25 . 81) (26 . 82) (
|
||||
27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89)
|
||||
(143 . 90) (42 . 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (
|
||||
147 . 97) (148 . 146) (149 . 147) (150 . 100) (170 . 149) (-1 . -86)) ((-1
|
||||
. -85)) ((-1 . -87)) ((-1 . -155)) ((-1 . -89)) ((-1 . -157)) ((-1 . -91)
|
||||
) ((-1 . -110)) ((38 . 219) (-1 . -111)) ((-1 . -115)) ((36 . 217) (38 .
|
||||
218) (-1 . -118)) ((-1 . -133)) ((-1 . -117)) ((38 . 216) (-1 . -120)) ((
|
||||
31 . 215) (-1 . -137)) ((38 . 214) (-1 . -125)) ((-1 . -126)) ((36 . 212)
|
||||
(38 . 213) (-1 . -129)) ((-1 . -134)) ((-1 . -139)) ((-1 . -140)) ((22 .
|
||||
67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74)
|
||||
(35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (25 . 81) (26 . 82) (27
|
||||
. 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (
|
||||
143 . 90) (42 . 91) (148 . 203) (149 . 204) (95 . 205) (133 . 206) (134 .
|
||||
207) (135 . 208) (136 . 211)) ((-1 . -149)) ((-1 . -148)) ((85 . 210) (-1
|
||||
. -144)) ((22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33
|
||||
. 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (25 . 81
|
||||
) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88
|
||||
) (142 . 89) (143 . 90) (42 . 91) (148 . 203) (149 . 204) (95 . 205) (133
|
||||
. 206) (134 . 207) (135 . 208) (136 . 209)) ((85 . 202) (-1 . -147)) ((6
|
||||
. 12) (7 . 13) (181 . 199) (128 . 200) (129 . 201)) ((85 . 198) (-1 . -168
|
||||
)) ((97 . -4) (-1 . -4)) ((63 . 104) (97 . -62) (-1 . -62)) ((60 . 197) (
|
||||
83 . 38)) ((92 . 196)) ((92 . 195)) ((97 . -10) (-1 . -10)) ((97 . -9) (-1
|
||||
. -9)) ((97 . -8) (-1 . -8)) ((91 . 140) (93 . 141) (80 . 142) (120 . 143
|
||||
) (127 . 144) (169 . 194) (92 . -20) (83 . -20)) ((92 . -17) (83 . -17)) (
|
||||
(92 . -15) (83 . -15)) ((92 . 192) (83 . 193)) ((90 . 191) (83 . 38)) ((97
|
||||
. -66) (-1 . -66)) ((97 . -79) (-1 . -79)) ((97 . -6) (-1 . -6)) ((97 .
|
||||
-7) (-1 . -7)) ((22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72
|
||||
) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (
|
||||
24 . 80) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (
|
||||
141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (43 . 92) (44 . 93) (
|
||||
45 . 94) (46 . 95) (47 . 96) (147 . 97) (148 . 146) (149 . 147) (150 . 100
|
||||
) (170 . 184) (171 . 291) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5
|
||||
) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13)
|
||||
(159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20
|
||||
) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (
|
||||
156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (
|
||||
155 . 35) (172 . 292)) ((92 . -19) (83 . -19)) ((85 . 237)) ((85 . 237) (
|
||||
97 . -26) (-1 . -26)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13)
|
||||
(179 . 16) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23)
|
||||
(80 . 24) (81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (
|
||||
176 . 33) (93 . 26) (168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (
|
||||
162 . 5) (161 . 6) (160 . 7) (159 . 14) (158 . 15) (157 . 19) (156 . 28) (
|
||||
155 . 290)) ((6 . 12) (7 . 13) (181 . 199) (128 . 200) (129 . 289)) ((59
|
||||
. 288) (84 . -171) (83 . -171)) ((84 . -169) (83 . -169)) ((84 . 286) (83
|
||||
. 287)) ((22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33
|
||||
. 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (25 . 81
|
||||
) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88
|
||||
) (142 . 89) (143 . 90) (42 . 91) (148 . 203) (149 . 204) (95 . 205) (133
|
||||
. 206) (134 . 207) (135 . 208) (136 . 285)) ((22 . 67) (28 . 68) (29 . 69)
|
||||
(30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38
|
||||
. 77) (37 . 78) (40 . 79) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139
|
||||
. 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (148
|
||||
. 203) (149 . 204) (133 . 152) (-1 . -158)) ((22 . 67) (28 . 68) (29 . 69
|
||||
) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (
|
||||
38 . 77) (37 . 78) (40 . 79) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139
|
||||
. 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (
|
||||
148 . 203) (149 . 204) (133 . 150) (-1 . -156)) ((95 . -304) (-1 . -304))
|
||||
((6 . 12) (7 . 13) (80 . 142) (93 . 279) (181 . 257) (126 . 258) (127 .
|
||||
280) (60 . 281) (145 . 282) (131 . 283) (132 . 284)) ((95 . -151) (-1 .
|
||||
-151)) ((95 . -150) (-1 . -150)) ((84 . 278) (22 . 67) (28 . 68) (29 . 69)
|
||||
(30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38
|
||||
. 77) (37 . 78) (40 . 79) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139
|
||||
. 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (148
|
||||
. 203) (149 . 204) (133 . 206) (135 . 275) (95 . 205) (134 . 276)) ((22
|
||||
. 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74
|
||||
) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (25 . 81) (26 . 82) (
|
||||
27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89)
|
||||
(143 . 90) (42 . 91) (148 . 203) (149 . 204) (95 . 205) (133 . 206) (134
|
||||
. 207) (135 . 208) (136 . 277)) ((84 . 274) (22 . 67) (28 . 68) (29 . 69)
|
||||
(30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38
|
||||
. 77) (37 . 78) (40 . 79) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 .
|
||||
85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (148
|
||||
. 203) (149 . 204) (133 . 206) (135 . 275) (95 . 205) (134 . 276)) ((38 .
|
||||
273) (-1 . -131)) ((-1 . -128)) ((-1 . -124)) ((-1 . -141)) ((-1 . -121))
|
||||
((38 . 272) (-1 . -122)) ((-1 . -119)) ((-1 . -112)) ((91 . 221) (93 . 222
|
||||
) (92 . -210) (83 . -210)) ((44 . 267) (90 . 268) (166 . 1) (165 . 2) (164
|
||||
. 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5
|
||||
. 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (181
|
||||
. 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 269) (81 .
|
||||
25) (93 . 26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 .
|
||||
32) (176 . 33) (168 . 34) (155 . 35) (172 . 270) (25 . 81) (26 . 82) (27
|
||||
. 83) (148 . 223) (125 . 271)) ((92 . 265) (22 . 67) (28 . 68) (29 . 69) (
|
||||
30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38
|
||||
. 77) (37 . 78) (40 . 79) (24 . 80) (25 . 81) (26 . 82) (27 . 83) (138 .
|
||||
84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42
|
||||
. 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (147 . 97) (148 .
|
||||
146) (149 . 147) (150 . 100) (170 . 227) (121 . 228) (122 . 229) (124 .
|
||||
266)) ((-1 . -196)) ((80 . 142) (127 . 264) (25 . 81) (26 . 82) (27 . 83)
|
||||
(148 . 250) (-1 . -192)) ((-1 . -195)) ((92 . 263)) ((6 . 12) (7 . 13) (
|
||||
181 . 257) (126 . 258) (145 . 259) (91 . 140) (93 . 260) (80 . 142) (120
|
||||
. 143) (127 . 261) (169 . 262) (92 . -204) (83 . -204)) ((83 . -200) (92
|
||||
. -200)) ((83 . 256) (92 . -198)) ((92 . 255)) ((-1 . -232)) ((90 . 254))
|
||||
((-1 . -223)) ((25 . 81) (26 . 82) (27 . 83) (148 . 223) (125 . 253)) ((44
|
||||
. 249) (25 . 81) (26 . 82) (27 . 83) (148 . 250) (90 . 251) (166 . 1) (
|
||||
165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9)
|
||||
(4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180
|
||||
. 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80
|
||||
. 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86
|
||||
. 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (172 . 252)) ((90 . 248)
|
||||
(-1 . -28)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (
|
||||
160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (
|
||||
158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21)
|
||||
(78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (89 . 239) (
|
||||
91 . 240) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
117 . 241) (168 . 34) (155 . 35) (118 . 242) (85 . 243) (172 . 244) (144
|
||||
. 245) (119 . 246) (173 . 247)) ((97 . -34) (-1 . -34)) ((6 . 12) (7 . 13)
|
||||
(181 . 329)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 .
|
||||
16) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24
|
||||
) (81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33)
|
||||
(93 . 26) (168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (
|
||||
161 . 6) (160 . 7) (159 . 14) (158 . 15) (157 . 19) (156 . 28) (155 . 295)
|
||||
(130 . 328)) ((59 . -242) (89 . -242) (91 . -242)) ((59 . 326) (89 . 239)
|
||||
(91 . 240) (117 . 327)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5
|
||||
) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13)
|
||||
(159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20
|
||||
) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (
|
||||
89 . 239) (91 . 240) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (
|
||||
176 . 33) (117 . 241) (168 . 34) (155 . 35) (118 . 242) (85 . 243) (172 .
|
||||
244) (144 . 245) (119 . 246) (173 . 325)) ((84 . -234) (83 . -234)) ((84
|
||||
. -238) (83 . -238)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (
|
||||
161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (
|
||||
159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20)
|
||||
(77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (
|
||||
156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (
|
||||
155 . 35) (85 . 243) (172 . 244) (144 . 324)) ((84 . 322) (83 . 323)) ((-1
|
||||
. -228)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (
|
||||
160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (
|
||||
158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21)
|
||||
(78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (
|
||||
82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (
|
||||
172 . 321)) ((-1 . -197)) ((-1 . -221)) ((90 . 320)) ((166 . 1) (165 . 2)
|
||||
(164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10)
|
||||
(5 . 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (
|
||||
181 . 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81
|
||||
. 25) (93 . 26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87
|
||||
. 32) (176 . 33) (168 . 34) (155 . 35) (172 . 318) (25 . 81) (26 . 82) (27
|
||||
. 83) (148 . 250) (90 . 319)) ((-1 . -222)) ((-1 . -231)) ((22 . 67) (28
|
||||
. 68) (29 . 69) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75
|
||||
) (36 . 76) (38 . 77) (37 . 78) (40 . 79) (24 . 80) (25 . 81) (26 . 82) (
|
||||
27 . 83) (138 . 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89)
|
||||
(143 . 90) (42 . 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (
|
||||
147 . 97) (148 . 146) (149 . 147) (150 . 100) (170 . 227) (121 . 316) (23
|
||||
. 317)) ((-1 . -179)) ((91 . 314) (93 . 315) (-1 . -178)) ((92 . -202) (83
|
||||
. -202)) ((91 . 140) (120 . 143) (169 . 226) (22 . 67) (28 . 68) (29 . 69
|
||||
) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (
|
||||
38 . 77) (37 . 78) (40 . 79) (24 . 80) (25 . 81) (26 . 82) (27 . 83) (138
|
||||
. 84) (139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42
|
||||
. 91) (43 . 92) (44 . 93) (45 . 94) (46 . 95) (47 . 96) (147 . 97) (148
|
||||
. 146) (149 . 147) (150 . 100) (170 . 227) (121 . 228) (122 . 229) (124 .
|
||||
230) (92 . 231) (6 . 12) (7 . 13) (80 . 142) (93 . 260) (181 . 257) (126
|
||||
. 258) (127 . 261) (145 . 305)) ((91 . 140) (120 . 220) (6 . 12) (7 . 13)
|
||||
(93 . 260) (181 . 257) (126 . 304) (92 . -209) (83 . -209)) ((92 . -203) (
|
||||
83 . -203)) ((-1 . -212)) ((-1 . -194)) ((-1 . -230)) ((92 . 313)) ((25 .
|
||||
81) (26 . 82) (27 . 83) (148 . 223) (125 . 312)) ((-1 . -216)) ((90 . 311)
|
||||
(-1 . -28)) ((90 . 310)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 .
|
||||
5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13)
|
||||
(159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 .
|
||||
20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27)
|
||||
(156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34)
|
||||
(155 . 35) (172 . 307) (25 . 81) (26 . 82) (27 . 83) (148 . 250) (90 .
|
||||
308) (44 . 309)) ((-1 . -123)) ((-1 . -130)) ((-1 . -143)) ((95 . -152) (
|
||||
-1 . -152)) ((95 . -153) (-1 . -153)) ((84 . 306) (22 . 67) (28 . 68) (29
|
||||
. 69) (30 . 70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76
|
||||
) (38 . 77) (37 . 78) (40 . 79) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (
|
||||
139 . 85) (140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91)
|
||||
(148 . 203) (149 . 204) (133 . 206) (135 . 275) (95 . 205) (134 . 276)) ((
|
||||
-1 . -146)) ((6 . 12) (7 . 13) (80 . 142) (93 . 279) (181 . 257) (126 .
|
||||
258) (127 . 280) (145 . 305)) ((6 . 12) (7 . 13) (93 . 279) (181 . 257) (
|
||||
126 . 304)) ((8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16
|
||||
) (180 . 17) (181 . 18) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24)
|
||||
(81 . 25) (177 . 27) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (
|
||||
93 . 26) (168 . 60) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161
|
||||
. 6) (160 . 7) (159 . 14) (158 . 15) (157 . 19) (156 . 28) (155 . 295) (
|
||||
130 . 303)) ((60 . 302) (48 . -161) (83 . -161)) ((48 . -159) (83 . -159))
|
||||
((48 . 300) (83 . 301)) ((84 . 299) (22 . 67) (28 . 68) (29 . 69) (30 .
|
||||
70) (31 . 71) (32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77)
|
||||
(37 . 78) (40 . 79) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (
|
||||
140 . 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (148 . 203)
|
||||
(149 . 204) (133 . 206) (135 . 275) (95 . 205) (134 . 276)) ((-1 . -166))
|
||||
((84 . 297) (6 . 12) (7 . 13) (181 . 199) (128 . 298)) ((8 . 8) (3 . 9) (
|
||||
4 . 10) (5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 .
|
||||
20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29)
|
||||
(167 . 30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 1)
|
||||
(165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (159 . 14) (
|
||||
158 . 15) (157 . 19) (156 . 28) (155 . 295) (130 . 296)) ((83 . 293) (84
|
||||
. 294)) ((97 . -64) (-1 . -64)) ((92 . -18) (83 . -18)) ((92 . -16) (83 .
|
||||
-16)) ((6 . 12) (7 . 13) (181 . 199) (128 . 298) (84 . 357)) ((-1 . -164))
|
||||
((-1 . -80)) ((84 . -172) (83 . -172)) ((-1 . -167)) ((84 . -170) (83 .
|
||||
-170)) ((-1 . -145)) ((94 . 354) (98 . 355) (151 . 356) (95 . -294) (-1 .
|
||||
-294)) ((6 . 12) (7 . 13) (80 . 142) (93 . 279) (181 . 257) (126 . 258) (
|
||||
127 . 280) (60 . 281) (145 . 282) (131 . 353)) ((8 . 8) (3 . 9) (4 . 10) (
|
||||
5 . 11) (6 . 12) (7 . 13) (179 . 16) (180 . 17) (181 . 18) (76 . 20) (77
|
||||
. 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (177 . 27) (82 . 29) (167 .
|
||||
30) (86 . 31) (87 . 32) (176 . 33) (93 . 26) (168 . 60) (166 . 1) (165 . 2
|
||||
) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (159 . 14) (158 . 15)
|
||||
(157 . 19) (156 . 28) (155 . 295) (130 . 352)) ((48 . -163) (83 . -163)) (
|
||||
(91 . 314) (93 . 315) (-1 . -177)) ((92 . 351)) ((-1 . -142)) ((90 . 350))
|
||||
((-1 . -214)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6
|
||||
) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14)
|
||||
(158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21
|
||||
) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28)
|
||||
(82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35)
|
||||
(172 . 349)) ((-1 . -215)) ((-1 . -227)) ((90 . 347) (25 . 81) (26 . 82) (
|
||||
27 . 83) (148 . 250) (166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (
|
||||
161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (
|
||||
159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20)
|
||||
(77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (
|
||||
156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (
|
||||
155 . 35) (172 . 348)) ((-1 . -229)) ((44 . 342) (90 . 343) (166 . 1) (165
|
||||
. 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4
|
||||
. 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 .
|
||||
17) (181 . 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 .
|
||||
344) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 .
|
||||
31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (172 . 345) (25 . 81) (26
|
||||
. 82) (27 . 83) (148 . 223) (125 . 346)) ((92 . 338) (6 . 12) (7 . 13) (
|
||||
181 . 339) (123 . 340) (22 . 67) (28 . 68) (29 . 69) (30 . 70) (31 . 71) (
|
||||
32 . 72) (33 . 73) (34 . 74) (35 . 75) (36 . 76) (38 . 77) (37 . 78) (40
|
||||
. 79) (24 . 80) (25 . 81) (26 . 82) (27 . 83) (138 . 84) (139 . 85) (140
|
||||
. 86) (141 . 87) (41 . 88) (142 . 89) (143 . 90) (42 . 91) (43 . 92) (44
|
||||
. 93) (45 . 94) (46 . 95) (47 . 96) (147 . 97) (148 . 146) (149 . 147) (
|
||||
150 . 100) (170 . 227) (121 . 228) (122 . 229) (124 . 341)) ((83 . -201) (
|
||||
92 . -201)) ((92 . -199)) ((90 . 337)) ((-1 . -225)) ((-1 . -220)) ((90 .
|
||||
336)) ((97 . -13) (-1 . -13)) ((84 . 333) (166 . 1) (165 . 2) (164 . 3) (
|
||||
163 . 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (
|
||||
6 . 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (
|
||||
157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93
|
||||
. 26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176
|
||||
. 33) (168 . 34) (155 . 35) (85 . 243) (172 . 244) (144 . 334) (89 . 239)
|
||||
(91 . 240) (117 . 241) (118 . 242) (119 . 335)) ((84 . -237) (83 . -237))
|
||||
((83 . 331) (84 . 332)) ((-1 . -241)) ((59 . -243) (89 . -243) (91 . -243)
|
||||
) ((90 . 330)) ((59 . -245) (91 . -245) (89 . -245)) ((59 . -244) (91 .
|
||||
-244) (89 . -244)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161
|
||||
. 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159
|
||||
. 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77
|
||||
. 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156
|
||||
. 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155
|
||||
. 35) (85 . 243) (172 . 244) (144 . 334) (89 . 239) (91 . 240) (117 . 241)
|
||||
(118 . 242) (119 . 335) (84 . 371)) ((84 . -235) (83 . -235)) ((97 . -14)
|
||||
(-1 . -14)) ((84 . -240) (83 . -240)) ((166 . 1) (165 . 2) (164 . 3) (163
|
||||
. 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6
|
||||
. 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157
|
||||
. 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 .
|
||||
26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 .
|
||||
33) (168 . 34) (155 . 35) (85 . 243) (172 . 244) (144 . 370)) ((-1 . -226)
|
||||
) ((-1 . -224)) ((-1 . -191)) ((92 . -205) (83 . -205)) ((92 . 368) (83 .
|
||||
369)) ((92 . 367)) ((25 . 81) (26 . 82) (27 . 83) (148 . 223) (125 . 366))
|
||||
((-1 . -184)) ((90 . 365) (-1 . -28)) ((90 . 364)) ((166 . 1) (165 . 2) (
|
||||
164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10)
|
||||
(5 . 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (179 . 16) (180 . 17) (
|
||||
181 . 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (79 . 23) (81 . 25) (93
|
||||
. 26) (177 . 27) (156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176
|
||||
. 33) (168 . 34) (155 . 35) (172 . 360) (25 . 81) (26 . 82) (27 . 83) (
|
||||
148 . 250) (90 . 361) (44 . 362) (80 . 363)) ((-1 . -218)) ((90 . 359)) ((
|
||||
90 . 358)) ((-1 . -213)) ((-1 . -180)) ((48 . -162) (83 . -162)) ((48 .
|
||||
-160) (83 . -160)) ((95 . -303) (-1 . -303)) ((95 . -295) (-1 . -295)) ((
|
||||
95 . -154) (-1 . -154)) ((-1 . -165)) ((-1 . -219)) ((-1 . -217)) ((90 .
|
||||
376)) ((-1 . -182)) ((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (
|
||||
161 . 6) (160 . 7) (8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (
|
||||
159 . 14) (158 . 15) (179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20)
|
||||
(77 . 21) (78 . 22) (79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (
|
||||
156 . 28) (82 . 29) (167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (
|
||||
155 . 35) (172 . 375)) ((90 . 374) (-1 . -28)) ((-1 . -183)) ((-1 . -188))
|
||||
((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (8
|
||||
. 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (
|
||||
179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (
|
||||
79 . 23) (80 . 24) (81 . 25) (93 . 26) (177 . 27) (156 . 28) (82 . 29) (
|
||||
167 . 30) (86 . 31) (87 . 32) (176 . 33) (168 . 34) (155 . 35) (172 . 373)
|
||||
(25 . 81) (26 . 82) (27 . 83) (148 . 250)) ((-1 . -189)) ((-1 . -190)) ((
|
||||
6 . 12) (7 . 13) (181 . 372)) ((84 . -239) (83 . -239)) ((84 . -236) (83
|
||||
. -236)) ((92 . -206) (83 . -206)) ((90 . 378)) ((-1 . -187)) ((90 . 377))
|
||||
((-1 . -181)) ((-1 . -186)) ((-1 . -185))))
|
||||
|
||||
(define c99x-rto-v
|
||||
#(#f 177 177 177 177 176 176 176 176 176 176 176 176 176 176 175 175 175
|
||||
175 171 171 168 168 168 168 168 168 167 167 167 167 167 167 166 166 165
|
||||
165 165 165 164 164 164 163 163 163 162 162 162 162 162 161 161 161 160
|
||||
160 159 159 158 158 157 157 156 156 155 155 172 172 154 154 154 154 154
|
||||
154 154 154 154 154 154 178 178 130 106 106 152 170 170 170 170 170 170
|
||||
170 170 153 153 146 146 150 150 150 150 150 149 149 149 149 149 149 149
|
||||
149 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143
|
||||
143 143 143 143 143 143 143 143 143 142 142 142 141 141 141 141 140 140
|
||||
140 140 140 140 137 137 136 136 136 136 135 133 133 133 133 132 132 131
|
||||
131 131 139 139 139 139 139 129 129 128 128 148 148 148 147 145 145 126
|
||||
126 126 126 126 126 126 126 126 126 126 126 126 127 127 127 127 125 125
|
||||
124 124 122 122 121 121 121 123 123 174 174 169 169 169 120 120 120 120
|
||||
120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 138
|
||||
144 144 144 173 173 173 173 119 118 118 117 117 109 109 109 109 109 109
|
||||
109 116 116 116 115 115 108 108 107 107 114 114 113 113 113 112 112 112
|
||||
105 105 105 104 104 111 111 111 111 111 182 103 103 102 102 102 102 102
|
||||
102 102 101 101 99 99 151 151 181 181 180 180 180 179 179 98 134 110 100))
|
||||
|
||||
(define c99x-mtab
|
||||
'((cpp-pragma . 1) (cpp-stmt . 2) ($chlit . 3) ($float . 4) ($fixed . 5) (
|
||||
cpp-ident . 6) ($ident . 7) ($string . 8) ("return" . 9) ("break" . 10) (
|
||||
"continue" . 11) ("goto" . 12) ("for" . 13) ("do" . 14) ("while" . 15) (
|
||||
"switch" . 16) ("else" . 17) (then . 18) ("if" . 19) ("default" . 20) (
|
||||
"case" . 21) (typename . 22) ("..." . 23) ("inline" . 24) ("restrict" . 25
|
||||
) ("volatile" . 26) ("const" . 27) ("enum" . 28) ("union" . 29) ("struct"
|
||||
. 30) ("_Complex" . 31) ("double" . 32) ("float" . 33) ("char" . 34) (
|
||||
"unsigned" . 35) ("long" . 36) ("signed" . 37) ("int" . 38) (imp . 39) (
|
||||
"short" . 40) ("_Bool" . 41) ("void" . 42) ("typedef" . 43) ("static" . 44
|
||||
) ("register" . 45) ("extern" . 46) ("auto" . 47) (";" . 48) ("|=" . 49) (
|
||||
"^=" . 50) ("&=" . 51) (">>=" . 52) ("<<=" . 53) ("%=" . 54) ("/=" . 55) (
|
||||
"*=" . 56) ("-=" . 57) ("+=" . 58) ("=" . 59) (":" . 60) ("?" . 61) ("||"
|
||||
. 62) ("&&" . 63) ("|" . 64) ("^" . 65) ("!=" . 66) ("==" . 67) (">=" . 68
|
||||
) ("<=" . 69) (">" . 70) ("<" . 71) (">>" . 72) ("<<" . 73) ("%" . 74) (
|
||||
"/" . 75) ("!" . 76) ("~" . 77) ("-" . 78) ("+" . 79) ("*" . 80) ("&" . 81
|
||||
) ("sizeof" . 82) ("," . 83) ("}" . 84) ("{" . 85) ("--" . 86) ("++" . 87)
|
||||
("->" . 88) ("." . 89) ("]" . 90) ("[" . 91) (")" . 92) ("(" . 93) (
|
||||
$code-comm . 94) ($lone-comm . 95) ($error . 96) ($end . 97)))
|
||||
|
||||
;;; end tables
|
|
@ -1,114 +0,0 @@
|
|||
;; ./mach.d/cppact.scm
|
||||
|
||||
;; Copyright (C) 2016,2017 Matthew R. Wette
|
||||
;;
|
||||
;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
;; or any later version published by the Free Software Foundation. See
|
||||
;; the file COPYING included with the this distribution.
|
||||
|
||||
(define cpp-act-v
|
||||
(vector
|
||||
;; $start => conditional-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; conditional-expression => logical-or-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; conditional-expression => logical-or-expression "?" logical-or-expres...
|
||||
(lambda ($5 $4 $3 $2 $1 . $rest)
|
||||
`(cond-expr ,$1 ,$3 ,$5))
|
||||
;; logical-or-expression => logical-and-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; logical-or-expression => logical-or-expression "||" logical-and-expre...
|
||||
(lambda ($3 $2 $1 . $rest) `(or ,$1 ,$3))
|
||||
;; logical-and-expression => bitwise-or-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; logical-and-expression => logical-and-expression "&&" bitwise-or-expr...
|
||||
(lambda ($3 $2 $1 . $rest) `(and ,$1 ,$3))
|
||||
;; bitwise-or-expression => bitwise-xor-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-or-expression => bitwise-or-expression "|" bitwise-xor-expres...
|
||||
(lambda ($3 $2 $1 . $rest) `(bitwise-or ,$1 ,$3))
|
||||
;; bitwise-xor-expression => bitwise-and-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-xor-expression => bitwise-xor-expression "^" bitwise-and-expr...
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(bitwise-xor ,$1 ,$3))
|
||||
;; bitwise-and-expression => equality-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; bitwise-and-expression => bitwise-and-expression "&" equality-expression
|
||||
(lambda ($3 $2 $1 . $rest)
|
||||
`(bitwise-and ,$1 ,$3))
|
||||
;; equality-expression => relational-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; equality-expression => equality-expression "==" relational-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(equal ,$1 ,$3))
|
||||
;; equality-expression => equality-expression "!=" relational-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(noteq ,$1 ,$3))
|
||||
;; relational-expression => shift-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; relational-expression => relational-expression "<" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(lt ,$1 ,$3))
|
||||
;; relational-expression => relational-expression "<=" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(le ,$1 ,$3))
|
||||
;; relational-expression => relational-expression ">" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(gt ,$1 ,$3))
|
||||
;; relational-expression => relational-expression ">=" shift-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(ge ,$1 ,$3))
|
||||
;; shift-expression => additive-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; shift-expression => shift-expression "<<" additive-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(lshift ,$1 ,$3))
|
||||
;; shift-expression => shift-expression ">>" additive-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(rshift ,$1 ,$3))
|
||||
;; additive-expression => multiplicative-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; additive-expression => additive-expression "+" multiplicative-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(add ,$1 ,$3))
|
||||
;; additive-expression => additive-expression "-" multiplicative-expression
|
||||
(lambda ($3 $2 $1 . $rest) `(sub ,$1 ,$3))
|
||||
;; multiplicative-expression => unary-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; multiplicative-expression => multiplicative-expression "*" unary-expr...
|
||||
(lambda ($3 $2 $1 . $rest) `(mul ,$1 ,$3))
|
||||
;; multiplicative-expression => multiplicative-expression "/" unary-expr...
|
||||
(lambda ($3 $2 $1 . $rest) `(div ,$1 ,$3))
|
||||
;; multiplicative-expression => multiplicative-expression "%" unary-expr...
|
||||
(lambda ($3 $2 $1 . $rest) `(mod ,$1 ,$3))
|
||||
;; unary-expression => postfix-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; unary-expression => "-" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(neg ,$2))
|
||||
;; unary-expression => "+" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(pos ,$2))
|
||||
;; unary-expression => "!" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(not ,$2))
|
||||
;; unary-expression => "~" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(bitwise-not ,$2))
|
||||
;; unary-expression => "++" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(pre-inc ,$2))
|
||||
;; unary-expression => "--" unary-expression
|
||||
(lambda ($2 $1 . $rest) `(pre-dec ,$2))
|
||||
;; postfix-expression => primary-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; postfix-expression => postfix-expression "++"
|
||||
(lambda ($2 $1 . $rest) `(post-inc ,$1))
|
||||
;; postfix-expression => postfix-expression "--"
|
||||
(lambda ($2 $1 . $rest) `(post-dec ,$1))
|
||||
;; primary-expression => '$ident
|
||||
(lambda ($1 . $rest) `(ident ,$1))
|
||||
;; primary-expression => '$fixed
|
||||
(lambda ($1 . $rest) `(fixed ,$1))
|
||||
;; primary-expression => '$chlit
|
||||
(lambda ($1 . $rest) `(char ,$1))
|
||||
;; primary-expression => "defined" "(" '$ident ")"
|
||||
(lambda ($4 $3 $2 $1 . $rest) `(defined ,$3))
|
||||
;; primary-expression => "defined" '$ident
|
||||
(lambda ($2 $1 . $rest) `(defined ,$2))
|
||||
;; primary-expression => "(" expression-list ")"
|
||||
(lambda ($3 $2 $1 . $rest) $2)
|
||||
;; expression-list => conditional-expression
|
||||
(lambda ($1 . $rest) $1)
|
||||
;; expression-list => expression-list "," conditional-expression
|
||||
(lambda ($3 $2 $1 . $rest) $3)
|
||||
))
|
||||
|
||||
;;; end tables
|
|
@ -1,118 +0,0 @@
|
|||
;; ./mach.d/cpptab.scm
|
||||
|
||||
;; Copyright (C) 2016,2017 Matthew R. Wette
|
||||
;;
|
||||
;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
;; or any later version published by the Free Software Foundation. See
|
||||
;; the file COPYING included with the this distribution.
|
||||
|
||||
(define cpp-len-v
|
||||
#(1 1 5 1 3 1 3 1 3 1 3 1 3 1 3 3 1 3 3 3 3 1 3 3 1 3 3 1 3 3 3 1 2 2 2 2
|
||||
2 2 1 2 2 1 1 1 4 2 3 1 3))
|
||||
|
||||
(define cpp-pat-v
|
||||
#(((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 .
|
||||
9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15) (41 . 16) (
|
||||
42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47 . 22) (48 . 23) (49
|
||||
. 24) (50 . 25)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7)
|
||||
(9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 .
|
||||
15) (41 . 16) (42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47 . 22)
|
||||
(48 . 23) (49 . 24) (50 . 55) (36 . 56)) ((3 . 53) (7 . 54)) ((35 . -43) (
|
||||
-1 . -43)) ((35 . -42) (-1 . -42)) ((35 . -41) (-1 . -41)) ((35 . -38) (-1
|
||||
. -38)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8)
|
||||
(10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 52)) ((3 . 1) (4
|
||||
. 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (
|
||||
16 . 11) (15 . 12) (38 . 13) (39 . 51)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (
|
||||
7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38
|
||||
. 13) (39 . 50)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7
|
||||
) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 49)) ((3
|
||||
. 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11
|
||||
. 10) (16 . 11) (15 . 12) (38 . 13) (39 . 48)) ((3 . 1) (4 . 2) (5 . 3) (
|
||||
6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15
|
||||
. 12) (38 . 13) (39 . 47)) ((9 . 45) (8 . 46) (35 . -31) (-1 . -31)) ((35
|
||||
. -27) (-1 . -27)) ((14 . 42) (13 . 43) (12 . 44) (35 . -24) (-1 . -24)) (
|
||||
(16 . 40) (15 . 41) (35 . -21) (-1 . -21)) ((18 . 38) (17 . 39) (35 . -16)
|
||||
(-1 . -16)) ((22 . 34) (21 . 35) (20 . 36) (19 . 37) (35 . -13) (-1 . -13
|
||||
)) ((24 . 32) (23 . 33) (35 . -11) (-1 . -11)) ((25 . 31) (35 . -9) (-1 .
|
||||
-9)) ((26 . 30) (35 . -7) (-1 . -7)) ((27 . 29) (35 . -5) (-1 . -5)) ((28
|
||||
. 28) (35 . -3) (-1 . -3)) ((31 . 26) (29 . 27) (2 . -1) (1 . -1) (35 . -1
|
||||
)) ((35 . 0)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9
|
||||
. 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15)
|
||||
(41 . 16) (42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47 . 22) (48
|
||||
. 23) (49 . 78)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7
|
||||
) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40
|
||||
. 15) (41 . 16) (42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47 . 22
|
||||
) (48 . 77)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9
|
||||
. 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15)
|
||||
(41 . 16) (42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47 . 76)) ((3
|
||||
. 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (
|
||||
11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15) (41 . 16) (42
|
||||
. 17) (43 . 18) (44 . 19) (45 . 20) (46 . 75)) ((3 . 1) (4 . 2) (5 . 3) (6
|
||||
. 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 .
|
||||
12) (38 . 13) (39 . 14) (40 . 15) (41 . 16) (42 . 17) (43 . 18) (44 . 19)
|
||||
(45 . 74)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 .
|
||||
8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15) (
|
||||
41 . 16) (42 . 17) (43 . 18) (44 . 73)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (
|
||||
7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38
|
||||
. 13) (39 . 14) (40 . 15) (41 . 16) (42 . 17) (43 . 72)) ((3 . 1) (4 . 2)
|
||||
(5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16
|
||||
. 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15) (41 . 16) (42 . 17) (43 . 71
|
||||
)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10
|
||||
. 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15) (41 . 16)
|
||||
(42 . 70)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9
|
||||
. 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15)
|
||||
(41 . 16) (42 . 69)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8
|
||||
. 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (
|
||||
40 . 15) (41 . 16) (42 . 68)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37
|
||||
. 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39
|
||||
. 14) (40 . 15) (41 . 16) (42 . 67)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7
|
||||
. 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38
|
||||
. 13) (39 . 14) (40 . 15) (41 . 66)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7
|
||||
. 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38
|
||||
. 13) (39 . 14) (40 . 15) (41 . 65)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7
|
||||
. 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38
|
||||
. 13) (39 . 14) (40 . 64)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 .
|
||||
6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 .
|
||||
14) (40 . 63)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (
|
||||
9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 62)) ((3 . 1
|
||||
) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 .
|
||||
10) (16 . 11) (15 . 12) (38 . 13) (39 . 61)) ((3 . 1) (4 . 2) (5 . 3) (6
|
||||
. 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 .
|
||||
12) (38 . 13) (39 . 60)) ((35 . -39) (-1 . -39)) ((35 . -40) (-1 . -40)) (
|
||||
(35 . -32) (-1 . -32)) ((35 . -33) (-1 . -33)) ((35 . -34) (-1 . -34)) ((
|
||||
35 . -35) (-1 . -35)) ((35 . -36) (-1 . -36)) ((35 . -37) (-1 . -37)) ((7
|
||||
. 59)) ((35 . -45) (-1 . -45)) ((2 . -47) (1 . -47)) ((2 . 57) (1 . 58)) (
|
||||
(35 . -46) (-1 . -46)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (
|
||||
8 . 7) (9 . 8) (10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14)
|
||||
(40 . 15) (41 . 16) (42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47
|
||||
. 22) (48 . 23) (49 . 24) (50 . 81)) ((2 . 80)) ((35 . -30) (-1 . -30)) ((
|
||||
35 . -29) (-1 . -29)) ((35 . -28) (-1 . -28)) ((14 . 42) (13 . 43) (12 .
|
||||
44) (35 . -26) (-1 . -26)) ((14 . 42) (13 . 43) (12 . 44) (35 . -25) (-1
|
||||
. -25)) ((16 . 40) (15 . 41) (35 . -23) (-1 . -23)) ((16 . 40) (15 . 41) (
|
||||
35 . -22) (-1 . -22)) ((18 . 38) (17 . 39) (35 . -20) (-1 . -20)) ((18 .
|
||||
38) (17 . 39) (35 . -19) (-1 . -19)) ((18 . 38) (17 . 39) (35 . -18) (-1
|
||||
. -18)) ((18 . 38) (17 . 39) (35 . -17) (-1 . -17)) ((22 . 34) (21 . 35) (
|
||||
20 . 36) (19 . 37) (35 . -15) (-1 . -15)) ((22 . 34) (21 . 35) (20 . 36) (
|
||||
19 . 37) (35 . -14) (-1 . -14)) ((24 . 32) (23 . 33) (35 . -12) (-1 . -12)
|
||||
) ((25 . 31) (35 . -10) (-1 . -10)) ((26 . 30) (35 . -8) (-1 . -8)) ((27
|
||||
. 29) (35 . -6) (-1 . -6)) ((28 . 28) (35 . -4) (-1 . -4)) ((30 . 79) (29
|
||||
. 27)) ((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (
|
||||
10 . 9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15) (41 .
|
||||
16) (42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47 . 22) (48 . 23)
|
||||
(49 . 24) (50 . 82)) ((35 . -44) (-1 . -44)) ((2 . -48) (1 . -48)) ((2 .
|
||||
-2) (1 . -2) (35 . -2))))
|
||||
|
||||
(define cpp-rto-v
|
||||
#(#f 50 50 49 49 48 48 47 47 46 46 45 45 44 44 44 43 43 43 43 43 42 42 42
|
||||
41 41 41 40 40 40 40 39 39 39 39 39 39 39 38 38 38 37 37 37 37 37 37 36 36
|
||||
))
|
||||
|
||||
(define cpp-mtab
|
||||
'(("," . 1) (")" . 2) ("(" . 3) ("defined" . 4) ($chlit . 5) ($fixed . 6)
|
||||
($ident . 7) ("--" . 8) ("++" . 9) ("~" . 10) ("!" . 11) ("%" . 12) ("/"
|
||||
. 13) ("*" . 14) ("-" . 15) ("+" . 16) (">>" . 17) ("<<" . 18) (">=" . 19)
|
||||
(">" . 20) ("<=" . 21) ("<" . 22) ("!=" . 23) ("==" . 24) ("&" . 25) ("^"
|
||||
. 26) ("|" . 27) ("&&" . 28) ("||" . 29) (":" . 30) ("?" . 31) (
|
||||
$code-comm . 32) ($lone-comm . 33) ($error . 34) ($end . 35)))
|
||||
|
||||
;;; end tables
|
|
@ -1,769 +0,0 @@
|
|||
;;; lang/c99/mach.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; C parser generator: based on ISO-C99; with comments and CPP statements
|
||||
|
||||
(define-module (nyacc lang c99 mach)
|
||||
#:export (c99-spec c99-mach dev-parse-c dev-parse-c99
|
||||
gen-c99-files gen-c99x-files)
|
||||
#:use-module (nyacc lang c99 cpp)
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module (nyacc lalr)
|
||||
#:use-module (nyacc parse)
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc util)
|
||||
#:use-module ((srfi srfi-43) #:select (vector-map))
|
||||
)
|
||||
|
||||
;; @deffn {Variable} c99-spec
|
||||
;; This variable is the specification a-list for the hacked ISO C99 language.
|
||||
;; Run this through @code{make-lalr-machine} to get an a-list for the
|
||||
;; automaton. The grammar is modified to parse CPP statements and comments.
|
||||
;; The output of the end parser will be a SXML tree (w/o the @code{*TOP*} node.
|
||||
;; @end deffn
|
||||
(define c99-spec
|
||||
(lalr-spec
|
||||
(notice (string-append "Copyright (C) 2016,2017 Matthew R. Wette"
|
||||
lang-crn-lic))
|
||||
(prec< 'then "else") ; "then/else" SR-conflict resolution
|
||||
(prec< 'imp ; "implied type" SR-conflict resolution
|
||||
"char" "short" "int" "long"
|
||||
"float" "double" "_Complex")
|
||||
(start translation-unit)
|
||||
(grammar
|
||||
|
||||
;; expressions
|
||||
(primary-expression ; S 6.5.1
|
||||
(identifier ($$ `(p-expr ,$1)))
|
||||
(constant ($$ `(p-expr ,$1)))
|
||||
(string-literal ($$ `(p-expr ,(tl->list $1))))
|
||||
("(" expression ")" ($$ $2))
|
||||
)
|
||||
|
||||
(postfix-expression ; S 6.5.2
|
||||
(primary-expression)
|
||||
(postfix-expression "[" expression "]" ($$ `(array-ref ,$3 ,$1)))
|
||||
(postfix-expression "(" argument-expression-list ")"
|
||||
($$ `(fctn-call ,$1 ,(tl->list $3))))
|
||||
(postfix-expression "(" ")" ($$ `(fctn-call ,$1 (expr-list))))
|
||||
(postfix-expression "." identifier ($$ `(d-sel ,$3 ,$1)))
|
||||
(postfix-expression "->" identifier ($$ `(i-sel ,$3 ,$1)))
|
||||
(postfix-expression "++" ($$ `(post-inc ,$1)))
|
||||
(postfix-expression "--" ($$ `(post-dec ,$1)))
|
||||
("(" type-name ")" "{" initializer-list "}"
|
||||
($$ `(comp-lit ,$2 ,(tl->list $5))))
|
||||
("(" type-name ")" "{" initializer-list "," "}"
|
||||
($$ `(comp-lit ,$2 ,(tl->list $5))))
|
||||
)
|
||||
|
||||
(argument-expression-list
|
||||
(assignment-expression ($$ (make-tl 'expr-list $1)))
|
||||
(argument-expression-list "," assignment-expression ($$ (tl-append $1 $3)))
|
||||
;; The following is a modification to deal with using abstract declarations
|
||||
;; as arguments to CPP macros (e.g., see offsetof in <stddef.h>).
|
||||
(arg-expr-hack ($$ (make-tl 'expr-list $1)))
|
||||
(argument-expression-list "," arg-expr-hack ($$ (tl-append $1 $3)))
|
||||
)
|
||||
(arg-expr-hack
|
||||
(declaration-specifiers
|
||||
abstract-declarator ($$ `(param-decl ,(tl->list $1) $2)))
|
||||
(declaration-specifiers ($$ `(param-decl ,(tl->list $1)))))
|
||||
|
||||
(unary-expression
|
||||
(postfix-expression) ; S 6.5.3
|
||||
("++" unary-expression ($$ `(pre-inc ,$2)))
|
||||
("--" unary-expression ($$ `(pre-dec ,$2)))
|
||||
(unary-operator cast-expression ($$ (list $1 $2)))
|
||||
("sizeof" unary-expression ($$ `(sizeof-expr ,$2)))
|
||||
("sizeof" "(" type-name ")" ($$ `(sizeof-type ,$3)))
|
||||
)
|
||||
(unary-operator ("&" ($$ 'ref-to)) ("*" ($$ 'de-ref))
|
||||
("+" ($$ 'pos)) ("-" ($$ 'neg))
|
||||
("~" ($$ 'bitwise-not)) ("!" ($$ 'not)))
|
||||
|
||||
(cast-expression ; S 6.5.4
|
||||
(unary-expression)
|
||||
("(" type-name ")" cast-expression ($$ `(cast ,$2 ,$4)))
|
||||
)
|
||||
|
||||
(multiplicative-expression ; S 6.5.5
|
||||
(cast-expression)
|
||||
(multiplicative-expression "*" cast-expression ($$ `(mul ,$1 ,$3)))
|
||||
(multiplicative-expression "/" cast-expression ($$ `(div ,$1 ,$3)))
|
||||
(multiplicative-expression "%" cast-expression ($$ `(mod ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(additive-expression ; S 6.5.6
|
||||
(multiplicative-expression)
|
||||
(additive-expression "+" multiplicative-expression ($$ `(add ,$1 ,$3)))
|
||||
(additive-expression "-" multiplicative-expression ($$ `(sub ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(shift-expression ; S 6.5.7
|
||||
(additive-expression)
|
||||
(shift-expression "<<" additive-expression ($$ `(lshift ,$1 ,$3)))
|
||||
(shift-expression ">>" additive-expression ($$ `(rshift ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(relational-expression ; S 6.5.8
|
||||
(shift-expression)
|
||||
(relational-expression "<" shift-expression ($$ `(lt ,$1 ,$3)))
|
||||
(relational-expression ">" shift-expression ($$ `(gt ,$1 ,$3)))
|
||||
(relational-expression "<=" shift-expression ($$ `(le ,$1 ,$3)))
|
||||
(relational-expression ">=" shift-expression ($$ `(ge ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(equality-expression ; S 6.5.9
|
||||
(relational-expression)
|
||||
(equality-expression "==" relational-expression ($$ `(eq ,$1 ,$3)))
|
||||
(equality-expression "!=" relational-expression ($$ `(ne ,$1 ,$3)))
|
||||
)
|
||||
|
||||
;; called AND-expression
|
||||
(bitwise-and-expression ; S 6.5.10
|
||||
(equality-expression)
|
||||
(bitwise-and-expression "&" equality-expression
|
||||
($$ `(bitwise-and ,$1 ,$3)))
|
||||
)
|
||||
|
||||
;; called exclusive-OR-expression
|
||||
(bitwise-xor-expression ; S 6.5.11
|
||||
(bitwise-and-expression)
|
||||
(bitwise-xor-expression "^" bitwise-and-expression
|
||||
($$ `(bitwise-xor ,$1 ,$3)))
|
||||
)
|
||||
|
||||
;; called inclusive-OR-expression
|
||||
(bitwise-or-expression ; S 6.5.12
|
||||
(bitwise-xor-expression)
|
||||
(bitwise-or-expression "|" bitwise-xor-expression
|
||||
($$ `(bitwise-or ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(logical-and-expression ; S 6.5.13
|
||||
(bitwise-or-expression)
|
||||
(logical-and-expression "&&" bitwise-or-expression
|
||||
($$ `(and ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(logical-or-expression ; 6.5.14
|
||||
(logical-and-expression)
|
||||
(logical-or-expression "||" logical-and-expression
|
||||
($$ `(or ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(conditional-expression
|
||||
(logical-or-expression)
|
||||
(logical-or-expression "?" expression ":" conditional-expression
|
||||
($$ `(cond-expr ,$1 ,$3 ,$5)))
|
||||
)
|
||||
|
||||
(assignment-expression ; S 6.5.16
|
||||
(conditional-expression)
|
||||
(unary-expression assignment-operator assignment-expression
|
||||
($$ `(assn-expr ,$1 (op ,$2) ,$3)))
|
||||
)
|
||||
(assignment-operator
|
||||
("=") ("+=") ("-=") ("*=") ("/=") ("%=")
|
||||
("<<=") (">>=") ("&=") ("^=") ("|="))
|
||||
|
||||
(expression ; S 6.5.17
|
||||
(assignment-expression)
|
||||
(expression "," assignment-expression
|
||||
($$ (if (eqv? 'comma-expr (sx-tag $1))
|
||||
(append $1 (list $3))
|
||||
`(comma-expr ,$1 ,$3))))
|
||||
)
|
||||
|
||||
(constant-expression ; S 6.6
|
||||
(conditional-expression)
|
||||
)
|
||||
|
||||
;; declarations
|
||||
(declaration ; S 6.7
|
||||
(declaration-specifiers
|
||||
init-declarator-list
|
||||
($$ (save-typenames `(decl ,(tl->list $1) ,(tl->list $2))))
|
||||
";" opt-code-comment
|
||||
($$ (if (pair? $5) (append $3 (list $5)) $3)))
|
||||
(declaration-specifiers
|
||||
";" opt-code-comment
|
||||
($$ (if (pair? $3)
|
||||
`(decl ,(tl->list $1) ,(list $3))
|
||||
`(decl ,(tl->list $1)))))
|
||||
)
|
||||
|
||||
(declaration-specifiers ; S 6.7
|
||||
;; storage-class-specifier declaration-specifiers_opt
|
||||
(storage-class-specifier ($$ (make-tl 'decl-spec-list $1)))
|
||||
(storage-class-specifier declaration-specifiers ($$ (tl-insert $2 $1)))
|
||||
;; type-specifier declaration-specifiers_opt
|
||||
(type-specifier ($$ (make-tl 'decl-spec-list $1)))
|
||||
(type-specifier declaration-specifiers ($$ (tl-insert $2 $1)))
|
||||
;; type-qualifier declaration-specifiers_opt
|
||||
(type-qualifier ($$ (make-tl 'decl-spec-list $1)))
|
||||
(type-qualifier declaration-specifiers ($$ (tl-insert $2 $1)))
|
||||
;; function-specifier declaration-specifiers_opt
|
||||
(function-specifier ($$ (make-tl 'decl-spec-list $1)))
|
||||
(function-specifier declaration-specifiers ($$ (tl-insert $2 $1)))
|
||||
)
|
||||
|
||||
(init-declarator-list ; S 6.7
|
||||
(init-declarator ($$ (make-tl 'init-declr-list $1)))
|
||||
(init-declarator-list "," init-declarator ($$ (tl-append $1 $3)))
|
||||
)
|
||||
|
||||
(init-declarator ; S 6.7
|
||||
(declarator ($$ `(init-declr ,$1)))
|
||||
(declarator "=" initializer ($$ `(init-declr ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(storage-class-specifier ; S 6.7.1
|
||||
("auto" ($$ '(stor-spec (auto))))
|
||||
("extern" ($$ '(stor-spec (extern))))
|
||||
("register" ($$ '(stor-spec (register))))
|
||||
("static" ($$ '(stor-spec (static))))
|
||||
("typedef" ($$ '(stor-spec (typedef))))
|
||||
)
|
||||
|
||||
(type-specifier ; S 6.7.2
|
||||
("void" ($$ '(type-spec (void))))
|
||||
(fixed-type-specifier ($$ `(type-spec ,$1))) ; I made this up
|
||||
(float-type-specifier ($$ `(type-spec ,$1))) ; I made this up
|
||||
("_Bool" ($$/ref 's5.1.5-01 '(type-spec (fixed-type "_Bool"))))
|
||||
(complex-type-specifier ($$ `(type-spec ,$1))) ; I made this up
|
||||
(struct-or-union-specifier ($$ `(type-spec ,$1)))
|
||||
(enum-specifier ($$ `(type-spec ,$1)))
|
||||
(typedef-name ($$ `(type-spec ,$1)))
|
||||
)
|
||||
|
||||
(fixed-type-specifier
|
||||
("short" ($prec 'imp) ($$ '(fixed-type "short")))
|
||||
("short" "int" ($$ '(fixed-type "short int")))
|
||||
("signed" "short" ($prec 'imp) ($$ '(fixed-type "signed short")))
|
||||
("signed" "short" "int" ($$ '(fixed-type "signed short int")))
|
||||
("int" ($$ '(fixed-type "int")))
|
||||
("signed" ($prec 'imp) ($$ '(fixed-type "signed")))
|
||||
("signed" "int" ($$ '(fixed-type "signed int")))
|
||||
("long" ($prec 'imp) ($$ '(fixed-type "long")))
|
||||
("long" "int" ($$ '(fixed-type "long int")))
|
||||
("signed" "long" ($prec 'imp) ($$ '(fixed-type "signed long")))
|
||||
("signed" "long" "int" ($$ '(fixed-type "signed long int")))
|
||||
("long" "long" ($prec 'imp) ($$ '(fixed-type "long long")))
|
||||
("long" "long" "int" ($$ '(fixed-type "long long int")))
|
||||
("signed" "long" "long" ($prec 'imp)
|
||||
($$ '(fixed-type "signed long long")))
|
||||
("signed" "long" "long" "int" ($$ '(fixed-type "signed long long int")))
|
||||
("unsigned" "short" "int" ($$ '(fixed-type "unsigned short int")))
|
||||
("unsigned" "short" ($prec 'imp) ($$ '(fixed-type "unsigned short")))
|
||||
("unsigned" "int" ($$ '(fixed-type "unsigned int")))
|
||||
("unsigned" ($prec 'imp) ($$ '(fixed-type "unsigned")))
|
||||
("unsigned" "long" "int" ($$ '(fixed-type "unsigned long")))
|
||||
("unsigned" "long" ($prec 'imp) ($$ '(fixed-type "unsigned long")))
|
||||
("unsigned" "long" "long" "int"
|
||||
($$ '(fixed-type "unsigned long long int")))
|
||||
("unsigned" "long" "long" ($prec 'imp)
|
||||
($$ '(fixed-type "unsigned long long")))
|
||||
("char" ($$ '(fixed-type "char")))
|
||||
("signed" "char" ($$ '(fixed-type "signed char")))
|
||||
("unsigned" "char" ($$ '(fixed-type "unsigned char"))))
|
||||
(float-type-specifier
|
||||
("float" ($prec 'imp) ($$ '(float-type "float")))
|
||||
("double" ($prec 'imp) ($$ '(float-type "double")))
|
||||
("long" "double" ($$ '(float-type "long double"))))
|
||||
(complex-type-specifier
|
||||
("_Complex" ($$ '(complex-type "_Complex")))
|
||||
("float" "_Complex" ($$ '(complex-type "float _Complex")))
|
||||
("double" "_Complex" ($$ '(complex-type "double _Complex")))
|
||||
("long" "double" "_Complex" ($$ '(complex-type "long double _Complex")))
|
||||
)
|
||||
|
||||
;; This one modified: split out struct-or-union = "struct"|"union"
|
||||
(struct-or-union-specifier ; S 6.7.2.1
|
||||
("struct" ident-like "{" struct-declaration-list "}"
|
||||
($$ `(struct-def ,$2 ,(tl->list $4))))
|
||||
("struct" "{" struct-declaration-list "}"
|
||||
($$ `(struct-def ,(tl->list $3))))
|
||||
("struct" ident-like ($$ `(struct-ref ,$2)))
|
||||
("union" ident-like "{" struct-declaration-list "}"
|
||||
($$ `(union-def ,$2 ,(tl->list $4))))
|
||||
("union" "{" struct-declaration-list "}"
|
||||
($$ `(union-def ,(tl->list $3))))
|
||||
("union" ident-like ($$ `(union-ref ,$2)))
|
||||
)
|
||||
;; because name following struct/union can be indentifier or typeref
|
||||
(ident-like (identifier) (typedef-name ($$ `(ident ,(cdr $1)))))
|
||||
|
||||
;; Calling this field-list in the parse tree.
|
||||
(struct-declaration-list ; S 6.7.2.1
|
||||
(struct-declaration ($$ (make-tl 'field-list $1)))
|
||||
(lone-comment ($$ (make-tl 'field-list $1)))
|
||||
(struct-declaration-list struct-declaration ($$ (tl-append $1 $2)))
|
||||
(struct-declaration-list lone-comment ($$ (tl-append $1 $2)))
|
||||
)
|
||||
|
||||
(struct-declaration ; S 6.7.2.1
|
||||
(specifier-qualifier-list
|
||||
struct-declarator-list ";" opt-code-comment
|
||||
($$ (if (pair? $4)
|
||||
`(comp-decl ,(tl->list $1) ,(tl->list $2) ,$4)
|
||||
`(comp-decl ,(tl->list $1) ,(tl->list $2)))))
|
||||
)
|
||||
|
||||
(specifier-qualifier-list ; S 6.7.2.1
|
||||
(type-specifier specifier-qualifier-list ($$ (tl-insert $2 $1)))
|
||||
(type-specifier ($$ (make-tl 'decl-spec-list $1)))
|
||||
(type-qualifier specifier-qualifier-list ($$ (tl-insert $2 $1)))
|
||||
(type-qualifier ($$ (make-tl 'decl-spec-list $1)))
|
||||
)
|
||||
|
||||
(struct-declarator-list ; S 6.7.2.1
|
||||
(struct-declarator ($$ (make-tl 'comp-declr-list $1)))
|
||||
(struct-declarator-list "," struct-declarator ($$ (tl-append $1 $3)))
|
||||
)
|
||||
|
||||
(struct-declarator ; S 6.7.2.1
|
||||
(declarator ($$ `(comp-declr ,$1)))
|
||||
(declarator ":" constant-expression ($$ `(comp-declr (bit-field ,$1 ,$3))))
|
||||
(":" constant-expression ($$ `(comp-declr (bit-field ,$2))))
|
||||
)
|
||||
|
||||
(enum-specifier ; S 6.7.2.2
|
||||
("enum" ident-like "{" enumerator-list "}"
|
||||
($$ `(enum-def ,$2 ,(tl->list $4))))
|
||||
("enum" ident-like "{" enumerator-list "," "}"
|
||||
($$ `(enum-def ,$2 ,(tl->list $4))))
|
||||
("enum" "{" enumerator-list "}" ($$ `(enum-def ,(tl->list $3))))
|
||||
("enum" "{" enumerator-list "," "}" ($$ `(enum-def ,(tl->list $3))))
|
||||
("enum" ident-like ($$ `(enum-ref ,$2)))
|
||||
)
|
||||
|
||||
;; keeping old enum-def-list in parse tree
|
||||
(enumerator-list ; S 6.7.2.2
|
||||
(enumerator ($$ (make-tl 'enum-def-list $1)))
|
||||
(enumerator-list "," enumerator ($$ (tl-append $1 $3)))
|
||||
)
|
||||
|
||||
;; Had to change enumeration-constant => identifier
|
||||
(enumerator ; S 6.7.2.2
|
||||
(identifier ($$ `(enum-defn ,$1)))
|
||||
(identifier "=" constant-expression ($$ `(enum-defn ,$1 ,$3)))
|
||||
)
|
||||
|
||||
(type-qualifier
|
||||
("const" ($$ `(type-qual ,$1)))
|
||||
("volatile" ($$ `(type-qual ,$1)))
|
||||
("restrict" ($$ `(type-qual ,$1)))
|
||||
)
|
||||
|
||||
(function-specifier ("inline" ($$ `(fctn-spec ,$1))))
|
||||
|
||||
(declarator
|
||||
(pointer direct-declarator ($$ `(ptr-declr ,$1 ,$2)))
|
||||
(direct-declarator)
|
||||
)
|
||||
|
||||
(direct-declarator ; S 6.7.6
|
||||
(identifier ($$ $1))
|
||||
("(" declarator ")" ($$ `(scope ,$2)))
|
||||
|
||||
(direct-declarator
|
||||
"[" type-qualifier-list assignment-expression "]"
|
||||
($$ `(array-of ,$1 ,$3 ,$4)))
|
||||
(direct-declarator "[" type-qualifier-list "]" ($$ `(array-of ,$1 ,$3)))
|
||||
(direct-declarator "[" assignment-expression "]" ($$ `(array-of ,$1 ,$3)))
|
||||
(direct-declarator "[" "]" ($$ `(array-of ,$1)))
|
||||
(direct-declarator
|
||||
"[" "static" type-qualifier-list assignment-expression "]"
|
||||
($$ `(array-of ,$1 ,(tl->list (tl-insert '(stor-spec "static") $4)) ,$5)))
|
||||
(direct-declarator
|
||||
"[" type-qualifier-list "static" assignment-expression "]"
|
||||
($$ `(array-of ,$1 ,(tl->list (tl-insert '(stor-spec "static") $3)) ,$5)))
|
||||
(direct-declarator
|
||||
"[" type-qualifier-list "*" "]" ; variable length array
|
||||
($$ `(array-of ,$1 ,$3 (var-len))))
|
||||
(direct-declarator
|
||||
"[" "*" "]" ; variable length array
|
||||
($$ `(array-of ,$1 (var-len))))
|
||||
(direct-declarator "(" parameter-type-list ")"
|
||||
($$ `(ftn-declr ,$1 ,(tl->list $3))))
|
||||
(direct-declarator "(" identifier-list ")"
|
||||
($$ `(ftn-declr ,$1 ,(tl->list $3))))
|
||||
(direct-declarator "(" ")" ($$ `(ftn-declr ,$1 (param-list))))
|
||||
)
|
||||
|
||||
(pointer ; S 6.7.6
|
||||
("*" type-qualifier-list ($$ `(pointer ,(tl->list $2))))
|
||||
("*" ($$ '(pointer)))
|
||||
("*" type-qualifier-list pointer ($$ `(pointer ,(tl->list $2) ,$3)))
|
||||
("*" pointer ($$ `(pointer ,$2)))
|
||||
)
|
||||
|
||||
;; But put in tree as decl-spec-list
|
||||
(type-qualifier-list
|
||||
(type-qualifier ($$ (make-tl 'decl-spec-list $1)))
|
||||
(type-qualifier-list type-qualifier ($$ (tl-append $1 $2)))
|
||||
)
|
||||
|
||||
(parameter-type-list
|
||||
(parameter-list ($$ $1))
|
||||
(parameter-list "," "..." ($$ (tl-append $1 '(ellipsis))))
|
||||
)
|
||||
|
||||
(parameter-list
|
||||
(parameter-declaration ($$ (make-tl 'param-list $1)))
|
||||
(parameter-list "," parameter-declaration ($$ (tl-append $1 $3)))
|
||||
)
|
||||
|
||||
(parameter-declaration
|
||||
(declaration-specifiers
|
||||
declarator ($$ `(param-decl ,(tl->list $1) (param-declr ,$2))))
|
||||
(declaration-specifiers
|
||||
abstract-declarator ($$ `(param-decl ,(tl->list $1) (param-declr ,$2))))
|
||||
(declaration-specifiers
|
||||
($$ `(param-decl ,(tl->list $1))))
|
||||
)
|
||||
|
||||
(identifier-list
|
||||
(identifier ($$ (make-tl 'ident-list $1)))
|
||||
(identifier-list "," identifier ($$ (tl-append $1 $3)))
|
||||
)
|
||||
|
||||
(type-name ; S 6.7.6
|
||||
;; e.g., (foo_t *)
|
||||
(specifier-qualifier-list abstract-declarator
|
||||
($$ `(type-name ,(tl->list $1) ,$2)))
|
||||
;; e.g., (int)
|
||||
(declaration-specifiers ($$ `(type-name ,(tl->list $1))))
|
||||
)
|
||||
|
||||
(abstract-declarator ; S 6.7.6
|
||||
(pointer ($$ `(abs-declr ,$1)))
|
||||
(pointer direct-abstract-declarator ($$ `(abs-declr ,$1 ,$2)))
|
||||
(direct-abstract-declarator ($$ `(abs-declr ,$1)))
|
||||
)
|
||||
|
||||
(direct-abstract-declarator
|
||||
("(" abstract-declarator ")" ($$ `(declr-scope ,$2)))
|
||||
(direct-abstract-declarator
|
||||
"[" type-qualifier-list assignment-expression "]"
|
||||
($$ `(declr-array ,$3 ,$4)))
|
||||
(direct-abstract-declarator
|
||||
"[" type-qualifier-list "]"
|
||||
($$ `(declr-array ,$1 ,$3)))
|
||||
(direct-abstract-declarator
|
||||
"[" assignment-expression "]"
|
||||
($$ `(declr-array ,$1 ,$3)))
|
||||
(direct-abstract-declarator
|
||||
"[" "]" ($$ `(declr-array ,$1)))
|
||||
(direct-abstract-declarator
|
||||
"[" "static" type-qualifier-list assignment-expression "]"
|
||||
($$ `(declr-array
|
||||
,$1 ,(tl->list (tl-insert '(stor-spec "static") $4)) ,$5)))
|
||||
(direct-abstract-declarator
|
||||
"[" "static" type-qualifier-list "]"
|
||||
($$ `(declr-array ,$1 ,(tl->list (tl-insert '(stor-spec "static") $4)))))
|
||||
(direct-abstract-declarator
|
||||
"[" type-qualifier-list "static" assignment-expression "]"
|
||||
($$ `(declr-array
|
||||
,$1 ,(tl->list (tl-insert '(stor-spec "static") $3)) ,$5)))
|
||||
;;
|
||||
("[" type-qualifier-list assignment-expression "]"
|
||||
($$ `(declr-anon-array ,$2 ,$3)))
|
||||
("[" type-qualifier-list "]" ($$ `(declr-anon-array ,$2)))
|
||||
("[" assignment-expression "]" ($$ `(declr-anon-array ,$2)))
|
||||
("[" "]" ($$ `(declr-anon-array)))
|
||||
("[" "static" type-qualifier-list assignment-expression "]"
|
||||
($$ `(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $3)) ,$4)))
|
||||
("[" "static" type-qualifier-list "]"
|
||||
($$ `(declr-anon-array ,(tl->list (tl-insert '(stor-spec "static") $3)))))
|
||||
("[" type-qualifier-list "static" assignment-expression "]"
|
||||
($$ `(declr-anon-array
|
||||
,(tl->list (tl-insert '(stor-spec "static") $2)) ,$4)))
|
||||
(direct-abstract-declarator "[" "*" "]" ($$ `(declr-STAR ,$1)))
|
||||
("[" "*" "]" ($$ '(declr-STAR)))
|
||||
(direct-abstract-declarator "(" parameter-type-list ")"
|
||||
($$ `(declr-fctn ,$1 ,(tl->list $3))))
|
||||
(direct-abstract-declarator "(" ")" ($$ `(declr-fctn ,$1)))
|
||||
("(" parameter-type-list ")" ($$ `(declr-anon-fctn ,(tl->list $2))))
|
||||
("(" ")" ($$ '(declr-anon-fctn)))
|
||||
)
|
||||
|
||||
;;typedef-name must be hacked w/ the lexical analyzer
|
||||
(typedef-name ('typename ($$ `(typename ,$1))))
|
||||
|
||||
(initializer ; S 6.7.9
|
||||
(assignment-expression ($$ `(initzer ,$1)))
|
||||
("{" initializer-list "}" ($$ `(initzer ,(tl->list $2))))
|
||||
("{" initializer-list "," "}" ($$ `(initzer ,(tl->list $2))))
|
||||
)
|
||||
|
||||
;; The designation productions are from C99.
|
||||
(initializer-list
|
||||
(designation initializer ($$ (make-tl 'initzer-list $1 $2)))
|
||||
(initializer ($$ (make-tl 'initzer-list $1)))
|
||||
(initializer-list "," designation initializer ($$ (tl-append $1 $3 $4)))
|
||||
(initializer-list "," initializer ($$ (tl-append $1 $3)))
|
||||
)
|
||||
|
||||
(designation ; S 6.7.8
|
||||
(designator-list "=" ($$ `(desig ,$1)))
|
||||
)
|
||||
|
||||
(designator-list
|
||||
(designator ($$ (make-tl 'desgr-list $1)))
|
||||
(designator-list designator ($$ (tl-append $1 $2)))
|
||||
)
|
||||
|
||||
(designator
|
||||
("[" constant-expression "]" ($$ (list 'array-dsgr $2)))
|
||||
("." identifier ($$ (list 'sel-dsgr $2)))
|
||||
)
|
||||
|
||||
;; statements
|
||||
(statement
|
||||
(labeled-statement)
|
||||
(compound-statement)
|
||||
(expression-statement)
|
||||
(selection-statement)
|
||||
(iteration-statement)
|
||||
(jump-statement)
|
||||
(cpp-statement)
|
||||
)
|
||||
|
||||
(labeled-statement
|
||||
(identifier ":" statement ($$ `(labeled-stmt ,$1 ,$3)))
|
||||
("case" constant-expression ":" statement ($$ `(case ,$2 ,$4)))
|
||||
("default" ":" statement ($$ `(default ,$3)))
|
||||
)
|
||||
|
||||
(compound-statement
|
||||
("{" block-item-list "}"
|
||||
($$ `(compd-stmt ,(tl->list $2))))
|
||||
("{" "}"
|
||||
($$ `(compd-stmt (block-item-list))))
|
||||
)
|
||||
|
||||
(block-item-list
|
||||
(block-item ($$ (make-tl 'block-item-list $1)))
|
||||
(block-item-list block-item ($$ (tl-append $1 $2)))
|
||||
)
|
||||
|
||||
(block-item
|
||||
(declaration)
|
||||
(statement)
|
||||
)
|
||||
|
||||
(expression-statement
|
||||
(expression ";" ($$ `(expr-stmt ,$1)))
|
||||
(";" ($$ '(expr-stmt)))
|
||||
)
|
||||
|
||||
(selection-statement
|
||||
("if" "(" expression ")" statement ($prec 'then)
|
||||
($$ `(if ,$3 ,$5)))
|
||||
("if" "(" expression ")" statement "else" statement
|
||||
($$ `(if ,$3 ,$5 ,$7)))
|
||||
("switch" "(" expression ")" statement ($$ `(switch ,$3 ,$5)))
|
||||
)
|
||||
|
||||
(iteration-statement
|
||||
("while" "(" expression ")" statement ($$ `(while ,$3 ,$5)))
|
||||
("do" statement "while" "(" expression ")" ";" ($$ `(do-while ,$2 ,$5)))
|
||||
("for" "(" initial-clause opt-expression ";" opt-expression ")" statement
|
||||
($$ `(for ,$3 ,$4 ,$6 ,$8)))
|
||||
)
|
||||
(initial-clause ; <= added for convenience
|
||||
(expression ";")
|
||||
(";" ($$ '(expr)))
|
||||
(declaration))
|
||||
(opt-expression ; <= added for convenience
|
||||
($empty ($$ '(expr)))
|
||||
(expression))
|
||||
|
||||
(jump-statement ; S 6.8.6
|
||||
("goto" identifier ";" ($$ `(goto ,$2)))
|
||||
("continue" ";" ($$ '(continue)))
|
||||
("break" ";" ($$ '(break)))
|
||||
("return" expression ";" ($$ `(return ,$2)))
|
||||
("return" ";" ($$ `(return (expr))))
|
||||
)
|
||||
|
||||
;; external definitions
|
||||
(translation-unit ; S 6.9
|
||||
(external-declaration-list ($$ (tl->list $1)))
|
||||
)
|
||||
(external-declaration-list
|
||||
;;(external-declaration ($$ (make-tl 'trans-unit $1)))
|
||||
($empty ($$ (make-tl 'trans-unit)))
|
||||
(external-declaration-list
|
||||
external-declaration
|
||||
;; A ``kludge'' to deal with @code{extern "C" ...}:
|
||||
($$ (if (eqv? (sx-tag $2) 'extern-block) (tl-extend $1 (sx-tail $2 1))
|
||||
(tl-append $1 $2))))
|
||||
)
|
||||
|
||||
(external-declaration ; S 6.9
|
||||
(function-definition)
|
||||
(declaration)
|
||||
(lone-comment)
|
||||
(cpp-statement)
|
||||
(pragma)
|
||||
("extern" $string "{" external-declaration-list "}"
|
||||
($$ `(extern-block (extern-begin ,$2)
|
||||
,@(sx-tail (tl->list $4) 1)
|
||||
(extern-end))))
|
||||
(";" ($$ `(decl (@ (extension . "GNU C")))))
|
||||
)
|
||||
|
||||
(function-definition
|
||||
(declaration-specifiers
|
||||
declarator declaration-list compound-statement
|
||||
($$ `(knr-fctn-defn ,(tl->list $1) ,$2 ,(tl->list $3) ,$4)))
|
||||
(declaration-specifiers
|
||||
declarator compound-statement
|
||||
($$ `(fctn-defn ,(tl->list $1) ,$2 ,$3)))
|
||||
)
|
||||
|
||||
(declaration-list
|
||||
(declaration ($$ (make-tl $1)))
|
||||
(declaration-list declaration ($$ (tl-append $1 $2)))
|
||||
)
|
||||
|
||||
(opt-code-comment ($empty) (code-comment))
|
||||
|
||||
;; non-terminal leaves
|
||||
(identifier
|
||||
($ident ($$ `(ident ,$1)))
|
||||
('cpp-ident ($$ `(ident ,$1)))
|
||||
)
|
||||
(constant
|
||||
($fixed ($$ `(fixed ,$1))) ; integer-constant
|
||||
($float ($$ `(float ,$1))) ; floating-constant
|
||||
($chlit ($$ `(char ,$1)))) ; char-constant
|
||||
(string-literal
|
||||
($string ($$ (make-tl 'string $1))) ; string-constant
|
||||
(string-literal $string ($$ (tl-append $1 $2))))
|
||||
(code-comment ($code-comm ($$ `(comment ,$1))))
|
||||
(lone-comment ($lone-comm ($$ `(comment ,$1))))
|
||||
(cpp-statement ('cpp-stmt ($$ `(cpp-stmt ,$1))))
|
||||
(pragma ('cpp-pragma))
|
||||
)))
|
||||
|
||||
|
||||
(define c99-mach
|
||||
(compact-machine
|
||||
(hashify-machine
|
||||
(make-lalr-machine c99-spec))))
|
||||
|
||||
;;; =====================================
|
||||
|
||||
;; The following are needed by the code in pbody.scm.
|
||||
(define c99-len-v (assq-ref c99-mach 'len-v))
|
||||
(define c99-pat-v (assq-ref c99-mach 'pat-v))
|
||||
(define c99-rto-v (assq-ref c99-mach 'rto-v))
|
||||
(define c99-mtab (assq-ref c99-mach 'mtab))
|
||||
(define c99-act-v (vector-map
|
||||
(lambda (ix f) (eval f (current-module)))
|
||||
(vector-map (lambda (ix actn) (wrap-action actn))
|
||||
(assq-ref c99-mach 'act-v))))
|
||||
|
||||
(include-from-path "nyacc/lang/c99/body.scm")
|
||||
|
||||
(define raw-parser (make-lalr-parser c99-mach))
|
||||
|
||||
(define (run-parse)
|
||||
(let ((info (fluid-ref *info*)))
|
||||
(raw-parser (gen-c-lexer) #:debug (cpi-debug info))))
|
||||
|
||||
(define* (dev-parse-c99 #:key
|
||||
(cpp-defs '()) ; CPP defines
|
||||
(inc-dirs '()) ; include directories
|
||||
(inc-help '()) ; typedef dictionary
|
||||
(mode 'file) ; mode: 'file or 'code
|
||||
(xdef? #f) ; expand def function: proc name mode
|
||||
(debug #f)) ; debug
|
||||
(catch
|
||||
#t ;; 'c99-error 'cpp-error 'nyacc-error
|
||||
(lambda ()
|
||||
(let ((info (make-cpi debug cpp-defs (cons "." inc-dirs) inc-help)))
|
||||
(with-fluid*
|
||||
*info* info
|
||||
(lambda ()
|
||||
(raw-parser (gen-c-lexer #:mode mode #:xdef? xdef?)
|
||||
#:debug debug)))))
|
||||
(lambda (key fmt . rest)
|
||||
(report-error fmt rest)
|
||||
#f)))
|
||||
|
||||
(define dev-parse-c dev-parse-c99)
|
||||
|
||||
;;; =====================================
|
||||
|
||||
;; @deffn {Procedure} gen-c99-files [dir] => #t
|
||||
;; Update or generate the files @quot{c99act.scm} and @quot{c99tab.scm}.
|
||||
;; These are the tables and actions for the C99 parser.
|
||||
;; If there are no changes to existing files, no update occurs.
|
||||
;; @end deffn
|
||||
(define (gen-c99-files . rest)
|
||||
(define (lang-dir path)
|
||||
(if (pair? rest) (string-append (car rest) "/" path) path))
|
||||
(define (xtra-dir path)
|
||||
(lang-dir (string-append "mach.d/" path)))
|
||||
|
||||
(write-lalr-actions c99-mach (xtra-dir "c99act.scm.new") #:prefix "c99-")
|
||||
(write-lalr-tables c99-mach (xtra-dir "c99tab.scm.new") #:prefix "c99-")
|
||||
(let ((a (move-if-changed (xtra-dir "c99act.scm.new")
|
||||
(xtra-dir "c99act.scm")))
|
||||
(b (move-if-changed (xtra-dir "c99tab.scm.new")
|
||||
(xtra-dir "c99tab.scm"))))
|
||||
#;(when (or a b)
|
||||
(system (string-append "touch " (lang-dir "parser.scm"))))
|
||||
(or a b)))
|
||||
|
||||
;; @deffn {Procedure} gen-c99x-files [dir] => #t
|
||||
;; Update or generate the files @quot{c99xact.scm} and @quot{c99xtab.scm}.
|
||||
;; These are the tables and actions for the C99 expression parser.
|
||||
;; If there are no changes to existing files, no update occurs.
|
||||
;; @end deffn
|
||||
(define (gen-c99x-files . rest)
|
||||
(define (lang-dir path)
|
||||
(if (pair? rest) (string-append (car rest) "/" path) path))
|
||||
(define (xtra-dir path)
|
||||
(lang-dir (string-append "mach.d/" path)))
|
||||
|
||||
(let* ((cexpr-spec (restart-spec c99-mach 'expression))
|
||||
(cexpr-mach (compact-machine
|
||||
(hashify-machine
|
||||
(make-lalr-machine cexpr-spec)))))
|
||||
(write-lalr-actions cexpr-mach (xtra-dir "c99xact.scm.new")
|
||||
#:prefix "c99x-")
|
||||
(write-lalr-tables cexpr-mach (xtra-dir "c99xtab.scm.new")
|
||||
#:prefix "c99x-"))
|
||||
|
||||
(let ((a (move-if-changed (xtra-dir "c99xact.scm.new")
|
||||
(xtra-dir "c99xact.scm")))
|
||||
(b (move-if-changed (xtra-dir "c99xtab.scm.new")
|
||||
(xtra-dir "c99xtab.scm"))))
|
||||
(when (or a b)
|
||||
(system (string-append "touch " (lang-dir "parser.scm")))
|
||||
#;(compile-file (lang-dir "xparser.scm"))
|
||||
)
|
||||
(or a b)))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,91 +0,0 @@
|
|||
;;; nyacc/lang/c99/parser.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; C parser
|
||||
|
||||
(define-module (nyacc lang c99 parser)
|
||||
#:export (parse-c99)
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc parse)
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module (nyacc lang c99 cpp)
|
||||
)
|
||||
|
||||
(include-from-path "nyacc/lang/c99/mach.d/c99tab.scm")
|
||||
(include-from-path "nyacc/lang/c99/body.scm")
|
||||
(include-from-path "nyacc/lang/c99/mach.d/c99act.scm")
|
||||
|
||||
;; Parse given a token generator. Uses fluid @code{*info*}.
|
||||
;; A little ugly wrt re-throw but
|
||||
(define raw-parser
|
||||
(let ((parser (make-lalr-parser
|
||||
(list (cons 'len-v c99-len-v) (cons 'pat-v c99-pat-v)
|
||||
(cons 'rto-v c99-rto-v) (cons 'mtab c99-mtab)
|
||||
(cons 'act-v c99-act-v)))))
|
||||
(lambda* (lexer #:key (debug #f))
|
||||
(catch
|
||||
'nyacc-error
|
||||
(lambda () (parser lexer #:debug debug))
|
||||
(lambda (key fmt . args)
|
||||
(report-error fmt args)
|
||||
(pop-input) ; not sure this is the right way
|
||||
(throw 'c99-error "C99 parse error"))))))
|
||||
|
||||
;; This is used to parse included files at top level.
|
||||
(define (run-parse)
|
||||
(let ((info (fluid-ref *info*)))
|
||||
(raw-parser (gen-c-lexer #:mode 'decl) #:debug (cpi-debug info))))
|
||||
|
||||
;; @deffn {Procedure} parse-c99 [#:cpp-defs def-a-list] [#:inc-dirs dir-list] \
|
||||
;; [#:mode ('code|'file|'decl)] [#:debug bool]
|
||||
;; This needs to be explained in some detail.
|
||||
;; tdd = typedef dict: (("<time>" time_t) ... ("<unistd.h>" ...))
|
||||
;; Default mode is @code{'code}.
|
||||
;; @example
|
||||
;; (with-input-from-file "abc.c"
|
||||
;; (parse-c #:cpp-defs '("ABC=123"))
|
||||
;; #:inc-dirs '(("." "./incs" "/usr/include"))
|
||||
;; #:inc-help (append '("myinc.h" "foo_t" "bar_t") c99-std-help)
|
||||
;; #:mode 'file))
|
||||
;; @end example
|
||||
;; Note: for @code{file} mode user still needs to make sure CPP conditional
|
||||
;; expressions can be fully evaluated, which may mean adding compiler generated
|
||||
;; defines (e.g., using @code{gen-cpp-defs}).
|
||||
;; @end deffn
|
||||
(define* (parse-c99 #:key
|
||||
(cpp-defs '()) ; CPP defines
|
||||
(inc-dirs '()) ; include dirs
|
||||
(inc-help '()) ; include helpers
|
||||
(mode 'code) ; mode: 'file, 'code or 'decl
|
||||
(xdef? #f) ; pred to determine expand
|
||||
(debug #f)) ; debug
|
||||
(catch
|
||||
'c99-error
|
||||
(lambda ()
|
||||
(if (and (pair? cpp-defs) (pair? (car cpp-defs)))
|
||||
(error "usage deprecated: use #:cpp-defs '(\"ABC=123\")"))
|
||||
(let ((info (make-cpi debug cpp-defs (cons "." inc-dirs) inc-help)))
|
||||
(with-fluid*
|
||||
*info* info
|
||||
(lambda ()
|
||||
(raw-parser (gen-c-lexer #:mode mode #:xdef? xdef?)
|
||||
#:debug debug)))))
|
||||
(lambda (key fmt . rest)
|
||||
(report-error fmt rest)
|
||||
#f)))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,573 +0,0 @@
|
|||
;;; nyacc/lang/c99/pprint.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (nyacc lang c99 pprint)
|
||||
#:export (pretty-print-c99)
|
||||
#:use-module ((srfi srfi-1) #:select (pair-for-each))
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module (sxml match)
|
||||
#:use-module (ice-9 pretty-print)
|
||||
)
|
||||
|
||||
(define op-sym
|
||||
(let ((ot '(("=" . eq) ("+=" . pl-eq) ("-=" . mi-eq) ("*=" . ti-eq)
|
||||
("/=" . di-eq) ("%=" . mo-eq) ("<<=" . ls-eq) (">>=" . rs-eq)
|
||||
("&=" . ba-eq) ("^=" . bx-eq) ("|=" bo-eq))))
|
||||
(lambda (name)
|
||||
(assoc-ref ot name))))
|
||||
|
||||
(define op-prec
|
||||
;; in order of decreasing precedence
|
||||
'((p-expr ident fixed float string)
|
||||
(comp-lit post-inc post-dec i-sel d-sel fctn-call array-ref)
|
||||
(de-ref ref-to neg pos not bitwise-not sizeof pre-inc pre-dec)
|
||||
(cast)
|
||||
(mul div mod)
|
||||
(add sub)
|
||||
(lshift rshift)
|
||||
(lt gt le ge)
|
||||
(eq ne)
|
||||
(bitwise-and)
|
||||
(bitwise-xor)
|
||||
(bitwise-or)
|
||||
(and)
|
||||
(or)
|
||||
(cond-expr)
|
||||
(assn-expr)
|
||||
(comma)))
|
||||
|
||||
(define op-assc
|
||||
'((left array-ref d-sel i-sel post-inc post-dec comp-lit mul div mod add sub
|
||||
lshift rshift lt gt le ge bitwise-and bitwise-xor bitwise-or and or)
|
||||
(right pre-inc pre-dec sizeof bitwise-not not pos neg ref-to de-ref cast
|
||||
cond assn-expr)
|
||||
(nonassoc)))
|
||||
|
||||
;; @deffn {Procedure} scmchs->c scm-chr-str => c-chr-str
|
||||
;; Convert 1-char scheme string into 1-char C string constant as typed by user.
|
||||
;; That is, exscaped.
|
||||
;; @example
|
||||
;; (scmchstr->c "#x00") => "\\0"
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (scmchs->c scm-chr-str)
|
||||
(let ((ch (string-ref scm-chr-str 0)))
|
||||
(case ch
|
||||
((#\nul) "\\0")
|
||||
((#\alarm) "\\a")
|
||||
((#\backspace) "\\b")
|
||||
((#\tab) "\\t")
|
||||
((#\newline) "\\n")
|
||||
((#\vtab) "\\v")
|
||||
((#\page) "\\f")
|
||||
((#\\) "\\")
|
||||
(else scm-chr-str))))
|
||||
|
||||
(define protect-expr? (make-protect-expr op-prec op-assc))
|
||||
|
||||
;; @deffn pretty-print-c99 tree [port] [options]
|
||||
;; Convert and print a C99 sxml tree to the current output port.
|
||||
;; The optional keyword argument @code{#:indent-level} provides the
|
||||
;; indent level, with default of 2.
|
||||
;; @table code
|
||||
;; @item #:indent-level <level>
|
||||
;; indent level for C code
|
||||
;; @item #:per-line-prefix <string>
|
||||
;; string
|
||||
;; @item #:ugly #t|#f
|
||||
;; pring ugly
|
||||
;; @end table
|
||||
;; @end deffn
|
||||
(define* (pretty-print-c99 tree
|
||||
#:optional (port (current-output-port))
|
||||
#:key (indent-level 2) ugly per-line-prefix)
|
||||
|
||||
(define fmtr
|
||||
((if ugly make-pp-formatter/ugly make-pp-formatter)
|
||||
port #:per-line-prefix per-line-prefix))
|
||||
(define (push-il)(fmtr 'push))
|
||||
(define (pop-il) (fmtr 'pop))
|
||||
|
||||
(define (sf . args) (apply fmtr args))
|
||||
|
||||
(define (cpp-ppx tree)
|
||||
(fmtr 'nlin)
|
||||
(sxml-match tree
|
||||
((define (name ,name) (args . ,args) (repl ,repl))
|
||||
(sf "#define ~A(" name)
|
||||
(pair-for-each
|
||||
(lambda (pair) (sf "~A" (car pair)) (if (pair? (cdr pair)) (sf ",")))
|
||||
args)
|
||||
(sf ") ~A\n" repl))
|
||||
((define (name ,name) (repl ,repl))
|
||||
(sf "#define ~A ~A\n" name repl))
|
||||
((if ,text) (sf "#if ~A\n" text))
|
||||
((elif ,text) (sf "#elif ~A\n" text))
|
||||
((else ,text) (sf "#else ~A\n" text))
|
||||
((else) (sf "#else\n"))
|
||||
((endif ,text) (sf "#endif ~A\n" text))
|
||||
((endif) (sf "#endif\n"))
|
||||
((include . ,rest) (sf "#include ~A\n" (sx-ref tree 1)))
|
||||
((error ,text) (sf "#error ~A\n" text))
|
||||
((pragma ,text) (sf "#pragma ~A\n" text))
|
||||
(,otherwise
|
||||
(simple-format #t "\n*** pprint/cpp-ppx: NO MATCH: ~S\n" tree))
|
||||
)
|
||||
(fmtr 'nlin))
|
||||
|
||||
(define (unary/l op rep rval)
|
||||
(sf rep)
|
||||
(if (protect-expr? 'rt op rval)
|
||||
(ppx/p rval)
|
||||
(ppx rval)))
|
||||
|
||||
(define (unary/r op rep lval)
|
||||
(if (protect-expr? 'lt op lval)
|
||||
(ppx/p lval)
|
||||
(ppx lval))
|
||||
(sf rep))
|
||||
|
||||
(define (binary op rep lval rval)
|
||||
(if (protect-expr? 'lt op lval)
|
||||
(ppx/p lval)
|
||||
(ppx lval))
|
||||
(sf rep)
|
||||
(if (protect-expr? 'rt op rval)
|
||||
(ppx/p rval)
|
||||
(ppx rval)))
|
||||
|
||||
(define (comp declr initr)
|
||||
(let ((iexpr (and initr (sx-ref initr 1))))
|
||||
(ppx declr)
|
||||
(when initr
|
||||
(sf " = ")
|
||||
(case (sx-tag iexpr)
|
||||
((initzer-list)
|
||||
(sf "{")
|
||||
(for-each
|
||||
(lambda (expr) (ppx (sx-ref expr 1)) (sf ", "))
|
||||
(sx-tail iexpr 1))
|
||||
(sf "}"))
|
||||
(else
|
||||
(ppx iexpr))))))
|
||||
|
||||
(define (struct-union-def struct-or-union name fields)
|
||||
(if name
|
||||
(sf "~A ~A {\n" struct-or-union name)
|
||||
(sf "~A {\n" struct-or-union))
|
||||
(push-il)
|
||||
(for-each ppx fields)
|
||||
(pop-il)
|
||||
(sf "}"))
|
||||
|
||||
(define (ppx/p tree) (sf "(") (ppx tree) (sf ")"))
|
||||
|
||||
;; TODO: comp-lit
|
||||
(define (ppx-1 tree)
|
||||
(sxml-match tree
|
||||
|
||||
((p-expr ,expr) (ppx expr))
|
||||
((ident ,name) (sf "~A" name))
|
||||
((char ,value) (sf "'~A'" (scmchs->c (sx-ref tree 1))))
|
||||
((fixed ,value) (sf "~A" value))
|
||||
((float ,value) (sf "~A" value))
|
||||
|
||||
((string . ,value-l)
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
(sf "~S" (car pair))
|
||||
(if (pair? (cdr pair)) (sf " ")))
|
||||
value-l))
|
||||
|
||||
((comment ,text) (sf "/*~A*/\n" text))
|
||||
|
||||
((scope ,expr) (sf "(") (ppx expr) (sf ")"))
|
||||
|
||||
((array-ref ,dim ,expr)
|
||||
(ppx expr) (sf "[") (ppx dim) (sf "]"))
|
||||
|
||||
((d-sel ,id ,ex) (binary 'd-sel "." ex id))
|
||||
((i-sel ,id ,ex) (binary 'i-sel "->" ex id))
|
||||
|
||||
((pre-inc ,expr) (unary/l 'pre-inc "++" expr))
|
||||
((pre-dec ,expr) (unary/l 'pre-dec "--" expr))
|
||||
((ref-to ,expr) (unary/l 'ref-to "&" expr))
|
||||
((de-ref ,expr) (unary/l 'de-ref "*" expr))
|
||||
((pos ,expr) (unary/l 'pos "+" expr))
|
||||
((neg ,expr) (unary/l 'neg "-" expr))
|
||||
((bitwise-not ,expr) (unary/l 'bitwise-not "~" expr))
|
||||
((not ,expr) (unary/l 'not "!" expr))
|
||||
((sizeof-expr ,expr) (sf "sizeof(") (ppx expr) (sf ")"))
|
||||
((sizeof-type ,type) (sf "sizeof(") (ppx type) (sf ")"))
|
||||
|
||||
((cast ,tn ,ex)
|
||||
(sf "(") (ppx tn) (sf ")")
|
||||
(if (protect-expr? 'rt 'cast ex)
|
||||
(ppx/p ex)
|
||||
(ppx ex)))
|
||||
|
||||
((add ,lval ,rval) (binary 'add " + " lval rval))
|
||||
((sub ,lval ,rval) (binary 'sub " - " lval rval))
|
||||
((mul ,lval ,rval) (binary 'mul "*" lval rval))
|
||||
((div ,lval ,rval) (binary 'div "/" lval rval))
|
||||
((mod ,lval ,rval) (binary 'mod "%" lval rval))
|
||||
|
||||
((lshift ,lval ,rval) (binary 'lshift "<<" lval rval))
|
||||
((rshift ,lval ,rval) (binary 'lshift "<<" lval rval))
|
||||
|
||||
((lt ,lval ,rval) (binary 'lt " < " lval rval))
|
||||
((gt ,lval ,rval) (binary 'gt " > " lval rval))
|
||||
|
||||
((le ,lval ,rval) (binary 'le " <= " lval rval))
|
||||
((ge ,lval ,rval) (binary 'ge " >= " lval rval))
|
||||
((eq ,lval ,rval) (binary 'eq " == " lval rval))
|
||||
((ne ,lval ,rval) (binary 'ne " != " lval rval))
|
||||
|
||||
((bitwise-and ,lval ,rval) (binary 'bitwise-and " & " lval rval))
|
||||
((bitwise-or ,lval ,rval) (binary 'bitwise-and " | " lval rval))
|
||||
((bitwise-xor ,lval ,rval) (binary 'bitwise-xor " ^ " lval rval))
|
||||
|
||||
((and ,lval ,rval) (binary 'and " && " lval rval))
|
||||
((or ,lval ,rval) (binary 'and " || " lval rval))
|
||||
|
||||
;; CHECK THIS
|
||||
((cond-expr ,cond ,tval ,fval)
|
||||
(ppx cond) (sf "? ") (ppx tval) (sf ": ") (ppx fval))
|
||||
|
||||
((post-inc ,expr) (unary/r 'post-inc "++" expr))
|
||||
((post-dec ,expr) (unary/r 'post-dec "--" expr))
|
||||
|
||||
;; TODO: check protection
|
||||
((fctn-call ,expr ,arg-list)
|
||||
(if (protect-expr? 'rt 'fctn-call expr)
|
||||
(ppx/p expr)
|
||||
(ppx expr))
|
||||
(sf "(")
|
||||
(ppx arg-list)
|
||||
(sf ")"))
|
||||
|
||||
((expr-list . ,expr-l)
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
(ppx (car pair))
|
||||
(if (pair? (cdr pair)) (sf ", ")))
|
||||
expr-l))
|
||||
|
||||
((assn-expr ,lval ,op ,rval)
|
||||
(binary (car op) (simple-format #f " ~A " (cadr op)) lval rval))
|
||||
|
||||
;; TODO: check protection
|
||||
((comma-expr . ,expr-list)
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
(cond
|
||||
((pair? (cdr pair))
|
||||
(if (protect-expr? 'rt 'comma-expr (car pair))
|
||||
(ppx/p (car pair))
|
||||
(ppx (car pair)))
|
||||
(sf ", "))
|
||||
(else (ppx (car pair)))))
|
||||
expr-list))
|
||||
|
||||
;; #|
|
||||
;; gotta break up ppx because sxml-match seems to eat stack space:
|
||||
;; everthing together results in SIGABRT from vm_error_stack_overflow()
|
||||
(,otherwise
|
||||
(ppx-2 tree))))
|
||||
|
||||
(define (ppx-2 tree)
|
||||
|
||||
(sxml-match tree
|
||||
;; sxml-match continues here to avoid stack overflow
|
||||
;; |#
|
||||
|
||||
((udecl . ,rest)
|
||||
(ppx `(decl . ,rest)))
|
||||
((decl ,decl-spec-list)
|
||||
(ppx decl-spec-list) (sf ";\n"))
|
||||
((decl ,decl-spec-list ,init-declr-list)
|
||||
(ppx decl-spec-list) (sf " ") (ppx init-declr-list) (sf ";\n"))
|
||||
((decl ,decl-spec-list ,init-declr-list ,comment)
|
||||
(ppx decl-spec-list) (sf " ")
|
||||
(ppx init-declr-list) (sf "; ") (ppx comment))
|
||||
((decl-no-newline ,decl-spec-list ,init-declr-list) ; for (int i = 0;
|
||||
(ppx decl-spec-list) (sf " ") (ppx init-declr-list) (sf ";"))
|
||||
|
||||
((comp-decl ,spec-qual-list ,declr-list)
|
||||
(ppx spec-qual-list) (ppx declr-list) (sf ";\n"))
|
||||
((comp-decl ,spec-qual-list ,declr-list ,comment)
|
||||
(ppx spec-qual-list) (ppx declr-list) (sf "; ") (ppx comment))
|
||||
|
||||
((decl-spec-list . ,dsl)
|
||||
(pair-for-each
|
||||
(lambda (dsl)
|
||||
(case (sx-tag (car dsl))
|
||||
((stor-spec) (sf "~A" (car (sx-ref (car dsl) 1))))
|
||||
((type-qual) (sf "~A" (sx-ref (car dsl) 1)))
|
||||
((type-spec) (ppx (car dsl)))
|
||||
(else (sf "[?:~S]" (car dsl))))
|
||||
(if (pair? (cdr dsl)) (sf " ")))
|
||||
dsl))
|
||||
|
||||
((init-declr-list . ,rest)
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
(ppx (car pair))
|
||||
(if (pair? (cdr pair)) (sf ", ")))
|
||||
rest))
|
||||
((comp-declr-list . ,rest)
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
(ppx (car pair))
|
||||
(if (pair? (cdr pair)) (sf ", ")))
|
||||
rest))
|
||||
|
||||
((init-declr ,declr ,initr) (comp declr initr))
|
||||
((init-declr ,declr) (comp declr #f))
|
||||
((comp-declr ,declr) (comp declr #f))
|
||||
((param-declr ,declr) (comp declr #f))
|
||||
|
||||
((type-spec ,arg)
|
||||
(case (sx-tag arg)
|
||||
((fixed-type) (sf "~A" (sx-ref arg 1)))
|
||||
((float-type) (sf "~A" (sx-ref arg 1)))
|
||||
((struct-ref) (ppx arg))
|
||||
((struct-def) (ppx arg))
|
||||
((union-ref) (ppx arg))
|
||||
((union-def) (ppx arg))
|
||||
((enum-def) (ppx arg))
|
||||
((typename) (sf "~A" (sx-ref arg 1)))
|
||||
((void) (sf "void "))
|
||||
(else (error "missing " arg))))
|
||||
|
||||
((struct-ref (ident ,name)) (sf "struct ~A" name))
|
||||
((union-ref (ident ,name)) (sf "union ~A" name))
|
||||
|
||||
((struct-def (ident ,name) (field-list . ,fields))
|
||||
(struct-union-def 'struct name fields))
|
||||
((struct-def (field-list . ,fields))
|
||||
(struct-union-def 'struct #f fields))
|
||||
((union-def (ident ,name) (field-list . ,fields))
|
||||
(struct-union-def 'union name fields))
|
||||
((union-def (field-list . ,fields))
|
||||
(struct-union-def 'union #f fields))
|
||||
|
||||
((enum-def (ident ,name) (enum-def-list . ,edl))
|
||||
(sf "enum ~A " name) (ppx `(enum-def-list . ,edl)))
|
||||
|
||||
((enum-def (enum-def-list . ,edl))
|
||||
(sf "enum ") (ppx `(enum-def-list . ,edl)))
|
||||
|
||||
((enum-def-list . ,defns)
|
||||
(sf "{\n") (push-il)
|
||||
(for-each ppx defns)
|
||||
(pop-il) (sf "}"))
|
||||
|
||||
((enum-defn (ident ,name) (p-expr (fixed ,value)))
|
||||
(sf "~A = ~A,\n" name value))
|
||||
((enum-defn (ident ,name) (neg (p-expr (fixed ,value))))
|
||||
(sf "~A = -~A,\n" name value))
|
||||
((enum-defn (ident ,name))
|
||||
(sf "~A,\n" name))
|
||||
|
||||
((fctn-spec "inline")
|
||||
(sf "inline "))
|
||||
|
||||
((ptr-declr ,ptr ,dir-declr)
|
||||
(ppx ptr) (ppx dir-declr))
|
||||
|
||||
((pointer) (sf "*"))
|
||||
((pointer ,one) (sf "*") (ppx one))
|
||||
((pointer ,one ,two) (sf "*") (ppx one) (ppx two))
|
||||
|
||||
((array-of ,dir-declr ,arg)
|
||||
(ppx dir-declr) (sf "[") (ppx arg) (sf "]"))
|
||||
((array-of ,dir-declr)
|
||||
(ppx dir-declr) (sf "[]"))
|
||||
;; MORE TO GO
|
||||
|
||||
((ftn-declr ,dir-declr ,param-list)
|
||||
(ppx dir-declr) (sf "(") (ppx param-list) (sf ")"))
|
||||
|
||||
((type-name ,spec-qual-list ,abs-declr)
|
||||
(ppx spec-qual-list) (ppx abs-declr))
|
||||
((type-name ,decl-spec-list)
|
||||
(ppx decl-spec-list))
|
||||
|
||||
((abs-declr ,pointer ,dir-abs-declr) (ppx pointer) (ppx dir-abs-declr))
|
||||
((abs-declr ,one-of-above) (ppx one-of-above))
|
||||
|
||||
((compd-stmt (block-item-list . ,items))
|
||||
(sf "{\n") (push-il) (for-each ppx items) (pop-il) (sf "}\n"))
|
||||
((compd-stmt-no-newline (block-item-list . ,items))
|
||||
(sf "{\n") (push-il) (for-each ppx items) (pop-il) (sf "} "))
|
||||
|
||||
;; #|
|
||||
;; gotta break up ppx because sxml-match seems to eat stack space:
|
||||
;; everthing together results in SIGABRT from vm_error_stack_overflow()
|
||||
(,otherwise
|
||||
(ppx-3 tree))))
|
||||
|
||||
(define (ppx-3 tree)
|
||||
|
||||
(sxml-match tree
|
||||
;; sxml-match continues here to avoid stack overflow
|
||||
;; |#
|
||||
|
||||
;; expression-statement
|
||||
((expr-stmt) (sf ";\n"))
|
||||
((expr-stmt ,expr) (ppx expr) (sf ";\n"))
|
||||
((expr-stmt ,expr ,comm) (ppx expr) (sf "; ") (ppx comm))
|
||||
|
||||
((expr) (sf "")) ; for lone expr-stmt and return-stmt
|
||||
|
||||
;; selection-statement
|
||||
((if . ,rest)
|
||||
(let ((cond-part (sx-ref tree 1))
|
||||
(then-part (sx-ref tree 2)))
|
||||
(sf "if (") (ppx cond-part) (sf ") ")
|
||||
(ppx then-part)
|
||||
(let iter ((else-l (sx-tail tree 3)))
|
||||
(cond
|
||||
((null? else-l) #t)
|
||||
((eqv? 'else-if (caar else-l))
|
||||
(sf "else if (") (ppx (sx-ref (car else-l) 1)) (sf ") ")
|
||||
(ppx (sx-ref (car else-l) 2))
|
||||
(iter (cdr else-l)))
|
||||
(else
|
||||
(sf "else ")
|
||||
(ppx (car else-l)))))))
|
||||
|
||||
((switch ,expr (compd-stmt (block-item-list . ,items)))
|
||||
(sf "switch (") (ppx expr) (sf ") {\n")
|
||||
(for-each
|
||||
(lambda (item)
|
||||
(unless (memq (car item) '(case default)) (push-il))
|
||||
(ppx item)
|
||||
(unless (memq (car item) '(case default)) (pop-il)))
|
||||
items)
|
||||
(sf "}\n"))
|
||||
|
||||
;; labeled-statement
|
||||
((case ,expr ,stmt)
|
||||
(sf "case ") (ppx expr) (sf ":\n")
|
||||
(push-il) (ppx stmt) (pop-il))
|
||||
|
||||
((default ,stmt)
|
||||
(sf "default:\n")
|
||||
(push-il) (ppx stmt) (pop-il))
|
||||
|
||||
;; CHECK THIS
|
||||
((while ,expr ,stmt)
|
||||
(sf "while (") (ppx expr) (sf ") ") (ppx stmt)
|
||||
)
|
||||
|
||||
;; This does not meet the convention of "} while" on same line.
|
||||
((do-while ,stmt ,expr)
|
||||
(sf "do ")
|
||||
(if (eqv? 'compd-stmt (sx-tag stmt))
|
||||
(ppx `(compd-stmt-no-newline ,(sx-ref stmt 1)))
|
||||
(ppx stmt))
|
||||
(sf "while (") (ppx expr) (sf ");\n"))
|
||||
|
||||
;; for
|
||||
((for (decl . ,rest) ,test ,iter ,stmt)
|
||||
(sf "for (") (ppx `(decl-no-newline . ,rest))
|
||||
(sf " ") (ppx test) (sf "; ") (ppx iter) (sf ") ")
|
||||
(ppx stmt))
|
||||
|
||||
((for (decl . ,rest) ,expr2 ,expr3 ,stmt)
|
||||
(sf "for (")
|
||||
(ppx `(decl . ,rest)) (sf " ") (ppx expr2) (sf "; ") (ppx expr3)
|
||||
(sf ") ") (ppx stmt))
|
||||
((for ,expr1 ,expr2 ,expr3 ,stmt)
|
||||
(sf "for (")
|
||||
(ppx expr1) (sf "; ") (ppx expr2) (sf "; ") (ppx expr3)
|
||||
(sf ") ") (ppx stmt))
|
||||
|
||||
;; jump-statement
|
||||
((goto ,where)
|
||||
(pop-il) ; unindent
|
||||
(sf "goto ~A;" (sx-ref where 1))
|
||||
;; comment?
|
||||
(sf "\n")
|
||||
(push-il)) ; re-indent
|
||||
|
||||
((continue) (sf "continue;\n"))
|
||||
((break) (sf "break;\n"))
|
||||
((return ,expr) (sf "return ") (ppx expr) (sf ";\n"))
|
||||
((return) (sf "return;\n"))
|
||||
|
||||
((trans-unit . ,items)
|
||||
(pair-for-each
|
||||
(lambda (pair)
|
||||
(let ((this (car pair))
|
||||
(next (and (pair? (cdr pair)) (cadr pair))))
|
||||
(ppx this)
|
||||
(cond ;; add blank line if next is different or fctn defn
|
||||
((not next))
|
||||
((not (eqv? (sx-tag this) (sx-tag next))) (sf "\n"))
|
||||
((eqv? (sx-tag next) 'fctn-defn) (sf "\n")))))
|
||||
items))
|
||||
|
||||
((fctn-defn . ,rest) ;; but not yet (knr-fctn-defn)
|
||||
(let* ((decl-spec-list (sx-ref tree 1))
|
||||
(declr (sx-ref tree 2))
|
||||
(compd-stmt (sx-ref tree 3)))
|
||||
(ppx decl-spec-list)
|
||||
(ppx declr)
|
||||
(sf " ")
|
||||
(ppx compd-stmt)))
|
||||
|
||||
((ptr-declr . ,rest)
|
||||
(ppx (sx-ref tree 1)) (ppx (sx-ref tree 2)))
|
||||
|
||||
((ftn-declr . ,rest)
|
||||
(ppx (sx-ref tree 1)) ; direct-declarator
|
||||
(sf "(") (ppx (sx-ref tree 2)) (sf ")"))
|
||||
|
||||
((param-list . ,params)
|
||||
(pair-for-each
|
||||
(lambda (pair) (ppx (car pair)) (if (pair? (cdr pair)) (sf ", ")))
|
||||
params))
|
||||
|
||||
((ellipsis) ;; should work
|
||||
(sf "..."))
|
||||
|
||||
((param-decl ,decl-spec-list ,param-declr)
|
||||
(ppx decl-spec-list) (sf " ") (ppx param-declr))
|
||||
((param-decl ,decl-spec-list)
|
||||
(ppx decl-spec-list))
|
||||
|
||||
((cpp-stmt . ,rest)
|
||||
(cpp-ppx (sx-ref tree 1)))
|
||||
|
||||
((extern-block ,begin ,guts ,end) (ppx begin) (ppx guts) (ppx end))
|
||||
((extern-begin ,lang) (sf "extern \"~A\" {\n" lang))
|
||||
((extern-end) (sf "}\n"))
|
||||
|
||||
(,otherwise
|
||||
(simple-format #t "\n*** pprint/ppx: NO MATCH: ~S\n" (car tree)))
|
||||
))
|
||||
|
||||
(define ppx ppx-1)
|
||||
|
||||
(if (not (pair? tree)) (error "expecing sxml tree"))
|
||||
(ppx tree)
|
||||
(if ugly (newline)))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,203 +0,0 @@
|
|||
;;; lang/c/util1.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015,2016 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; C parser utilities
|
||||
|
||||
(define-module (nyacc lang c99 util1)
|
||||
#:export (c99-std-help
|
||||
gen-gcc-defs
|
||||
remove-inc-trees
|
||||
merge-inc-trees!
|
||||
elifify)
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module ((srfi srfi-1) #:select (append-reverse))
|
||||
#:use-module (srfi srfi-2) ;; and-let*
|
||||
#:use-module (sxml fold)
|
||||
#:use-module (sxml match)
|
||||
#:use-module (ice-9 popen) ; gen-cc-defs
|
||||
#:use-module (ice-9 rdelim) ; gen-cc-defs
|
||||
#:use-module (ice-9 regex) ; gen-cc-defs
|
||||
)
|
||||
|
||||
;; include-helper for C99 std
|
||||
(define c99-std-help
|
||||
'(("alloca.h")
|
||||
("complex.h" "complex" "imaginary" "_Imaginary_I=C99_ANY" "I=C99_ANY")
|
||||
("ctype.h")
|
||||
("fenv.h" "fenv_t" "fexcept_t")
|
||||
("float.h" "float_t" "FLT_MAX=C99_ANY" "DBL_MAX=C99_ANY")
|
||||
("inttypes.h"
|
||||
"int8_t" "uint8_t" "int16_t" "uint16_t" "int32_t" "uint32_t"
|
||||
"int64_t" "uint64_t" "uintptr_t" "intptr_t" "intmax_t" "uintmax_t"
|
||||
"int_least8_t" "uint_least8_t" "int_least16_t" "uint_least16_t"
|
||||
"int_least32_t" "uint_least32_t" "int_least64_t" "uint_least64_t"
|
||||
"imaxdiv_t")
|
||||
("limits.h"
|
||||
"INT_MIN=C99_ANY" "INT_MAX=C99_ANY" "LONG_MIN=C99_ANY" "LONG_MAX=C99_ANY")
|
||||
("math.h" "float_t" "double_t")
|
||||
("regex.h" "regex_t" "regmatch_t")
|
||||
("setjmp.h" "jmp_buf")
|
||||
("signal.h" "sig_atomic_t")
|
||||
("stdarg.h" "va_list")
|
||||
("stddef.h" "ptrdiff_t" "size_t" "wchar_t")
|
||||
("stdint.h"
|
||||
"int8_t" "uint8_t" "int16_t" "uint16_t" "int32_t" "uint32_t"
|
||||
"int64_t" "uint64_t" "uintptr_t" "intptr_t" "intmax_t" "uintmax_t"
|
||||
"int_least8_t" "uint_least8_t" "int_least16_t" "uint_least16_t"
|
||||
"int_least32_t" "uint_least32_t" "int_least64_t" "uint_least64_t")
|
||||
("stdio.h" "FILE" "size_t")
|
||||
("stdlib.h" "div_t" "ldiv_t" "lldiv_t" "wchar_t")
|
||||
("string.h" "size_t")
|
||||
("strings.h" "size_t")
|
||||
("time.h" "time_t" "clock_t" "size_t")
|
||||
("unistd.h" "size_t" "ssize_t" "div_t" "ldiv_t")
|
||||
("wchar.h" "wchar_t" "wint_t" "mbstate_t" "size_t")
|
||||
("wctype.h" "wctrans_t" "wctype_t" "wint_t")
|
||||
))
|
||||
|
||||
;; @deffn {Procedure} gen-gcc-defs args [#:CC "clang"] => '("ABC=123" ...)
|
||||
;; Generate a list of default defines produced by gcc (or clang).
|
||||
;; @end deffn
|
||||
(define gen-gcc-defs
|
||||
;; @code{"gcc -dM -E"} will generate lines like @code{"#define ABC 123"}.
|
||||
;; We generate and return a list like @code{'(("ABC" . "123") ...)}.
|
||||
(let ((rx1 (make-regexp "#define\\s+([A-Za-z0-9_]+\\([^)]*\\))\\s+(.*)"))
|
||||
(rx2 (make-regexp "#define\\s+([A-Za-z0-9_]+)\\s+(.*)")))
|
||||
(case-lambda*
|
||||
((args #:key (CC "gcc"))
|
||||
(map
|
||||
(lambda (l)
|
||||
;; could use (string-delete #\space (match:substring m 1))
|
||||
(let ((m (or (regexp-exec rx1 l) (regexp-exec rx2 l))))
|
||||
(string-append (match:substring m 1) "=" (match:substring m 2))))
|
||||
(let ((ip (open-input-pipe (string-append CC " -dM -E - </dev/null"))))
|
||||
(let iter ((lines '()) (line (read-line ip 'trim)))
|
||||
(if (eof-object? line) lines
|
||||
(iter (cons line lines) (read-line ip 'trim)))))))
|
||||
((#:key (CC "gcc")) (gen-gcc-defs '() #:CC CC)))))
|
||||
|
||||
;; @deffn {Procedure} remove-inc-trees tree
|
||||
;; Remove the trees included with cpp-include statements.
|
||||
;; @example
|
||||
;; '(... (cpp-stmt (include "<foo.h>" (trans-unit ...))) ...)
|
||||
;; => '(... (cpp-stmt (include "<foo.h>")) ...)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (remove-inc-trees tree)
|
||||
(if (not (eqv? 'trans-unit (car tree))) (error "expecting c-tree"))
|
||||
(let iter ((rslt (make-tl 'trans-unit))
|
||||
;;(head '(trans-unit)) (tail (cdr tree))
|
||||
(tree (cdr tree)))
|
||||
(cond
|
||||
((null? tree) (tl->list rslt))
|
||||
((and (eqv? 'cpp-stmt (car (car tree)))
|
||||
(eqv? 'include (caadr (car tree))))
|
||||
(iter (tl-append rslt `(cpp-stmt (include ,(cadadr (car tree)))))
|
||||
(cdr tree)))
|
||||
(else (iter (tl-append rslt (car tree)) (cdr tree))))))
|
||||
|
||||
;; @deffn {Procedure} merge-inc-trees tree
|
||||
;; Remove the trees included with cpp-include statements.
|
||||
;; @example
|
||||
;; '(... (cpp-stmt (include "<foo.h>" (trans-unit (stmt ...))) ...)
|
||||
;; => '(... (stmt...) ...)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
#;(define (Xmerge-inc-trees tree)
|
||||
(if (not (eqv? 'trans-unit (car tree))) (error "expecting c-tree"))
|
||||
(let iter ((rslt (make-tl 'trans-unit))
|
||||
(tree (cdr tree)))
|
||||
(cond
|
||||
((null? tree) (tl->list rslt))
|
||||
((and (eqv? 'cpp-stmt (caar tree)) (eqv? 'include (cadar tree)))
|
||||
(iter (tl-extend rslt (cdr (merge-inc-trees (cdddar tree)))) (cdr tree)))
|
||||
(else (iter (tl-append rslt (car tree)) (cdr tree))))))
|
||||
|
||||
|
||||
;; @deffn {Procedure} merge-inc-trees! tree => tree
|
||||
;; This will (recursively) merge code from cpp-includes into the tree.
|
||||
;; @example
|
||||
;; (trans-unit
|
||||
;; (decl (a))
|
||||
;; (cpp-stmt (include "<hello.h>" (trans-unit (decl (b)))))
|
||||
;; (decl (c)))
|
||||
;; =>
|
||||
;; (trans-unit (decl (a)) (decl (b)) (decl (c)))
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (merge-inc-trees! tree)
|
||||
|
||||
;; @item find-span (trans-unit a b c) => ((a . +->) . (c . '())
|
||||
(define (find-span tree)
|
||||
(cond
|
||||
((not (pair? tree)) '()) ; maybe parse failed
|
||||
((not (eqv? 'trans-unit (car tree))) (error "expecting c-tree"))
|
||||
((null? (cdr tree)) (error "null c99-tree"))
|
||||
(else
|
||||
(let ((fp tree)) ; first pair
|
||||
(let iter ((lp tree) ; last pair
|
||||
(np (cdr tree))) ; next pair
|
||||
(cond
|
||||
((null? np) (cons (cdr fp) lp))
|
||||
;; The following is an ugly hack to find cpp-include
|
||||
;; with trans-unit attached.
|
||||
((and-let* ((expr (car np))
|
||||
((eqv? 'cpp-stmt (car expr)))
|
||||
((eqv? 'include (caadr expr)))
|
||||
(rest (cddadr expr))
|
||||
((pair? rest))
|
||||
(span (find-span (car rest))))
|
||||
(set-cdr! lp (car span))
|
||||
(iter (cdr span) (cdr np))))
|
||||
(else
|
||||
(set-cdr! lp np)
|
||||
(iter np (cdr np)))))))))
|
||||
|
||||
;; Use cons to generate a new reference:
|
||||
;; (cons (car tree) (car (find-span tree)))
|
||||
;; or not:
|
||||
(find-span tree)
|
||||
tree)
|
||||
|
||||
|
||||
;; @deffn {Procedure} elifify tree => tree
|
||||
;; This procedure will find patterns of
|
||||
;; @example
|
||||
;; (if cond-1 then-part-1
|
||||
;; (if cond-2 then-part-2
|
||||
;; else-part-2
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; and convert to
|
||||
;; @example
|
||||
;; (if cond-1 then-part-1
|
||||
;; (elif cond-2 then-part-2)
|
||||
;; else-part-2
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (elifify tree)
|
||||
(define (fU tree)
|
||||
(sxml-match tree
|
||||
((if ,x1 ,t1 (if ,x2 ,t2 (else-if ,x3 ,t3) . ,rest))
|
||||
`(if ,x1 ,t1 (else-if ,x2 ,t2) (else-if ,x3 ,t3) . ,rest))
|
||||
((if ,x1 ,t1 (if ,x2 ,t2 . ,rest))
|
||||
`(if ,x1 ,t1 (else-if ,x2 ,t2) . ,rest))
|
||||
(,otherwise
|
||||
tree)))
|
||||
(foldt fU identity tree))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,803 +0,0 @@
|
|||
;;; nyacc/lang/c99/util2.scm - C processing code
|
||||
;;; call this munge.scm ?
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; utilities for processing output trees
|
||||
|
||||
;; KEEPING STRUCTS ENUMS etc
|
||||
;; if have typename and want to keep it, then change
|
||||
;; (typename "foo_t")
|
||||
;; to
|
||||
;; (typename (@ (base "struct")) "foo_t")
|
||||
|
||||
;; ALSO
|
||||
;; (make-proxy comp-udecl) => udecl
|
||||
;; (revert-proxy udecl) => comp-udecl
|
||||
|
||||
;; NOTE
|
||||
;; stripdown no longer deals with typeref expansion
|
||||
;; use
|
||||
;; expand-typerefs, then stripdown, then udecl->mspec
|
||||
|
||||
(define-module (nyacc lang c99 util2)
|
||||
#:export (c99-trans-unit->udict
|
||||
c99-trans-unit->udict/deep
|
||||
|
||||
expand-typerefs
|
||||
stripdown
|
||||
udecl->mspec udecl->mspec/comm
|
||||
|
||||
unwrap-decl
|
||||
canize-enum-def-list
|
||||
fixed-width-int-names
|
||||
|
||||
munge-decl munge-comp-decl munge-param-decl
|
||||
declr->ident
|
||||
|
||||
clean-field-list
|
||||
|
||||
;; deprecated
|
||||
tree->udict tree->udict/deep
|
||||
match-decl match-comp-decl match-param-decl
|
||||
expand-decl-typerefs
|
||||
fix-fields
|
||||
;; debuggins
|
||||
stripdown-1 stripdown-2
|
||||
)
|
||||
#:use-module (nyacc lang c99 pprint)
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module ((sxml fold) #:select (foldts foldts*))
|
||||
#:use-module (sxml match)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-2)
|
||||
;;#:use-module (system base pmatch)
|
||||
#:use-module (nyacc lang c99 pprint)
|
||||
#:use-module (ice-9 pretty-print)
|
||||
)
|
||||
|
||||
(define tmap-fmt
|
||||
'(("char" "%hhd")
|
||||
("unsigned char" "%hhu")
|
||||
("short int" "%hd")
|
||||
("unsigned short int" "%hu")
|
||||
("int" "%d")
|
||||
("unsigned int" "%u")
|
||||
("long int" "%ld")
|
||||
("unsigned long int" "%lu")
|
||||
("long long int" "%lld")
|
||||
("unsigned long long int" "%llu")))
|
||||
|
||||
;; Use the term @dfn{udecl}, or unit-declaration, for a declaration which has
|
||||
;; only one decl-item. That is where,
|
||||
;; @example
|
||||
;; @end example
|
||||
;; (decl (decl-spec-list ...) (init-declr-list (init-declr ...) ...))
|
||||
;; @noindent
|
||||
;; has been replaced by
|
||||
;; (decl (decl-spec-list ...) (init-declr ...))
|
||||
;; ...
|
||||
;; @example
|
||||
;; @end example
|
||||
|
||||
;; mspec is
|
||||
;; ("foo" (pointer-to) (array-of 3) (fixed-type "unsigned int"))
|
||||
;; which can be converted to
|
||||
;; ("(*foo) (array-of 3) (fixed-type "unsigned int"))
|
||||
;; which can be converted to
|
||||
;; (("((*foo)[0])" (fixed-type "unsigned int"))
|
||||
;; ("((*foo)[1])" (fixed-type "unsigned int"))
|
||||
;; ("((*foo)[2])" (fixed-type "unsigned int"))
|
||||
|
||||
;; may need to replace (typename "int32_t") with (fixed-type "int32_t")
|
||||
|
||||
;; @deffn {Procedure} declr->ident declr => (ident "name")
|
||||
;; Given a declarator, aka @code{init-declr}, return the identifier.
|
||||
;; This is used by @code{trans-unit->udict}.
|
||||
;; See also: declr->id-name in body.scm.
|
||||
;; @end deffn
|
||||
(define (declr->ident declr)
|
||||
(sxml-match declr
|
||||
((ident ,name) declr)
|
||||
((init-declr ,declr . ,rest) (declr->ident declr))
|
||||
((comp-declr ,declr) (declr->ident declr))
|
||||
((param-declr ,declr) (declr->ident declr))
|
||||
((array-of ,dir-declr ,array-spec) (declr->ident dir-declr))
|
||||
((array-of ,dir-declr) (declr->ident dir-declr))
|
||||
((ptr-declr ,pointer ,dir-declr) (declr->ident dir-declr))
|
||||
((ftn-declr ,dir-declr ,rest ...) (declr->ident dir-declr))
|
||||
((scope ,declr) (declr->ident declr))
|
||||
(,otherwise (throw 'util-error "c99/util2: unknown declarator: " declr))))
|
||||
|
||||
;; @deffn {Procedure} c99-trans-unit->udict tree [seed] [#:filter f] => udict
|
||||
;; @deffnx {Procedure} c99-trans-unit->udict/deep tree [seed]=> udict
|
||||
;; Turn a C parse tree into a assoc-list of global names and definitions.
|
||||
;; This will unwrap @code{init-declr-list} into list of decls w/
|
||||
;; @code{init-declr}.
|
||||
;; @example
|
||||
;; BUG: need to add struct and union defn's: struct foo { int x; };
|
||||
;; how to deal with this
|
||||
;; lookup '(struct . "foo"), "struct foo", ???
|
||||
;; wanted "struct" -> dict but that is not great
|
||||
;; solution: munge-decl => '(struct . "foo") then filter to generate
|
||||
;; ("struct" ("foo" . decl) ("bar" . decl) ...)
|
||||
;; ("union" ("bar" . decl) ("bar" . decl) ...)
|
||||
;; ("enum" ("" . decl) ("foo" . decl) ("bar" . decl) ...)
|
||||
;; @end example
|
||||
;; So globals could be in udict, udefs or anon-enum.
|
||||
;; @example
|
||||
;; What about anonymous enums? And enums in general?
|
||||
;; Anonmous enum should be expaneded into
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
;; @noindent
|
||||
;; If @var{tree} is not a pair then @var{seed} -- or @code{'()} -- is returned.
|
||||
;; The filter @var{f} is either @code{#t}, @code{#f} or predicate procedure
|
||||
;; of one argument, the include path, to indicate whether it should be included
|
||||
;; in the dictionary.
|
||||
(define* (c99-trans-unit->udict tree #:optional (seed '()) #:key filter)
|
||||
(define (inc-keeper? tree)
|
||||
(if (and (eqv? (sx-tag tree) 'cpp-stmt)
|
||||
(eqv? (sx-tag (sx-ref tree 1)) 'include))
|
||||
(if (procedure? filter)
|
||||
(filter (let ((arg (sx-ref (sx-ref tree 1) 1)))
|
||||
(substring arg 1 (1- (string-length arg)))))
|
||||
filter)
|
||||
#f))
|
||||
(if (pair? tree)
|
||||
(fold
|
||||
(lambda (tree seed)
|
||||
(cond
|
||||
((eqv? (sx-tag tree) 'decl)
|
||||
(munge-decl tree seed))
|
||||
((inc-keeper? tree)
|
||||
(c99-trans-unit->udict (sx-ref tree 1) seed #:filter filter))
|
||||
(else seed)))
|
||||
seed
|
||||
(cdr tree))
|
||||
seed))
|
||||
(define (c99-trans-unit->udict/deep tree)
|
||||
(c99-trans-unit->udict tree #:filter #t))
|
||||
(define tree->udict c99-trans-unit->udict)
|
||||
(define tree->udict/deep c99-trans-unit->udict/deep)
|
||||
|
||||
;; @deffn {Procedure} munge-decl decl seed [#:expand-enums #f] => seed
|
||||
;; This is a fold iterator to used by @code{tree->udict}. It converts the
|
||||
;; multiple @code{init-declr} items in an @code{init-declr-list} of a
|
||||
;; @code{decl} into an a-list of multiple pairs of name and @code{udecl}
|
||||
;; trees with a single @code{init-declr} and no @code{init-declr-list}.
|
||||
;; That is, a @code{decl} of the form
|
||||
;; @example
|
||||
;; (decl (decl-spec-list ...)
|
||||
;; (init-declr-list (init-declr (... "a")) (init-declr (... "b")) ...))
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; is munged into list with elements
|
||||
;; @example
|
||||
;; ("a" . (udecl (decl-spec-list ...) (init-declr (... "a"))))
|
||||
;; ("b" . (udecl (decl-spec-list ...) (init-declr (... "b"))))
|
||||
;; @end example
|
||||
;; The @code{/deep} version will plunge into cpp-includes.
|
||||
;; Here we generate a dictionary of all declared items in a file:
|
||||
;; @example
|
||||
;; (let* ((sx0 (with-input-from-file src-file parse-c))
|
||||
;; (sx1 (merge-inc-trees! sx0))
|
||||
;; (name-dict (fold match-decl-1 '() (cdr sx1))))
|
||||
;; @end example
|
||||
;; TODO: add enums because they are global!!, but this should be user opt
|
||||
;; @example
|
||||
;; enum { ABC = 123 }; => ???
|
||||
;; @end example
|
||||
;; Unexpanded, unnamed enums have keys @code{"enum"}.
|
||||
;; Enum, struct and union def's have keys @code{(enum . "name")},
|
||||
;; @code{(struct . "name")} and @code{(union . "name)}, respectively.
|
||||
;; See @code{udict-struct-ref}, @code{udict-union-ref}, @code{udict-enum-ref}
|
||||
;; and @code{udict-ref}.
|
||||
;; @end deffn
|
||||
|
||||
;; TODO:
|
||||
;; enum tag => "enum" (tag . udecl)
|
||||
;; enum { NAME } => "enum" ("" . udecl) ???? WHAT TO DO ????
|
||||
;; need (ud-lookup name) (ud-lookup-struct name) (ud-lookup-union name)
|
||||
;; USING ud-udict-struct-ref
|
||||
(define* (munge-decl decl seed #:key (expand-enums #f))
|
||||
|
||||
(define (iter-declrs init-declr-l tail seed)
|
||||
(if (not init-declr-l) seed
|
||||
(let iter ((seed seed) (idl (cdr init-declr-l)))
|
||||
(if (null? idl) seed
|
||||
(let* ((tag 'udecl) (attr (sx-attr decl))
|
||||
(specl (sx-ref decl 1)) (declr (sx-ref (car idl) 1))
|
||||
(ident (declr->ident declr)) (name (cadr ident)))
|
||||
(iter
|
||||
(acons name (sx-cons* tag attr specl (car idl) tail) seed)
|
||||
(cdr idl)))))))
|
||||
|
||||
;;(simple-format #t "munge-decl ~S\n" decl)
|
||||
(cond
|
||||
((not (pair? decl)) seed)
|
||||
((eqv? (sx-tag decl) 'decl)
|
||||
(let* ((tag (sx-tag decl)) (tag 'udecl)
|
||||
(attr (sx-attr decl))
|
||||
(spec (sx-ref decl 1)) ; (decl-spec-list ...)
|
||||
(sx2 (sx-ref decl 2)) ; (init-declr-list ...) OR ...
|
||||
(init-d-l (if (and sx2 (eqv? (sx-tag sx2) 'init-declr-list)) sx2 #f))
|
||||
(tail (sx-tail decl (if init-d-l 3 2))))
|
||||
(sxml-match spec
|
||||
((decl-spec-list
|
||||
(type-spec (struct-def (ident ,name) . ,rest2) . ,rest1))
|
||||
(acons `(struct . ,name) decl (iter-declrs init-d-l tail seed)))
|
||||
((decl-spec-list
|
||||
(type-spec (struct-def . ,rest2) . ,rest1))
|
||||
(acons `(struct . "*anon*") decl (iter-declrs init-d-l tail seed)))
|
||||
((decl-spec-list
|
||||
(type-spec (union-def (ident ,name) . ,rest2) . ,rest1))
|
||||
(acons `(union . ,name) decl (iter-declrs init-d-l tail seed)))
|
||||
((decl-spec-list
|
||||
(type-spec (union-def . ,rest2) . ,rest1))
|
||||
(acons `(union . "*anon*") decl (iter-declrs init-d-l tail seed)))
|
||||
((decl-spec-list
|
||||
(type-spec (enum-def (ident ,name) . ,rest2) . ,rest1))
|
||||
(acons `(enum . ,name) decl (iter-declrs init-d-l tail seed)))
|
||||
((decl-spec-list
|
||||
(type-spec (enum-def . ,rest2) . ,rest1))
|
||||
(acons `(enum . "*anon*") decl (iter-declrs init-d-l tail seed)))
|
||||
(,otherwise
|
||||
(iter-declrs init-d-l tail seed)))))
|
||||
((eqv? (sx-tag decl) 'comp-decl)
|
||||
(munge-comp-decl decl seed #:expand-enums expand-enums))
|
||||
((eqv? (sx-tag decl) 'param-decl)
|
||||
(munge-param-decl decl seed #:expand-enums expand-enums))
|
||||
(else seed)))
|
||||
|
||||
;; @deffn {Procedure} munge-comp-decl decl seed [#:expand-enums #f]
|
||||
;; This will turn
|
||||
;; @example
|
||||
;; (comp-decl (decl-spec-list (type-spec "int"))
|
||||
;; (comp-decl-list
|
||||
;; (comp-declr (ident "a")) (comp-declr (ident "b"))))
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; into
|
||||
;; @example
|
||||
;; ("a" . (comp-decl (decl-spec-list ...) (comp-declr (ident "a"))))
|
||||
;; ("b" . (comp-decl (decl-spec-list ...) (comp-declr (ident "b"))))
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; This is coded to be used with fold-right in order to preserve order
|
||||
;; in @code{struct} and @code{union} field lists.
|
||||
;; @end deffn
|
||||
(define* (munge-comp-decl decl seed #:key (expand-enums #f))
|
||||
(if (not (eqv? 'comp-decl (car decl))) seed
|
||||
(let* ((tag (sx-ref decl 0))
|
||||
(attr (sx-attr decl))
|
||||
(spec (sx-ref decl 1)) ; (type-spec ...)
|
||||
(id-l (sx-ref decl 2)) ; (init-declr-list ...)
|
||||
(tail (sx-tail decl 3))) ; opt comment, different here
|
||||
(let iter ((res seed) (idl (cdr id-l)))
|
||||
(if (null? idl) res
|
||||
(let* ((declr (sx-ref (car idl) 1))
|
||||
(ident (declr->ident declr))
|
||||
(name (cadr ident)))
|
||||
(acons name
|
||||
(if attr
|
||||
(cons* tag attr spec (car idl) tail)
|
||||
(cons* tag spec (car idl) tail))
|
||||
(iter res (cdr idl)))))))))
|
||||
(define match-comp-decl munge-comp-decl)
|
||||
|
||||
;; @deffn {Procedure} match-param-decl param-decl seed [#:expand-enums #f]
|
||||
;; This will turn
|
||||
;; @example
|
||||
;; (param-decl (decl-spec-list (type-spec "int"))
|
||||
;; (param-declr (ident "a")))
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; into
|
||||
;; @example
|
||||
;; ("a" . (comp-decl (decl-spec-list ...) (comp-declr (ident "a"))))
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; This is coded to be used with fold-right in order to preserve order
|
||||
;; in @code{struct} and @code{union} field lists.
|
||||
;; @end deffn
|
||||
(define* (munge-param-decl decl seed #:key (expand-enums #f))
|
||||
(if (not (eqv? 'param-decl (car decl))) seed
|
||||
(let* ((tag (sx-ref decl 0))
|
||||
(attr (sx-attr decl))
|
||||
(spec (sx-ref decl 1)) ; (type-spec ...)
|
||||
(declr (sx-ref decl 2)) ; (param-declr ...)
|
||||
(ident (declr->ident declr))
|
||||
(name (cadr ident)))
|
||||
(acons name decl seed))))
|
||||
(define match-param-decl munge-param-decl)
|
||||
|
||||
;; like member but returns first non-declr of type in dict
|
||||
(define (non-declr type udict)
|
||||
(let iter ((dict udict))
|
||||
(cond
|
||||
((null? dict) #f)
|
||||
((and (pair? (car dict)) (eqv? type (caar dict))) dict)
|
||||
(else (iter (cdr dict))))))
|
||||
|
||||
;; @deffn {Procedure} udict-ref name
|
||||
;; @deffnx {Procedure} udict-struct-ref name
|
||||
;; @deffnx {Procedure} udict-union-ref name
|
||||
;; @deffnx {Procedure} udict-enum-ref name
|
||||
;; @end deffn
|
||||
(define (udict-ref udict name)
|
||||
(or (assoc-ref udict name)
|
||||
(let iter ((dict (non-declr 'enum udict)))
|
||||
(cond
|
||||
((not dict) #f)
|
||||
((assoc-ref (cdar dict) name))
|
||||
(else (iter (non-declr 'enum dict)))))))
|
||||
(define (udict-struct-ref udict name)
|
||||
#f)
|
||||
(define (udict-union-ref udict name)
|
||||
#f)
|
||||
(define (udict-enum-ref udict name)
|
||||
#f)
|
||||
|
||||
;; @deffn {Variable} fixed-width-int-names
|
||||
;; This is a list of standard integer names (e.g., @code{"uint8_t"}).
|
||||
;; @end deffn
|
||||
(define fixed-width-int-names
|
||||
'("int8_t" "uint8_t" "int16_t" "uint16_t"
|
||||
"int32_t" "uint32_t" "int64_t" "uint64_t"))
|
||||
|
||||
;; @deffn {Procedure} typedef-decl? decl)
|
||||
;; @end deffn
|
||||
(define (typedef-decl? decl)
|
||||
(sxml-match decl
|
||||
((decl (decl-spec-list (stor-spec (typedef)) . ,r1) . ,r2) #t)
|
||||
(,otherwise #f)))
|
||||
|
||||
;; @deffn {Procedure} splice-declarators orig-declr tdef-declr =>
|
||||
;; Splice the original declarator into the typedef declarator.
|
||||
;; This is a helper for @code{expand-*-typename-ref} procecures.
|
||||
;; @end deffn
|
||||
(define (splice-declarators orig-declr tdef-declr)
|
||||
|
||||
(define (fD seed tree) ; => (values seed tree)
|
||||
(sxml-match tree
|
||||
((param-list . ,rest) (values tree '())) ; don't process
|
||||
((ident ,name) (values (reverse (cadr orig-declr)) '())) ; replace
|
||||
(,otherwise (values '() tree))))
|
||||
|
||||
(define (fU seed kseed tree)
|
||||
(let ((ktree (case (car kseed)
|
||||
((param-list ident) kseed)
|
||||
(else (reverse kseed)))))
|
||||
(if (null? seed) ktree (cons ktree seed))))
|
||||
|
||||
(define (fH seed tree)
|
||||
(cons tree seed))
|
||||
|
||||
;; This cons transfers the tag from orig-declr to the result.
|
||||
(cons
|
||||
(car orig-declr) ; init-declr or comp-declr
|
||||
(cdr (foldts* fD fU fH '() tdef-declr)))) ; always init-declr
|
||||
|
||||
|
||||
;; @deffn {Procedure} repl-typespec decl-spec-list replacement
|
||||
;; This is a helper for expand-decl-typerefs
|
||||
;; @end deffn
|
||||
(define (repl-typespec decl-spec-list replacement)
|
||||
(fold-right
|
||||
(lambda (item seed)
|
||||
(cond ((symbol? item) (cons item seed))
|
||||
((eqv? 'type-spec (car item))
|
||||
(if (pair? (car replacement))
|
||||
(append replacement seed)
|
||||
(cons replacement seed)))
|
||||
(else (cons item seed))))
|
||||
'() decl-spec-list))
|
||||
|
||||
;; @deffn {Procedure} expand-typerefs udecl udecl-dict [#:keep '()]
|
||||
;; Given a declaration or component-declaration, return a udecl with all
|
||||
;; typenames (not in @var{keep}), struct, union and enum refs expanded.
|
||||
;; (but enums to int?)
|
||||
;; @example
|
||||
;; typedef const int (*foo_t)(int a, double b);
|
||||
;; extern foo_t fctns[2];
|
||||
;; =>
|
||||
;; extern const int (*fctns[2])(int a, double b);
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define* (expand-typerefs udecl udecl-dict #:key (keep '()))
|
||||
;; ??? add (init-declr-list) OR having predicate (has-init-declr? decl)
|
||||
(let* ((tag (sx-tag udecl)) ; decl or comp-decl
|
||||
(attr (sx-attr udecl)) ; (@ ...)
|
||||
(specl (sx-ref udecl 1)) ; decl-spec-list
|
||||
(declr (or (sx-find 'init-declr udecl) ; declarator
|
||||
(sx-find 'comp-declr udecl)
|
||||
(sx-find 'param-declr udecl)))
|
||||
(tail (if declr (sx-tail udecl 3) (sx-tail udecl 2))) ; opt comment
|
||||
(tspec (cadr (sx-find 'type-spec specl))))
|
||||
(case (car tspec)
|
||||
((typename)
|
||||
(cond
|
||||
((member (cadr tspec) keep) udecl)
|
||||
(else ;; splice in the typedef
|
||||
(let* ((name (sx-ref tspec 1))
|
||||
(decl (or (assoc-ref udecl-dict name) ; decl for typename
|
||||
(throw 'c99-error "util2 decl error")))
|
||||
(tdef-specl (sx-ref decl 1)) ; decl-spec-list for typename
|
||||
(tdef-declr (sx-ref decl 2)) ; init-declr for typename
|
||||
;; splice the typedef specifiers into target:
|
||||
(fixd-specl (repl-typespec specl (sx-tail tdef-specl 2)))
|
||||
(fixd-declr (splice-declarators declr tdef-declr))
|
||||
(fixed-udecl (cons* tag fixd-specl fixd-declr tail)))
|
||||
(expand-decl-typerefs fixed-udecl udecl-dict #:keep keep)))))
|
||||
|
||||
((struct-ref union-ref)
|
||||
(simple-format (current-error-port)
|
||||
"+++ c99/util2: struct/union-ref: more to do?\n")
|
||||
(simple-format #t "\nstruct-ref:\n") (pretty-print udecl)
|
||||
(let* ((is-struct (eqv? 'struct-ref (car tspec)))
|
||||
(ident (cadr tspec))
|
||||
(name (cadr ident))
|
||||
(ref (if is-struct
|
||||
(udict-struct-ref udecl-dict name)
|
||||
(udict-union-ref udecl-dict name)))
|
||||
)
|
||||
#f)
|
||||
udecl)
|
||||
|
||||
((struct-def union-def)
|
||||
(let* ((ident (sx-find 'ident tspec))
|
||||
(field-list (sx-find 'field-list tspec))
|
||||
(orig-flds (cdr field-list))
|
||||
(unit-flds (map cdr (fold-right match-comp-decl '() orig-flds)))
|
||||
(fixd-flds (map
|
||||
(lambda (fld)
|
||||
(expand-decl-typerefs fld udecl-dict #:keep keep))
|
||||
unit-flds))
|
||||
(fixd-tspec
|
||||
(if #f ;;ident
|
||||
`(type-spec (struct-def ,ident (field-list ,@fixd-flds)))
|
||||
`(type-spec (struct-def (field-list ,@fixd-flds)))))
|
||||
(fixd-specl (repl-typespec specl fixd-tspec)))
|
||||
(if declr (cons* tag fixd-specl declr tail)
|
||||
(cons* tag fixd-specl tail))))
|
||||
|
||||
((enum-def)
|
||||
(let* ((enum-def-list (sx-find 'enum-def-list tspec))
|
||||
(fixd-def-list (canize-enum-def-list enum-def-list))
|
||||
(fixd-tspec `(type-spec (enum-def ,fixd-def-list)))
|
||||
(fixd-specl (repl-typespec specl fixd-tspec))
|
||||
(fixed-decl (cons* tag fixd-specl declr tail))) ;; !!!
|
||||
fixed-decl))
|
||||
|
||||
((enum-ref)
|
||||
(simple-format (current-error-port) "chack: enum-ref NOT DONE\n")
|
||||
udecl)
|
||||
|
||||
(else
|
||||
udecl))))
|
||||
(define expand-decl-typerefs expand-typerefs)
|
||||
|
||||
;; === enum handling ...
|
||||
|
||||
;; @deffn {Procedure} canize-enum-def-list
|
||||
;; Fill in constants for all entries of an enum list.
|
||||
;; @end deffn
|
||||
(define (canize-enum-def-list enum-def-list)
|
||||
(define (get-used edl)
|
||||
(let iter ((uzd '()) (edl edl))
|
||||
(cond
|
||||
((null? edl) uzd)
|
||||
((assq-ref (cdar edl) 'p-expr) =>
|
||||
(lambda (x)
|
||||
(iter (cons (string->number (cadar x)) uzd) (cdr edl))))
|
||||
(else
|
||||
(iter uzd (cdr edl))))))
|
||||
(let ((used (get-used (cdr enum-def-list))))
|
||||
(let iter ((rez '()) (ix 0) (edl (cdr enum-def-list)))
|
||||
(cond
|
||||
((null? edl) (cons (car enum-def-list) (reverse rez)))
|
||||
((assq-ref (cdar edl) 'p-expr)
|
||||
(iter (cons (car edl) rez) ix (cdr edl)))
|
||||
(else
|
||||
(let* ((ix1 (let iter ((ix (1+ ix)))
|
||||
(if (memq ix used) (iter (1+ ix)) ix)))
|
||||
(is1 (number->string ix1)))
|
||||
(iter (cons (append (car edl) `((p-expr (fixed ,is1)))) rez)
|
||||
ix1 (cdr edl))))))))
|
||||
|
||||
;; @deffn {Procecure} enum-ref enum-def-list name => string
|
||||
;; Gets value of enum where @var{enum-def-list} looks like
|
||||
;; @example
|
||||
;; (enum-def-list (enum-defn (ident "ABC") (p-expr (fixed "123")) ...))
|
||||
;; @end example
|
||||
;; so that
|
||||
;; @example
|
||||
;; (enum-def-list edl "ABC") => "123"
|
||||
;; @end example
|
||||
(define (enum-ref enum-def-list name)
|
||||
(let iter ((el (cdr (canize-enum-def-list enum-def-list))))
|
||||
(cond
|
||||
((null? el) #f)
|
||||
((not (eqv? 'enum-defn (caar el))) (iter (cdr el)))
|
||||
((string=? name (cadr (cadar el))) (cadadr (caddar el)))
|
||||
(else (iter (cdr el))))))
|
||||
|
||||
;; @deffn {Procedure} gen-enum-udecl nstr vstr => (udecl ...)
|
||||
;; @example
|
||||
;; (gen-enum-udecl "ABC" "123")
|
||||
;; =>
|
||||
;; (udecl (decl-spec-list
|
||||
;; (type-spec
|
||||
;; (enum-def
|
||||
;; (enum-def-list
|
||||
;; (enum-defn (ident "ABC") (p-expr (fixed "123")))))))))
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (gen-enum-udecl nstr vstr)
|
||||
`(udecl (decl-spec-list
|
||||
(type-spec
|
||||
(enum-def
|
||||
(enum-def-list
|
||||
(enum-defn (ident ,nstr) (p-expr (fixed ,vstr)))))))))
|
||||
|
||||
;; === enum handling ...
|
||||
|
||||
;;@deffn {Procedure} stripdown-1 udecl decl-dict [options]=> decl
|
||||
;; This is deprecated.
|
||||
;; 1) remove stor-spec
|
||||
;; 2) expand typenames
|
||||
;; @example
|
||||
;; typedef int *x_t;
|
||||
;; x_t a[10];
|
||||
;; (spec (typename x_t)) (init-declr (array-of 10 (ident a)))
|
||||
;; (spec (typedef) (fixed-type "int")) (init-declr (pointer) (ident "x_t"))
|
||||
;; =>
|
||||
;; (udecl (decl-spec-list (type-spec ...) ... (type-qual "const"))
|
||||
;; (init-declr (ptr-declr (pointer ...)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define* (stripdown-1 udecl decl-dict #:key (keep '()))
|
||||
|
||||
;;(define strip-list '(stor-spec type-qual comment))
|
||||
(define strip-list '(stor-spec type-qual))
|
||||
|
||||
(define (fsD seed tree)
|
||||
'())
|
||||
|
||||
(define (fsU seed kseed tree)
|
||||
(cond
|
||||
((eqv? (sx-tag tree) 'stor-spec) seed)
|
||||
((eqv? (sx-tag tree) 'type-qual) seed)
|
||||
((null? seed) (reverse kseed))
|
||||
(else (cons (reverse kseed) seed))))
|
||||
|
||||
(define (fsH seed tree)
|
||||
(cons tree seed))
|
||||
|
||||
(let* ((xdecl (expand-decl-typerefs udecl decl-dict #:keep keep))
|
||||
(tag (sx-tag xdecl))
|
||||
(attr (sx-attr xdecl))
|
||||
(specl (sx-ref xdecl 1))
|
||||
(declr (sx-ref xdecl 2))
|
||||
(specl1 (foldts fsD fsU fsH '() specl)))
|
||||
(list tag specl1 declr)))
|
||||
|
||||
(define* (stripdown-declr declr #:key const-ptr)
|
||||
(define (fD seed tree) '())
|
||||
|
||||
(define (fU seed kseed tree)
|
||||
(cond
|
||||
((null? seed) (reverse kseed))
|
||||
((eqv? (sx-tag tree) 'stor-spec) seed)
|
||||
((eqv? (sx-tag tree) 'type-qual)
|
||||
(if (and const-ptr (string=? (sx-ref tree 1) "const"))
|
||||
(cons (reverse kseed) seed)
|
||||
seed))
|
||||
(else (cons (reverse kseed) seed))))
|
||||
|
||||
(define (fH seed tree)
|
||||
(cons tree seed))
|
||||
|
||||
(foldts fD fU fH '() declr))
|
||||
|
||||
;; @deffn {Procedure} stripdown udecl decl-dict [options]=> decl
|
||||
;; 1) remove stor-spec
|
||||
;; @example
|
||||
;; =>
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define* (stripdown udecl decl-dict #:key const-ptr)
|
||||
(let* (;;(speclt (sx-tail udecl)) ; decl-spec-list tail
|
||||
(xdecl udecl)
|
||||
(tag (sx-tag xdecl))
|
||||
(attr (sx-attr xdecl))
|
||||
(specl (sx-ref xdecl 1))
|
||||
(declr (sx-ref xdecl 2))
|
||||
(s-declr (stripdown-declr declr))
|
||||
(is-ptr? (declr-is-ptr? declr))
|
||||
;;
|
||||
(s-tag (sx-tag specl))
|
||||
(s-attr (sx-attr specl))
|
||||
(s-tail (strip-decl-spec-tail
|
||||
(sx-tail specl) #:keep-const? (and #:const-ptr is-ptr?)))
|
||||
(specl (sx-cons* s-tag s-attr s-tail)))
|
||||
;;(pretty-print declr)
|
||||
;;(pretty-print s-declr)
|
||||
(sx-list tag attr specl s-declr)))
|
||||
|
||||
(define (declr-is-ptr? declr)
|
||||
(and
|
||||
(pair? (cdr declr))
|
||||
(eqv? 'ptr-declr (caadr declr))))
|
||||
|
||||
(define* (strip-decl-spec-tail dsl-tail #:key keep-const?)
|
||||
;;(simple-format #t "spec=tail: ~S\n" dsl-tail)
|
||||
(let iter ((dsl1 '()) (const-seen? #f) (tail dsl-tail))
|
||||
(if (null? tail)
|
||||
(reverse (if (and const-seen? keep-const?)
|
||||
(cons '(type-qual "const") dsl1)
|
||||
dsl1))
|
||||
(case (caar tail)
|
||||
((type-qual)
|
||||
(if (string=? (cadar tail) "const")
|
||||
(iter dsl1 #t (cdr tail))
|
||||
(iter dsl1 const-seen? (cdr tail))))
|
||||
((stor-spec)
|
||||
(iter dsl1 const-seen? (cdr tail)))
|
||||
(else
|
||||
(iter (cons (car tail) dsl1) const-seen? (cdr tail)))))))
|
||||
|
||||
;; @deffn {Procedure} udecl->mspec udecl
|
||||
;; @deffnx {Procedure} udecl->mspec/comm udecl [#:def-comm ""]
|
||||
;; Turn a stripped-down unit-declaration into an m-spec. The second version
|
||||
;; include a comment. This assumes decls have been run through
|
||||
;; @code{stripdown}.
|
||||
;; @example
|
||||
;; (decl (decl-spec-list (type-spec "double"))
|
||||
;; (init-declr-list (
|
||||
;; (comment "state vector")
|
||||
;; =>
|
||||
;; ("x" "state vector" (array-of 10) (float "double")
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (udecl->mspec decl)
|
||||
|
||||
(define (cnvt-array-size size-spec)
|
||||
(with-output-to-string (lambda () (pretty-print-c99 size-spec))))
|
||||
|
||||
(define (unwrap-specl specl)
|
||||
(and=> (assq-ref (sx-tail specl) 'type-spec) car))
|
||||
;;? (sxml-match tspec
|
||||
;;? ((xxx-struct-def (field-list . ,rest))
|
||||
|
||||
(define* (unwrap-declr declr #:key (const #f))
|
||||
;;(simple-format #t "#:const=~S (car declr)=~S\n" const (car declr))
|
||||
(sxml-match declr
|
||||
((ident ,name)
|
||||
(list name))
|
||||
((init-declr ,item)
|
||||
(unwrap-declr item #:const const))
|
||||
((ptr-declr (pointer . ,r) ,dir-declr)
|
||||
(if const
|
||||
(cons* '(const) '(pointer-to) (unwrap-declr dir-declr))
|
||||
(cons '(pointer-to) (unwrap-declr dir-declr))))
|
||||
((array-of ,dir-declr ,size)
|
||||
(cons `(array-of ,(cnvt-array-size size)) (unwrap-declr dir-declr)))
|
||||
((ftn-declr ,dir-declr ,params)
|
||||
(cons '(function-returning) (unwrap-declr dir-declr)))
|
||||
((scope ,expr)
|
||||
(unwrap-declr expr))
|
||||
((comp-declr ,item) (unwrap-declr item))
|
||||
((param-declr ,item) (unwrap-declr item))
|
||||
(,otherwise
|
||||
(simple-format #t "unwrap-declr: OTHERWISE\n") (pretty-print otherwise)
|
||||
;; failed got: (array-of (ident "foo")) FROM const char foo[];
|
||||
(error "udecl->mspec failed")
|
||||
#f)))
|
||||
|
||||
(define (find-type-spec decl-spec-list)
|
||||
(let iter ((tsl (cdr decl-spec-list)))
|
||||
(if (eqv? 'type-spec (caar tsl)) (car tsl)
|
||||
(iter (cdr tsl)))))
|
||||
|
||||
(let* (;;(decl-dict (if (pair? rest) (car rest) '()))
|
||||
(specl (sx-ref decl 1))
|
||||
(tspec (cadr specl)) ; type-spec
|
||||
(const (and=> (sx-ref specl 2) ; const pointer ???
|
||||
(lambda (sx) (equal? (sx-ref sx 1) "const"))))
|
||||
(declr (or (sx-ref decl 2) ;; param-decl -- e.g., f(void)
|
||||
'(ident "@arg")))
|
||||
(comm (sx-ref decl 3))
|
||||
(m-specl (unwrap-specl specl))
|
||||
(m-declr (unwrap-declr declr #:const const))
|
||||
(m-decl (reverse (cons m-specl m-declr))))
|
||||
m-decl))
|
||||
|
||||
(define* (udecl->mspec/comm decl #:key (def-comm ""))
|
||||
(let* ((comm (or (and=> (sx-ref decl 3) cadr) def-comm))
|
||||
(spec (udecl->mspec decl)))
|
||||
(cons* (car spec) comm (cdr spec))))
|
||||
|
||||
;; @deffn {Procedure} clean-field-list field-list => flds
|
||||
;; Process the tagged field-list element of a struct and remove lone comments.
|
||||
;; If a field following a lone comment has no code-comment, the lone comment
|
||||
;; will be used. For example,
|
||||
;; @example
|
||||
;; /* foo */
|
||||
;; int x;
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; will be treated as if it was denereed
|
||||
;; @example
|
||||
;; int x; /* foo */
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; @end deffn
|
||||
(define (clean-field-list fld-list)
|
||||
(let iter ((rz '()) (cl '()) (fl (cdr fld-list)))
|
||||
;;(pretty-print fl)
|
||||
(cond
|
||||
((null? fl) (cons 'field-list (reverse rz)))
|
||||
((eqv? 'comment (caar fl))
|
||||
(iter rz (cons (cadar fl) cl) (cdr fl)))
|
||||
((eqv? 'comp-decl (caar fl))
|
||||
(if (eq? 4 (length (car fl)))
|
||||
(iter (cons (car fl) rz) '() (cdr fl)) ; has comment
|
||||
(let* ((cs (apply string-append (reverse cl))) ; add comment
|
||||
(fd (append (car fl) (list (list 'comment cs)))))
|
||||
(iter (cons fd rz) '() (cdr fl)))))
|
||||
(else
|
||||
(error "bad field")))))
|
||||
|
||||
(define (fix-fields flds)
|
||||
(cdr (clean-field-list `(field-list . ,flds))))
|
||||
|
||||
;; ===== not used? ====================
|
||||
|
||||
;;.@deffn {Procedure} unwrap-decl decl seed => seed
|
||||
;; This is a fold to break up multiple declarators.
|
||||
;; @example
|
||||
;; (decl (decl-spec-list ...) (init-declr-list (init-declr ...) ...))
|
||||
;; =>
|
||||
;; ((decl (decl-spec-list ...) (init-declr ...))
|
||||
;; (decl (decl-spec-list ...) (init-declr ...))
|
||||
;; ...)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (unwrap-decl decl seed)
|
||||
(cond
|
||||
((not (eqv? 'decl (car decl))) seed)
|
||||
((< (length decl) 3) seed) ; this should catch struct-ref etc.
|
||||
(else
|
||||
(let* ((tag (sx-ref decl 0))
|
||||
(attr (sx-attr decl))
|
||||
(spec (sx-ref decl 1)) ; (decl-spec-list ...)
|
||||
(id-l (sx-ref decl 2)) ; (init-declr-list ...)
|
||||
(tail (sx-tail decl 3))) ; comment
|
||||
(let iter ((res seed) (idl (cdr id-l)))
|
||||
(if (null? idl) res
|
||||
(let* ((declr (sx-ref (car idl) 1))
|
||||
(ident (declr->ident declr))
|
||||
(name (cadr ident)))
|
||||
(iter (cons (if attr
|
||||
(cons* tag attr spec (car idl) tail)
|
||||
(cons* tag spec (car idl) tail))
|
||||
res)
|
||||
(cdr idl)))))))))
|
||||
|
||||
|
||||
;; --- last line ---
|
|
@ -1,80 +0,0 @@
|
|||
;;; nyacc/lang/c99/xparser.scm - copied from parser.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; C parser
|
||||
|
||||
(define-module (nyacc lang c99 xparser)
|
||||
#:export (parse-c99x)
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc parse)
|
||||
#:use-module (nyacc lang util)
|
||||
#:use-module (nyacc lang c99 cpp)
|
||||
#:use-module ((srfi srfi-9) #:select (define-record-type))
|
||||
#:use-module ((sxml xpath) #:select (sxpath))
|
||||
)
|
||||
|
||||
(include-from-path "nyacc/lang/c99/mach.d/c99xtab.scm")
|
||||
(define c99-mtab c99x-mtab)
|
||||
(include-from-path "nyacc/lang/c99/body.scm")
|
||||
(include-from-path "nyacc/lang/c99/mach.d/c99xact.scm")
|
||||
|
||||
;; Parse given a token generator. Uses fluid @code{*info*}.
|
||||
(define raw-parser
|
||||
(let ((parser (make-lalr-parser
|
||||
(list (cons 'len-v c99x-len-v) (cons 'pat-v c99x-pat-v)
|
||||
(cons 'rto-v c99x-rto-v) (cons 'mtab c99x-mtab)
|
||||
(cons 'act-v c99x-act-v)))))
|
||||
(lambda* (lexer #:key (debug #f))
|
||||
(catch
|
||||
'nyacc-error
|
||||
(lambda () (parser lexer #:debug debug))
|
||||
(lambda (key fmt . args)
|
||||
(report-error fmt args)
|
||||
(pop-input) ; not sure this is right
|
||||
(throw 'c99-error "C99 parse error"))))))
|
||||
|
||||
(define (run-parse)
|
||||
(let ((info (fluid-ref *info*)))
|
||||
(raw-parser (gen-c-lexer #:mode 'decl) #:debug (cpi-debug info))))
|
||||
|
||||
;; @item {Procedure} parse-c99x [#:cpp-defs defs] [#:debug bool]
|
||||
;; This needs to be explained in some detail.
|
||||
;; [#:tyns '("foo_t")]
|
||||
(define* (parse-c99x expr-string
|
||||
#:key
|
||||
(cpp-defs '()) ; CPP defines
|
||||
(inc-help '()) ; include helper
|
||||
(xdef? #f) ; pred to determine expand
|
||||
(debug #f) ; debug?
|
||||
(tyns '())) ; defined typenames
|
||||
(with-input-from-string expr-string
|
||||
(lambda ()
|
||||
(catch
|
||||
'c99-error
|
||||
(lambda ()
|
||||
(let ((info (make-cpi debug cpp-defs '(".") inc-help)))
|
||||
(set-cpi-ptl! info (cons tyns (cpi-ptl info)))
|
||||
(with-fluid*
|
||||
*info* info
|
||||
(lambda ()
|
||||
(raw-parser (gen-c-lexer #:mode 'code #:xdef? xdef?)
|
||||
#:debug debug)))))
|
||||
(lambda (key fmt . rest)
|
||||
(report-error fmt rest)
|
||||
#f)))))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,66 +0,0 @@
|
|||
;;; nyacc/lang/calc/parser
|
||||
;;;
|
||||
;;; Copyright (C) 2015,2016 Matthew R. Wette
|
||||
;;;
|
||||
;;; This program 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.
|
||||
;;;
|
||||
;;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (nyacc lang calc parser)
|
||||
#:export (calc-parse calc-spec calc-mach)
|
||||
#:use-module (nyacc lalr)
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc parse)
|
||||
)
|
||||
|
||||
(define calc-spec
|
||||
(lalr-spec
|
||||
(prec< (left "+" "-") (left "*" "/"))
|
||||
(start stmt-list-proxy)
|
||||
(grammar
|
||||
|
||||
(stmt-list-proxy
|
||||
(stmt-list "\n" ($$ `(stmt-list ,@(reverse $1)))))
|
||||
|
||||
(stmt-list
|
||||
(stmt ($$ (list $1)))
|
||||
(stmt-list ";" stmt ($$ (cons $3 $1))))
|
||||
|
||||
(stmt
|
||||
(ident "=" expr ($$ `(assn-stmt ,$1 ,$3)))
|
||||
(expr ($$ `(expr-stmt ,$1)))
|
||||
( ($$ '(empty-stmt))))
|
||||
|
||||
(expr
|
||||
(expr "+" expr ($$ `(add ,$1 ,$3)))
|
||||
(expr "-" expr ($$ `(sub ,$1 ,$3)))
|
||||
(expr "*" expr ($$ `(mul ,$1 ,$3)))
|
||||
(expr "/" expr ($$ `(div ,$1 ,$3)))
|
||||
($fixed ($$ `(fixed ,$1)))
|
||||
($float ($$ `(float ,$1)))
|
||||
("(" expr ")" ($$ $2)))
|
||||
|
||||
(ident ($ident ($$ `(ident ,$1))))
|
||||
)))
|
||||
|
||||
(define calc-mach
|
||||
(compact-machine
|
||||
(hashify-machine
|
||||
(make-lalr-machine calc-spec))))
|
||||
|
||||
(define calc-parse
|
||||
(let ((gen-lexer (make-lexer-generator (assq-ref calc-mach 'mtab)
|
||||
#:space-chars " \t"))
|
||||
(parser (make-lalr-ia-parser calc-mach)))
|
||||
(lambda* (#:key (debug #f)) (parser (gen-lexer) #:debug debug))))
|
||||
|
||||
;; --- last line ---
|
|
@ -1,477 +0,0 @@
|
|||
;;; module/nyacc/util.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
;;; or any later version published by the Free Software Foundation. See
|
||||
;;; the file COPYING included with the nyacc distribution.
|
||||
|
||||
;; runtime utilities for the parsers -- needs work
|
||||
|
||||
(define-module (nyacc lang util)
|
||||
#:export (lang-crn-lic
|
||||
report-error
|
||||
push-input pop-input reset-input-stack
|
||||
make-tl tl->list ;; rename?? to tl->sx for sxml-expr
|
||||
tl-append tl-insert tl-extend tl+attr
|
||||
sx-tag sx-attr sx-tail sx-ref sx-cons* sx-list
|
||||
sx-attr-ref sx-has-attr? sx-set-attr! sx-set-attr*
|
||||
sx-find
|
||||
;; for pretty-printing
|
||||
make-protect-expr make-pp-formatter make-pp-formatter/ugly
|
||||
;; for ???
|
||||
move-if-changed
|
||||
fmterr)
|
||||
#:use-module ((srfi srfi-1) #:select(find))
|
||||
)
|
||||
|
||||
;; This is a generic copyright/licence that will be printed in the output
|
||||
;; of the examples/nyacc/lang/*/ actions.scm and tables.scm files.
|
||||
(define lang-crn-lic "
|
||||
|
||||
This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
|
||||
or any later version published by the Free Software Foundation. See
|
||||
the file COPYING included with the this distribution.")
|
||||
|
||||
(define (fmterr fmt . args)
|
||||
(apply simple-format (current-error-port) fmt args))
|
||||
|
||||
;; @deffn report-error fmt args
|
||||
;; Report an error: to stderr, providing file and line num info, and add nl.
|
||||
(define (report-error fmt args)
|
||||
(let ((fn (or (port-filename (current-input-port)) "(unknown)"))
|
||||
(ln (1+ (port-line (current-input-port)))))
|
||||
(apply simple-format (current-error-port)
|
||||
(string-append "~A:~A: " fmt "\n") fn ln args)))
|
||||
|
||||
;; === input stack =====================
|
||||
|
||||
(define *input-stack* (make-fluid '()))
|
||||
|
||||
(define (reset-input-stack)
|
||||
(fluid-set! *input-stack* '()))
|
||||
|
||||
(define (push-input port)
|
||||
(let ((curr (current-input-port))
|
||||
(ipstk (fluid-ref *input-stack*)))
|
||||
(fluid-set! *input-stack* (cons curr ipstk))
|
||||
(set-current-input-port port)))
|
||||
|
||||
;; Return #f if empty
|
||||
(define (pop-input)
|
||||
(let ((ipstk (fluid-ref *input-stack*)))
|
||||
(if (null? ipstk) #f
|
||||
(begin
|
||||
(set-current-input-port (car ipstk))
|
||||
(fluid-set! *input-stack* (cdr ipstk))))))
|
||||
|
||||
;; === tl ==============================
|
||||
|
||||
;; @section Tagged Lists
|
||||
;; Tagged lists are
|
||||
;; They are implemented as a cons cell with the car and the cdr a list.
|
||||
;; The cdr is used to accumulate appended items and the car is used to
|
||||
;; keep the tag, attributes and inserted items.
|
||||
;; @example
|
||||
;; tl => '(H . T), H => (c a b 'tag); T =>
|
||||
;; @end example
|
||||
|
||||
;; @table code
|
||||
|
||||
;; @deffn {Procedure} make-tl tag [item item ...]
|
||||
;; Create a tagged-list structure.
|
||||
;; @end deffn
|
||||
(define (make-tl tag . rest)
|
||||
(let iter ((tail tag) (l rest))
|
||||
(if (null? l) (cons '() tail)
|
||||
(iter (cons (car l) tail) (cdr l)))))
|
||||
|
||||
;; @deffn {Procedure} tl->list tl
|
||||
;; Convert a tagged list structure to a list. This collects added attributes
|
||||
;; and puts them right after the (leading) tag, resulting in something like
|
||||
;; @example
|
||||
;; (<tag> (@ <attr>) <rest>)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (tl->list tl)
|
||||
(let ((heda (car tl))
|
||||
(head (let iter ((head '()) (attr '()) (tl-head (car tl)))
|
||||
(if (null? tl-head)
|
||||
(if (pair? attr)
|
||||
(cons (cons '@ attr) (reverse head))
|
||||
(reverse head))
|
||||
(if (and (pair? (car tl-head)) (eq? '@ (caar tl-head)))
|
||||
(iter head (cons (cdar tl-head) attr) (cdr tl-head))
|
||||
(iter (cons (car tl-head) head) attr (cdr tl-head)))))))
|
||||
(let iter ((tail '()) (tl-tail (cdr tl)))
|
||||
(if (pair? tl-tail)
|
||||
(iter (cons (car tl-tail) tail) (cdr tl-tail))
|
||||
(cons tl-tail (append head tail))))))
|
||||
|
||||
;; @deffn {Procedure} tl-insert tl item
|
||||
;; Insert item at front of tagged list (but after tag).
|
||||
;; @end deffn
|
||||
(define (tl-insert tl item)
|
||||
(cons (cons item (car tl)) (cdr tl)))
|
||||
|
||||
;; @deffn {Procedure} tl-append tl item ...
|
||||
;; Append items at end of tagged list.
|
||||
;; @end deffn
|
||||
(define (tl-append tl . rest)
|
||||
(cons (car tl)
|
||||
(let iter ((tail (cdr tl)) (items rest))
|
||||
(if (null? items) tail
|
||||
(iter (cons (car items) tail) (cdr items))))))
|
||||
|
||||
;; @deffn {Procedure} tl-extend tl item-l
|
||||
;; Extend with a list of items.
|
||||
;; @end deffn
|
||||
(define (tl-extend tl item-l)
|
||||
(apply tl-append tl item-l))
|
||||
|
||||
;; @deffn {Procedure} tl-extend! tl item-l
|
||||
;; Extend with a list of items. Uses @code{set-cdr!}.
|
||||
;; @end deffn
|
||||
(define (tl-extend! tl item-l)
|
||||
(set-cdr! (last-pair tl) item-l)
|
||||
tl)
|
||||
|
||||
;; @deffn {Procedure} tl+attr tl key val)
|
||||
;; Add an attribute to a tagged list. Return the tl.
|
||||
;; @example
|
||||
;; (tl+attr tl 'type "int")
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (tl+attr tl key val)
|
||||
(tl-insert tl (cons '@ (list key val))))
|
||||
|
||||
;; @deffn {Procedure} tl-merge tl tl1
|
||||
;; Merge guts of phony-tl @code{tl1} into @code{tl}.
|
||||
;; @end deffn
|
||||
(define (tl-merge tl tl1)
|
||||
(error "not implemented (yet)")
|
||||
)
|
||||
|
||||
;; === sx ==============================
|
||||
;; @section SXML Utility Procedures
|
||||
;; Some lot of these look like existing Guile list procedures (e.g.,
|
||||
;; @code{sx-tail} versus @code{list-tail} but in sx lists the optional
|
||||
;; attributea are `invisible'. For example, @code{'(elt (@abc) "d")}
|
||||
;; is an sx of length two: the tag @code{elt} and the payload @code{"d"}.
|
||||
|
||||
;; @deffn {Procedure} sx-ref sx ix => item
|
||||
;; Reference the @code{ix}-th element of the list, not counting the optional
|
||||
;; attributes item. If the list is shorter than the index, return @code{#f}.
|
||||
;; @example
|
||||
;; (sx-ref '(abc "def") 1) => "def"
|
||||
;; (sx-ref '(abc (@ (foo "1")) "def") 1) => "def"
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (sx-ref sx ix)
|
||||
(define (list-xref l x) (if (> (length l) x) (list-ref l x) #f))
|
||||
(cond
|
||||
((zero? ix) (car sx))
|
||||
((and (pair? (cadr sx)) (eqv? '@ (caadr sx)))
|
||||
(list-xref sx (1+ ix)))
|
||||
(else
|
||||
(list-xref sx ix))))
|
||||
|
||||
;; @deffn {Procedure} sx-tag sx => tag
|
||||
;; Return the tag for a tree
|
||||
;; @end deffn
|
||||
(define (sx-tag sx)
|
||||
(if (pair? sx) (car sx) #f))
|
||||
|
||||
;; @deffn {Procedure} sx-cons* tag (attr|#f)? ... => sx
|
||||
;; @deffnx {Procedure} sx-list tag (attr|#f)? ... => sx
|
||||
;; Generate the tag and the attr list if it exists. Note that
|
||||
;; @end deffn
|
||||
(define (sx-cons* tag . rest)
|
||||
(cond
|
||||
((null? rest) (list tag))
|
||||
((not (car rest)) (apply cons* tag (cdr rest)))
|
||||
(else (apply cons* tag rest))))
|
||||
(define (sx-list tag . rest)
|
||||
(cond
|
||||
((null? rest) (list tag))
|
||||
((not (car rest)) (apply list tag (cdr rest)))
|
||||
(else (apply list tag rest))))
|
||||
|
||||
;; @deffn {Procedure} sx-tail sx [ix] => (list)
|
||||
;; Return the ix-th tail starting after the tag and attribut list, where
|
||||
;; @var{ix} must be positive. For example,
|
||||
;; @example
|
||||
;; (sx-tail '(tag (@ (abc . "123")) (foo) (bar)) 1) => ((foo) (bar))
|
||||
;; @end example
|
||||
;; Without second argument @var{ix} is 1.
|
||||
;; @end deffn
|
||||
(define sx-tail
|
||||
(case-lambda
|
||||
((sx ix)
|
||||
(cond
|
||||
((zero? ix) (error "sx-tail: expecting index greater than 0"))
|
||||
((and (pair? (cadr sx)) (eqv? '@ (caadr sx))) (list-tail sx (1+ ix)))
|
||||
(else (list-tail sx ix))))
|
||||
((sx)
|
||||
(sx-tail sx 1))))
|
||||
|
||||
;; @deffn {Procedure} sx-has-attr? sx
|
||||
;; p to determine if @arg{sx} has attributes.
|
||||
;; @end deffn
|
||||
(define (sx-has-attr? sx)
|
||||
(and (pair? (cdr sx)) (pair? (cadr sx)) (eqv? '@ (caadr sx))))
|
||||
|
||||
;; @deffn {Procedure} sx-attr sx => '(@ ...)|#f
|
||||
;; @example
|
||||
;; (sx-attr '(abc (@ (foo "1")) def) 1) => '(@ (foo "1"))
|
||||
;; @end example
|
||||
;; should change this to
|
||||
;; @example
|
||||
;; (sx-attr sx) => '((a . 1) (b . 2) ...)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (sx-attr sx)
|
||||
(if (and (pair? (cdr sx)) (pair? (cadr sx)))
|
||||
(if (eqv? '@ (caadr sx))
|
||||
(cadr sx)
|
||||
#f)
|
||||
#f))
|
||||
|
||||
;; @deffn {Procedure} sx-attr-ref sx key => val
|
||||
;; Return an attribute value given the key, or @code{#f}.
|
||||
;; @end deffn
|
||||
(define (sx-attr-ref sx key)
|
||||
(and=> (sx-attr sx)
|
||||
(lambda (attr)
|
||||
(and=> (assq-ref (cdr attr) key) car))))
|
||||
|
||||
;; @deffn {Procedure} sx-set-attr! sx key val
|
||||
;; Set attribute for sx. If no attributes exist, if key does not exist,
|
||||
;; add it, if it does exist, replace it.
|
||||
;; @end deffn
|
||||
(define (sx-set-attr! sx key val . rest)
|
||||
(if (sx-has-attr? sx)
|
||||
(let ((attr (cadr sx)))
|
||||
(set-cdr! attr (assoc-set! (cdr attr) key (list val))))
|
||||
(set-cdr! sx (cons `(@ (,key ,val)) (cdr sx))))
|
||||
sx)
|
||||
|
||||
;; @deffn sx-set-attr* sx key val [key val [key ... ]]
|
||||
;; Generate sx with added or changed attributes.
|
||||
;; @end deffn
|
||||
(define (sx-set-attr* sx . rest)
|
||||
(let iter ((attr (or (and=> (sx-attr sx) cdr) '())) (kvl rest))
|
||||
(cond
|
||||
((null? kvl) (cons* (sx-tag sx) (cons '@ (reverse attr)) (sx-tail sx 1)))
|
||||
(else (iter (cons (list (car kvl) (cadr kvl)) attr) (cddr kvl))))))
|
||||
|
||||
;; @deffn sx-find tag sx => ((tag ...) (tag ...))
|
||||
;; Find the first matching element (in the first level).
|
||||
;; @end deffn
|
||||
(define (sx-find tag sx)
|
||||
(find (lambda (node)
|
||||
(and (pair? node) (eqv? tag (car node))))
|
||||
sx))
|
||||
|
||||
;;; === pp ==========================
|
||||
;; @section Pretty-Print and Other Utility Procedures
|
||||
|
||||
;; @deffn {Procedure} make-protect-expr op-prec op-assc => side op expr => #t|#f
|
||||
;; Generate procedure @code{protect-expr} for pretty-printers, which takes
|
||||
;; the form @code{(protect-expr? side op expr)} and where @code{side}
|
||||
;; is @code{'lval} or @code{'rval}, @code{op} is the operator and @code{expr}
|
||||
;; is the expression. The argument @arg{op-prec} is a list of equivalent
|
||||
;; operators in order of decreasing precedence and @arg{op-assc} is an
|
||||
;; a-list of precedence with keys @code{'left}, @code{'right} and
|
||||
;; @code{nonassoc}.
|
||||
;; @example
|
||||
;; (protect-expr? 'left '+ '(mul ...)) => TBD
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (make-protect-expr op-prec op-assc)
|
||||
|
||||
(define (assc-lt? op)
|
||||
(memq op (assq-ref op-assc 'left)))
|
||||
|
||||
(define (assc-rt? op)
|
||||
(memq op (assq-ref op-assc 'right)))
|
||||
|
||||
;; @deffn {Procedure} prec a b => '>|'<|'=|#f
|
||||
;; Returns the prececence relation of @code{a}, @code{b} as
|
||||
;; @code{<}, @code{>}, @code{=} or @code{#f} (no relation).
|
||||
;; @end deffn
|
||||
(define (prec a b)
|
||||
(let iter ((ag #f) (bg #f) (opg op-prec)) ;; a-group, b-group
|
||||
(cond
|
||||
((null? opg) #f) ; indeterminate
|
||||
((memq a (car opg))
|
||||
(if bg '<
|
||||
(if (memq b (car opg)) '=
|
||||
(iter #t bg (cdr opg)))))
|
||||
((memq b (car opg))
|
||||
(if ag '>
|
||||
(if (memq a (car opg)) '=
|
||||
(iter ag #t (cdr opg)))))
|
||||
(else
|
||||
(iter ag bg (cdr opg))))))
|
||||
|
||||
(lambda (side op expr)
|
||||
(let ((assc? (case side
|
||||
((lt lval left) assc-rt?)
|
||||
((rt rval right) assc-lt?)))
|
||||
(vtag (car expr)))
|
||||
(case (prec op vtag)
|
||||
((>) #t)
|
||||
((<) #f)
|
||||
((=) (assc? op))
|
||||
(else #f)))))
|
||||
|
||||
;; @deffn {Procedure} make-pp-formatter [port] [#:per-line-prefix ""] => fmtr
|
||||
;; @example
|
||||
;; (fmtr 'push) ;; push indent level
|
||||
;; (fmtr 'pop) ;; pop indent level
|
||||
;; (fmtr "fmt" arg1 arg2 ...)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define* (make-pp-formatter #:optional (port (current-output-port))
|
||||
#:key per-line-prefix)
|
||||
(letrec
|
||||
((maxcol (- 78 (if per-line-prefix (string-length per-line-prefix) 0)))
|
||||
;;(maxcol 78)
|
||||
(maxind 36)
|
||||
(column 0)
|
||||
(ind-lev 0)
|
||||
(ind-len 0)
|
||||
(blanks " ")
|
||||
(ind-str (lambda () (substring blanks 0 ind-len)))
|
||||
(cnt-str (lambda () (substring blanks 0 (+ 4 ind-len))))
|
||||
;;(sf-nl (lambda () (newline) (set! column 0)))
|
||||
|
||||
(push-il
|
||||
(lambda ()
|
||||
(set! ind-lev (min maxind (1+ ind-lev)))
|
||||
(set! ind-len (* 2 ind-lev))))
|
||||
|
||||
(pop-il
|
||||
(lambda ()
|
||||
(set! ind-lev (max 0 (1- ind-lev)))
|
||||
(set! ind-len (* 2 ind-lev))))
|
||||
|
||||
(inc-column!
|
||||
(lambda (inc)
|
||||
(set! column (+ column inc))))
|
||||
|
||||
(set-column!
|
||||
(lambda (val)
|
||||
(set! column val)))
|
||||
|
||||
(sf
|
||||
(lambda (fmt . args)
|
||||
(let* ((str (apply simple-format #f fmt args))
|
||||
(len (string-length str)))
|
||||
(cond
|
||||
((zero? column)
|
||||
(if per-line-prefix (display per-line-prefix port))
|
||||
(display (ind-str) port)
|
||||
(inc-column! ind-len))
|
||||
((> (+ column len) maxcol)
|
||||
(newline port)
|
||||
(if per-line-prefix (display per-line-prefix port))
|
||||
(display (cnt-str) port)
|
||||
(set-column! (+ ind-len 4))))
|
||||
(display str port)
|
||||
(inc-column! len)
|
||||
(when (and (positive? len)
|
||||
(eqv? #\newline (string-ref str (1- len))))
|
||||
(set! column 0))))))
|
||||
|
||||
(lambda (arg0 . rest)
|
||||
(cond
|
||||
;;((string? arg0) (if (> (string-length arg0) 0) (apply sf arg0 rest)))
|
||||
((string? arg0) (apply sf arg0 rest))
|
||||
((eqv? 'push arg0) (push-il))
|
||||
((eqv? 'pop arg0) (pop-il))
|
||||
((eqv? 'nlin arg0) ;; newline if needed
|
||||
(cond ((positive? column) (newline) (set! column 0))))
|
||||
(else (error "pp-formatter: bad args"))
|
||||
))))
|
||||
|
||||
;; @deffn {Procedure} make-pp-formatter/ugly => fmtr
|
||||
;; Makes a @code{fmtr} like @code{make-pp-formatter} but no indentation
|
||||
;; and just adds strings on ...
|
||||
;; This is specific to C/C++ because it will newline if #\# seen first.
|
||||
;; @end deffn
|
||||
(define* (make-pp-formatter/ugly)
|
||||
(let*
|
||||
((maxcol 78)
|
||||
(column 0)
|
||||
(sf (lambda (fmt . args)
|
||||
(let* ((str (apply simple-format #f fmt args))
|
||||
(len (string-length str)))
|
||||
(if (and (positive? len)
|
||||
(char=? #\newline (string-ref str (1- len))))
|
||||
(string-set! str (1- len) #\space))
|
||||
(cond
|
||||
((zero? len) #t) ; we reference str[0] next
|
||||
((and (equal? len 1) (char=? #\newline (string-ref str 0))) #t)
|
||||
((char=? #\# (string-ref str 0)) ; CPP-stmt: force newline
|
||||
(when (positive? column) (newline))
|
||||
(display str) ; str always ends in \n
|
||||
(set! column ; if ends \n then col= 0 else len
|
||||
(if (char=? #\newline (string-ref str (1- len)))
|
||||
0 len)))
|
||||
((zero? column)
|
||||
(display str)
|
||||
(set! column len))
|
||||
(else
|
||||
(when (> (+ column len) maxcol)
|
||||
(newline)
|
||||
(set! column 0))
|
||||
(display str)
|
||||
(set! column (+ column len))))))))
|
||||
|
||||
(lambda (arg0 . rest)
|
||||
(cond
|
||||
((string? arg0) (apply sf arg0 rest))
|
||||
((eqv? 'nlin arg0) ;; newline if needed
|
||||
(cond ((positive? column) (newline) (set! column 0))))
|
||||
((eqv? 'push arg0) #f)
|
||||
((eqv? 'pop arg0) #f)
|
||||
(else (error "pp-formatter/ugly: bad args"))))))
|
||||
|
||||
;; @deffn {Procedure} move-if-changed src-file dst-file [sav-file]
|
||||
;; Return @code{#t} if changed.
|
||||
;; @end deffn
|
||||
(define (move-if-changed src-file dst-file . rest)
|
||||
|
||||
(define (doit)
|
||||
(let ((sav-file (if (pair? rest) (car rest) #f)))
|
||||
(if (and sav-file (access? sav-file W_OK))
|
||||
(system (simple-format #f "mv ~A ~A" dst-file sav-file)))
|
||||
(system (simple-format #f "mv ~A ~A" src-file dst-file))
|
||||
#t))
|
||||
|
||||
(cond
|
||||
;; src-file does not exist
|
||||
((not (access? src-file R_OK)) #f)
|
||||
|
||||
;; dst-file does not exist, update anyhow
|
||||
((not (access? dst-file F_OK))
|
||||
(system (simple-format #f "mv ~A ~A" src-file dst-file)) #t)
|
||||
|
||||
;; both exist, but no changes
|
||||
((zero? (system
|
||||
(simple-format #f "cmp ~A ~A >/dev/null" src-file dst-file)))
|
||||
(system (simple-format #f "rm ~A" src-file)) #f)
|
||||
|
||||
;; both exist, update
|
||||
((access? dst-file W_OK)
|
||||
(doit))
|
||||
|
||||
(else
|
||||
(simple-format (current-error-port) "move-if-changed: no write access\n")
|
||||
#f)))
|
||||
|
||||
;; @end table
|
||||
|
||||
;;; --- last line ---
|
|
@ -1,588 +0,0 @@
|
|||
;;; nyacc/lex.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2015-2017 - Matthew R.Wette
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or modify it
|
||||
;;; under the terms of the GNU Lesser General Public License as published by
|
||||
;;; the Free Software Foundation; either version 3 of the License, or (at
|
||||
;;; your option) any later version.
|
||||
;;;
|
||||
;;; This library 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
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public License
|
||||
;;; along with this library; if not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
;; A module providing procedures for constructing lexical analyzers.
|
||||
|
||||
;; '$fixed '$float '$string '$chlit '$ident
|
||||
|
||||
;; todo: change lexer to return @code{cons-source} instead of @code{cons}
|
||||
;; todo: to be fully compliant, C readers need to deal with \ at end of line
|
||||
|
||||
;; todo: figure out what readers return atoms and which pairs
|
||||
;; tokens: read-c-ident
|
||||
;; pairs: num-reader read-c-num read-c-string
|
||||
;; issue: if returning pairs we need this for hashed parsers:
|
||||
;; (define (assc-$ pair) (cons (assq-ref symbols (car pair)) (cdr pair)))
|
||||
;; read-comm changed to (read-comm ch bol) where bol is begin-of-line cond
|
||||
;;
|
||||
;; read-c-ident
|
||||
|
||||
(define-module (nyacc lex)
|
||||
#:export (make-lexer-generator
|
||||
make-ident-reader
|
||||
make-comm-reader
|
||||
make-string-reader
|
||||
make-chseq-reader
|
||||
make-num-reader
|
||||
eval-reader
|
||||
make-like-ident-p
|
||||
read-c-ident
|
||||
read-c-comm
|
||||
read-c-string
|
||||
read-c-chlit
|
||||
read-c-num
|
||||
read-oct read-hex
|
||||
like-c-ident?
|
||||
cnumstr->scm
|
||||
filter-mt remove-mt map-mt make-ident-like-p
|
||||
c:ws c:if c:ir)
|
||||
#:use-module ((srfi srfi-1) #:select (remove append-reverse))
|
||||
#:use-module (ice-9 pretty-print)
|
||||
)
|
||||
|
||||
;; @section Constructing Lexical Analyzers
|
||||
;; The @code{lex} module provides a set of procedures to build lexical
|
||||
;; analyzers. The approach is to first build a set of @defn{readers} for
|
||||
;; MORE TO COME
|
||||
;;
|
||||
;; Readers are procecures that take one character (presumably from the
|
||||
;; current-input-port) and determine try to make a match. If a match is
|
||||
;; made something is returned, with any lookaheads pushed back into the
|
||||
;; input port. If no match is made @code{#f} is returned and the input
|
||||
;; argument is still the character to work on.
|
||||
;;
|
||||
;; Here are the procedures used:
|
||||
;; @table @code
|
||||
|
||||
(define digit "0123456789")
|
||||
(define ucase "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
(define lcase "abcdefghijklmnopqrstuvwxyz")
|
||||
|
||||
;; C lexemes are popular so include those.
|
||||
;;(define c:ws (list->char-set '(#\space #\tab #\newline #\return )))
|
||||
(define c:ws char-set:whitespace)
|
||||
(define c:if (let ((cs (char-set #\_))) ; ident, first char
|
||||
(string->char-set! ucase cs)
|
||||
(string->char-set! lcase cs)))
|
||||
(define c:ir (string->char-set digit c:if)) ; ident, rest chars
|
||||
(define c:nx (string->char-set "eEdD")) ; number exponent
|
||||
(define c:hx (string->char-set "abcdefABCDEF"))
|
||||
(define c:sx (string->char-set "lLuU")) ; suffix
|
||||
|
||||
(define (lsr chl) (list->string (reverse chl))) ; used often
|
||||
|
||||
;; @deffn {Procedure} eval-reader reader string => result
|
||||
;; For test and debug, this procedure will evaluate a reader on a string.
|
||||
;; A reader is a procedure that accepts a single character argument intended
|
||||
;; to match a specific character sequence. A reader will read more characters
|
||||
;; by evaluating @code{read-char} until it matches or fails. If it fails, it
|
||||
;; will pushback all characters read via @code{read-char} and return @code{#f}.
|
||||
;; If it succeeds the input pointer will be at the position following the
|
||||
;; last matched character.
|
||||
;; @end deffn
|
||||
(define (eval-reader reader string)
|
||||
(with-input-from-string string
|
||||
(lambda () (reader (read-char)))))
|
||||
|
||||
;; @deffn {Procedure} make-space-skipper chset => proc
|
||||
;; This routine will generate a reader to skip whitespace.
|
||||
;; @end deffn
|
||||
(define (make-space-skipper chset)
|
||||
(lambda (ch)
|
||||
(if (char-set-contains? chset ch)
|
||||
(let iter ((ch (read-char)))
|
||||
(cond
|
||||
((char-set-contains? chset ch)
|
||||
(iter (read-char)))
|
||||
(else
|
||||
(unread-char ch)
|
||||
#t)))
|
||||
#f)))
|
||||
|
||||
;; @deffn {Procedure} skip-c-space ch => #f|#t
|
||||
;; If @code{ch} is space, skip all spaces, then return @code{#t}, else
|
||||
;; return @code{#f}.
|
||||
;; @end deffn
|
||||
(define skip-c-space (make-space-skipper c:ws))
|
||||
|
||||
|
||||
;; @deffn {Procedure} make-ident-reader cs-first cs-rest => ch -> #f|string
|
||||
;; For identifiers, given the char-set for first character and the char-set
|
||||
;; for following characters, return a return a reader for identifiers.
|
||||
;; The reader takes a character as input and returns @code{#f} or @code{string}.
|
||||
;; This will generate exception on @code{#<eof>}.
|
||||
;; @end deffn
|
||||
(define (make-ident-reader cs-first cs-rest)
|
||||
(lambda (ch)
|
||||
(if (char-set-contains? cs-first ch)
|
||||
(let iter ((chl (list ch)) (ch (read-char)))
|
||||
(cond
|
||||
((eof-object? ch)
|
||||
(if (null? chl) #f
|
||||
(lsr chl)))
|
||||
((char-set-contains? cs-rest ch)
|
||||
(iter (cons ch chl) (read-char)))
|
||||
(else (unread-char ch)
|
||||
(lsr chl))))
|
||||
#f)))
|
||||
|
||||
;; @deffn {Procedure} read-c-ident ch => #f|string
|
||||
;; If ident pointer at following char, else (if #f) ch still last-read.
|
||||
;; @end deffn
|
||||
(define read-c-ident (make-ident-reader c:if c:ir))
|
||||
|
||||
;; @deffn {Procedure} make-ident-like-p ident-reader
|
||||
;; Generate a predicate, from a reader, that determines if a string qualifies
|
||||
;; as an identifier.
|
||||
;; @end deffn
|
||||
(define (make-like-ident-p reader)
|
||||
(lambda (s) (and (string? s) (eval-reader reader s))))
|
||||
(define make-ident-like-p make-like-ident-p)
|
||||
(define like-c-ident? (make-like-ident-p read-c-ident))
|
||||
|
||||
|
||||
;; @deffn {Procedure} make-string-reader delim
|
||||
;; Generate a reader that uses @code{delim} as delimiter for strings.
|
||||
;; TODO: need to handle matlab-type strings.
|
||||
;; TODO: need to handle multiple delim's (like python)
|
||||
;; @end deffn
|
||||
(define (make-string-reader delim) ;; #:xxx
|
||||
(lambda (ch)
|
||||
(if (eq? ch delim)
|
||||
(let iter ((cl '()) (ch (read-char)))
|
||||
(cond ((eq? ch #\\)
|
||||
(let ((c1 (read-char)))
|
||||
(if (eq? c1 #\newline)
|
||||
(iter cl (read-char))
|
||||
(iter (cons* c1 cl) (read-char)))))
|
||||
((eq? ch delim) (cons '$string (lsr cl)))
|
||||
(else (iter (cons ch cl) (read-char)))))
|
||||
#f)))
|
||||
|
||||
;; @deffn {Procedure} read-oct ch => "0123"|#f
|
||||
;; Read octal number.
|
||||
;; @end deffn
|
||||
(define read-oct
|
||||
(let ((cs:oct (string->char-set "01234567")))
|
||||
(lambda (ch)
|
||||
(let iter ((cv 0) (ch ch) (n 1))
|
||||
(cond
|
||||
((eof-object? ch) cv)
|
||||
((> n 3) (unread-char ch) cv)
|
||||
((char-set-contains? cs:oct ch)
|
||||
(iter (+ (* 8 cv) (- (char->integer ch) 48)) (read-char) (1+ n)))
|
||||
(else
|
||||
(unread-char ch)
|
||||
cv))))))
|
||||
|
||||
;; @deffn {Procedure} read-hex ch => "0x7f"|#f
|
||||
;; Read octal number.
|
||||
;; @end deffn
|
||||
(define read-hex
|
||||
(let ((cs:dig (string->char-set "0123456789"))
|
||||
(cs:uhx (string->char-set "ABCDEF"))
|
||||
(cs:lhx (string->char-set "abcdef")))
|
||||
(lambda (ch) ;; ch == #\x always
|
||||
(let iter ((cv 0) (ch (read-char)) (n 0))
|
||||
(simple-format #t "ch=~S\n" ch)
|
||||
(cond
|
||||
((eof-object? ch) cv)
|
||||
((> n 2) (unread-char ch) cv)
|
||||
((char-set-contains? cs:dig ch)
|
||||
(iter (+ (* 16 cv) (- (char->integer ch) 48)) (read-char) (1+ n)))
|
||||
((char-set-contains? cs:uhx ch)
|
||||
(iter (+ (* 16 cv) (- (char->integer ch) 55)) (read-char) (1+ n)))
|
||||
((char-set-contains? cs:lhx ch)
|
||||
(iter (+ (* 16 cv) (- (char->integer ch) 87)) (read-char) (1+ n)))
|
||||
(else (unread-char ch) cv))))))
|
||||
|
||||
;; @deffn {Procedure} read-c-string ch => ($string . "foo")
|
||||
;; Read a C-code string. Output to code is @code{write} not @code{display}.
|
||||
;; Return #f if @var{ch} is not @code{"}. @*
|
||||
;; TODO: parse trigraphs
|
||||
;; ??=->#, ??/->\, ??'->^, ??(->[, ??)->], ??~->|, ??<->{, ??>->}, ??-->~
|
||||
;; and digraphs <:->[, :>->], <%->{ %>->} %:->#
|
||||
;; @end deffn
|
||||
(define (read-c-string ch)
|
||||
(if (not (eq? ch #\")) #f
|
||||
(let iter ((cl '()) (ch (read-char)))
|
||||
(cond ((eq? ch #\\)
|
||||
(let ((c1 (read-char)))
|
||||
(iter
|
||||
(case c1
|
||||
((#\newline) cl)
|
||||
((#\\) (cons #\\ cl))
|
||||
((#\") (cons #\" cl))
|
||||
((#\') (cons #\' cl))
|
||||
((#\n) (cons #\newline cl))
|
||||
((#\r) (cons #\return cl))
|
||||
((#\b) (cons #\backspace cl))
|
||||
((#\t) (cons #\tab cl))
|
||||
((#\f) (cons #\page cl))
|
||||
((#\a) (cons #\alarm cl))
|
||||
((#\v) (cons #\vtab cl))
|
||||
((#\x) (cons (integer->char (read-hex ch)) cl))
|
||||
(else
|
||||
(if (char-numeric? ch)
|
||||
(cons (integer->char (read-oct ch)) cl)
|
||||
(cons c1 cl))))
|
||||
(read-char))))
|
||||
((eq? ch #\") (cons '$string (lsr cl)))
|
||||
(else (iter (cons ch cl) (read-char)))))))
|
||||
|
||||
;; @deffn {Procedure} make-chlit-reader
|
||||
;; Generate a reader for character literals. NOT DONE.
|
||||
;; For C, this reads @code{'c'} or @code{'\n'}.
|
||||
;; @end deffn
|
||||
(define (make-chlit-reader . rest) (error "NOT IMPLEMENTED"))
|
||||
|
||||
;; @deffn {Procedure} read-c-chlit ch
|
||||
;; @example
|
||||
;; ... 'c' ... => (read-c-chlit #\') => '($ch-lit . #\c)
|
||||
;; @end example
|
||||
;; @end deffn
|
||||
(define (read-c-chlit ch)
|
||||
(if (not (eqv? ch #\')) #f
|
||||
(let ((c1 (read-char)) (c2 (read-char)))
|
||||
(if (eqv? c1 #\\)
|
||||
(let ((c3 (read-char)))
|
||||
(cons '$chlit
|
||||
(case c2
|
||||
((#\0) "\0") ; nul U+0000 (#\U+...)
|
||||
((#\a) "\a") ; alert U+0007
|
||||
((#\b) "\b") ; backspace U+0008
|
||||
((#\t) "\t") ; horizontal tab U+0009
|
||||
((#\n) "\n") ; newline U+000A
|
||||
((#\v) "\v") ; verticle tab U+000B
|
||||
((#\f) "\f") ; formfeed U+000C
|
||||
((#\\) "\\") ; backslash
|
||||
((#\' #\" #\?) (string c2))
|
||||
(else (error "bad escape sequence")))))
|
||||
(cons '$chlit (string c1))))))
|
||||
|
||||
(define (fix-dot l) (if (char=? #\. (car l)) (cons #\0 l) l))
|
||||
|
||||
;; @deffn {Procedure} make-num-reader => (proc ch) => #f|($fixed . "1")|($float . "1.0")
|
||||
;; Reads C numbers.
|
||||
;; This routine will clean by adding "0" before or after dot.
|
||||
;; may want to replace "eEdD" w/ "e"
|
||||
;; integer decimal(#t/#f) fraction exponent looking-at
|
||||
;; i, f and e are lists of characters
|
||||
;; @end deffn
|
||||
(define (make-num-reader)
|
||||
;; 0: start; 1: p-i; 2: p-f; 3: p-e-sign; 4: p-e-d; 5: packup
|
||||
;; Removed support for leading '.' to be a number.
|
||||
(lambda (ch1)
|
||||
;; chl: char list; ty: '$fixed or '$float; st: state; ch: input char
|
||||
(let iter ((chl '()) (ty #f) (st 0) (ch ch1))
|
||||
(case st
|
||||
((0)
|
||||
(cond
|
||||
((eof-object? ch) (iter chl ty 5 ch))
|
||||
((char=? #\0 ch) (iter (cons ch chl) '$fixed 10 (read-char)))
|
||||
((char-numeric? ch) (iter chl '$fixed 1 ch))
|
||||
(else #f)))
|
||||
((10) ;; allow x after 0
|
||||
(cond
|
||||
((eof-object? ch) (iter chl ty 5 ch))
|
||||
((char=? #\x ch) (iter (cons ch chl) ty 1 (read-char)))
|
||||
(else (iter chl ty 1 ch))))
|
||||
((1)
|
||||
(cond
|
||||
((eof-object? ch) (iter chl ty 5 ch))
|
||||
((char-numeric? ch) (iter (cons ch chl) ty 1 (read-char)))
|
||||
((char=? #\. ch) (iter (cons #\. chl) '$float 2 (read-char)))
|
||||
((char-set-contains? c:hx ch)
|
||||
(iter (cons ch chl) ty 1 (read-char)))
|
||||
((char-set-contains? c:sx ch)
|
||||
(iter (cons ch chl) ty 11 (read-char)))
|
||||
((char-set-contains? c:if ch) (error "lex/num-reader st=1"))
|
||||
(else (iter chl '$fixed 5 ch))))
|
||||
((11) ;; got l L u or U, look for l or L
|
||||
(cond
|
||||
((eof-object? ch) (cons '$fixed (lsr chl)))
|
||||
((char=? #\L ch) (cons '$fixed (lsr (cons ch chl))))
|
||||
((char=? #\l ch) (cons '$fixed (lsr (cons ch chl))))
|
||||
(else (iter chl '$fixed 5 ch))))
|
||||
((2)
|
||||
(cond
|
||||
((eof-object? ch) (iter chl ty 5 ch))
|
||||
((char-numeric? ch) (iter (cons ch chl) ty 2 (read-char)))
|
||||
((char-set-contains? c:nx ch)
|
||||
(iter (cons ch (fix-dot chl)) ty 3 (read-char)))
|
||||
((char-set-contains? c:if ch) (error "lex/num-reader st=2"))
|
||||
(else (iter (fix-dot chl) ty 5 ch))))
|
||||
((3)
|
||||
(cond
|
||||
((eof-object? ch) (iter chl ty 5 ch))
|
||||
((or (char=? #\+ ch) (char=? #\- ch))
|
||||
(iter (cons ch chl) ty 4 (read-char)))
|
||||
((char-numeric? ch) (iter chl ty 4 ch))
|
||||
(else (error "syntax3"))))
|
||||
((4)
|
||||
(cond
|
||||
((eof-object? ch) (iter chl ty 5 ch))
|
||||
((char-numeric? ch) (iter (cons ch chl) ty 4 (read-char)))
|
||||
((char-set-contains? c:if ch) (error "lex/num-reader st=4"))
|
||||
(else (iter chl ty 5 ch))))
|
||||
((5)
|
||||
(unless (eof-object? ch) (unread-char ch))
|
||||
(cons ty (lsr chl)))))))
|
||||
|
||||
;; @deffn {Procedure} cnumstr->scm C99-str => scm-str
|
||||
;; Convert C number-string (e.g, @code{0x123LL}) to Scheme numbers-string
|
||||
;; (e.g., @code{#x123}).
|
||||
;; @end deffn
|
||||
(define (cnumstr->scm str)
|
||||
(define (2- n) (1- (1- n)))
|
||||
(let* ((nd (string-length str)))
|
||||
(define (trim-rt st) ;; trim LlUu from right
|
||||
(if (char-set-contains? c:sx (string-ref str (1- nd)))
|
||||
(if (char-set-contains? c:sx (string-ref str (2- nd)))
|
||||
(substring str st (2- nd))
|
||||
(substring str st (1- nd)))
|
||||
(substring str st nd)))
|
||||
(if (< nd 2) str
|
||||
(if (char=? #\0 (string-ref str 0))
|
||||
(if (char=? #\x (string-ref str 1))
|
||||
(string-append "#x" (trim-rt 2))
|
||||
(if (char-numeric? (string-ref str 1))
|
||||
(string-append "#o" (trim-rt 1))
|
||||
(trim-rt 0)))
|
||||
(trim-rt 0)))))
|
||||
|
||||
;; @deffn {Procedure} read-c-num ch => #f|string
|
||||
;; Reader for unsigned numbers as used in C (or close to it).
|
||||
;; @end deffn
|
||||
(define read-c-num (make-num-reader))
|
||||
|
||||
;;.@deffn {Procedure} si-map string-list ix => a-list
|
||||
;; Convert list of strings to alist of char at ix and strings.
|
||||
;; This is a helper for make-tree.
|
||||
;; @end deffn
|
||||
(define (si-map string-list ix)
|
||||
(let iter ((sal '()) (sl string-list))
|
||||
(cond
|
||||
((null? sl) sal)
|
||||
((= ix (string-length (car sl)))
|
||||
(iter (reverse (acons 'else (car sl) sal)) (cdr sl)))
|
||||
((assq (string-ref (car sl) ix) sal) =>
|
||||
(lambda (pair)
|
||||
(set-cdr! pair (cons (car sl) (cdr pair)))
|
||||
(iter sal (cdr sl))))
|
||||
(else ;; Add (#\? . string) to alist.
|
||||
(iter (cons (cons (string-ref (car sl) ix) (list (car sl))) sal)
|
||||
(cdr sl))))))
|
||||
|
||||
;;.@deffn {Procedure} make-tree strtab -> tree
|
||||
;; This routine takes an alist of strings and symbols and makes a tree
|
||||
;; that parses one char at a time and provide @code{'else} entry for
|
||||
;; signaling sequence found. That is, if @code{("ab" . 1)} is an entry
|
||||
;; then a chseq-reader (see below) would stop at @code{"ab"} and
|
||||
;; return @code{1}.
|
||||
;; @end deffn
|
||||
(define (make-tree strtab)
|
||||
(define (si-cnvt string-list ix)
|
||||
(map (lambda (pair)
|
||||
(if (pair? (cdr pair))
|
||||
(cons (car pair) (si-cnvt (cdr pair) (1+ ix)))
|
||||
(cons (car pair) (assq-ref strtab (cdr pair)))))
|
||||
(si-map string-list ix)))
|
||||
(si-cnvt (map car strtab) 0))
|
||||
|
||||
;; @deffn {Procedure} make-chseq-reader strtab
|
||||
;; Given alist of pairs (string, token) return a function that eats chars
|
||||
;; until (token . string) is returned or @code{#f} if no match is found.
|
||||
;; @end deffn
|
||||
(define (make-chseq-reader strtab)
|
||||
;; This code works on the assumption that the else-part is always last
|
||||
;; in the list of transitions.
|
||||
(let ((tree (make-tree strtab)))
|
||||
(lambda (ch)
|
||||
(let iter ((cl (list ch)) (node tree))
|
||||
(cond
|
||||
((assq-ref node (car cl)) => ;; accept or shift next character
|
||||
(lambda (n)
|
||||
(if (eq? (caar n) 'else) ; if only else, accept, else read on
|
||||
(cons (cdar n) (lsr cl))
|
||||
(iter (cons (read-char) cl) n))))
|
||||
((assq-ref node 'else) => ; else exists, accept
|
||||
(lambda (tok)
|
||||
(unread-char (car cl))
|
||||
(cons tok (lsr (cdr cl)))))
|
||||
(else ;; reject
|
||||
(let pushback ((cl cl))
|
||||
(unless (null? (cdr cl))
|
||||
(unread-char (car cl))
|
||||
(pushback (cdr cl))))
|
||||
#f))))))
|
||||
|
||||
;; @deffn {Procedure} make-comm-reader comm-table [#:eat-newline #t] => \
|
||||
;; ch bol -> ('$code-comm "..")|('$lone-comm "..")|#f
|
||||
;; comm-table is list of cons for (start . end) comment.
|
||||
;; e.g. ("--" . "\n") ("/*" . "*/")
|
||||
;; test with "/* hello **/"
|
||||
;; If @code{eat-newline} is specified as true then for read comments
|
||||
;; ending with a newline a newline swallowed with the comment.
|
||||
;; Note: assumes backslash is never part of the end
|
||||
;; @end deffn
|
||||
(define* (make-comm-reader comm-table #:key (eat-newline #f))
|
||||
|
||||
(define (mc-read-char) ;; CHECK THIS
|
||||
(let ((ch (read-char)))
|
||||
(if (eqv? ch #\\)
|
||||
(let ((ch (read-char)))
|
||||
(if (eqv? ch #\newline)
|
||||
(read-char)
|
||||
(begin (unread-char ch) #\\)))
|
||||
ch)))
|
||||
|
||||
(let ((tree (make-tree comm-table)))
|
||||
(lambda (ch bol)
|
||||
(letrec
|
||||
((tval (if bol '$lone-comm '$code-comm))
|
||||
(match-beg ;; match start of comment, return end-string
|
||||
(lambda (cl node)
|
||||
(cond
|
||||
((assq-ref node (car cl)) => ;; shift next character
|
||||
(lambda (n) (match-beg (cons (mc-read-char) cl) n)))
|
||||
((assq-ref node 'else) =>
|
||||
(lambda (res) (unread-char (car cl)) res)) ; yuck?
|
||||
(else
|
||||
(let pushback ((cl cl))
|
||||
(unless (null? (cdr cl))
|
||||
(unread-char (car cl))
|
||||
(pushback (cdr cl))))
|
||||
#f))))
|
||||
(find-end ;; find end of comment, return comment
|
||||
;; cl: comm char list; sl: shift list; il: input list;
|
||||
;; ps: pattern string; px: pattern index
|
||||
(lambda (cl sl il ps px)
|
||||
(cond
|
||||
((eq? px (string-length ps))
|
||||
(if (and (not eat-newline) (eq? #\newline (car sl)))
|
||||
(unread-char #\newline))
|
||||
(if (and (pair? cl) (eqv? (car cl) #\cr)) ;; rem trailing \r
|
||||
(cons tval (lsr (cdr cl)))
|
||||
(cons tval (lsr cl))))
|
||||
((null? il) (find-end cl sl (cons (mc-read-char) il) ps px))
|
||||
;;((eof-object? (car il)) (error "open comment" cl))
|
||||
((eof-object? (car il))
|
||||
(if (char=? (string-ref ps px) #\newline) (lsr cl)
|
||||
(throw 'nyacc-error "open comment")))
|
||||
((eqv? (car il) (string-ref ps px))
|
||||
(find-end cl (cons (car il) sl) (cdr il) ps (1+ px)))
|
||||
(else
|
||||
(let ((il1 (append-reverse sl il)))
|
||||
(find-end (cons (car il1) cl) '() (cdr il1) ps 0)))))))
|
||||
(let ((ep (match-beg (list ch) tree))) ;; ep == end pattern?
|
||||
(if ep (find-end '() '() (list (mc-read-char)) ep 0) #f))))))
|
||||
|
||||
(define read-c-comm (make-comm-reader '(("/*" . "*/") ("//" . "\n"))))
|
||||
|
||||
;; @deffn {Procedure} filter-mt p? al => al
|
||||
;; Filter match-table based on cars of al.
|
||||
;; @end deffn
|
||||
(define (filter-mt p? al) (filter (lambda (x) (p? (car x))) al))
|
||||
|
||||
;; @deffn {Procedure} remove-mt p? al => al
|
||||
;; Remove match-table based on cars of al.
|
||||
;; @end deffn
|
||||
(define (remove-mt p? al) (remove (lambda (x) (p? (car x))) al))
|
||||
|
||||
;; @deffn {Procedure} map-mt f al => al
|
||||
;; Map cars of al.
|
||||
;; @end deffn
|
||||
(define (map-mt f al) (map (lambda (x) (cons (f (car x)) (cdr x))) al))
|
||||
|
||||
;; @deffn {Procedure} make-lexer-generator match-table => lexer-generator
|
||||
;; @example
|
||||
;; (define gen-lexer (make-lexer-generator #:ident-reader my-id-rdr))
|
||||
;; (with-input-from-file "foo" (parse (gen-lexer)))
|
||||
;; @end example
|
||||
;;
|
||||
;; Return a thunk that returns tokens.
|
||||
;; Change this to have user pass the following routines (optionally?)
|
||||
;; read-num, read-ident, read-comm
|
||||
;; reztab = reserved ($ident, $fixed, $float ...
|
||||
;; chrtab = characters
|
||||
;; comm-reader : if parser does not deal with comments must return #f
|
||||
;; but problem with character ..
|
||||
;; match-table:
|
||||
;; @enumerate
|
||||
;; symbol -> (string . symbol)
|
||||
;; reserved -> (symbol . symbol)
|
||||
;; char -> (char . char)
|
||||
;; @end enumerate
|
||||
;; todo: add bol status
|
||||
;; todo: maybe separate reading of keywords from identifiers: (keywd ch) =>
|
||||
;; @end deffn
|
||||
(define* (make-lexer-generator match-table
|
||||
#:key ident-reader num-reader
|
||||
string-reader chlit-reader
|
||||
comm-reader comm-skipper
|
||||
space-chars)
|
||||
(let* ((read-ident (or ident-reader (make-ident-reader c:if c:ir)))
|
||||
(read-num (or num-reader (make-num-reader)))
|
||||
(read-string (or string-reader (make-string-reader #\")))
|
||||
(read-chlit (or chlit-reader (lambda (ch) #f)))
|
||||
(read-comm (or comm-reader (lambda (ch bol) #f)))
|
||||
(skip-comm (or comm-skipper (lambda (ch) #f)))
|
||||
(spaces (or space-chars " \t\r\n"))
|
||||
(space-cs (cond ((string? spaces) (string->char-set spaces))
|
||||
((list? spaces) (list->char-set spaces))
|
||||
((char-set? spaces) spaces)
|
||||
(else (error "expecting string list or char-set"))))
|
||||
;;
|
||||
(ident-like? (make-ident-like-p read-ident))
|
||||
;;
|
||||
(strtab (filter-mt string? match-table)) ; strings in grammar
|
||||
(kwstab (filter-mt ident-like? strtab)) ; keyword strings =>
|
||||
(keytab (map-mt string->symbol kwstab)) ; keywords in grammar
|
||||
(chrseq (remove-mt ident-like? strtab)) ; character sequences
|
||||
(symtab (filter-mt symbol? match-table)) ; symbols in grammar
|
||||
(chrtab (filter-mt char? match-table)) ; characters in grammar
|
||||
;;
|
||||
(read-chseq (make-chseq-reader chrseq))
|
||||
(assc-$ (lambda (pair) (cons (assq-ref symtab (car pair)) (cdr pair))))
|
||||
)
|
||||
(lambda ()
|
||||
(let ((bol #f))
|
||||
(lambda ()
|
||||
(let iter ((ch (read-char)))
|
||||
(cond
|
||||
((eof-object? ch) (assc-$ (cons '$end ch)))
|
||||
;;((eq? ch #\newline) (set! bol #t) (iter (read-char)))
|
||||
((char-set-contains? space-cs ch) (iter (read-char)))
|
||||
((and (eqv? ch #\newline) (set! bol #t) #f))
|
||||
((read-comm ch bol) =>
|
||||
(lambda (p) (set! bol #f) (assc-$ p)))
|
||||
((skip-comm ch) (iter (read-char)))
|
||||
((read-ident ch) =>
|
||||
(lambda (s) (or (and=> (assq-ref keytab (string->symbol s))
|
||||
(lambda (tval) (cons tval s)))
|
||||
(assc-$ (cons '$ident s)))))
|
||||
((read-num ch) => assc-$) ; => $fixed or $float
|
||||
((read-string ch) => assc-$) ; => $string
|
||||
((read-chlit ch) => assc-$) ; => $chlit
|
||||
((read-chseq ch) => identity)
|
||||
((assq-ref chrtab ch) => (lambda (t) (cons t (string ch))))
|
||||
(else (cons ch ch))))))))) ; should be error
|
||||
|
||||
;; @end table
|
||||
|
||||
;; --- last line ---
|
|
@ -1,220 +0,0 @@
|
|||
;;; nyacc/parse.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2014-2017 Matthew R. Wette
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library 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
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public License
|
||||
;;; along with this library; if not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
;; make parser that provide list of la-toks to lexer:
|
||||
;; e.g., if comment not in latok, just throw away
|
||||
|
||||
(define-module (nyacc parse)
|
||||
#:export (make-lalr-parser make-lalr-ia-parser)
|
||||
#:use-module (nyacc util)
|
||||
#:use-module ((srfi srfi-43) #:select (vector-map vector-for-each))
|
||||
)
|
||||
|
||||
;; @item (machine-hashed? mach) => #t|#f
|
||||
;; Indicate if the machine has been hashed.
|
||||
(define (machine-hashed? mach)
|
||||
(number? (caar (vector-ref (assq-ref mach 'pat-v) 0))))
|
||||
|
||||
;; @item make-lalr-parser mach => parser
|
||||
;; This generates a procedure that takes one argument, a lexical analyzer:
|
||||
;; @example
|
||||
;; (parser lexical-analyzer [#:debug #t])
|
||||
;; @end example
|
||||
;; and is used as
|
||||
;; @example
|
||||
;; (define xyz-parse (make-lalr-parser xyz-mach))
|
||||
;; (with-input-from-file "sourcefile.xyz" (lambda () (xyz-parse (gen-lexer))))
|
||||
;; @end example
|
||||
;; The generated parser is reentrant.
|
||||
(define* (make-lalr-parser mach)
|
||||
(let* ((len-v (assq-ref mach 'len-v)) ; production RHS length
|
||||
(rto-v (assq-ref mach 'rto-v)) ; reduce to
|
||||
(pat-v (assq-ref mach 'pat-v)) ; parse action (shift, reduce) table
|
||||
(actn-v (assq-ref mach 'act-v)) ; symbolic actions
|
||||
(mtab (assq-ref mach 'mtab))
|
||||
(xact-v (if (procedure? (vector-ref actn-v 0)) actn-v
|
||||
(vector-map
|
||||
;; Turn symbolic action into executable procedures:
|
||||
(lambda (ix f) (eval f (current-module)))
|
||||
(vector-map
|
||||
(lambda (ix actn) (wrap-action actn))
|
||||
actn-v))))
|
||||
;;
|
||||
(dmsg (lambda (s t a) (fmtout "state ~S, token ~S\t=> ~S\n" s t a)))
|
||||
(hashed (number? (caar (vector-ref pat-v 0)))) ; been hashified?
|
||||
;;(def (assq-ref mtab '$default))
|
||||
(def (if hashed -1 '$default))
|
||||
(end (assq-ref mtab '$end))
|
||||
(err (assq-ref mtab '$error))
|
||||
(comm (list (assq-ref mtab '$lone-comm) (assq-ref mtab '$code-comm)))
|
||||
;; predicate to test for shift action:
|
||||
(shift? (if hashed
|
||||
(lambda (a) (positive? a))
|
||||
(lambda (a) (eq? 'shift (car a)))))
|
||||
;; On shift, transition to this state:
|
||||
(shift-to (if hashed (lambda (x) x) (lambda (x) (cdr x))))
|
||||
;; Predicate to test for reduce action:
|
||||
(reduce? (if hashed
|
||||
(lambda (a) (negative? a))
|
||||
(lambda (a) (eq? 'reduce (car a)))))
|
||||
;; On reduce, reduce this production-rule:
|
||||
(reduce-pr (if hashed abs cdr))
|
||||
;; If error, make the right packet.
|
||||
(other (if hashed 0 '(other . 0)))
|
||||
)
|
||||
|
||||
(lambda* (lexr #:key debug)
|
||||
(let iter ((state (list 0)) ; state stack
|
||||
(stack (list '$@)) ; sval stack
|
||||
(nval #f) ; prev reduce to non-term val
|
||||
(lval (lexr))) ; lexical value (from lex'er)
|
||||
|
||||
(let* ((tval (car (if nval nval lval))) ; token (syntax value)
|
||||
(sval (cdr (if nval nval lval))) ; semantic value
|
||||
(stxl (vector-ref pat-v (car state))) ; state transition xtra
|
||||
(oact #f) ;; if not shift/reduce, then accept, error or skip
|
||||
(stx (cond ;; state transition
|
||||
((assq-ref stxl tval)) ; shift/reduce in table
|
||||
((memq tval comm) (set! oact 'skip) other)
|
||||
((assq-ref stxl err)) ; error recovery
|
||||
((assq-ref stxl def)) ; default action
|
||||
(else (set! oact 'error) other))))
|
||||
|
||||
(if debug (dmsg (car state) (if nval tval sval) stx))
|
||||
(cond
|
||||
((shift? stx)
|
||||
;; We could check here to determine if next transition only has a
|
||||
;; default reduction and, if so, go ahead and process the reduction
|
||||
;; without reading another input token. Needed for interactive.
|
||||
(iter (cons (shift-to stx) state) (cons sval stack)
|
||||
#f (if nval lval (lexr))))
|
||||
((reduce? stx)
|
||||
(let* ((gx (reduce-pr stx)) (gl (vector-ref len-v gx))
|
||||
($$ (apply (vector-ref xact-v gx) stack)))
|
||||
(iter (list-tail state gl)
|
||||
(list-tail stack gl)
|
||||
(cons (vector-ref rto-v gx) $$)
|
||||
lval)))
|
||||
(else ;; other action: skip, error, or accept
|
||||
(case oact
|
||||
((skip) (iter state stack nval (lexr)))
|
||||
((error) (throw 'nyacc-error
|
||||
"parse failed at state ~A, on input ~S"
|
||||
(car state) sval))
|
||||
(else ;; accept
|
||||
(car stack))))))))))
|
||||
|
||||
;; @item make-lalr-ia-parser mach
|
||||
;; Make an interactive parser. This will automatically process default
|
||||
;; redunctions if that is the only choice, and does not wait for '$end to
|
||||
;; return. This needs algorithm verification. Makes some assumptions that
|
||||
;; need to be verified.
|
||||
(use-modules (ice-9 pretty-print))
|
||||
(define* (make-lalr-ia-parser mach)
|
||||
(let* ((len-v (assq-ref mach 'len-v))
|
||||
(rto-v (assq-ref mach 'rto-v)) ; reduce to
|
||||
(pat-v (assq-ref mach 'pat-v))
|
||||
(actn-v (assq-ref mach 'act-v)) ; unknown action vector
|
||||
(mtab (assq-ref mach 'mtab))
|
||||
(xact-v (if (procedure? (vector-ref actn-v 0)) actn-v
|
||||
(vector-map
|
||||
;; Turn symbolic action into executable procedures:
|
||||
(lambda (ix f) (eval f (current-module)))
|
||||
(vector-map
|
||||
(lambda (ix actn) (wrap-action actn))
|
||||
actn-v))))
|
||||
;;
|
||||
(dmsg (lambda (s t a) (fmtout "state ~S, token ~S\t=> ~S\n" s t a)))
|
||||
(hashed (number? (caar (vector-ref pat-v 0)))) ; been hashified?
|
||||
;;(def (assq-ref (assq-ref mach 'mtab) '$default))
|
||||
(def (if hashed -1 '$default))
|
||||
(end (assq-ref mtab '$end))
|
||||
;; predicate to test for shift action:
|
||||
(shift? (if hashed
|
||||
(lambda (a) (positive? a))
|
||||
(lambda (a) (eq? 'shift (car a)))))
|
||||
;; On shift, transition to this state:
|
||||
(shift-to (if hashed (lambda (x) x) (lambda (x) (cdr x))))
|
||||
;; predicate to test for reduce action:
|
||||
(reduce? (if hashed
|
||||
(lambda (a) (negative? a))
|
||||
(lambda (a) (eq? 'reduce (car a)))))
|
||||
;; On reduce, reduce this production-rule:
|
||||
;;(reduce-pr (if hashed (lambda (a) (abs a)) (lambda (a) (cdr a))))
|
||||
(reduce-pr (if hashed abs cdr))
|
||||
;; If no action found in transition list, then this:
|
||||
(parse-error (if hashed #f (cons 'error 0)))
|
||||
;; predicate to test for error
|
||||
(error? (if hashed
|
||||
(lambda (a) (eq? #f a))
|
||||
(lambda (a) (eq? 'error (car a)))))
|
||||
)
|
||||
(lambda* (lexr #:key debug)
|
||||
(let iter ((state (list 0)) ; state stack
|
||||
(stack (list '$@)) ; sval stack
|
||||
(nval #f) ; prev reduce to non-term val
|
||||
(lval #f)) ; lexical value (from lex'er)
|
||||
(let ((stxl (vector-ref pat-v (car state))))
|
||||
(cond
|
||||
((eqv? def (caar stxl))
|
||||
(let* ((stx (cdar stxl))
|
||||
(gx (reduce-pr stx))
|
||||
(gl (vector-ref len-v gx))
|
||||
($$ (apply (vector-ref xact-v gx) stack)))
|
||||
(if debug (fmtout "state ~S, default => reduce ~S, goto ~S\n"
|
||||
(car state) gx (list-ref state gl)))
|
||||
(iter (list-tail state gl) (list-tail stack gl)
|
||||
(cons (vector-ref rto-v gx) $$) lval)))
|
||||
((eqv? end (caar stxl)) ; only '$end remains, return for i/a
|
||||
(if debug (fmtout "in state ~S, looking at '$end => accept\n"
|
||||
(car state)))
|
||||
(if (reduce? (cdar stxl))
|
||||
;; Assuming this is the final reduction ...
|
||||
(apply (vector-ref xact-v (reduce-pr (cdar stxl))) stack)
|
||||
;; Or already done ...
|
||||
(car stack)))
|
||||
(else
|
||||
(let* ((laval (or nval (or lval (lexr))))
|
||||
(tval (car laval)) (sval (cdr laval))
|
||||
(stx (or (assq-ref stxl tval)
|
||||
(assq-ref stxl def)
|
||||
parse-error)))
|
||||
;;(if debug (fmtout " lval=~S laval=~S\n" lval laval))
|
||||
(if debug (dmsg (car state) (if nval tval sval) stx))
|
||||
(cond
|
||||
((error? stx)
|
||||
(let ((fn (or (port-filename (current-input-port)) "(???)"))
|
||||
(ln (1+ (port-line (current-input-port)))))
|
||||
(fmterr "~A:~A: parse failed at state ~A, on input ~S\n"
|
||||
fn ln (car state) sval))
|
||||
#f)
|
||||
((shift? stx)
|
||||
(iter (cons (shift-to stx) state) (cons sval stack)
|
||||
#f (if nval lval #f)))
|
||||
((reduce? stx)
|
||||
(let* ((gx (reduce-pr stx)) (gl (vector-ref len-v gx))
|
||||
($$ (apply (vector-ref xact-v gx) stack)))
|
||||
(iter (list-tail state gl)
|
||||
(list-tail stack gl)
|
||||
(cons (vector-ref rto-v gx) $$)
|
||||
(if nval lval laval)
|
||||
)))
|
||||
(else ;; accept
|
||||
(car stack)))))))))))
|
||||
|
||||
;; @end itemize
|
||||
;;; --- last line ---
|
|
@ -1,304 +0,0 @@
|
|||
;;; nyacc/util.scm
|
||||
;;;
|
||||
;;; Copyright (C) 2014-2016 Matthew R. Wette
|
||||
;;;
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library 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
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
(define-module (nyacc util)
|
||||
#:export (
|
||||
fmtstr fmtout fmterr fmt
|
||||
wrap-action
|
||||
obj->str
|
||||
fixed-point prune-assoc
|
||||
map-attr->vector
|
||||
x-flip x-comb
|
||||
write-vec
|
||||
ugly-print
|
||||
tzort
|
||||
)
|
||||
#:use-module ((srfi srfi-43) #:select (vector-fold))
|
||||
)
|
||||
|
||||
(define (fmtstr fmt . args)
|
||||
(apply simple-format #f fmt args))
|
||||
(define (fmtout fmt . args)
|
||||
(apply simple-format (current-output-port) fmt args))
|
||||
(define (fmterr fmt . args)
|
||||
(apply simple-format (current-error-port) fmt args))
|
||||
(define fmt simple-format)
|
||||
|
||||
;; @item make-arg-list N => '($N $Nm1 $Nm2 ... $1 . $rest)
|
||||
;; This is a helper for @code{mkact}.
|
||||
(define (make-arg-list n)
|
||||
(let ((mkarg
|
||||
(lambda (i) (string->symbol (string-append "$" (number->string i))))))
|
||||
(let iter ((r '(. $rest)) (i 1))
|
||||
(if (> i n) r (iter (cons (mkarg i) r) (1+ i))))))
|
||||
|
||||
;; @item wrap-action (n . guts) => `(lambda ($n ... $2 $1 . $rest) ,@guts)
|
||||
;; Wrap user-specified action (body, as list) of n arguments in a lambda.
|
||||
;; The rationale for the arglist format is that we can @code{apply} this
|
||||
;; lambda to the the semantic stack.
|
||||
(define (wrap-action actn)
|
||||
(cons* 'lambda (make-arg-list (car actn)) (cdr actn)))
|
||||
|
||||
;; @deffn obj->str object => string
|
||||
;; Convert terminal (symbol, string, character) to string.
|
||||
;; This is like @code{write} but will prefix symbols with @code{'}.
|
||||
(define (obj->str obj)
|
||||
(cond ((string? obj) (simple-format #f "~S" obj))
|
||||
((symbol? obj) (string-append "'" (symbol->string obj)))
|
||||
((char? obj) (simple-format #f "~S" obj))))
|
||||
|
||||
;; @deffn prune-assoc al
|
||||
;; Prune obsolete entries from an a-list. This is order n^2.
|
||||
(define (prune-assoc al)
|
||||
(let iter ((al1 '()) (al0 al))
|
||||
(if (null? al0) al1
|
||||
(iter (if (assoc (caar al0) al1) al1 (cons (car al0) al1)) (cdr al0)))))
|
||||
|
||||
;; @deffn fixed-point proc seed
|
||||
;; .item fixed-point-by-elt proc seed
|
||||
;; @example
|
||||
;; proc: element list -> list
|
||||
;; @end example
|
||||
;; proc will take an element and insert updates at the front of list
|
||||
;; and return the list
|
||||
;; seed is a list
|
||||
;; fixed-point processes a list
|
||||
;; The procedure @code{proc} takes as arguments an element from the list
|
||||
;; and the entire list. Updates should be cons'd onto the front of the
|
||||
;; list.
|
||||
;; It works by setting prev to the empty list and next, curr and item to
|
||||
;; the seed. The item reference is propagated through the current list
|
||||
;; until it reaches prev. The calls to proc will update @code{next}.
|
||||
;; @example
|
||||
;; next-> +---+
|
||||
;; | |
|
||||
;; curr-> +---+
|
||||
;; | |
|
||||
;; item-> | |
|
||||
;; | |
|
||||
;; prev-> +---+
|
||||
;; | |
|
||||
;; +---+
|
||||
;; @end example
|
||||
(define (fixed-point proc seed)
|
||||
;; (let ((seed (if (null? seed) (fixed-point proc (proc seed '())))))
|
||||
(let iter ((prev '()) (item seed) (curr seed) (next seed))
|
||||
(cond
|
||||
((not (eqv? item prev))
|
||||
(iter prev (cdr item) curr (proc (car item) next)))
|
||||
((not (eqv? next curr))
|
||||
(iter curr next next next))
|
||||
(else
|
||||
curr))))
|
||||
|
||||
;; @deffn vector-fixed-point proc vec => vec
|
||||
;; (proc vec) => chg (boolean)
|
||||
;; Not used yet (in step3).
|
||||
(define (vector-fixed-point proc vec)
|
||||
(let iter ((chg #t))
|
||||
(if chg (proc vec) vec)))
|
||||
|
||||
;; @deffn map-attr->vector list-of-alists key => vector
|
||||
;; map list of attribute lists to vector of attr
|
||||
;; @example
|
||||
;; (map-attr->vector '(((a . 1) ...) ((a . 2) ...) ...) => #(1 2 ...)
|
||||
;; @end example
|
||||
(define (map-attr->vector al-l key)
|
||||
(list->vector (map (lambda (al) (assq-ref al key)) al-l)))
|
||||
|
||||
;; @deffn flip al => a-list
|
||||
;; change (a 1 2 3) to ((1 . a) (2 . a) (3 . a))
|
||||
(define (x-flip al)
|
||||
(let iter ((result '()) (tail (cdr al)))
|
||||
(if (null? tail) result
|
||||
(iter (acons (car tail) (car al) result) (cdr tail)))))
|
||||
|
||||
;; @deffn x-comb (a1 a2 a3) (b1 b2 b3) => (a1 b1) (a1 b2) ...
|
||||
;; The implementation needs work.
|
||||
(define (x-comb a b)
|
||||
(let iter ((res '()) (al a) (bl b))
|
||||
(cond
|
||||
((null? al) res)
|
||||
((pair? bl) (iter (acons (car al) (car bl) res) al (cdr bl)))
|
||||
((pair? al) (iter res (cdr al) b)))))
|
||||
|
||||
(define (write-vec port vec)
|
||||
(let* ((nv (vector-length vec)))
|
||||
(fmt port " #(")
|
||||
(let iter ((col 4) (ix 0))
|
||||
(if (eq? ix nv) #f
|
||||
(let* ((item (vector-ref vec ix))
|
||||
(stng (fmt #f "~S " item))
|
||||
(leng (string-length stng)))
|
||||
(cond
|
||||
((> (+ col leng) 78)
|
||||
(fmt port "\n ~A" stng)
|
||||
(iter (+ 4 leng) (1+ ix)))
|
||||
(else
|
||||
(fmt port "~A" stng)
|
||||
(iter (+ col leng) (1+ ix)))))))
|
||||
(fmt port ")")))
|
||||
|
||||
|
||||
;; @deffn ugly-print sexp [#:indent 4] [#:extent 78] [#:port port]
|
||||
;; This will print in compact form which shows no structure.
|
||||
(define* (ugly-print sexp #:optional port #:key (indent 4) (extent 78))
|
||||
|
||||
(define (obj->str obj)
|
||||
(simple-format #f "~S" obj))
|
||||
|
||||
;; @deffn make-strout indent extent port
|
||||
;; This will generate a procedure of signature @code{(proc col str)} which
|
||||
;; takes a column and string, prints the string and returns updated column.
|
||||
(define (make-strout ind ext port)
|
||||
(let ((leader (make-string ind #\space)))
|
||||
(lambda (col str)
|
||||
(let* ((len (string-length str)))
|
||||
(cond
|
||||
((> (+ col len) ext)
|
||||
(newline port)
|
||||
(display leader port)
|
||||
(unless (string-every #\space str) (display str port))
|
||||
(+ ind len))
|
||||
(else
|
||||
(display str port)
|
||||
(+ col len)))))))
|
||||
|
||||
(letrec ((out-p (or port (current-output-port)))
|
||||
(leader (make-string 2 #\space))
|
||||
(strout (make-strout indent extent out-p))
|
||||
|
||||
(iter1
|
||||
(lambda (col sx)
|
||||
(cond
|
||||
((pair? sx) (strout (iter2 (strout col "(") sx) ")"))
|
||||
((vector? sx)
|
||||
(strout
|
||||
(vector-fold
|
||||
(lambda (ix col elt)
|
||||
(iter1 (if (zero? ix) col (strout col " ")) elt))
|
||||
(strout col "#(") sx) ")"))
|
||||
(else (strout col (obj->str sx))))))
|
||||
|
||||
(iter2
|
||||
(lambda (col sx)
|
||||
(cond
|
||||
((pair? sx)
|
||||
(if (null? (cdr sx))
|
||||
(iter2 (iter1 col (car sx)) (cdr sx))
|
||||
(iter2 (strout (iter1 col (car sx)) " ") (cdr sx))))
|
||||
((null? sx) col)
|
||||
(else (strout (strout col ". ") (obj->str sx))))))
|
||||
)
|
||||
;;(simple-format out-p leader)
|
||||
(iter1 (if (pair? sexp) (strout indent "'") indent) sexp)
|
||||
;;(iter1 indent sexp)
|
||||
;;(newline out-p)
|
||||
))
|
||||
|
||||
;; stuff
|
||||
|
||||
;; @deffn depth-first-search graph => (values ht gv tv xl)
|
||||
;; The argument @var{gfraph} is a list of verticies and adjacency nodes:
|
||||
;; @example
|
||||
;; graph => ((1 2 3 4) (2 6 7) ...)
|
||||
;; @end example
|
||||
;; @noindent
|
||||
;; @table @var
|
||||
;; @item ht
|
||||
;; hash of vertex to index
|
||||
;; @item gv
|
||||
;; vector of index to vertex
|
||||
;; @item tv
|
||||
;; vector of (d . f)
|
||||
;; @end table
|
||||
;; ref: Algorithms, p 478
|
||||
(define (depth-first-search graph)
|
||||
(let* ((n (length graph))
|
||||
(ht (make-hash-table n)) ; vertex -> index
|
||||
(gv (make-vector n)) ; index -> vertex
|
||||
(tv (make-vector n #f)) ; index -> times
|
||||
(pv (make-vector n #f)) ; index -> predecessor :unused
|
||||
(xl '()))
|
||||
(letrec
|
||||
((next-t (let ((t 0)) (lambda () (set! t (+ 1 t)) t)))
|
||||
(visit (lambda (k)
|
||||
(vector-set! tv k (cons (next-t) #f))
|
||||
(let iter ((l (cdr (vector-ref gv k))))
|
||||
(if (not (null? l))
|
||||
(let ((ix (hashq-ref ht (car l))))
|
||||
(unless (vector-ref tv ix)
|
||||
(fmtout "set-pv! ~a ~a" ix k)
|
||||
(vector-set! pv ix k)
|
||||
(visit ix))
|
||||
(iter (cdr l)))))
|
||||
(set! xl (cons k xl))
|
||||
(set-cdr! (vector-ref tv k) (next-t))
|
||||
))
|
||||
)
|
||||
;; Set up hash of vertex to index.
|
||||
(do ((i 0 (+ i 1)) (l graph (cdr l))) ((= i n))
|
||||
(vector-set! gv i (car l)) ; (vector-ref gv i) = (list-ref graph i)
|
||||
(hashq-set! ht (caar l) i)) ; (hash-ref ht (list-ref graph i)) = i
|
||||
;; Run through vertices.
|
||||
(do ((i 0 (+ 1 i))) ((= i n))
|
||||
(unless (vector-ref tv i) (visit i)))
|
||||
(values ht gv tv xl))))
|
||||
|
||||
;; @deffn tzort dag
|
||||
;; Given DAG return order of nodes. The DAG is provided as list of:
|
||||
;; (<node> <priors>)
|
||||
;; ref: D.E.Knuth - The Art of C.P., Vol I, Sec 2.2.3
|
||||
(define (tzort dag)
|
||||
(let* ((n (length dag))
|
||||
(ht (make-hash-table n)) ; node -> ix
|
||||
(nv (make-vector n #f)) ; ix -> (node . adj-list)
|
||||
(cv (make-vector n 0)) ; ix -> count
|
||||
(incr (lambda (ix) (vector-set! cv ix (+ (vector-ref cv ix) 1))))
|
||||
(decr (lambda (ix) (vector-set! cv ix (- (vector-ref cv ix) 1)))))
|
||||
;; Set up ht and nv.
|
||||
(do ((i 0 (+ i 1)) (l dag (cdr l))) ((= n i))
|
||||
(vector-set! nv i (car l))
|
||||
(hashq-set! ht (caar l) i))
|
||||
;; set up cv
|
||||
(do ((i 0 (+ i 1))) ((= n i))
|
||||
(for-each (lambda (n) (incr (hashq-ref ht n)))
|
||||
(cdr (vector-ref nv i))))
|
||||
;; Iterate through nodes until cv all zero.
|
||||
(let iter1 ((ol '()) (uh '()) ; ordered list, unordered head
|
||||
(ut (let r ((l '()) (x 0)) ; unordered tail
|
||||
(if (= x n) l (r (cons x l) (+ x 1))))))
|
||||
(cond
|
||||
((null? ut)
|
||||
(if (null? uh)
|
||||
(reverse (map (lambda (e) (car (vector-ref nv e))) ol))
|
||||
(iter1 ol '() uh)))
|
||||
(else
|
||||
(let* ((ix (car ut)))
|
||||
(if (zero? (vector-ref cv ix))
|
||||
(iter1
|
||||
(let iter2 ((l (cdr (vector-ref nv ix))))
|
||||
(if (null? l) (cons ix ol)
|
||||
(begin
|
||||
(decr (hashq-ref ht (car l)))
|
||||
(iter2 (cdr l)))))
|
||||
uh
|
||||
(cdr ut))
|
||||
(iter1 ol (cons ix uh) (cdr ut)))))))))
|
||||
|
||||
;;; --- last line ---
|
Loading…
Reference in a new issue