Fórum WebTuga

Tecnologia => Programação => Topic started by: KTachyon on May 04, 2006, 03:44:16 AM

Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 04, 2006, 03:44:16 AM
Queria propor um projecto aki ao ppl para a criação de uma linguagem de programação. Podem dar ideias para a linguagem e sugerir alterações.

A primeira fase é inventar uma linguagem de programação para depois se poder criar o compilador. De preferência uma linguagem simples que apenas funciona em linha de comandos. Mais tarde pode-se melhorar a linguagem e aumentar o âmbito para janelas e gráficos, mas deixemos isto para mais tarde se a linguagem se for desenvolvendo.

Depois de inventada a linguagem, irei utilizar as ferramentas open source para a criação de um pseudo-compilador (que converte o código gerado para, por exemplo, C). As ferramentas são as seguintes:

Lex ou Flex
Yacc ou Bison
CC ou GCC

Para quem quiser ajudar no desenvolvimento do código, estas ferramentas são standard na maioria das distros de Linux, BSDs e em Mac OS X (com os Developer Tools). No Windows, existem umas quantas ferramentas que se podem sacar da net (www.google.com  ), no entanto não aconselho a utilização do Windows para programação (sucks).


Seria interessante a criação de uma linguagem de programação que tivesse piada e/ou que facilitasse a programação nessa linguagem.

Como é óbvio, existem algumas restrições ao desenvolvimento do projecto, como o facto de provávelmente todos os membros que queiram ajudar tenham outras actividades que ocupam uma certa quantidade de tempo, de forma a que se o projecto for muito lento a ser desenvolvido, penso k será normal.



Finalmente, vou tentar manter actualizada uma lista de participantes no projecto, quer sejam programadores ou apenas ppl que dá a sua contribuição para a linguagem e até (futuramente) designers para um logo da linguagem,...




Sugestões de base para a linguagem:
- Podiamos por exemplo criar uma linguagem associada ao forum dando origem a uma linguagem de programação do WebTuga, trazendo mais contribuição para o forum e publicando a linguagem em locais de prestígio.
- Podiamos fazer com que a linguagem de base fosse em português, ou k fosse cómica e/ou de fácil utilização.

Força nisso.




Equipa:

Desenvolvimento:
- KhAoTiK TaChYoN

Contribuição:
- kingless
- cenourinha
- LycosMan
- Pedrolopes
- revx
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 04, 2006, 04:12:49 AM
Ja tens alguma ideia sobre como vai ou pode ser o codigo da linguagem ?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: lycosman on May 04, 2006, 07:33:08 AM
Eu alinho apesar de não fazer ideia de como se cria uma linguagem... Mas pra isso (pós n00bs nisto da criação de linguagens) podiamos criar um canal de IRC ou utilizar o do Webtuga (se o Tio Cenouras deixar claro) mas por acaso é uma ideia interessante... E se piuder ajudar contem comigo...
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 04, 2006, 08:35:57 AM
Tambem não faço ideia como fazer uma linguagem, mas poderiamos fazer uma linguagem simples, em que tivesse a sintaxe em Português!

Quanto ao canal, foi criar, mas primeiro temos de decidir o nome do projecto.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 04, 2006, 09:29:26 PM
Basicamente, depois de termos a linguagem definida é apenas preciso criar um aceitador para a linguagem (utilizando o Lex e o Yacc, e depois criar a estruturas para os comandos da linguagem, as tabelas de símbolos, que contêm os nomes das variáveis utilizadas, as stacks, que contêm o espaço da memória k onde se colocam os valores das variáveis, e depois a transformação do código para C (para o Pseudo-compilador).

Depois do pseudo-compilador apenas é necessário correr um assemblador pelo código.

É de interesse inicial k a linguagem possa ter condicionais (ifs, k podiam ser Se xxx então, ou kk coisa parecida), definição de variáveis, funções, ciclos (faz ... até xxx),...
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 04, 2006, 09:52:02 PM
Isso poderia ser uma linguagem adaptada a ensino, visto ser parecida com o pascal!
Basico!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 04, 2006, 10:03:17 PM
tava a pensar o seguinte:


@webtuga = "portal";

 

se (@webtuga ig portal):

mostrar("Webtuga é um portal");

ou se (@webtuga dif portal):

mostrar("Webtuga não é um portal");

se;


@  -> variaveis.
ig  -> igual
dif -> diferente
mostrar -> como se fosse echo ou print.
se (): -> mesmo que if
ou se -> mesmo que else if
se; -> fechar se

LOOOL  : beer :
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 05, 2006, 06:30:14 PM
É uma ideia, mas não gosto muito do \\'ig\\'. Penso k podemos não permitir atribuições dentro dos \\'se\\', ou seja, um \\'=\\' fora de um \\'se\\' (ou kk outra instrução k permita comparação) é uma atribuição, caso contrário seria uma comparação.

Outra coisa é utilizar apenas caracteres dentro dos 127 caracteres ASCII para comandos, pois eu já fiz algumas experiências com analise de linguagens utilizando o Flex, e reparei k ele não gosta muito. Mais tarde talvez valha a pena um pekeno esforço para poder acertar esses pormenores, mas por enkuanto podemos simplificar as coisas para conseguir um compilador funcional.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: _K-D-E_ on May 06, 2006, 10:42:16 AM
Well, ora aki está um optimo projecto!!!!!
Eu ALinho!!!
Podem contar com muito trabalho e ajuda da minha parte, embora seja noob no desenvolvimento d linguagens, kero aprender o mais rapido possível e ajudar-vos com este grande projecto!!!

Fikem bem
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 06, 2006, 10:47:10 PM
Ok. K tal utilizar-mos o esquema do C, mas de uma maneira mais legível?

Por exemplo:

if teste {
//...
}
else {
//...
}

Quando há parametros condicionais, ciclos for,... temos { e } para indicar k está tudo dentro no mesmo bloco. Na nossa linguagem, podiamos pensar em utilizar, por exemplo:

Se teste,
.
Senão,
//...
.

Ou seja, utilizaria-mos o . para indicar o fim de um bloco e a , para significar o seu início.

Outra kestão é ter em conta k os caracteres invisíveis (espaços e returns) não são contabilizados na linguagem, de modo a k poderiamos escrever perfeitamente:

Se o_teste_correu_bem, mostra(\\"K bem.\\"). Senão, mostra(\\"Estás na lama.\\").
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 06, 2006, 10:55:32 PM
Foi nisso que eu pensei!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 06, 2006, 11:22:54 PM
KhAoTiK_TaChYoN gostei da tua ideia!!  

Quando começamos a programar a linguagem ??  Estamos a espera de ti KhAoTiK_TaChYoN!!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: revx on May 06, 2006, 11:34:05 PM
nao seria melhor \\'outro\\' em vez de \\'senão\\' ?

Já podias explicar como pretendes criar a linguagem ? (e o interpretador para puder instalar no pc) isso nao ficou muito claro...  : bom trabalho :
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: _K-D-E_ on May 07, 2006, 02:44:06 PM
yah temos k nos reunir pa falar sobre o projecto!!!
Eu ja adicionei o KhAoTiK_TaChYoN no msn, kem kiser, adicione no msn fisgazi@hotmail.com pa falar sobre este ganda projecto!!!

Fikem bem
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: malaquias_ on May 07, 2006, 04:19:46 PM
Eu alinho.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 07, 2006, 05:59:51 PM
QuoteKhAoTiK_TaChYoN gostei da tua ideia!!  

Quando começamos a programar a linguagem ??  Estamos a espera de ti KhAoTiK_TaChYoN!!

Ainda faltam acertar um pormenores:
- Como fazemos as funções
- Como passamos argumentos para as funções
- Como definimos as funções
- Tipos (inteiros, reais, strings,...)
- Definir a sensibilidade do código (se a para a linguagem SE = se = Se = sE ou se definimos como sendo coisas diferentes).
- ...

Depois, o início da programação, penso k vai ser relativamente lento para dar tempo para o ppl perceber em k ponto está.


Quotenao seria melhor \\'outro\\' em vez de \\'senão\\' ?

Penso k o \\'Senão\\' é mais adekuado, pk basicamente um \\'else\\' é um \\'senão\\'. Assim até dá para programar quase como se estivessemos a escrever em português. O problema é só o ã, k é capaz de dar uns problemas no Lex, mas se não der para o \\'senão\\' de início, axo k o \\'senao\\' serve perfeitamente.


QuoteJá podias explicar como pretendes criar a linguagem ? (e o interpretador para puder instalar no pc) isso nao ficou muito claro...  : bom trabalho :

A fase inicial é quase na totalidade feita em Lex e Yacc, que vão analizar akilo que lhe é dado. Por exemplo, o ficheiro escrito em Lex e Yacc, depois de compilado irá poder receber o código k nós keremos compilar e verifica se está bem escrito. Imagina k kerias escrever Se x = 0, (...), mas em vez disso escreves Sr x = 0, (...), a parte feita em Lex e Yacc não aceita o Sr, logo a compilação é abortada e dá a mensagem de erro.

Só mm no fim de tudo é k o programa vai compilar alguma coisa, pk até lá, apenas vai identificar erros, aceitando ou não o código.


Quanto às ferramentas, para os sistemas *nix (que tenham já o material para programação, k é standard em kuase todas as distros) já têm o lex e o yacc pela linha de comandos.

Para Windows, existe uma ferramenta aki (http://www.bumblebeesoftware.com/), que serve de Lex e Yacc (embora nunca a tenha utilizado), e é necessário um compilador de C. O mais conhecido penso k é o Borland (http://www.borland.com/downloads/download_cbuilder.html), mas existem outros como o Miracle C Compiler (http://www.c-compiler.com/) e MinGW (http://www.mingw.org/), entre outros.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 07, 2006, 06:07:16 PM
E quando é que vamos acertar  os pormenores ?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 07, 2006, 06:24:15 PM
Definição de funções:

Define area_rect com largura, comprimento:

resultado = largura * comprimento

Retorna resultado.

(Retorna ou Devolve?)


Chamada de funções:

area = area_rect com 2, 4
ou

area = area_rect:2, 4
ou

area = [area_rect 2 4]

Isto é no caso de uma linguagem sem tipos definidos (ou seja, uma variável pode ser kk coisa... depois pode dar bode, lol - é possível prevenir isto sem ter k definir tipos, por isso continua a ser uma ideia). Um problema aqui é, como fazemos para separar duas expressões:

resultado = largura * comprimento

Retorna resultado.

Podemos assumir que há um return entre cada expressão, mas eu não gosto dessa abordagem. Prefiro k o código possa ser escrito sequencialmente. Talvez um ; ou mesmo uma , penso k não traz problemas:

resultado = largura * comprimento,

Retorna resultado.

Aki o . significa o final da definição da função, tal como significa o fim de um Se.


Podemos assumir que não há lookahead, ou seja, uma função tem k ser definida (e criada, coisa k aki está a ser feita em conjunto) antes de ser utilizada. E basicamente o código é todo escritode seguida sem nada de especial pelo meio.



Agora, ideias para o formato dos comentários? Utilizamos o conhecido // do C e do Java? Ou o ; do Lisp? Ou outra coisa kk?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 07, 2006, 06:30:09 PM
Variáveis:

Pensei na ideia do kingless em utilizar o @ antes do nome das variáveis, num estilo semelhante ao do PHP, mas penso que não é realmente necessário. Podemos libertar as variáveis de sinais extra, embora um sinal como o @ pudesse facilitar a análise do código. Como preferem?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 07, 2006, 06:30:20 PM
Esta linguagem vai servir para criar o que ?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 07, 2006, 06:43:34 PM
É apenas uma linguagem de programação básica. Inicialmente apenas irá funcionar em linha de comandos.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 07, 2006, 10:53:18 PM
penso que o @ será uma boa opção!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 10, 2006, 06:41:58 PM
Ok. Já comecei a fazer a parte do Lex, mas sem a parte do Yacc não é muito fácil de parceber como isto funciona, por isso, por enquanto só aki coloco a parte do Lex. Depois, kdo tiver a parte do Yacc feita, coloco aki a explicação.

%{

#include "structures.h"

#include "y.tab.h"

#include

#include

%}



%%

"//".*n {line++;}



"-"?[0-9]+ {yylval.inteiro = atoi(yytext); return INTEIRO;}

"-"?[0-9]+"."[0-9]+ {yylval.nint = atof(yytext); return FLOAT;}

""".""" {yylval.str = (*char) strdup(yytext);}



"@"[a-zA-Z0-9-_]* {yylval.var = (char*) strdup(yytext); return VAR;}



"SE" {return SE;}

"OU SE" {return OU_SE;}

"SENÃÆ'O" {return SENAO;}

"DEFINE" {return DEFINE;}

"COM" {return COM;}



"=" {return EQUAL;}

">" {return MAIOR;}

"<" {return MENOR;}

"<=" {return MENOR_EQ;}

">=" {return MAIOR_EQ;}



"+" {return SOMA;}

"-" {return SUBT;}

"*" {return MULT;}

"/" {return DIVI;}



"," {return BLOCK_INIT;}

"." {return BLOCK_END;}

":" {return BLOCK_DEF_INIT;}



[ t] ;



n {line++;}



. return yytext[0];

%%

int yywrap()

{

return 1;

}
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 10, 2006, 06:56:08 PM
KhAoTiK_TaChYoN  : bom trabalho :
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Pedrolopes on May 12, 2006, 06:12:08 PM
pa...

uma ideia que podima aproveitar era a usada por Python... em que as {} são substituidas pela identação! acho que é uma das melhores coisas dessa linguagem e permite que o código escrito seja mais simples e legível!

exemplo:

for (i; i < n; i++)

{

   ah e tal...

   pq é jovem...

}



só com a identação...



for (i; i < n; i++)

ah e tal...

pq é jovem...

não sei se me fiz entender...

se precisarem de algum beta tester digam
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 12, 2006, 06:35:18 PM
PedroLopes, tive a dar uns toques em Python e parece ser bastante porreira.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 12, 2006, 07:31:27 PM
É uma ideia, mas obrigarmos ao uso da identação queria dizer k não poderia-mos contruir código como se fosse uma frase simples, quase em português, o k normalmente facilita mais a leitura do código. Obrigar a identação axo k retira muita flexibilidade ao código.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 12, 2006, 08:11:27 PM
Eu acho que se o codigo fosse muito facil e todo mundo podesse aprender muito rapido nao teria graça a linguagem, mas isso sou eu.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: lycosman on May 12, 2006, 08:27:02 PM
concordo com o KhAoTiK_TaChYoN. acho que o objectivo e criar uma linguagem diferente e user-friendly... se tiver uma sintaxe baseada em lingua corrente qualquer pessoa pode xegar e começar a programar... Tipo pascal e muito facil por isso mesmo, basta saber ingles e mais umas coisitas, Delphi a mesma coisa... basic já nem tanto mas aproxima-se, C já se afasta bastante por já n ser uma linguagem exclusivamente de alto nivel, e entao assembly e que já n tem nada a ver... concluindo, uma linguagem com sintaxe familiar era o ideal...
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 12, 2006, 10:51:09 PM
Eu gosto do estilo da linguagem php.
É muito organizada e isso faz dela uma linguagem facil de aprender.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: lycosman on May 12, 2006, 10:59:54 PM
Eu sou adepto ferrenho de linguagens Basic-based... Familiarizei-me com elas logo desde quando começei a programar.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 13, 2006, 09:39:47 PM
Ja passaram quase 2 semanas, e ainda não vi quase nada...

Acho que isto está muito lento!!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 13, 2006, 10:20:10 PM
Pois... terminei agr a keima das fitas, e vou começar a trabalhar nos projectos k tenho k pôr em dia. Infelizmente só posso trabalhar no projecto nos meus tempos livres.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: lycosman on May 13, 2006, 10:31:14 PM
QuoteJa passaram quase 2 semanas, e ainda não vi quase nada...

Acho que isto está muito lento!!

O KhAoTiK_TaChYoN avisou que era para ir as calmas...
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 13, 2006, 10:34:26 PM
Quote
QuoteJa passaram quase 2 semanas, e ainda não vi quase nada...

Acho que isto está muito lento!!

O KhAoTiK_TaChYoN avisou que era para ir as calmas...

Não sabia que ele tinha avisado para ir nas calmas!!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 14, 2006, 11:23:06 AM
Oki, ppl. Aki vai mais um bocado:

WPL.l
%{

#include "y.tab.h"

#include

#include

%}



%%

"//".*n {/*line++*/;}



"-"?[0-9]+ {yylval.inteiro = atoi(yytext); return INTEIRO;}

"-"?[0-9]+"."[0-9]+ {yylval.nint = atof(yytext); return FLOAT;}

""".""" {yylval.str = (char*) strdup(yytext);}



"@"[a-zA-Z0-9-_]* {yylval.var = (char*) strdup(yytext); return VAR;}



"SE" {return SE;}

"OU SE" {return OU_SE;}

"SENÃÆ'O" {return SENAO;}

"DEFINE" {return DEFINE;}

"COM" {return COM;}



"=" {return IGUAL;}

">" {return MAIOR;}

"<" {return MENOR;}

"<=" {return MENOR_IGUAL;}

">=" {return MAIOR_IGUAL;}



"+" {return SOMA;}

"-" {return SUBT;}

"*" {return MULT;}

"/" {return DIVI;}



[ t] ;



n {/*line++*/;}



. return yytext[0];

%%

int yywrap()

{

return 1;

}


WPL.y
%{

#include

#include

%}

%token INTEGER

%token FLOAT

%token STRING

%token VAR



%token SE

%token OU_SE

%token SENAO

%token DEFINE

%token COM



%token IGUAL

%token MAIOR

%token MENOR

%token MENOR_IGUAL

%token MAIOR_IGUAL



%token SOMA

%token SUBT

%token MULT

%token DIVI



%union{

int inteiro;

char *str;

float nint;

char *var;

}



%%



statement: codeline

| statement codeline

;



codelines: codeline

| codelines codeline

;



codeline: function_if

| function_defun

| function_call

| attrib

;



function_if: SE testcond \\',\\' codelines \\'.\\'

  | SE testcond \\',\\' codelines \\'.\\' cicle_else_if

  | SE testcond \\',\\' codelines \\'.\\' cicle_else_if SENAO \\',\\' codelines \\'.\\'

  | SE testcond \\',\\' codelines \\'.\\' SENAO \\',\\' codelines \\'.\\'

 ;



cicle_else_if: OU_SE testcond \\',\\' codelines \\'.\\'

| cicle_else_if OU_SE testcond \\',\\' codelines \\'.\\'

;



testcond: test_type

| test_type test_oper test_type

;



test_type: INTEGER

| FLOAT

| VAR

;



test_oper: IGUAL

| MAIOR

| MENOR

| MAIOR_IGUAL

| MENOR_IGUAL

;



function_defun: DEFINE VAR COM arg_list \\':\\' function_def \\'.\\'

 | DEFINE VAR \\':\\' function_def \\'.\\'

;



arg_list: VAR

| VAR \\',\\' arg_list

;



function_call: VAR COM call_arg_list

| VAR

;



call_arg_list: test_type

| test_type \\',\\' call_arg_list

;





%%

int main()

{

//line = 1;



yyparse();

}



void yyerror (char *s)

{

printf("%sn", s);

}

Há um problema k ainda não foi resolvido na parte de design do código, que descobri enquanto estava a começar a criar o aceitador de linguagem. Falta definir como terminam as expressões. Por exemplo, em C, tudo acaba com o famoso \\';\\'. Nesta linguagem tb vamos precisar de um caracter/símbolo terminal para cada uma das linhas, e não pode ser um \\'.\\'

Alguma ideia?


Ainda é possível utilizar as vírgulas desta forma:

Se xxx, faz_isto, faz_akilo, etc.
Ou se yyy, faz_akilo, faz_isto, etc.
Senao, faz_outra_coisa_kk.

Mas todo o código teria k ser terminado com uma vírgula, excepto os que terminam em \\'.\\':

@var = \\"Olá!\\",
@test = 5,

Se @test < 10, mostra @var.


Ok. A seguir... faltam ciclos. Como querem implementá-los?

FAZ ... ATÉ?
ENQUANTO?
REPETE?

Dpois arranjo tempo para os próximos 5 min de código
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 14, 2006, 03:29:01 PM
Pode-se usar a \\",\\" ou um #, mas a ideia da virgula é mais facil.

De resto acho que ficaria assim:
FAZ ... ATE?
ENQUANTO?
REPETIR?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on May 14, 2006, 04:12:07 PM
Boa ideia!!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 14, 2006, 04:27:56 PM
WPL.l
%{

#include "y.tab.h"

#include

#include

%}



%%

"//".*n {/*line++*/;}



"-"?[0-9]+ {yylval.inteiro = atoi(yytext); return INTEIRO;}

"-"?[0-9]+"."[0-9]+ {yylval.nint = atof(yytext); return FLOAT;}

""".""" {yylval.str = (char*) strdup(yytext);}



"@"[a-zA-Z0-9-_]* {yylval.var = (char*) strdup(yytext); return VAR;}



"SE" {return SE;}

"OU SE" {return OU_SE;}

"SENÃÆ'O" {return SENAO;}



"DEFINE" {return DEFINE;}

"COM" {return COM;}

"RETORNA" {return RETORNA;}



"FAZ" {return FAZ;}

"ATÉ" {return ATE;}

"REPETE" {return REPETE;}

"ENQUANTO" {return ENQUANTO;}



"=" {return IGUAL;}

">" {return MAIOR;}

"<" {return MENOR;}

"<=" {return MENOR_IGUAL;}

">=" {return MAIOR_IGUAL;}



"+" {return SOMA;}

"-" {return SUBT;}

"*" {return MULT;}

"/" {return DIVI;}



[ t] ;



n {/*line++*/;}



. return yytext[0];

%%

int yywrap()

{

return 1;

}

WPL.y
%{

#include

#include

%}

%token INTEGER

%token FLOAT

%token STRING

%token VAR



%token SE

%token OU_SE

%token SENAO



%token DEFINE

%token COM

%token RETORNA



%token FAZ

%token ATE

%token REPETE

%token ENQUANTO



%token IGUAL

%token MAIOR

%token MENOR

%token MENOR_IGUAL

%token MAIOR_IGUAL



%token SOMA

%token SUBT

%token MULT

%token DIVI



%union{

int inteiro;

char *str;

float nint;

char *var;

}



%%



statement: codeline

| statement codeline

;



codelines: codeline

| codeline codelines

;



codeline: function_if

| function_defun

| function_call

| attrib

| cicle_until

| cicle_while

| cicle_dotimes

;



attrib: VAR IGUAL expression

;



expression: STRING

 | simple_type oper simple_type

;



oper: SOMA

| SUBT

| MULT

| DIVI

;



function_if: SE testcond \\',\\' codelines \\'.\\'

  | SE testcond \\',\\' codelines \\'.\\' cicle_else_if

  | SE testcond \\',\\' codelines \\'.\\' cicle_else_if SENAO \\',\\' codelines \\'.\\'

  | SE testcond \\',\\' codelines \\'.\\' SENAO \\',\\' codelines \\'.\\'

 ;



cicle_else_if: OU_SE testcond \\',\\' codelines \\'.\\'

| cicle_else_if OU_SE testcond \\',\\' codelines \\'.\\'

;



testcond: simple_type

| simple_type test_oper simple_type

;



simple_type: INTEGER

  | FLOAT

  | VAR

 ;



returnable_type: INTEGER

  | FLOAT

  | VAR

  | STRING

 ;



test_oper: IGUAL

| MAIOR

| MENOR

| MAIOR_IGUAL

| MENOR_IGUAL

;



function_defun: DEFINE VAR COM arg_list \\':\\' function_def \\'.\\'

 | DEFINE VAR \\':\\' function_def \\'.\\'

;



function_def: codelines

| RETORNA returnable_type

| function_def codelines

| function_def RETORNA returnable_type

;



arg_list: VAR

| VAR \\',\\' arg_list

;



function_call: VAR COM call_arg_list

| VAR

;



call_arg_list: returnable_type

| returnable_type \\',\\' call_arg_list

;



cicle_until: FAZ codelines ATE testcond \\'.\\'

 ;



cicle_while: ENQUANTO testcond \\',\\' codelines \\'.\\'

 ;



cicle_dotimes: REPETE INTEGER \\':\\' codelines \\'.\\'

;





%%

int main()

{

//line = 1;



yyparse();

}



void yyerror (char *s)

{

printf("%sn", s);

}

A parte do YACC ainda tem 6 shift/reduce conflicts, mas estou no processo de os corrigir.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 15, 2006, 05:25:54 PM
Estou de momento noutro projecto de criação de uma outra linguagem (diga-se de passagem, mais complexa, mas com menos utilidade) para uma das cadeiras, de forma a k o processo de criação desta linguagem vai continuar lento, a não ser k alguém com alguma experiência no assunto se junte para ajudar à criação da mesma. De kk forma, a minha cooperação vai continuar, mesmo lentamente.

P.S.: Aproveitei para actualizar a lista de contribuidores.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 24, 2006, 02:23:40 AM
Estou a criar um repositório para este projecto no SourceForge.net. Depois vou fazendo updates acerca do projecto neste tópico.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 24, 2006, 02:34:13 AM
Segundo as normas do SourceForge, o projecto será Open Source, tendo obrigatoriamente que seguir as seguintes normas (passo a citar):

QuoteThe Open Source Definition

Introduction

Open source doesn\\'t just mean access to the source code. The distribution terms of open-source software must comply with the following criteria:


1. Free Redistribution

The license shall not restrict any party from selling or giving away the software as a component of an aggregate software distribution containing programs from several different sources. The license shall not require a royalty or other fee for such sale.

2. Source Code

The program must include source code, and must allow distribution in source code as well as compiled form. Where some form of a product is not distributed with source code, there must be a well-publicized means of obtaining the source code for no more than a reasonable reproduction cost preferably, downloading via the Internet without charge. The source code must be the preferred form in which a programmer would modify the program. Deliberately obfuscated source code is not allowed. Intermediate forms such as the output of a preprocessor or translator are not allowed.

3. Derived Works

The license must allow modifications and derived works, and must allow them to be distributed under the same terms as the license of the original software.

4. Integrity of The Author\\'s Source Code

The license may restrict source-code from being distributed in modified form only if the license allows the distribution of \\"patch files\\" with the source code for the purpose of modifying the program at build time. The license must explicitly permit distribution of software built from modified source code. The license may require derived works to carry a different name or version number from the original software.

5. No Discrimination Against Persons or Groups

The license must not discriminate against any person or group of persons.

6. No Discrimination Against Fields of Endeavor

The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.

7. Distribution of License

The rights attached to the program must apply to all to whom the program is redistributed without the need for execution of an additional license by those parties.

8. License Must Not Be Specific to a Product

The rights attached to the program must not depend on the program\\'s being part of a particular software distribution. If the program is extracted from that distribution and used or distributed within the terms of the program\\'s license, all parties to whom the program is redistributed should have the same rights as those that are granted in conjunction with the original software distribution.

9. License Must Not Restrict Other Software

The license must not place restrictions on other software that is distributed along with the licensed software. For example, the license must not insist that all other programs distributed on the same medium must be open-source software.

*10. License Must Be Technology-Neutral

No provision of the license may be predicated on any individual technology or style of interface.

Espero k concordem com isto... podem opinar acerca disto.

Depois ainda vou ter k escolher uma mais específica.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 24, 2006, 03:30:21 AM
E a licença escolhida foi... GPL, lol. Hope you like it.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 24, 2006, 10:09:31 AM
KhAoTiK_TaChYoN boas escolhas.
Precisamos de um nome para o projecto antes disso...
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Ghetto_Smurf on May 24, 2006, 01:50:28 PM
concordo com a GPL, não é muito restricta e não é tão livre como a BSD
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 24, 2006, 04:06:28 PM
Eu dei-lhe o nome de WebTugaPL (WebTuga Programming Language). Agora estou à espera que eles aceitem o projecto e me forneçam o espaço.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 24, 2006, 07:24:39 PM
QuoteEu dei-lhe o nome de WebTugaPL (WebTuga Programming Language). Agora estou à espera que eles aceitem o projecto e me forneçam o espaço.

Depois vamos criar uma página com apresentação digna do Webtuga.
Acho o nome bem escolhido.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 27, 2006, 01:43:10 AM
http://sourceforge.net/projects/webtugapl (http://sourceforge.net/projects/webtugapl)

Vou tratar de fazer a configuração inicial.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 27, 2006, 02:25:59 AM
WebTuga Programming Language Compiler v0.01a released

Apenas código fonte. Nem sequer é compilável. Alguém para fazer a webpage?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on May 27, 2006, 09:26:19 AM
Eu, é só me dares os dados que eu faço...
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on May 27, 2006, 02:40:48 PM
Cria uma conta no SourceForge.net e depois dá-m o teu username para eu te adicionar à equipa.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on June 13, 2006, 05:17:20 AM
Ok, isto vai indo mas d-e-v-a-g-a-r... Estive a ver akilo que já fiz com o código e achei a linguagem um pouco vazia. Penso que vou adicionar um tipo de variável boleana, que pode ter um dos seguintes valores:

sim ou verdadeiro
não ou falso

Depois, ainda tenho que pensar como aceito as condições de teste dos ifs e ciclos. E ainda faltam as operações sobre strings... Ideias?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on June 13, 2006, 05:32:03 AM
WPL.l - June 13, 2006

%{

#include "y.tab.h"

#include

#include

%}



%%

"//".*n {/*line++*/;}



"-"?[0-9]+ {yylval.inteiro = atoi(yytext); return INTEGER;}

"-"?[0-9]+"."[0-9]+ {yylval.nint = atof(yytext); return FLOAT;}

""".""" {yylval.str = (char*) strdup(yytext);}



"@"[a-zA-Z0-9_]* {yylval.var = (char*) strdup(yytext); return VAR;}



"SE" {return SE;}

"OU SE" {return OU_SE;}

"SENÃÆ'O" {return SENAO;}



"DEFINE" {return DEFINE;}

"COM" {return COM;}

"RETORNA" {return RETORNA;}



"FAZ" {return FAZ;}

"ATÉ" {return ATE;}

"REPETE" {return REPETE;}

"ENQUANTO" {return ENQUANTO;}



"=" {return IGUAL;}

">" {return MAIOR;}

"<" {return MENOR;}

"<=" {return MENOR_IGUAL;}

">=" {return MAIOR_IGUAL;}



"+" {return SOMA;}

"-" {return SUBT;}

"*" {return MULT;}

"/" {return DIVI;}



[a-zA-Z][a-zA-Z0-9_]* {yylval.function = (char*) strdup(yytext); return FUNCTION;}



[ t] ;



n {/*line++*/;}



. return yytext[0];

%%

int yywrap()

{

return 1;

}
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on June 13, 2006, 05:32:32 AM
WPL.y - June 13, 2006

%{

#include

#include

%}

%token INTEGER

%token FLOAT

%token STRING

%token VAR

%token FUNCTION



%token SE

%token OU_SE

%token SENAO



%token DEFINE

%token COM

%token RETORNA



%token FAZ

%token ATE

%token REPETE

%token ENQUANTO



%token IGUAL

%token MAIOR

%token MENOR

%token MENOR_IGUAL

%token MAIOR_IGUAL



%token SOMA

%token SUBT

%token MULT

%token DIVI



%union{

int inteiro;

char *str;

float nint;

char *var;

char *function;

}



%%



// statement? codelines? são a mm m****...

statement: codeline

| statement codeline

;



// vírgulas? hmm...

codelines: codeline

| codelines codeline

;



// são todas terminadas com \\'.\\'?

codeline: function_if

| function_defun

| function_call

| attrib

| cicle_until

| cicle_while

| cicle_dotimes

;



attrib: VAR IGUAL returnable_type

;



operacao: operacao oper simple_type

| simple_type oper simple_type

;



oper: SOMA

| SUBT

| MULT

| DIVI

;



function_if: SE testcond \\':\\' codelines \\'.\\'

  | SE testcond \\':\\' codelines \\'.\\' cicle_else_if

  | SE testcond \\':\\' codelines \\'.\\' cicle_else_if SENAO \\':\\' codelines \\'.\\'

  | SE testcond \\':\\' codelines \\'.\\' SENAO \\':\\' codelines \\'.\\'

 ;



cicle_else_if: OU_SE testcond \\':\\' codelines \\'.\\'

| cicle_else_if OU_SE testcond \\':\\' codelines \\'.\\'

;



testcond: simple_type

| simple_type test_oper simple_type

;



simple_type: INTEGER

  | FLOAT

  | VAR

 ;



returnable_type: INTEGER

  | FLOAT

  | VAR

  | STRING

  | operacao

  | function_call

 ;



test_oper: IGUAL

| MAIOR

| MENOR

| MAIOR_IGUAL

| MENOR_IGUAL

;



function_defun: DEFINE FUNCTION COM arg_list \\':\\' function_def \\'.\\'

 | DEFINE FUNCTION \\':\\' function_def \\'.\\'

;



function_def: codelines

| RETORNA returnable_type

| codelines \\',\\' RETORNA returnable_type

;



arg_list: VAR

| arg_list \\',\\' VAR

;



function_call: FUNCTION COM call_arg_list \\'.\\'

| FUNCTION \\'.\\'

;



call_arg_list: returnable_type

| call_arg_list \\',\\' returnable_type

;



cicle_until: FAZ codelines ATE testcond \\'.\\'

 ;



cicle_while: ENQUANTO testcond \\':\\' codelines \\'.\\'

 ;



cicle_dotimes: REPETE INTEGER \\':\\' codelines \\'.\\'

;





%%

int main()

{

//line = 1;



yyparse();

}



void yyerror (char *s)

{

printf("%sn", s);

}
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on June 13, 2006, 05:33:14 AM
structures.h - June 13, 2006




typedef struct _a1 is_statement;

typedef struct _a2 is_codeline_list;

typedef struct _a3 is_codeline;

typedef struct _a4 is_attrib;

typedef struct _a5 is_operacao;

typedef struct _a6 is_function_if;

typedef struct _a7 is_cicle_else_if;

typedef struct _a8 is_testcond;

typedef struct _a9 is_simple_type;

typedef struct _a10 is_returnable_type;

typedef struct _a11 is_function_defun;

typedef struct _a12 is_arg_list;

typedef struct _a13 is_function_def;

typedef struct _a14 is_function_call;

typedef struct _a15 is_call_arg_list;

typedef struct _a16 is_cicle_until;

typedef struct _a17 is_cicle_while;

typedef struct _a18 is_cicle_dotimes;



typedef enum {d_function_if, d_function_defun, d_function_call, d_attrib, d_cicle_until, d_cicle_while, d_cicle_dotimes} d_codeline;

typedef enum {d_SOMA, d_SUBT, d_MULT, d_DIVI} d_oper;

typedef enum {d_INTEGER, d_FLOAT, d_VAR} d_simple_type;

typedef enum {d_INTEGER_ret, d_FLOAT_ret, d_VAR_ret, d_STRING, d_operacao, d_function_call_ret} d_returnable_type;

typedef enum {d_IGUAL, d_MAIOR, d_MENOR, d_MAIOR_IGUAL, d_MENOR_IGUAL} d_test_oper;



struct _a1 {

is_codeline *icl;

struct _a1 *next;

}



struct _a2 {

is_codeline *icl;

struct _a1 *next;

}



struct _a3 {

d_codeline type;



union {

is_function_if *ifi;

is_function_defun *ifd;

is_function_call *ifc;

is_attrib *ia;

is_cicle_until *icu;

is_cicle_while *icw;

is_cicle_dotimes *icd;

}

}



struct _a4 {

char *var;

ir_returnable_type *irt;

}



struct _a5 {

is_simple_type *istInit;

is_oper io;

is_simple_type *ist;

is_operacao *next;

}



struct _a6 {

is_testcond *it;

is_codeline_list *icl;

is_cicle_else_if *icei;

is_codeline_list *iclElse;

}



struct _a7 {

is_testcond *it;

is_codeline_list *icl;

is_cicle_else_if *next;

}



struct _a8 {

is_simple_type *ist;

d_test_oper to;

is_simple_type *istComp;

}



struct _a9 {

d_simple_type type;



union {

int integer;

float floating;

char *var;

}

}



struct _a10 {

d_returnable_type type;



union {

int integer;

float floating;

char *var;

char *string;

is_operacao *io;

is_function_call *ifc;

}

}



struct _a11 {

char *function;

is_arg_list *ial;

is_function_def *ifd;

}



struct _a12 {

char *var;

struct _a12 *next;

}



struct _a13 {

is_codeline_list *icl;

is_returnable_type *irt;

}



struct _a14 {

char *function;

is_call_arg_list *ial;

}



struct _a15 {

is_returnable_type *irt;

struct _a15 *next;

}



struct _a16 {

is_codeline_list *icl;

is_testcond *it;

}



// really needed? _a16 and _a17 are all but the same...

struct _a17 {

is_testcond *it;

is_codeline_list *icl;

}



struct _a18 {

int *integer;

is_codeline_list *icl;

}
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on June 13, 2006, 10:42:16 AM
Junta o código todo e mostra quando estiver acabado, a funcionar e compilavel.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: XTK on June 13, 2006, 11:46:07 AM
wow isto ta a andar bem!  se puder ajudar em alguma coisa digam!
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on June 13, 2006, 12:54:26 PM
Pois... o problema é k afinal que está a inventar a linguagem toda parece k estou a ser eu, visto que encontro muitas falhas que precisam de ser preenchidas...

Ainda falta muito código para completar a linguagem. Depois de finalmente acabar de remendar a gramática da linguagem e análise sintáctica, falta fazer as inserções de dados nas estruturas, análise semântica e só depois é que se começa a pensar em converter o código.

O código já é compilável, só que apenas verifica se as instruções estão bem escritas. Para compilar:


lex WPL.l

yacc -d WPL.y

gcc -o WPL y.tab.c lex.yy.c -ll -ly
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: dobone on June 15, 2006, 12:05:37 AM
mas tipo, essa linguagem serveria apenas para programas ? ou só web design ? ou os dois ? programa e web design
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on June 15, 2006, 01:17:22 AM
Apenas linha de comandos. Depois é possível implementar a programação de janelas e programação gráfica, mas deve apenas ser implementada numa fase em que o projecto se mostre minimamente maduro.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: kingless on July 08, 2006, 07:50:02 PM
Como é que está o projecto ?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on July 08, 2006, 07:57:29 PM
Tá em stand by até eu acabar os exames.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: Teotónio Ricardo on September 04, 2006, 11:00:02 PM
Como é que vai isto?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on October 08, 2006, 03:17:22 AM
Este projecto fica em stand by até que eu consiga arranjar tempo para continuar a trabalhar nele e resolver uns porblemas de parsing que o programa tem. Possívelmente posso ter que voltar a refazer a linguagem para a libertar de algumas ambiguidades que possam eventualmente existir.

Por enquanto tenho 3 projectos para fazer este semestre e as coisas estão apertadas.
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: exalt on October 10, 2006, 04:03:01 PM
Boas

eu sei umas coisas s programação e ajudo s precisarem, na boa :boa:

cumps
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on January 15, 2007, 07:33:50 AM
Estado actual das coisas:

In file included from functions.h:1,

from functions.c:1:

structures.h:61: error: two or more data types in declaration specifiers

structures.h:77: error: parse error before \\'d_testcond\\'

structures.h:77: warning: no semicolon at end of struct or union

structures.h:87: error: parse error before \\'}\\' token

structures.h:150: error: parse error before \\'is_codelines\\'

structures.h:150: warning: no semicolon at end of struct or union

structures.h:152: error: parse error before \\'}\\' token

structures.h:156: error: parse error before \\'is_codelines\\'

structures.h:156: warning: no semicolon at end of struct or union

structures.h:161: error: parse error before \\'is_codelines\\'

structures.h:161: warning: no semicolon at end of struct or union

In file included from functions.h:1,

from functions.c:1:

structures.h:1:1: error: unterminated #ifndef

In file included from functions.c:1:

functions.h:3: error: parse error before \\'*\\' token

functions.h:3: error: parse error before \\'*\\' token

functions.h:3: warning: data definition has no type or storage class

functions.h:4: error: parse error before \\'*\\' token

functions.h:4: warning: data definition has no type or storage class

functions.h:5: error: parse error before \\'*\\' token

functions.h:5: warning: data definition has no type or storage class

functions.h:6: error: parse error before \\'*\\' token

functions.h:6: error: parse error before \\'*\\' token

functions.h:6: warning: data definition has no type or storage class

functions.h:7: error: parse error before \\'*\\' token

functions.h:7: error: parse error before \\'*\\' token

functions.h:7: warning: data definition has no type or storage class

functions.h:8: error: parse error before \\'*\\' token

functions.h:8: warning: data definition has no type or storage class

functions.h:9: error: parse error before \\'*\\' token

functions.h:9: error: parse error before \\'*\\' token

functions.h:9: warning: data definition has no type or storage class

functions.h:10: error: parse error before \\'*\\' token

functions.h:10: error: parse error before \\'*\\' token

functions.h:10: warning: data definition has no type or storage class

functions.h:11: error: parse error before \\'*\\' token

functions.h:11: error: parse error before \\'*\\' token

functions.h:11: warning: data definition has no type or storage class

functions.h:12: error: parse error before \\'*\\' token

functions.h:12: error: parse error before \\'*\\' token

functions.h:12: warning: data definition has no type or storage class

functions.h:13: error: parse error before \\'*\\' token

functions.h:13: error: parse error before \\'*\\' token

functions.h:13: warning: data definition has no type or storage class

functions.h:14: error: parse error before \\'*\\' token

functions.h:14: warning: data definition has no type or storage class

functions.h:15: error: parse error before \\'*\\' token

functions.h:15: warning: data definition has no type or storage class

functions.h:17: error: parse error before \\'is_single_exp_list\\'

functions.h:18: error: parse error before \\'*\\' token

functions.h:18: error: parse error before \\'is_single_exp\\'

functions.h:18: warning: data definition has no type or storage class

functions.h:19: error: parse error before \\'*\\' token

functions.h:19: error: parse error before \\'*\\' token

functions.h:19: warning: data definition has no type or storage class

functions.h:20: error: parse error before \\'*\\' token

functions.h:20: error: parse error before \\'*\\' token

functions.h:20: warning: data definition has no type or storage class

functions.h:21: error: parse error before \\'*\\' token

functions.h:21: error: parse error before \\'*\\' token

functions.h:21: warning: data definition has no type or storage class

functions.h:22: error: parse error before \\'*\\' token

functions.h:22: error: parse error before \\'*\\' token

functions.h:22: warning: data definition has no type or storage class

functions.h:23: error: parse error before \\'*\\' token

functions.h:23: error: parse error before \\'is_single_exp_list\\'

functions.h:23: warning: data definition has no type or storage class

functions.h:24: error: parse error before \\'*\\' token

functions.h:24: error: parse error before \\'op\\'

functions.h:24: warning: data definition has no type or storage class

functions.h:25: error: parse error before \\'*\\' token

functions.h:25: error: parse error before \\'*\\' token

functions.h:25: warning: data definition has no type or storage class

functions.c: In function \\'insert_codeline_list\\':

functions.c:6: warning: incompatible implicit declaration of built-in function \\'malloc\\'

functions.c:10: error: \\'NULL\\' undeclared (first use in this function)

functions.c:10: error: (Each undeclared identifier is reported only once

functions.c:10: error: for each function it appears in.)

functions.c:15: warning: assignment from incompatible pointer type

functions.c:17: warning: assignment from incompatible pointer type

functions.c: In function \\'insert_attrib\\':

functions.c:26: warning: incompatible implicit declaration of built-in function \\'malloc\\'

functions.c:28: error: \\'ial\\' undeclared (first use in this function)

functions.c:28: warning: incompatible implicit declaration of built-in function \\'strdup\\'

functions.c: At top level:

functions.c:34: error: parse error before \\'is_oper\\'

functions.c:39: error: parse error before \\'is_oper\\'
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on January 15, 2007, 10:04:08 AM
Bem me parecia que isto não estava assim tão avançado... As funções de parsing da linguagem não estão ainda feitas. Por isso dava este bocado só de erros das funções:

functions.h:3: error: parse error before \\'*\\' token

functions.h:3: error: parse error before \\'*\\' token

functions.h:3: warning: data definition has no type or storage class

functions.h:4: error: parse error before \\'*\\' token

functions.h:4: warning: data definition has no type or storage class

functions.h:5: error: parse error before \\'*\\' token

functions.h:5: warning: data definition has no type or storage class

functions.h:6: error: parse error before \\'*\\' token

functions.h:6: error: parse error before \\'*\\' token

functions.h:6: warning: data definition has no type or storage class

functions.h:7: error: parse error before \\'*\\' token

functions.h:7: error: parse error before \\'*\\' token

functions.h:7: warning: data definition has no type or storage class

functions.h:8: error: parse error before \\'*\\' token

functions.h:8: warning: data definition has no type or storage class

functions.h:9: error: parse error before \\'*\\' token

functions.h:9: error: parse error before \\'*\\' token

functions.h:9: warning: data definition has no type or storage class

functions.h:10: error: parse error before \\'*\\' token

functions.h:10: error: parse error before \\'*\\' token

functions.h:10: warning: data definition has no type or storage class

functions.h:11: error: parse error before \\'*\\' token

functions.h:11: error: parse error before \\'*\\' token

functions.h:11: warning: data definition has no type or storage class

functions.h:12: error: parse error before \\'*\\' token

functions.h:12: error: parse error before \\'*\\' token

functions.h:12: warning: data definition has no type or storage class

functions.h:13: error: parse error before \\'*\\' token

functions.h:13: error: parse error before \\'*\\' token

functions.h:13: warning: data definition has no type or storage class

functions.h:14: error: parse error before \\'*\\' token

functions.h:14: warning: data definition has no type or storage class

functions.h:15: error: parse error before \\'*\\' token

functions.h:15: warning: data definition has no type or storage class

functions.h:17: error: parse error before \\'is_single_exp_list\\'

functions.h:18: error: parse error before \\'*\\' token

functions.h:18: error: parse error before \\'is_single_exp\\'

functions.h:18: warning: data definition has no type or storage class

functions.h:19: error: parse error before \\'*\\' token

functions.h:19: error: parse error before \\'*\\' token

functions.h:19: warning: data definition has no type or storage class

functions.h:20: error: parse error before \\'*\\' token

functions.h:20: error: parse error before \\'*\\' token

functions.h:20: warning: data definition has no type or storage class

functions.h:21: error: parse error before \\'*\\' token

functions.h:21: error: parse error before \\'*\\' token

functions.h:21: warning: data definition has no type or storage class

functions.h:22: error: parse error before \\'*\\' token

functions.h:22: error: parse error before \\'*\\' token

functions.h:22: warning: data definition has no type or storage class

functions.h:23: error: parse error before \\'*\\' token

functions.h:23: error: parse error before \\'is_single_exp_list\\'

functions.h:23: warning: data definition has no type or storage class

functions.h:24: error: parse error before \\'*\\' token

functions.h:24: error: parse error before \\'op\\'

functions.h:24: warning: data definition has no type or storage class

functions.h:25: error: parse error before \\'*\\' token

functions.h:25: error: parse error before \\'*\\' token

functions.h:25: warning: data definition has no type or storage class

functions.c: In function \\'insert_codeline_list\\':

functions.c:6: warning: incompatible implicit declaration of built-in function \\'malloc\\'

functions.c:10: error: \\'NULL\\' undeclared (first use in this function)

functions.c:10: error: (Each undeclared identifier is reported only once

functions.c:10: error: for each function it appears in.)

functions.c:15: warning: assignment from incompatible pointer type

functions.c:17: warning: assignment from incompatible pointer type

functions.c: In function \\'insert_attrib\\':

functions.c:26: warning: incompatible implicit declaration of built-in function \\'malloc\\'

functions.c:28: error: \\'ial\\' undeclared (first use in this function)

functions.c:28: warning: incompatible implicit declaration of built-in function \\'strdup\\'

functions.c: At top level:

functions.c:34: error: parse error before \\'is_oper\\'

functions.c:39: error: parse error before \\'is_oper\\'

Portanto, os erros anteriores nas estruturas (structures.h) estão resolvidos. Agora é começar as funções de inserção. Algum voluntário para completar isto?

Vou ter k ser eu, n é?
Title: Desafio - Compilador (Inventem uma liguagem)
Post by: KTachyon on January 15, 2007, 10:06:17 AM
Já agora, quem tiver sugestões (modificações) a fazer sobre a linguagem, é melhor que comece a sugeri-las já, que é para eu não ter que voltar a modificar o código dos motores de parsing.