1 / 4

AST no ANTLR

AST no ANTLR. Teoria e Implementação de Linguagens Computacionais - IF688. Allan J. Souza { ajss }@ cin.ufpe.br. Construção da AST (ANTLR). Campo options na gramática options{ output=AST; ASTLabelType=CommonTree; } Outras opções: Linguagem do código a ser gerado;

dahlia
Télécharger la présentation

AST no ANTLR

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AST no ANTLR Teoria e Implementação de Linguagens Computacionais - IF688 Allan J. Souza{ajss}@cin.ufpe.br

  2. Construção da AST (ANTLR) • Campo options na gramática options{ output=AST; ASTLabelType=CommonTree; } • Outras opções: • Linguagem do código a ser gerado; • Tipo dos tokens gerados; • ...

  3. Construção da AST (ANTLR) • Construção da árvore • Geração de sub-árvores em cada produção • Operadores sobre as regras • ! – não incluir o nó ou sub-árvore; • ^ – transformar o nó em raiz de uma sub-árvore • Reescrita de regras • Operador -> • Ex: args : arg (‘,’ arg)* -> arg+ • Nós imaginários • Ex: declaration : type ID ';' -> ^(DECL type ID) ; //DECL é imaginário

  4. Aula.g Exemplo

More Related