README 3.49 KB
Newer Older
1
BoxedSdf                                                  -*- Text -*-
2
3
--------

4
This package is to make easier the writing of Pretty-Print tables for Generic
5
6
Pretty-Printer.

7
Author: Valentin David <valentin@lrde.epita.fr>
8
9
10
11

Requirements
------------

12
StrategoXT 0.9.5 or above (http://www.stratego-language.org/)
13
14
15
16
17
18
19
20
21
22
23
24
25

Installation
------------

$ ./configure --with-xt=<PATH>
$ make
$ make install

Working with BoxedSdf grammar
-----------------------------

A common using is:

26
$ pack-boxedsdf -i MyGrammar.ppsdf |
27
28
  asfix-yield -o MyGrammar.ppdef

29
30
$ parse-boxedsdf -i MyGrammar.ppdef |
  boxed2sdf |
31
  pp-sdf -o MyGrammar.def
32

33
34
$ parse-boxedsdf -i MyGrammar.ppdef |
  boxed2pp-table |
35
36
  pp-pp-table -o MyGrammar.pp

37
38
Note: if you have to use sdf-cons on your grammar, you should do it before the
      boxed2* filters.
39
40
41
42

Using old grammars
------------------

43
If you want to use an already written grammar, you can merge PP information
44
into the Sdf grammar. Let's suppose having MyOldGrammar.def and MyOldGrammar.pp
45

46
47
$ parse-sdf -i MyOldGrammar.def |
  boxedsdf-merge -p MyOldGrammar.pp |
48
49
50
51
  pp-boxedsdf -o MyOldGrammar.ppdef

If you want to get modular files, you can use the unpack-sdf of the StrategoXT
package.
52
53
54
55
56
57
58
59

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.

60
61
$ parse-boxedsdf -i MyUpdatedGrammar.ppdef |
  boxedsdf-merge -d MuOldGrammar.ppdef --verbose 1 |
62
  pp-boxedsdf -o MyCorrectedGrammar.ppdef
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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:

77
78
79
80
$ pack-boxedsdf -I /path/to/your/syntax -s YourSdfSyntax -i YourGrammar |
  implode-asfix |
  YourSdfSyntax-to-BoxedSdf |
  boxed2pp-table |
81
  pp-pp-table -o YourGrammar.pp
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

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.
98
99
100

--

101
Copyright (C) 2003, 2004  EPITA Research and Development Laboratory.
102

103
This file is part of BoxedSdf from the Transformers project.
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

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