;; -*- Hen -*- ;; ;; A grammar for I-expressions ;; ;; Copyright 2010-2011 Ivan Raikov and the Okinawa Institute of ;; Science and Technology. ;; ;; 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. ;; ;; A full copy of the GPL license can be found at ;; . ;; (require-extension lalr ) (define expr-parser (lalr-parser (output: parser "iexpr.grm.scm") (out-table: "iexpr.grm.out") ;; --- token definitions ( END (left: SPACE WORD NAT REAL COMMA RPAREN ) (right: LPAREN BREAK) ) ;; Toplevel entry point (stream () : (Empty) (block) : $1 (stream END) : $1 (stream BREAK) : $1 (stream END block) : (tree-add-sibling $1 $3)) (block (block0) : (final-line-tree $1) (BREAK block) : $2) (block0 (line) : (initial-line-tree $1) (block0 line) : (tree-insert-line $2 $1) ) (line (list) : (make-line 0 $1) (SPACE list) : (make-line $1 $2) (line BREAK) : $1 ) (group (LPAREN RPAREN) : `() (LPAREN list RPAREN) : $2 (LPAREN listsep list RPAREN) : $3 ) (list (list0) : (reverse $1)) (list0 (listelem) : (list $1) (list0 listsep listelem) : (cons $3 $1) (list0 listsep) : $1 ) (listsep (SPACE) (COMMA) (listsep listsep)) (listelem (scalar) : $1 (group) : $1) (scalar (WORD) : $1 (NAT) : $1 (REAL) : $1) ))