|Introdução ao Desenvolvimento de Compiladores|
|Aspectos Teóricos de Análise Lexical|
|A Ferramenta Flex|
|Introdução à Sintaxe|
|Análise Sintáctica Descendente|
|A Ferramenta YACC|
|Análise Sintáctica Ascendente|
|Geração de Código|
|Tópicos de Optimização|
Attributes in grammar symbols form a fundamental concept in compiler design, especially in semantic analysis. Attributes provide a way to associate information with each grammar symbol. This information is used to store properties of language constructs like the datatype, number of digits in a number, the value of a constant, etc. When the parser recognizes a language construct represented by a grammar symbol, it uses the attribute values to build other attributes or the abstract syntax tree. These attributes may be used later in the symbol table.
During analysis, the parser computes the values of the attributes. This is called syntax-directed evaluation and provides a simple form of semantics. Syntax-directed translates a sequence of input symbols (such as a source program) into an output sequence (such as object code) by means of a syntax-directed translator (often integrated with the parsing process). This method is based on the grammar and its added semantic rules, linking the grammar productions with actions to be performed when these productions are used during parsing. The semantic rules can access and manipulate the attributes of grammar symbols.
The attributes are usually divided into two groups, according with their dependencies on the parse tree:
Depending on the type of parser (frequently, top-down or bottom-up), and the type of attribute, attribute computation may occur in specific ways for each grammar type: