<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://robots.hlt.inesc-id.pt/w/pt/index.php?action=history&amp;feed=atom&amp;title=The_YACC_Parser_Generator%2FExercise_8</id>
	<title>The YACC Parser Generator/Exercise 8 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://robots.hlt.inesc-id.pt/w/pt/index.php?action=history&amp;feed=atom&amp;title=The_YACC_Parser_Generator%2FExercise_8"/>
	<link rel="alternate" type="text/html" href="https://robots.hlt.inesc-id.pt/w/pt/index.php?title=The_YACC_Parser_Generator/Exercise_8&amp;action=history"/>
	<updated>2026-05-24T01:32:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>https://robots.hlt.inesc-id.pt/w/pt/index.php?title=The_YACC_Parser_Generator/Exercise_8&amp;diff=14850&amp;oldid=prev</id>
		<title>Root: /* Problema */</title>
		<link rel="alternate" type="text/html" href="https://robots.hlt.inesc-id.pt/w/pt/index.php?title=The_YACC_Parser_Generator/Exercise_8&amp;diff=14850&amp;oldid=prev"/>
		<updated>2022-05-27T15:39:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Problema&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:39, 27 May 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l2&quot;&gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Problema ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Problema ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Considere uma linguagem constituída por uma sequência de intervalos&lt;/del&gt;, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; possivelmente vazia&lt;/del&gt;. Os &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;intervalos são definidos por valores reais (os limites inferior &lt;/del&gt;e &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;superior &lt;/del&gt;são &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;separados &lt;/del&gt;por &#039;&#039;&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/del&gt;&#039;&#039;&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;)&lt;/del&gt;. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Os intervalos são separados entre si &lt;/del&gt;por &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;vírgulas (&lt;/del&gt;&#039;&#039;&#039;,&#039;&#039;&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;). A representação dos números reais é como &lt;/del&gt;em &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;C++&lt;/del&gt;. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Pretende-se determinar &lt;/del&gt;a &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;largura do menor intervalo da &lt;/del&gt;sequência, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ignorando os intervalos inválidos (em que &lt;/del&gt;o &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;limite superior &lt;/del&gt;é &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;menor que &lt;/del&gt;o &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;limite inferior&lt;/del&gt;).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Uma máquina reconhece os símbolos &#039;&#039;&#039;0&#039;&#039;&#039;, &#039;&#039;&#039;1&#039;&#039;&#039;&lt;/ins&gt;, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;*&#039;&#039;&#039; e &#039;&#039;&#039;#&#039;&#039;&#039;&lt;/ins&gt;. Os &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;símbolos &#039;&#039;&#039;0&#039;&#039;&#039; &lt;/ins&gt;e &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;1&#039;&#039;&#039; &lt;/ins&gt;são &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;organizados em sequências numéricas separadas umas das outras &lt;/ins&gt;por &#039;&#039;&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*&#039;&#039;&#039; ou &#039;&#039;&#039;#&lt;/ins&gt;&#039;&#039;&#039;. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Se a sequência numérica começar &lt;/ins&gt;por &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;0&lt;/ins&gt;&#039;&#039;&#039;, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;então o seu valor inicial é 2 e duplica a cada &#039;&#039;&#039;0&lt;/ins&gt;&#039;&#039;&#039; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;adicional e incrementa &lt;/ins&gt;em &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;uma unidade a cada &#039;&#039;&#039;1&#039;&#039;&#039; adicional&lt;/ins&gt;. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Se &lt;/ins&gt;a sequência &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;numérica for começar por &#039;&#039;&#039;1&#039;&#039;&#039;&lt;/ins&gt;, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;então &lt;/ins&gt;o &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;seu valor inicial &lt;/ins&gt;é &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;1, sendo incrementada de 2 a cada &#039;&#039;&#039;0&#039;&#039;&#039; adicional e duplicada a cada &#039;&#039;&#039;1&#039;&#039;&#039; adicional. O símbolo &#039;&#039;&#039;*&#039;&#039;&#039; corresponde ao operador binário “mínimo” e &lt;/ins&gt;o &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;símbolo &#039;&#039;&#039;#&#039;&#039;&#039; ao operador binário “máximo” (ambos associativos à esquerda e com a mesma precedência&lt;/ins&gt;).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Escreva uma especificação YACC para o problema acima. Codifique toda a especificação (incluindo as zonas de declarações e de regras) e todas as funções auxiliares. &#039;&#039;&#039;Não utilizar variáveis globais.&#039;&#039;&#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Exemplo: à sequência &#039;&#039;&#039;00100*1100#0010&#039;&#039;&#039; corresponde ao valor 10 (decimal).&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Escreva uma especificação YACC para o problema acima. Codifique toda a especificação (incluindo as zonas de declarações e de&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;regras) e todas as funções auxiliares. &#039;&#039;&#039;Não utilizar variáveis globais.&#039;&#039;&#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The Lexical Analyzer (Flex) Specification ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== The Lexical Analyzer (Flex) Specification ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Root</name></author>
	</entry>
	<entry>
		<id>https://robots.hlt.inesc-id.pt/w/pt/index.php?title=The_YACC_Parser_Generator/Exercise_8&amp;diff=14849&amp;oldid=prev</id>
		<title>Root: /* How to Compile? */</title>
		<link rel="alternate" type="text/html" href="https://robots.hlt.inesc-id.pt/w/pt/index.php?title=The_YACC_Parser_Generator/Exercise_8&amp;diff=14849&amp;oldid=prev"/>
		<updated>2022-05-27T15:36:29Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;How to Compile?&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:36, 27 May 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l66&quot;&gt;Line 66:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 66:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Flex specification is processed as follows (the file &amp;#039;&amp;#039;&amp;#039;lex.yy.c&amp;#039;&amp;#039;&amp;#039; is produced):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Flex specification is processed as follows (the file &amp;#039;&amp;#039;&amp;#039;lex.yy.c&amp;#039;&amp;#039;&amp;#039; is produced):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   flex &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;minint&lt;/del&gt;.l&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   flex &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;numseq&lt;/ins&gt;.l&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The YACC specification is processed as follows (files &#039;&#039;&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;y&lt;/del&gt;.tab.h&#039;&#039;&#039;, needed by the Flex-generated code, and &#039;&#039;&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;y&lt;/del&gt;.tab.c&#039;&#039;&#039;):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The YACC specification is processed as follows (files &#039;&#039;&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;numseq&lt;/ins&gt;.tab.h&#039;&#039;&#039;, needed by the Flex-generated code, and &#039;&#039;&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;numseq&lt;/ins&gt;.tab.c&#039;&#039;&#039;):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   bison -dtv &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;minint&lt;/del&gt;.y&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   bison -dtv &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;numseq&lt;/ins&gt;.y&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compiling the C/C++ code (it is C++ simply because we programmed the extra code in that language):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compiling the C/C++ code (it is C++ simply because we programmed the extra code in that language):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   g++ -std=c++17 -c lex.yy.c&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   g++ -std=c++17 -c lex.yy.c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   g++ -std=c++17 -c &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;y&lt;/del&gt;.tab.c&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   g++ -std=c++17 -c &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;numseq&lt;/ins&gt;.tab.c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   g++ -o &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;minint y&lt;/del&gt;.tab.o lex.yy.o&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   g++ -o &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;numseq numseq&lt;/ins&gt;.tab.o lex.yy.o&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[category:Compiladores]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[category:Compiladores]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[category:Ensino]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[category:Ensino]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Root</name></author>
	</entry>
	<entry>
		<id>https://robots.hlt.inesc-id.pt/w/pt/index.php?title=The_YACC_Parser_Generator/Exercise_8&amp;diff=14848&amp;oldid=prev</id>
		<title>Root: Created page with &quot;{{TOCright}} == Problema ==  Considere uma linguagem constituída por uma sequência de intervalos,  possivelmente vazia. Os intervalos são definidos por valores reais (os li...&quot;</title>
		<link rel="alternate" type="text/html" href="https://robots.hlt.inesc-id.pt/w/pt/index.php?title=The_YACC_Parser_Generator/Exercise_8&amp;diff=14848&amp;oldid=prev"/>
		<updated>2022-05-27T15:35:40Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{TOCright}} == Problema ==  Considere uma linguagem constituída por uma sequência de intervalos,  possivelmente vazia. Os intervalos são definidos por valores reais (os li...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{TOCright}}&lt;br /&gt;
== Problema ==&lt;br /&gt;
&lt;br /&gt;
Considere uma linguagem constituída por uma sequência de intervalos,  possivelmente vazia. Os intervalos são definidos por valores reais (os limites inferior e superior são separados por &amp;#039;&amp;#039;&amp;#039;:&amp;#039;&amp;#039;&amp;#039;). Os intervalos são separados entre si por vírgulas (&amp;#039;&amp;#039;&amp;#039;,&amp;#039;&amp;#039;&amp;#039;). A representação dos números reais é como em C++. Pretende-se determinar a largura do menor intervalo da sequência, ignorando os intervalos inválidos (em que o limite superior é menor que o limite inferior).&lt;br /&gt;
&lt;br /&gt;
Escreva uma especificação YACC para o problema acima. Codifique toda a especificação (incluindo as zonas de declarações e de regras) e todas as funções auxiliares. &amp;#039;&amp;#039;&amp;#039;Não utilizar variáveis globais.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== The Lexical Analyzer (Flex) Specification ==&lt;br /&gt;
&lt;br /&gt;
The lexical analyzer (&amp;#039;&amp;#039;&amp;#039;numseq.l&amp;#039;&amp;#039;&amp;#039;) is very simple and limited to recognizing the indispensable tokens.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
%option noyywrap&lt;br /&gt;
%{&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;quot;numseq.tab.h&amp;quot;&lt;br /&gt;
%}&lt;br /&gt;
%%&lt;br /&gt;
[01*#]           return *yytext;&lt;br /&gt;
.|\n                                    ; /* ignore the rest */&lt;br /&gt;
%%&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Syntactic Analyzer (YACC) Specification ==&lt;br /&gt;
&lt;br /&gt;
The syntactic analyzer (&amp;#039;&amp;#039;&amp;#039;numseq.y&amp;#039;&amp;#039;&amp;#039;) will be built to immediately compute the maximum values in a syntax-directed fashion (as they occur). Note that the use of numeric limits is correct, but other such names would be acceptable (e.g. &amp;#039;&amp;#039;&amp;#039;MAXDOUBLE&amp;#039;&amp;#039;&amp;#039;).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
%{&lt;br /&gt;
#include &amp;lt;limits&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
extern int yylex();&lt;br /&gt;
inline void yyerror(const char *msg) { std::cerr &amp;lt;&amp;lt; msg &amp;lt;&amp;lt; std::endl; }&lt;br /&gt;
%}&lt;br /&gt;
&lt;br /&gt;
%union { int i; }&lt;br /&gt;
%type &amp;lt;i&amp;gt; seq0 seq1 expr&lt;br /&gt;
%left &amp;#039;*&amp;#039; &amp;#039;#&amp;#039;&lt;br /&gt;
&lt;br /&gt;
%%&lt;br /&gt;
&lt;br /&gt;
top  : expr           { std::cout &amp;lt;&amp;lt; $1 &amp;lt;&amp;lt; std::endl; }&lt;br /&gt;
     ;&lt;br /&gt;
&lt;br /&gt;
expr : seq0           { $$ = $1; }&lt;br /&gt;
     | seq1           { $$ = $1; }&lt;br /&gt;
     | expr &amp;#039;#&amp;#039; expr  { $$ = std::max($1, $3); }&lt;br /&gt;
     | expr &amp;#039;*&amp;#039; expr  { $$ = std::min($1, $3); }&lt;br /&gt;
     ;&lt;br /&gt;
&lt;br /&gt;
seq0 : &amp;#039;0&amp;#039;      { $$ = 2; }&lt;br /&gt;
     | seq0 &amp;#039;0&amp;#039; { $$ = $1 * 2; }&lt;br /&gt;
     | seq0 &amp;#039;1&amp;#039; { $$ = $1 + 1; }&lt;br /&gt;
     ;&lt;br /&gt;
&lt;br /&gt;
seq1 : &amp;#039;1&amp;#039;      { $$ = 1; }&lt;br /&gt;
     | seq1 &amp;#039;0&amp;#039; { $$ = $1 + 2; }&lt;br /&gt;
     | seq1 &amp;#039;1&amp;#039; { $$ = $1 * 2; }&lt;br /&gt;
     ;&lt;br /&gt;
&lt;br /&gt;
%%&lt;br /&gt;
extern int yyparse();&lt;br /&gt;
int main() { return yyparse(); }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to Compile? ==&lt;br /&gt;
&lt;br /&gt;
The Flex specification is processed as follows (the file &amp;#039;&amp;#039;&amp;#039;lex.yy.c&amp;#039;&amp;#039;&amp;#039; is produced):&lt;br /&gt;
&lt;br /&gt;
  flex minint.l&lt;br /&gt;
&lt;br /&gt;
The YACC specification is processed as follows (files &amp;#039;&amp;#039;&amp;#039;y.tab.h&amp;#039;&amp;#039;&amp;#039;, needed by the Flex-generated code, and &amp;#039;&amp;#039;&amp;#039;y.tab.c&amp;#039;&amp;#039;&amp;#039;):&lt;br /&gt;
&lt;br /&gt;
  bison -dtv minint.y&lt;br /&gt;
&lt;br /&gt;
Compiling the C/C++ code (it is C++ simply because we programmed the extra code in that language):&lt;br /&gt;
&lt;br /&gt;
  g++ -std=c++17 -c lex.yy.c&lt;br /&gt;
  g++ -std=c++17 -c y.tab.c&lt;br /&gt;
  g++ -o minint y.tab.o lex.yy.o&lt;br /&gt;
&lt;br /&gt;
[[category:Compiladores]]&lt;br /&gt;
[[category:Ensino]]&lt;/div&gt;</summary>
		<author><name>Root</name></author>
	</entry>
</feed>