1
Precedence Graph Grammar for Hierarchical Program Diagram
○Takaaki Goto (Toyo University) Kenji Ruise (Kirigaoka School for the
Physically Challenged, University of Tsukuba )
Kensei Tsuchida (Toyo University) Takeo Yaku (Nihon University)
2
1. Introduction2. Hichart/DXL3. Preliminaries4. Graph Grammar for Hichart/DXL5. Parsing of precedence graph grammar for
Hichart/DXL6. Hichart Editor7. Conclusion
Contents
3
1. Introduction
1.1 Background1.2 Motivation1.3 Purpose1.4 Results
4
1.1 Background
Various researches have been done on graph grammars and their application
We have been developing a software development environment based on graph grammars to formalize of diagram’s structure and layout information to formalize of diagram processing method
5
1.1 Background (cont.)
The program diagram called Hichart (HIerachical flowCHART description language) in this environment is treated
We have already developed bidirectional translators that translatePascal, C, or DXL to Hichart Hichart to Pascal, C, or DXL
6
1.2 Motivation
A parser plays a key role in our processing system and needs to be efficient as large-scale program diagrams are parsed
7
1.3 Purpose
To adopt a precedence relation of graph grammar for Hichart/DXL to parse Hichart diagram efficiently
8
1.4 Results Adapted a precedence relation of
graph grammar for Hichart/DXL productions 70semantic rules 888precedence relations 256
Implemented graphical editor with parser in JAVA
9
2. Hichart/DXL
10
2. Hichart/DXL (cont.)
Characteristics of Hichart(1) Diagram is a tree-flowchart with the
same flow control lines as a Neumann program flowchart
(2) The hierarchy of the data structure and the control flow are displayed on a plane simultaneously
11
DXL(1) Diagram eXchange Language for
tree-structure charts, DXL, was specified in the 1997 ISO
(2) Purpose of DXL is to facilitate the interchange of different tree-structure charts between CASE tools
2. Hichart/DXL (cont.)
12
Data exchange between various tree-structure diagrams through DXL
2. Hichart/DXL (cont.)
(Hitachi)
13
3. Preliminaries
3.1 edNCE Graph Grammar3.2 Precedence Graph Grammar
14
3.1 edNCE Graph Grammar [Rozenberg, 1997]
15
3.1 edNCE Graph Grammar (cont.)
(c) Result
Example of production & derivation
(a) Host
(b) Production
X:=
16
3.2 Precedence Graph Grammar
A graph grammar that is ・ confluent
・ symmetric・ uniquely invertible・ has no reflexive nonterminals・ no precedence conflicts
is called precedence graph grammar [Kaul, 1986].
17
3.2 Precedence Graph Grammar (cont.)
derivation specifications , where
is an isomorphic graph of the left hand side of a production
is an isomorphic graph of the right hand side of a production
is an isomorphism
)~
,~
,~
,( bDXps
X~
D~
b~
RRVV ~
18
3.2 Precedence Graph Grammar (cont.)
derivation sequences
precedes if The reflexive and transitive closure of this
relation is denoted are incomparable if neither nor
iS jS j iL R
D
)~
,~
,~
,(,),1|( 1 iiiiiis
i bRLpsNnniGGDi
ji ss , iDj ss jDi ss
19
3.2 Precedence Graph Grammar (cont.)
DD v D wv w s s
An ordering of the nodes in Gn is
,,, are the precedence relation between nodes
The precedence relations between labels
,,,,R
is the set of all )}(),,(),,(),({),( wλvwEwvEvλwvlab GGG
20
4. Graph Grammar for Hichart/DXL
4.1 Attribute Graph Grammar for Hichart/DXL
4.2 Derivation of GGHD
4.3 Precedence Relation for GGHD
21
4.1 Attribute Graph Grammar for Hichart/DXL
GGHD (Graph Grammar for Hichart/DXL)
GG Type Productions
Semantic rules
GGHD Context-free
70 888
22
4.1 Attribute Graph Grammar for Hichart/DXL (cont.)
Fig. Example of production and semantic rules of GGHD
23
4.2 Derivation of GGHD
We substitute (D’,C’) for a node X’ in H as follows.(1) Remove a mother node X’ , and edges that
connect with X’ from host graph H,(2) Embed the daughter graph D’ into H- , and(3) Establish edges between the nodes of D’ and
the nodes that were connected to the mother node in the H of H− using the connection instructions of C’.
24
4.2 Derivation of GGHD
(cont.)
Remove mother node and edges that connect
with [profile_module_list]
25
4.2 Derivation of GGHD
(cont.)
Embed the daughter graph
26
4.2 Derivation of GGHD
(cont.)
Establish edges using the connection instructions
27
4.3 Precedence Relation for GGHD
We adopted a precedence relation of graph grammar for Hichart/DXL using Kaul’s definitions
28
4.3 Precedence Relation for GGHD (cont.)
29
4.3 Precedence Relation for GGHD (cont.)
30
4.3 Precedence Relation for GGHD (cont.)
s1=(P1, [module_packet], D1, b)
sD(2)=s1
sD(3)=s1
31
4.3 Precedence Relation for GGHD (cont.)
32
4.3 Precedence Relation for GGHD (cont.)
s2=(P3, [profile_module_list], D2, b)
sD(4)=s2
sD(5)=s2
33
4.3 Precedence Relation for GGHD (cont.)
34
4.3 Precedence Relation for GGHD (cont.)
s3=(P4, [profile], D3, b)
sD(6)=s3
sD(7)=s3
35
4.3 Precedence Relation for GGHD (cont.)
36
4.3 Precedence Relation for GGHD (cont.)
s4=(P5, [module_list], D4, b)
sD(8)=s4
37
4.3 Precedence Relation for GGHD (cont.)
432104321
GGGGGssssderivation
sequence :
sD(6)=s3, sD(7)=s3, s3 =D s3, 6 = 7
6 7 ⇔ sD(6) D sD(7)
lab(6, 7) = ("profile", #, , "explanation") R ∈ =
[The precedence relation between 6 and 7 ]
421321 ,, ssssss DDDD
38
4.3 Precedence Relation for GGHD (cont.) We defined all the precedence relations
between labels for grammar GGHD
We call this grammar the Precedence Graph Grammar for Hichart/DXL (PGGHD)
[Property 1]PGGHD is a precedence graph grammar
39
5. Parsing of Precedence Graph Grammar for Hichart/DXL
5.1 Algorithm for parsing5.2 Example of Parsing
40
5.1 Algorithm for parsing
uses a stack for storing traversed nodes Starts parsing from the root node of an input graph
[parsing]1. shift as long as possible2. If there is no ascending node, the parser searches
a production where the right-hand-side is isomorphic to the precedence handle.
3. reduce the precedence handle to lhs of the production
41
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”
<
< <
<
M_Packet
0
G
K※
5.2 Example of ParsingAn input
graph
An ordered listof G
42
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”
<
< <
<
“m_packet”
0
G
K
※
5.2 Example of Parsing (cont.)
43
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”
<
< <
<
“m_packet”
0
G
K
TOP(G,K)
※
5.2 Example of Parsing (cont.)
44
“m_packet”
0
“profile”
1
G
K
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”
<
< <
<
※
45
G
K
TOP(G,K)
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”< <
※“m_packet”
0
“profile”
1
< <
46
G
K “explanation”
2
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”< <
※
< <
“m_packet”
0
“profile”
1
47
G
K “explanation”
2
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”< <
※
< <
“m_packet”
0
“profile”
1
TOP(G,K)
48
G
K “explanation”
2
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
“explanation”
“module_algorithm”
“BoxEmpty1”< <
※
< <
“m_packet”
0
“profile”
1
TOP(G,K)
find_production
P10
49
G
K [explanation]
2
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
[explanation]
“module_algorithm”
“BoxEmpty1”< <
※
< =
“m_packet”
0
“profile”
1
50
G
K [explanation]
2
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
[explanation]
“module_algorithm”
“BoxEmpty1”< <
※
< =
“m_packet”
0
“profile”
1
TOP(G,K)
51
G
K [explanation]
2
5.2 Example of Parsing (cont.)
“m_packet” “profile”
“identifier_is”
[explanation]
“module_algorithm”
“BoxEmpty1”< <
※
< =
“m_packet”
0
“profile”
1
TOP(G,K)
find_production
P04
52
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
53
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
TOP(G,K)
54
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2
55
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2
TOP(G,K)
56
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3
57
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3
TOP(G,K)
58
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3
“BoxEmpty1”
4
59
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3
“BoxEmpty1”
4
TOP(G,K)
60
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
“BoxEmpty1”< <
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3
“BoxEmpty1”
4
TOP(G,K)
find_production
P14
61
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
[statement_list]
< =
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3[statement_
list]
4
62
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
[statement_list]
< =
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3[statement_
list]
4
TOP(G,K)
63
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
“module_algorithm”
[statement_list]
< =
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2“module_algorithm”
3[statement_
list]
4
TOP(G,K)
find_production
P11
64
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
<
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2[module_algorithm]
3
[module_algorithm]
65
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
<
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2[module_algorithm]
3
[module_algorithm]
TOP(G,K)
66
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
<
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2[module_algorithm]
3
[module_algorithm]
TOP(G,K)
find_production
P08
67
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
=
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2
[explanation_modue_algorithm]
[explanation_modue_algorithm]
3
68
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
=
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2
[explanation_modue_algorithm]
[explanation_modue_algorithm]
3
TOP(G,K)
69
G
K
5.2 Example of Parsing (cont.)
“m_packet”
“identifier_is”
=
<
“m_packet”
0
[profile]
1
[profile]
<
“identifier_is”
2
[explanation_modue_algorithm]
[explanation_modue_algorithm]
3
TOP(G,K)
find_production
P07
70
G
K
5.2 Example of Parsing (cont.)
“m_packet”<
“m_packet”
0
[profile]
1
[profile]
<
[module]
[module]
2
71
G
K
5.2 Example of Parsing (cont.)
“m_packet”<
“m_packet”
0
[profile]
1
[profile]
<
[module]
[module]
2
TOP(G,K)
72
G
K
5.2 Example of Parsing (cont.)
“m_packet”<
“m_packet”
0
[profile]
1
[profile]
<
[module]
[module]
2
TOP(G,K)
find_production
P05
73
G
K
5.2 Example of Parsing (cont.)
“m_packet”<
“m_packet”
0
[profile]
1
[profile]
=
[module_list]
[module_list]
2
74
G
K
5.2 Example of Parsing (cont.)
“m_packet”<
“m_packet”
0
[profile]
1
[profile]
=
[module_list]
[module_list]
2
TOP(G,K)
75
G
K
5.2 Example of Parsing (cont.)
“m_packet”<
“m_packet”
0
[profile]
1
[profile]
=
[module_list]
[module_list]
2
TOP(G,K)
find_production
P03
76
G
K
5.2 Example of Parsing (cont.)
“m_packet”=
“m_packet”
0
profile_module_list
profile_module_list
1
77
G
K
5.2 Example of Parsing (cont.)
“m_packet”=
“m_packet”
0
profile_module_list
profile_module_list
1
TOP(G,K)
78
G
K
5.2 Example of Parsing (cont.)
“m_packet”=
“m_packet”
0
profile_module_list
profile_module_list
1
TOP(G,K)
find_productionP01
79
[module_packet]
[module_packet]
0
G
K
5.2 Example of Parsing (cont.)
80
[module_packet]
[module_packet]
0
G
K
5.2 Example of Parsing (cont.)
finish parsing
TOP(G,K)
81
6. Hichart Editor【 Outline 】Hichart Editor Supports non-syntax-directed editing has parserJava ( 10,000steps )【 features 】
1. To check the correctness of diagrams2. To draw Hichart diagrams aesthetically3. To generate an SVG file
82
Input: Hichart diagrams
Output: Hichart code with derivation tree
SVG files with aesthetically drawing
6. Hichart Editor (cont.)
83
DEMO
Parsing on Hichart Editor Generating SVG file on Hichart Editor
84
7. ConclusionSummary Adapted a precedence relation of graph
grammar for Hichart/DXL productions 70 semantic rules 888 precedence relations 256
Implemented graphical editor with parser in JAVA
85
7. Conclusion (cont.)
Our graph grammar based method would be able to apply to other visual programming systems that treat tree-like graphs
86
7. Conclusion (cont.)
Future workTo apply our method of graph grammar
to Object-Oriented Language