guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nyacc version 0.71.0 released


From: Matt Wette
Subject: nyacc version 0.71.0 released
Date: Thu, 14 Apr 2016 18:47:05 -0700

nyacc version 0.71.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
* prototype parsers for C99,(partial) _javascript_, matlab that output parse trees in a SXML format
* update: C99 preprocessor updated to expand defines in C code
* update: cleaned up file structure
* update: started working on test-suite
* update: added grammar for C++
* update: build parsers via bison
  + to use in example below replace `make-lalr-machine' with `make-lalr-machine/bison’,
     after adding (use-module (nyacc bison)
  + the bison module will 
     - export a bison gram.y file, 
     - run "bison -x gram.y” to produce a gram.xml file
     - translate gram.xml file into the nyacc “machine” data structure
  
To run a simple demo:
$ tar xzf nyacc-0.71.tar.gz
$ cd examples/nyacc/lang/calc
$ ./calc
2 + 2 => 4

Tcalc.scm:

(use-modules (nyacc lalr))
(use-modules (nyacc lex))
(use-modules (nyacc parse))

(define simple-spec
  (lalr-spec
   (prec< (left "+" "-") (left "*" "/"))
   (start expr)
   (grammar
    (expr
     (expr "+" expr ($$ (+ $1 $3)))
     (expr "-" expr ($$ (- $1 $3)))
     (expr "*" expr ($$ (* $1 $3)))
     (expr "/" expr ($$ (/ $1 $3)))
     ($fixed ($$ (string->number $1)))
     ($float ($$ (string->number $1)))
     ("(" expr ")" ($$ $2))))))

(define simple-mach (make-lalr-machine simple-spec))

(define match-table (assq-ref simple-mach 'mtab))

(define gen-lexer (make-lexer-generator match-table))

(define parse (make-lalr-parser simple-mach))

(define demo-string "2 + 2")

(simple-format #t "~A => ~A\n"
      demo-string
      (with-input-from-string demo-string
(lambda () (parse (gen-lexer)))))

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]