-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexpresiones.l
55 lines (38 loc) · 1.35 KB
/
expresiones.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* scanner for a toy Pascal-like language*/
%{
/*need this for the call to atof() below*/
#include "levenstein.h"
#include<math.h>
FILE *pFile=NULL;
%}
PALABRAS [a-z|A-Z|0-9]*
LIBRERIAS #[a-z]*
LIBRERIAS2 [a-z]*"."h
VARIABLES void|int|float|boolean|char|string|array|long|short|byte
GRUPOS "{"|"}"|"("|")"|"["|"]"|"<"|">"
COMENTARIOS "/*"[a-z|A-Z|" "|0-9|\n]*"*/"|"//"[a-z|A-Z|" "|0-9]*
RESERVADAS printf|exit|return|scanf|main|NULL|break|initscr|clear|move|refresh|getch|endwin|struct
CICLOS if|else|for|do|while|switch|case
SIMBOLOS ";"|"="|"+"|"-"|"_"|":"|","|"%"|"!"|"¡"|"?"|"¿"|"*"|"/"|"@"|"$"|"&"
COMILLAS \"
COMPARACIONES "=="|"&&"|"||"|"!="
%%
{LIBRERIAS}+ total_palabras(pFile,num);
{LIBRERIAS2}+ total_palabras(pFile,num);
{VARIABLES}+ total_palabras(pFile,num);
{GRUPOS}+ total_palabras(pFile,num);
{COMENTARIOS}+ total_palabras(pFile,num);
{RESERVADAS}+ total_palabras(pFile,num);
{CICLOS}+ total_palabras(pFile,num);
{PALABRAS}+ total_palabras(pFile,num);
{SIMBOLOS}+ total_palabras(pFile,num);
{COMILLAS}+ total_palabras(pFile,num);
{COMPARACIONES}+ total_palabras(pFile,num);
%%
int main( int argc, char **argv )
{
fp = fopen("correciondeerrores.txt","r");
++argv, --argc; /*skip over program name*/
yylex();
fclose(fp);
}