unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* nyacc 0.65.0 released
@ 2015-12-29 21:01 Matt Wette
  2015-12-30 14:35 ` Ludovic Courtès
  2015-12-31  4:11 ` Nala Ginrut
  0 siblings, 2 replies; 9+ messages in thread
From: Matt Wette @ 2015-12-29 21:01 UTC (permalink / raw)
  To: guile-user

nyacc version 0.65.0 is released as beta

nyacc is a LALR parser generator written from the ground up in guile

Features/Updates:
* clean scheme-flavored syntax for grammar specification 
* updated documentation (but still rough draft)
* prototype parsers for c, javascript, matlab that output parse trees in a SXML format
* partial sxml-parse-tree to il-tree conversion for javascript and C
* partial sxml-parse-tree pretty printer for javascript and C

Demo:
Use C parser and pretty printer to clean up C expressions (e.g., remove unneeded paren’s):

(use-modules (nyacc lang c99 pprint))
(use-modules (nyacc lang c99 xparser))
(use-modules (ice-9 pretty-print))

(let* ((st0 "(int)(((((foo_t*)0)->x)->y)->z)")
       (sx0 (parse-cx st0 #:tyns '("foo_t")))
       (st1 (with-output-to-string (lambda () (pretty-print-c99 sx0))))
       (sx1 (parse-cx st1 #:tyns '("foo_t"))))
  (simple-format #t "~S => \n" st0)
  (pretty-print sx0 #:per-line-prefix " ")
  (simple-format #t "==[pretty-print-c99]==>\n")
  (simple-format #t "~S =>\n" st1)
  (pretty-print sx1 #:per-line-prefix " “))

"(int)(((((foo_t*)0)->x)->y)->z)" => 
 (cast (type-name
         (decl-spec-list (type-spec (fixed-type "int"))))
       (i-sel (ident "z")
              (i-sel (ident "y")
                     (i-sel (ident "x")
                            (cast (type-name
                                    (decl-spec-list
                                      (type-spec (typename "foo_t")))
                                    (abs-declr (pointer)))
                                  (p-expr (fixed "0")))))))
==[pretty-print-c99]==>
"(int)((foo_t*)0)->x->y->z" =>
 (cast (type-name
         (decl-spec-list (type-spec (fixed-type "int"))))
       (i-sel (ident "z")
              (i-sel (ident "y")
                     (i-sel (ident "x")
                            (cast (type-name
                                    (decl-spec-list
                                      (type-spec (typename "foo_t")))
                                    (abs-declr (pointer)))
                                  (p-expr (fixed "0")))))))

http://download.savannah.gnu.org/releases/nyacc/
or
git clone git://git.savannah.nongnu.org/nyacc.git


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-12-31 17:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-29 21:01 nyacc 0.65.0 released Matt Wette
2015-12-30 14:35 ` Ludovic Courtès
2015-12-30 16:54   ` Matt Wette
2015-12-30 17:38     ` Ludovic Courtès
2015-12-30 20:58     ` Christopher Allan Webber
2015-12-30 21:32       ` Matt Wette
2015-12-31  4:11 ` Nala Ginrut
2015-12-31 15:21   ` Matt Wette
2015-12-31 17:22     ` Matt Wette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).