Modelling Parsing and Unparsing Vadim Zaytsev Anya Helene Bagge University of Amsterdam University of Bergen Parsing@SLE 2014-09-14 Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 1 / 10
SLE Artifacts String ��������������� Parse Tree ������ ��� ������ ��� ������ ��� ���� ������ ���� ��� ��� ���� ������ ��� Token List ��� ��� ��� ������ ��� � ��� � ��� � � � ����� ���� ������ ��� ������ ���� ���� ��� �� ���� ���� ������ ����� ��� Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 2 / 10
Te Megamodel m2m transformation structural editing Abstract visualise Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) serialise e t e flatten d c d m2m a o o r l l p code transformation t p x m x Layoutless e e i parse TTk Cst Gra (typed tokens) unparse (concrete syntax tree) (graph model) format t t strip p a p a m m i i r r t t r r s o s o f f visual editing parse Layout refactoring Tok Ptr Dra (tokens) unparse (parse tree) (vector drawing) e t a e tokenise t u s r i a g e n c d i g n b n o m o e c c r a e scannerless parse s r i Raw d Str For Pic filtering drawing (string) unparse (parse forest) (rasterised picture) text editing Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 3 / 10
Classic (Lex+Yacc) Parsing Abstract Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) Layoutless parse TTk Cst Gra (typed tokens) (concrete syntax tree) (graph model) Layout Tok Ptr Dra (tokens) (parse tree) (vector drawing) scan Raw Str For Pic (string) (parse forest) (rasterised picture) Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 4 / 10
Code Formatting Abstract Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) Layoutless TTk Cst Gra (typed tokens) unparse (concrete syntax tree) (graph model) format Layout Tok Ptr Dra (tokens) (parse tree) (vector drawing) concat Raw Str For Pic (string) (parse forest) (rasterised picture) Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 5 / 10
Rascal Abstract Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) implode Layoutless TTk Gra (typed tokens) (figure) Cst render (concrete syntax tree) Ptr (parse tree) Layout Tok Dra unparse (tokens) (vector drawing) filter scannerless parse Raw Str For Pic (string) (parse forest) (rasterised picture) unparse Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 6 / 10
Lowered Transformations Ast Ast transform Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 7 / 10
Lowered Transformations Ast Ast transform implode explode Cst Cst transform Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 7 / 10
Lowered Transformations Ast Ast transform implode explode Cst Cst transform format strip Ptr Ptr transform Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 7 / 10
Lowered Transformations Ast Ast transform implode explode Cst Cst transform format strip Ptr Ptr transform unparse parse Str Str t r a n s f o r m Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 7 / 10
Composing Transformations Abstract Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) Layoutless TTk Cst Gra (typed tokens) unparse (concrete syntax tree) (graph model) format Layout Tok Ptr Dra (tokens) (parse tree) (vector drawing) concat Raw Str For Pic (string) (parse forest) (rasterised picture) Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 8 / 10
Composing Transformations Abstract Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) Layoutless TTk Cst Gra (typed tokens) unparse (concrete syntax tree) (graph model) format Layout Tok Ptr Dra (tokens) (parse tree) (vector drawing) concat Raw Str For Pic parse (string) (parse forest) (rasterised picture) Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 8 / 10
Composing Transformations Abstract Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) Layoutless TTk Cst Gra (typed tokens) unparse (concrete syntax tree) (graph model) format Layout Tok Ptr Dra (tokens) (parse tree) (vector drawing) concat filter Raw Str For Pic parse (string) (parse forest) (rasterised picture) Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 8 / 10
Composing Transformations Abstract Lex Ast Dia (lexical model) (abstract syntax tree) (diagram) Layoutless TTk Cst Gra (typed tokens) unparse (concrete syntax tree) (graph model) format strip Layout Tok Ptr Dra (tokens) (parse tree) (vector drawing) concat filter Raw Str For Pic parse (string) (parse forest) (rasterised picture) Graphical Textual Structured Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 8 / 10
Is it Useful? Explain representations and transformations to students Explain what you mean with “parsing” in your paper Simplify dealing with bidirectional transformations Amaze your friends with fancy graphic models in your papers Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 9 / 10
Conclusion We have identified SLE artifacts and translations between them Prototype w/transformations: https://github.com/grammarware/bx-parsing The full paper: Vadim Zaytsev and Anya Helene Bagge. Parsing in a Broad Sense. In Jurgen Dingel and Wolfram Schulte, editors, Proceedings of the 17th International Conference on Model Driven Engineering Languages and Systems (MODELS’14), volume 8767 of LNCS, pages 50–67. Springer, 2014. Zaytsev & Bagge (UvA/UiB) Modelling Parsing and Unparsing 2014-09-14 10 / 10
Recommend
More recommend