Académique Documents
Professionnel Documents
Culture Documents
h> #includ
e<string.h> #include<alloc.h> #include<process.h> #include<ctype.h> /* constante
s de nmeros de tokens */ #define NUMERO_INGREDIENTE 32 #define NUMERO_MEDIDA 8 #d
efine NUMERO_PRESENTACION 14 /* tokens */ #define ADEREZO #define CANTIDAD_1 #de
fine CANTIDAD_2_O_MAS #define CANTIDAD_FRACCION #define COMA #define CONJUNCION
#define FIN #define INGREDIENTE #define MEDIDA #define PREPOSICION #define PRESE
NTACION #define SALTO_LINEA 0 1 /* se definen 3 constantes para cantidad */ 2 /*
por cuestiones sem nticas */ 3 4 5 6 7 8 9 10 11
char *entrada; /* apuntador que contiene la receta */ int numero_linea = 1; /* c
ontador de lneas */ /* variables de l xico */ unsigned int token; /* nmero econmico
de token */ unsigned char cadena_token[50]; /* cadena actual del token */ /* va
riables de sem ntica */ int indice_cantidad, indice_medida, indice_ingrediente, in
dice_presentacion; /* prototipos de funciones */ void cargar_archivo_memoria(int
a, char *b); void error(int a); void lexico(); void semantica_cantidad_medida()
; void semantica_ingrediente_presentacion(); void sintaxis(); /*****************
*****************************************/ void main(int argc, char *argv[]) { c
argar_archivo_memoria(argc, argv[1]); do { sintaxis(); }while (token!=FIN); prin
tf("Receta correcta"); }
}; if (relacion_cantidad_medida[indice_cantidad][indice_medida] != 1) error(5);
} /**********************************************************/ void semantica_in
grediente_presentacion() { static unsigned int relacion_ingrediente_presentacion
[NUMERO_INGREDIENTE][NUME RO_PRESENTACION] = { /* gusto duro finrall necesar mol
ido picados rebanada */ /* oliva */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*
aguacate */ 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, /* ajo */ 1, 0, 0, 0, 1,
0, 0, 0, 1, 1, 1, 0, 0, 1, /* apio */ 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0,
/* carne res */ 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, /* cebolla */ 1, 1, 0,
1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, /* championes */ 1, 0, 0, 1, 0, 0, 0, 0, 0, 0,
1, 0, 0, 1, /* chile ancho */ 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, /* chile
s chipo */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, /* chiles huaji */ 1, 0, 0,
0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, /* consome pollo */ 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, /* dientes ajo */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, /* f
alda res */ 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, /* germ soya */ 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* huevo */ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, /* jengibre */ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, /* jugo maggi */
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* lechuga */ 1, 0, 0, 1, 1, 0, 0, 0,
0, 1, 0, 0, 0, 0, /* mayonesa */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* mo
ztaza */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* pimientas */ 1, 0, 0, 0, 0
, 0, 0, 1, 0, 0, 0, 0, 0, 0, /* pim gordas */ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0
, 0, 0, /* pim morrn */ 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, /* pollo */ 0,
0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, /* queso panela */ 1, 0, 0, 1, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, /* salsa inglesa */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, /* tomates */ 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, /* tomillo */ 1, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* tripa puerco */ 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, /* sal */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* vinagre */
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* zanahorias */ 1, 0, 0, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0 }; /* cort alto tiras fresco molida picado rallado rebanado
s */ if (relacion_ingrediente_presentacion[indice_ingrediente][indice_presentaci
on] != 1) error(6); } /*********************************************************
*/ void sintaxis() { unsigned char semantica_cantidad[50], semantica_ingrediente
[50]; lexico(); /* se toma el primer token */ switch (token) /* camino opcional
*/
lexico(); } }