Commit 318f9463 authored by david_v's avatar david_v
Browse files

2003-07-02 Valentin David <valentin@lrde.epita.fr>

	* configure.ac: Change version to 0.2 and add a new tool.
	* src/Makefile.am: Add the boxedsdf-update directory.

	* README: Update.
	* NEWS: Update.

	* src/boxedsdf-update/Makefile.am,
	* src/boxedsdf-update/boxedsdf-update.str: New.
parent a1edea6c
2003-07-02 Valentin David <valentin@lrde.epita.fr>
* configure.ac: Change version to 0.2 and add a new tool.
* src/Makefile.am: Add the boxedsdf-update directory.
* README: Update.
* NEWS: Update.
* src/boxedsdf-update/Makefile.am,
* src/boxedsdf-update/boxedsdf-update.str: New.
2003-06-20 Valentin David <valentin@lrde.epita.fr> 2003-06-20 Valentin David <valentin@lrde.epita.fr>
* src/pack-boxedsdf/pack-boxedsdf.str, * src/pack-boxedsdf/pack-boxedsdf.str,
......
0.2
---
* boxedsdf-update was added.
This tool is useful when updating a grammar to check that pp is updated too.
* pack-boxedsdf now accept the -s/--syntax option.
0.1 0.1
--- ---
......
...@@ -41,7 +41,7 @@ Using old grammars ...@@ -41,7 +41,7 @@ Using old grammars
------------------ ------------------
If you want to use an already written grammar, you can merge PP information If you want to use an already written grammar, you can merge PP information
into the Sdf grammar. Let's suppose have MyOldGrammar.def and MyOldGrammar.pp into the Sdf grammar. Let's suppose having MyOldGrammar.def and MyOldGrammar.pp
$ parse-sdf -i MyOldGrammar.def | \ $ parse-sdf -i MyOldGrammar.def | \
boxedsdf-merge -p MyOldGrammar.pp | \ boxedsdf-merge -p MyOldGrammar.pp | \
...@@ -49,3 +49,48 @@ $ parse-sdf -i MyOldGrammar.def | \ ...@@ -49,3 +49,48 @@ $ parse-sdf -i MyOldGrammar.def | \
If you want to get modular files, you can use the unpack-sdf of the StrategoXT If you want to get modular files, you can use the unpack-sdf of the StrategoXT
package. package.
Updating grammars
-----------------
Sometimes, when updating grammar, it is possible to forget to change some
pp entries. boxedsdf-update is a tool that can test it. If the pp entries were
not modified, it is deleted so as to be regenerated by boxed2pp-table.
$ parse-boxedsdf -i MyUpdatedGrammar.def | \
boxedsdf-merge -d MuOldGrammar.def --verbose 1 -o MyCorrectedGrammar.def
Production has changed, but not the pp. Reseting it: "constructor1"
Production has changed, but not the pp. Reseting it: "constructor2"
$
Note that your grammar must have constructor's names on the productions.
Using your own grammar
----------------------
pack-boxedsdf and boxedsdf-update load and parse concrete syntax files. If
you want to use your own grammar, you just have to use the -s/--syntax option.
example of use:
$ pack-boxedsdf -I /path/to/your/syntax -s YourSdfSyntax -i YourGrammar | \
implode-asfix | \
YourSdfSyntax-to-PureSdf | \
boxed2pp-table | \
pp-pp-table
Writing in BoxedSdf
-------------------
To specify pp entries to a production rule, you have to use the pp() attribute.
When writing severals pp entries for one rule, these entries has to be
seperated by a comma. The path (optional) of a entry precedes it separated by
a equal symbol.
module Example
exports
context-free syntax
Blah Blih? -> Bloh {pp(V vs=1[_1 _2], .2:opt=H hs=0[_1])
When a pp entry is not specified, boxed2pp-table will generate the default one
(with ppgen). So, many production do not have to have pp entries.
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT(boxedsdf, 0.1, valentin@lrde.epita.fr) AC_INIT(boxedsdf, 0.2, valentin@lrde.epita.fr)
AC_CONFIG_AUX_DIR(config) AC_CONFIG_AUX_DIR(config)
AC_CONFIG_FILES(config/Makefile) AC_CONFIG_FILES(config/Makefile)
AM_INIT_AUTOMAKE([foreign 1.7.1 dist-bzip2]) AM_INIT_AUTOMAKE([foreign 1.7.1 dist-bzip2])
USE_XT_PACKAGES USE_XT_PACKAGES
AC_PROG_CC AC_PROG_CC
...@@ -23,6 +23,7 @@ AC_CONFIG_FILES([Makefile ...@@ -23,6 +23,7 @@ AC_CONFIG_FILES([Makefile
src/pack-boxedsdf/Makefile src/pack-boxedsdf/Makefile
src/pp/Makefile src/pp/Makefile
src/boxedsdf-merge/Makefile src/boxedsdf-merge/Makefile
src/boxedsdf-update/Makefile
src/parser/Makefile src/parser/Makefile
test/Makefile test/Makefile
test/defs]) test/defs])
......
...@@ -6,6 +6,7 @@ SUBDIRS = syn \ ...@@ -6,6 +6,7 @@ SUBDIRS = syn \
pack-boxedsdf \ pack-boxedsdf \
pp \ pp \
parser \ parser \
boxedsdf-merge boxedsdf-merge \
boxedsdf-update
BOOTCLEAN_SUBDIRS = $(SUBDIRS) BOOTCLEAN_SUBDIRS = $(SUBDIRS)
include $(top_srcdir)/config/Makefile.xt
-include boxedsdf-update.c.dep
bin_PROGRAMS = boxedsdf-update
SCFLAGS = --main $* --verbose 0
STRINCLUDES = -I $(top_builddir)/src/syn \
-I $(XTC)/share/xtc
BOOTCLEANFILES = boxedsdf-update.c
CLEANFILES = boxedsdf-update.c.dep
EXTRA_DIST = boxedsdf-update.str
/**
* BoxedSdf
* Copyright (C) 2003 LRDE
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Sdf update checker
*
* When rewriting a grammar, sometimes, some pp informations are forgotten.
* It compares the old grammar with the new one and delete (and prevent with
* verbose level more than 1) all the pp entries that are not updated.
* When a pp entry is deleted, the default one will be generated by
* boxed2pp-table tool.
*
* Author: Valentin David <valentin@lrde.epita.fr>
*/
module boxedsdf-update
imports BoxedSdf2 xtc-lib
signature
constructors
Old : String -> Option
rules
readgrammar : infile -> tree
where xtc-temp-files(<xtc-transform(!"sglri", !["-p", <get-syntax>])>
FILE(infile)
; read-from => tree)
strategies
get-syntax = (<get-config> "-s" <+ !"BoxedSdf2")
; if-verbose2(debug(!"Using grammar: "))
; !(<id>, ".tbl")
; conc-strings
; (<find-in-path> (<id>, <get-config> "-I") <+ xtc-find)
; if-verbose6(debug(!"Using grammar table: "))
/**
* -d/--old grammar
* to specify the old grammar
*/
old-option =
ArgOption("-d" + "--old"
, where(<set-config> ("-d",<id>)); !Old(<id>)
, !"-d n|--old n Generated module will import n"
)
/**
* -s/--syntax syntax
* to specify the syntax of the old grammar
*/
syntax-option =
ArgOption("-s" + "--syntax"
, where(<set-config> ("-s", <id>))
, !"-s g|--syntax g Use g syntax for old grammar, default BoxedSdf2"
)
at-cons(s) = oncetd(cons(s))
at-pp(s) = oncetd(BoxedAttr(pplist(s)))
eq-prod = ?(prod(a, b, _), prod(a, b, _))
eq-pp = (prod(id,id,at-pp(?pp)), prod(id,id, at-pp(?pp)))
reset-old-pp = alltd(lexical-syntax(id)
<+ context-free-priorities(id)
<+ lexical-priorities(id)
<+ priorities(id)
<+ { c, p :
prod(id,id,at-cons(?c))
; ?p
; <not(eq-prod)> (<id>, <GetOldProd> c)
; eq-pp
; where(<if-verbose1(debug(!"Production has changed, but not the pp. Reseting it: "))> c)
; <prod(id,id,attrs(filter(not(BoxedAttr(id))))
; try(attrs([])
; !no-attrs))> p
})
boxedsdf-update = iowrap(
(option-defined(?Old(grammar))
; where (
<readgrammar> grammar
; alltd(lexical-syntax(id)
<+ context-free-priorities(id)
<+ lexical-priorities(id)
<+ priorities(id)
<+ { c, p:
prod(id,id,at-cons(?c))
; ?p
; rules(GetOldProd : c -> p)
})
), id)
; (id, reset-old-pp)
, old-option + syntax-option)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment