Coupled Transformations of SPPFs Dr. Vadim Zaytsev aka @grammarware GCM @ STAF 2015
Grammars ✓ Finite language definitions ✓ Text biased ✓ Tree biased ✓ Can be generalised http://rikiji.it/2010/06/21/compilers.html
Grammars ⇒ Trees E E ::= E "+" E; E + E E ::= "x" | "y"; x y
Grammars ⇒ Trees E E ::= E "+" E; E + E E ::= "x" | "y"; E + E x x y
Grammars ⇒ Trees E E OR E + E E + E x E + E y x E + E x x y
Grammars ⇒ Trees E E AND E + E E + E x E + E y x E + E x x y generalised parsing
Grammars ⇒ Graphs generalised E E parse E E E + E + E x y x
SPPF e 1 E E E e 2 e 3 E E E E e 5 e e E E E 4 6 2 + 2 + 2 + 2 t 1 t 2 t 3 t 4 t 5 t 6 t 7 � h e 1 , ( e 2 , t 6 , t 7 ) i , h e 1 , ( e 4 , t 4 , e 6 ) i , h e 1 , ( t 1 , t 2 , e 3 ) i , h e 2 , ( e 4 , t 4 , t 5 ) i , h e 2 , ( t 1 , t 2 , e 5 ) i , h e 3 , ( e 5 , t 6 , t 7 ) i , h e 3 , ( t 3 , t 4 , e 6 ) i , h e 4 , ( t 1 , t 2 , t 3 ) i , h e 5 , ( t 3 , t 4 , t 5 ) i , h e 6 , ( t 5 , t 6 , t 7 ) i
Boolean grammars S S S E ::= ABC nice parse view & AB c+ ABC & a+ BC; a+ AB b+ BC c+ ABC ::= a+ b+ c+ AB ::= a AB? b; BC ::= b AB? c; AB? BC? context-sensitivity trick a b c ε ε
The real problem: transformation
The real problem: ✓ Manipulate “nice” views ✓ let the rest keep up ✓ Merge views ✓ disambiguate ✓ Modular transformations ✓ temporary inconsistencies ✓ Many solutions ✓ none satisfactory ✓ Standing challenge
State of the art [grammars] XBGF Ξ BGF . . . SLEIR http://grammarware.github.io/lab/
This paper coupled transformation grammars SPPFs
extract S S S S S S S S S ABP a+ AB b+ BC c+ AP AB b+ BC c+ a+ AB b+ BC c+ a+ AB? BC? AB? BC? AB? BC? a b c a b c a b c ε ε ε ε ε ε S ::= a+ b+ c+ & AB c+ & a+ BC; S ::= AP b+ c+ & AB c+ & AP BC; S ::= ABP c+ & AB c+ & a+ BC; AB ::= a AB? b; AB ::= a AB? b; AB ::= a AB? b; BC ::= b BC? c; BC ::= b BC? c; BC ::= b BC? c; AP ::= a+; ABP ::= a+ b+; (a) (b) (c)
fold S S S S S S S S S ABC AP ABC ABC a+ AB b+ BC c+ a+ AB b+ BC c+ AP AB b+ BC c+ a+ AB? BC? AB? BC? AB? BC? a b c a b c a b c ε ε ε ε ε ε S ::= ABC & AB c+ & a+ BC; S ::= ABC & AB c+ & AP BC; S ::= ABC & AB c+ & AP BC; AB ::= a AB? b; AB ::= a AB? b; AB ::= a AB? b; BC ::= b BC? c; BC ::= b BC? c; BC ::= b BC? c; ABC ::= a+ b+ c+; ABC ::= a+ b+ c+; ABC ::= AP b+ c+; AP ::= a+; AP ::= a+; AP ::= a+; (a) (b) (c)
inline S S S S S S ABC a+ AB b+ BC c+ a+ AB b+ BC c+ AB? BC? AB? BC? a b c a b c ε ε ε ε S ::= ABC & AB c+ & a+ BC; S ::= a+ b+ c+ & AB c+ & a+ BC; AB ::= a AB? b; AB ::= a AB? b; BC ::= b BC? c; BC ::= b BC? c; ABC ::= a+ b+ c+; (a) (b)
Solution (graphs) Language SPPFs Examples preserved preserved introduce, unlabel fold, inline preserved refactored extended preserved addV, define extended refactored removeC, widen reduced preserved? removeV, undefine reduced refactored disappear reduced refactored? addC, narrow revised refactored permute, renameT revised refactored? redefine, replace revised — inject
Conclusion ✓ Programmably cotransform ✓ string/term grammars ✓ forest representations ✓ Applicable to grammars in a broad sense ✓ views and models with uncertainty ✓ Still unclear ✓ What is the best way? ✓ Formalisation?
e 1 E E E e 2 e 3 E E E E e 5 e e E E E 4 6 2 + 2 + 2 + 2 t 1 t 2 t 3 t 4 t 5 t 6 t 7 Questions? Suggestions?
Recommend
More recommend