gSync - A Tree-based Diff/Merge Tool for ANTLR v3 Grammars

jetmorebrisketΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 5 χρόνια και 1 μήνα)

345 εμφανίσεις

gSync











A Tree
-
based Diff/Merge Tool for ANTLR v3 Grammars


Shaoting Cai

About gSync


What is gSync?


2
-
way diff, 3
-
way diff and merge


Swing GUI


Tree
-
based


Background


Yang's Java grammar


ANTLR grammar example repository

Features


Tree
-
based diff/merge algorithm


Grammar semantics


Ignore irrelevant information


Fuzzy matching


Pattern recognition


Add/Remove rule definitions and references


Tree movements

Screen casts


Tree
-
based vs. text
-
based


2
-
way diff


3
-
way diff and merge

Tree
-
based vs. Text
-
based

My changes...


Group some rules


Format alternatives


Add some comments


Delete a rule


Definition


References


KDE Kompare


14 differences


gSync Diff Tool


1 delete pattern


1 changed rule

KDE Kompare

gSync Diff Tool

Diff


exmple 1


do...while statement


'while' '(' expression ')' statement


'do' statement 'while' '(' expression ')'


Alternative paired using similarity


Element level analysis

Diff


exmple 2


'and' operator


Add alternative

gSync


Merge Tool

Making gSync


Using ANTLR, for ANTLR


Grammar parsing


AST generation


Tools


Using ANTLRWorks


NetBeans and Java 6

Diff


Parsing


AST


Analyzer Pipeline


Diff results


Swing GUI

Gr ammar A
Gr ammar B
AST
AST
Tr ee Matcher
Mat ch Table
Rule
Alt
Element
Pat t er ns
Diff Res ult s
Swing GUI
AST


Rules


Alternatives


Elements

gr ammar
Rule
Rule
Alt
Alt
Alt
Alt
Element
Element
Element
Tree Matching


Node matching:
type

and
text


Match table


Node pairing using tree similarity


For finding changed sub
-
trees

A
x
y
z
A'
x
z
80%
p r ot o
d er ived
X
Y
Z
...
X
Z
...
Analysis Pipeline

Rule
Alt er na t ive
Element
Pa t t er n
Add e d r ule s
Re move d r u le s
Change d rule s
Ma t che d r u le s
Add e d Alt s
Re move d
Alt s
Change d
Alt s
Ma t che d
Alt s
Move d Alt s
Add e d Ele me n t s
Re move d
Ele m
Ma t che d
Ele m
Move d Ele m

Find matches and changes


Top
-
down


Combine changes into patterns

3
-
way Diff


3 versions


Proto


Derived


Revised


2 change
-
sets


Local changes


Remote changes*

pr ot o.g
der ived.g
r evised.g
Local change s
Re m ot e
change s
S y n c ch ang e s
Merge


Push changes into
derived

version.


Focus on
remote

changes


Merge strategy
matrix


TokenRewriteStream


Preview and merge


Using
rewrite program

Future works


GUI


More patterns


Diff on actions


Performance improvements

Thank you


Questions or comments?


Contact me:

caishaoting@gmail.com