;;; 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 . ;; 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) ) (cond-expand (guile-2) (guile (use-modules (ice-9 syncase)) (use-modules (ice-9 optargs))) (mes)) (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 len-v) (cons 'pat-v pat-v) (cons 'rto-v rto-v) (cons 'mtab mtab) (cons 'act-v 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) #:debug (cpi-debug info)))) ;; @deffn {Procedure} parse-c99 [#:cpp-defs def-a-list] [#:inc-dirs dir-list] \ ;; [#:mode ('code|'file)] [#:debug bool] ;; This needs to be explained in some detail. ;; tdd = typedef dict: (("