Commit e213a94b authored by Bruno Guillaume's avatar Bruno Guillaume

add info about new_grs section

parent ebb0f7e8
......@@ -24,7 +24,7 @@ A Grew Graph Rewriting System (GRS) is defined by:
* the definition of sequences of modules (keyword `sequences`)
## Domain definition
The domain is defined as a pair of a feture domain and an edge label domain.
The domain is defined as a pair of a feature domain and an edge label domain.
### Feature domain
In graphs and in rules, nodes contain feature structures.
......@@ -50,7 +50,7 @@ features {
**REM:** values of pers feature are numerals but the only way to restrict to the finite domain {1, 2, 3} is to declare it as a closed feature and possible values as strings.
### edge labe domain
### edge label domain
An explicit set of valid labels for edges may be given after the `labels` keyword.
By default, edges are drawn with a black solid line and above the figure in DEP representation.
......
+++
date = "2017-05-29T18:30:19+02:00"
title = "new_grs"
menu = "main"
Categories = ["Development","GoLang"]
Tags = ["Development","golang"]
Description = ""
+++
# GRS syntax
:warning: This page describes the new GRS syntax which is still in project :warning:
## Global structure
A GRS is composed by a set of declarations that may be provided in several files.
These files are expected to used the `.grs` of the `.dom` file extension.
Five kinds of declarations can be used:
* **Feature domain** declarations (keyword `features`)
* **Label domain** declarations (keyword `labels`)
* **Rule** declaration (keyword `rule`)
* **Strategy** declaration (keyword `strategy`)
* **Package** declaration (keyword `package`)
The first two kinds (Feature domain and label domain) can only be used at the top level and they cannot be nested (see below the multi-file handling).
## Feature domains
In graphs and in rules, nodes contain feature structures.
To control these feature structures, a feature domain may be given first.
In the feature domain declaration, feature names are identifiers and are defined as:
* **closed** feature accepts only an explicit given set of possible values (like the cat feature value below);
* **open** feature name accepts any string value (like the lemma feature value below);
* **numerical** feature (like the position feature below).
In closed features definition, feature values can be any strings; double quotes are required for string that are not lexical identifier (like values for pers).
:question: Explain merging of two feature domain declarations.
~~~grew
features {
cat: n, np, v, adj;
mood: inf, ind, subj, pastp, presp;
lemma: STRING;
phon: STRING;
pers: "1","2","3";
position: NUMERIC;
}
~~~
**REM:** values of pers feature are numerals but the only way to restrict to the finite domain {1, 2, 3} is to declare it as a closed feature and possible values as strings.
## Label domains
An explicit set of valid labels for edges may be given after the `labels` keyword.
It is possible to give several label domain declarations; the union of the different sets is then considered (:question: what about duplicates?, see [#4](https://gitlab.inria.fr/grew/libcaml-grew/issues/4)).
By default, edges are drawn with a black solid line and above the figure in DEP representation.
To modify the color or the position of the edges, the user can add attributes to a label with suffixes:
* `@bottom` to put the label above
* `@red`, `@blue`, … to modify the color of the link and the label
* `@dot` or `@dash` to modify the style of the link
Several suffixes can be used simultaneously.
~~~grew
labels { OBJ, SUJ, DE_OBJ, ANT, ANT_REL@red, ANT_REP@blue@bottom@dash }
~~~
:warning: the color, style and position management will change soon (see [#5](https://gitlab.inria.fr/grew/libcaml-grew/issues/5))
## Rules
Rule declaration is introduced by the keyword `rule`. For the syntax, see [rule page](../rule).
## Strategies
Strategies are used specify the way are applied during transformation.
Syntax of strategies definition:
~~~grew
strat strat_id {
<<< strategy_description >>>
}
~~~
Strategy descriptions are defined by the following syntax:
~~~grew
S ::= rule_id
| strat_id
| Pick (S)
| Alt (S_1, …, S_n)
| Seq (S_1, …, S_n)
| Iter (S)
| If (S_1, S_2, S_3)
~~~
A few other contructors are available as syntactic sugar for frequently used strategies:
~~~grew
Empty ≜ Seq ()
Try (S) ≜ If (S, S, Empty)
Rules (package_id)
~~~
## Packages
Packages are used to organize the set of declarations and to define scopes of definitions.
Syntax of packages definition:
~~~grew
package package_id {
declarations_list
}
~~~
where `declarations_list` is a list of declarations of **rules**, **packages** and **strategies**.
The syntax for accessing to some element `e` defined in package `P` is `P.e`.
In case of nested packages, an identifier may look like `P1.P2.P3.e`.
Note that it is not allowed to have a domain declaration inside a package.
## Multi-file managment
When a GRS become large and contains an high number of rules, it is sensible to define it in through a set of files.
Two mechanisms are available for this purpose: external file import and external file inclusion.
### External file import
At any place in a list of declaration in a GRS file, one can use the syntax:
```grew
import "filename.grs"
```
This creates a new package with the same name as the file. Hence, the meaning is the same as the following code:
```grew
package filename {
<<< content of the file "filename.grs" >>>
}
```
As a consequence, it is not allowed to import a file which contains domain declarations because it would be equivalent to a domain declaration inside a package and this is forbidden.
To use a external domain declaration, one should use the file inclusion.
### External file inclusion
With file inclusion, the content of the external file is interpreted as if it was placed directly in the file at the same place.
In other words the code:
```grew
include "filename.grs"
```
has the same meaning as
```grew
<<< content of the file "filename.grs" >>>
```
......@@ -31,6 +31,12 @@
<li><a href="/commands">Command syntax</a></li>
<li><a href="/rule">Rule syntax</a></li>
<li><a href="/grs">GRS syntax</a></li>
<hr/>
<li class="section">Developper corner</li>
<li><a href="/new_grs">New GRS syntax</a></li>
<li><a href="https://gitlab.inria.fr/grew/libcaml-grew">Gitlab for Grew library</a></li>
<li><a href="https://gitlab.inria.fr/grew/grew">Gitlab for Grew GUI</a></li>
</ul>
</div>
......
......@@ -81,6 +81,17 @@ pre[class*="language-"] {
color: #999;
}
/* added for grew */
.token.command {
color: #905;
}
/* added for grew */
.token.strat {
color: #D63;
}
.namespace {
opacity: .7;
}
......
Prism.languages.grew = {
'comment': /%.*/,
'keyword': /\b(?:module|rule|deterministic|pattern|without|commands|sequences|graph|features|labels|domain)\b/,
'number': /\b(?:del_edge|add_edge|shift|shift_in|shift_out|del_node|add_node)\b/,
'keyword': /\b(?:module|rule|deterministic|pattern|without|commands|sequences|graph|features|labels|domain|package|rule|strat|import|include)\b/,
'command': /\b(?:del_edge|add_edge|shift|shift_in|shift_out|del_node|add_node)\b/,
'strat': /\b(?:Iter|Pick|Alt|Seq|If|Empty|Rules|Try)\b/,
'constant': /\b(?:STRING|NUMERIC)\b/,
'string': [
{
pattern: /"(?:\\.|[^\\\r\n"])*"/,
......
Markdown is supported
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