Unifying Parsing and Reflective Printing for Fully Disambiguated Grammars

dc.contributor.author Ko,HS en
dc.contributor.author Hu,ZJ en
dc.contributor.author João Alexandre Saraiva en
dc.contributor.author Martins,P en
dc.contributor.author Zhang,YZ en
dc.contributor.author Zhu,ZR en
dc.contributor.other 5597 en
dc.date.accessioned 2020-07-22T09:03:36Z
dc.date.available 2020-07-22T09:03:36Z
dc.date.issued 2020 en
dc.description.abstract Language designers usually need to implement parsers and printers. Despite being two closely related programs, in practice they are often designed separately, and then need to be revised and kept consistent as the language evolves. It will be more convenient if the parser and printer can be unified and developed in a single program, with their consistency guaranteed automatically. Furthermore, in certain scenarios (like showing compiler optimisation results to the programmer), it is desirable to have a more powerful reflective printer that, when an abstract syntax tree corresponding to a piece of program text is modified, can propagate the modification to the program text while preserving layouts, comments, and syntactic sugar. To address these needs, we propose a domain-specific language BiYacc, whose programs denote both a parser and a reflective printer for a fully disambiguated context-free grammar. BiYacc is based on the theory of bidirectional transformations, which helps to guarantee by construction that the generated pairs of parsers and reflective printers are consistent. Handling grammatical ambiguity is particularly challenging: we propose an approach based on generalised parsing and disambiguation filters, which produce all the parse results and (try to) select the only correct one in the parsing direction; the filters are carefully bidirectionalised so that they also work in the printing direction and do not break the consistency between the parsers and reflective printers. We show that BiYacc is capable of facilitating many tasks such as Pombrio and Krishnamurthi's 'resugaring', simple refactoring, and language evolution. en
dc.identifier.uri http://repositorio.inesctec.pt/handle/123456789/11450
dc.identifier.uri http://dx.doi.org/10.1007/s00354-019-00082-y en
dc.language eng en
dc.rights info:eu-repo/semantics/openAccess en
dc.title Unifying Parsing and Reflective Printing for Fully Disambiguated Grammars en
dc.type Publication en
dc.type article en
Files
Original bundle
Now showing 1 - 1 of 1
Thumbnail Image
Name:
P-00S-28X.pdf
Size:
6.96 MB
Format:
Adobe Portable Document Format
Description: