Propostas para Dissertação

Mestrados no Departamento de Informática

Consultar ficha completa de uma proposta de dissertação

proponente: Daniela da Cruz, Nuno Oliveira
instituição/empresa: Checkmarx
tema/título: Visual editor for Antlr4 grammars to generate abstract syntax trees
área científica: Grammars, language processing, parsing
local: Braga
curso de mestrado: Mestrado Integrado em Engenharia Informática
In order to help developing a new language, the idea is to pick an existing Antlr4 grammar (or even
if created from scratch) and automatically generate the code to create the AST. The step ahead when
having more grammars is to populate this tool with knowledge from previous grammars and
automatically suggest mappings for the rules in grammar to the AST nodes. Details: Usually, we have a rule in grammar for class declarations. In Javascript it looks like this: classDeclaration: Class Identifier classHeritage? OpenBrace classBody CloseBrace; and the visitor to create the node in our Unified AST is: public override SyntaxNode VisitClassDeclaration(ClassDeclarationContext context) { SyntaxToken classToken = Visit(context.Class()).Token; SyntaxToken name = Visit(context.Identifier()).Token; SyntaxNodeList baseList = Visit(context.classHeritage()); SyntaxNode body = Visit(context.classBody()); return new ClassDeclarationSyntax(classToken, name, baseList, body); } In Python the same rule is written as: class_def: decorator* CLASS IDENT (LPAREN expr_list? RPAREN)? COLON suite; The code above in the visitor would be almost the same for Python.