-
Notifications
You must be signed in to change notification settings - Fork 0
/
final.l
48 lines (37 loc) · 870 Bytes
/
final.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
%{
/*Declaracoes C diversas */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define JAVAENDLEN 24
#define JAVABEGINLEN 7
int cont = 0;
FILE *fp;
/**
* Retorna os caracteres que se encontram entre </code> e <code [^>]*>
* @param s String ainda com tags
* @param len Tamanho da string s
* @return string que se encontram entre </code> e <code [^>]*>
*/
char * btwinTags(char * s, int len){
int i = JAVABEGINLEN, j = 0;
char * string = (char *)malloc(len * sizeof(char));
while(i<len-JAVAENDLEN)
string[j++] = s[i++];
return string;
}
%}
%x body rest
%%
"</code>"["\n" {};|()$&]*"<code "[^>]*">" {fprintf(fp,"%s",btwinTags(yytext,yyleng)); }
.|\n {fprintf(fp,"%s",yytext);}
%%
int yywrap(){
return(1);
}
int main(int agrc, char* argv[]) {
fp = fopen("final.out", "w");
yylex();
fclose(fp);
return 0;
}