17.01.2013 Views

COMPORT – Compilador Portugol - Nilo Menezes

COMPORT – Compilador Portugol - Nilo Menezes

COMPORT – Compilador Portugol - Nilo Menezes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PARSER.CPP<br />

ComPort <strong>–</strong> <strong>Compilador</strong> <strong>Portugol</strong><br />

/*<br />

* Módulo OSP - Parser Universidade do Amazonas Comport - <strong>Compilador</strong><br />

* <strong>Portugol</strong> Aluno: <strong>Nilo</strong> Ney Coutinho <strong>Menezes</strong><br />

*<br />

* Baseado no compilador Oberon-0 de Niklaus Wirth<br />

*<br />

*/<br />

#include <br />

#include <br />

#include <br />

#define PARSER<br />

#include "parser.h"<br />

#include "codegenerator.h"<br />

int sym, loaded;<br />

Object topScope, universe, guard;<br />

void<br />

NewObj (Object & obj, int Class)<br />

{<br />

Object nova, x;<br />

x = topScope;<br />

strcpy(guard->name, id);<br />

while (strcmp(x->next->name, id)!=0)<br />

x = x->next;<br />

if (x->next==guard)<br />

{<br />

nova = new ObjDesc;<br />

strcpy(nova->name, id);<br />

nova->Class = Class;<br />

nova->next = guard;<br />

x->next = nova;<br />

obj = nova;<br />

}<br />

else<br />

{<br />

obj = x->next;<br />

Mark ("Definição múltipla !");<br />

}<br />

}<br />

void<br />

find (Object & obj)<br />

{<br />

Object s, x;<br />

s = topScope;<br />

strcpy(guard->name, id);<br />

do<br />

{<br />

x = s->next;<br />

while (!strcmp (x->name, id))<br />

67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!