Hello sirs,
i need some help... i am confuse when i use re2c...
i want parse simple url of this buffer:
"sdfsdfsdfsdf <a href='/page/site.jsp'> sdfsdfsdfsdfsdf<\a>"
to extract path, look this:
---
#include <stdio.h>
#include <stdlib.h>
enum {
PATH, END
};
int scan(char** p, char** lex)
{
char* marker;
if (lex) *lex = *p;
/*!re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = *p;
re2c:define:YYMARKER = marker;
re2c:yyfill:enable = 0;
re2c:yych:conversion = 1;
re2c:indent:top = 1;
"href=".+'>' { return PATH; }
[^] { return END; }
*/
}
int main() {
char *p="sdfsdfsdfsdf <a href='/page/site.jsp'> sdfsdfsdfsdfsdf<a>";
char *last;
int token;
while ((token = scan(&p, &last)) != END) {
int sz = p - last;
switch (token) {
case PATH: printf("url is: '%.*s'\n", sz, last); break;
}
}
return 0;
}
---
my ask is:
How i can extract the chunk 'href='/page/site.jsp'> ?
tks
cheers
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Re2c-general mailing list
Re2c-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/re2c-general