Skip to content
Snippets Groups Projects
Commit 675060ae authored by marivil's avatar marivil
Browse files

Arreglado core dump

parent d186d086
No related branches found
No related tags found
1 merge request!1Arbol
......@@ -32,7 +32,7 @@ char *keywords[KWLEN] = {
"sin",
"tan",
"var",
"while"
"while",
"do"
};
......@@ -53,7 +53,7 @@ unsigned keycodes[KWLEN] = {
TAN,
VAR,
WHILE,
WHILE
DO
};
static void lower(char *s); /* Pasar todas las letras a minúsculas (definida abajo) */
......@@ -93,25 +93,26 @@ CHAR (\'.?\')
COMSIMP (\/\/.*)
COMMULT (\\\*.*\*\/)
%%
{WSPC} ;
{NEWLN} {
yylineno+=1;
}
{WSPC} ;
{COMSEP} {
return yytext[0];
}
{COMSIMP} ;
{COMMULT} ;
{IDENT} {
int i = 0;
int i ;
char *res;
lower(yytext); /* Se pasa a minúsculas */
/* Se busca si es palabra una clave */
for (i = 0; i<KWLEN; i++ ){
if (strcmp(keywords[i],yytext)==0) return keycodes[i];
if (strcmp(keywords[i],yytext)==0)
return keycodes[i];
}
/* Si no es una palabra clave */
yyStr(yylval)=sdup(yytext); /* Se copia el identificador leído */
yyFlag(yylval)=fIDENT; /* Se apunta que es un identificador */
......@@ -119,9 +120,6 @@ COMMULT (\\\*.*\*\/)
return IDENT; /* Se devuelve que se ha leído un identificador */
}
{COMSEP} {
return yytext[0];
}
{DIGITS} {
/* Se lee el número entero */
......@@ -252,6 +250,3 @@ static char *readStr(void) {
return buff;
}
/* -- EOF -- */
......@@ -150,7 +150,7 @@ cuerpo
$$.u.ast = NULL;
}
| '{' cuerpo sentencia ';' '}'
{+
{
$$.flag = fAST;
$$.u.ast = appR(';', $2.u.ast, $3.u.ast);
}
......
print('j');
//print('j');
var a = 0;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment