Forum Posts

Showing page 1 of 1
Post Title Author Date Views
Help on Backward Reference concept of Regular Expression ...

Hi blockcomment = "|" @initbuf1([a-z]+ $ident1collect tagcomment); tagcomment = "#" @comment( newline%{ entity = INTERNALNL; } %curlccallback | ws | (nonnewline - ws)@comment)* :>> "#" @initbuf2 ... [More] [a-z]+ $ident2_collect "|" when {index1 == index2 && strncmp(buf1, buf2, index1) == 0} @comment; In above code ident1collect and ident2collect is action implemented which actually collect begin and end tag name in buf1 and buf2 respectively But it throws some duplicate output having wrong parsing line as comment when tag are not matched like below for a given input file mylang comment |abc# mylang comment Source file created mylang code |abc# mylang code Source file created mylang code #ab| And when tag are matched it gives valid output for input file as below mylang comment |abc# mylang comment Source file created mylang comment #abc| Can anybody suggest what's went wrong to have duplicate output with wrong parsing as comment for not matching tag ? Thanks Hardik [Less]

hardik_parikh  over 4 years ago 2197
Help on Backward Reference concept of Regular Expression ...

I tried out suggested solution but somehow it does not produce any output when i use ./ohcount --annotate command. It seems like fgoto is not working in my case. I am not able to understand what is going wrong?

hardik_parikh  over 4 years ago 2197
Help on Backward Reference concept of Regular Expression ...

Hi mitchell In above code there is reference to tag_line in regex for tag_comment_end but i could not find definition for tag_line. Even I have tried with replacing it with tag_comment but it throws ... [More] compilation error : Can not enter inside longest match constuction as an entry point. So can you please describe what is here tag_line should be? Thanks Hardik Parikh [Less]

hardik_parikh  over 4 years ago 2197
Help on Backward Reference concept of Regular Expression ...

Consider follwing is valid comment /abc/ Some description ……. /abc/ And following is invalid comment /abc/ Some description ……. /xyz/ As per your suggestion I ... [More] tried with following code action mark_start{ start = fpc+1; // printf(" Mark start at %c\n",fc); } action tagstart{ size_t len = fpc - start ; s = calloc(len,sizeof(char)); strncpy(s,start,len); s[len]='\0'; // printf("Start : %s\n",s); } action tagend{ size_t len = fpc - start ; e = calloc(len,sizeof(char)); strncpy(e,start,len); e[len]='\0'; stringcmp = strncmp(e,s,sizeof(s)); //printf("End : %s\n",e); } curltagcomment = '/'@mark_start (nonnewline - ws)* '/'@tagstart @enqueue @comment( newline %{ entity = INTERNAL_NL; } %curl_ccallback | ws | (nonnewline - ws) @comment )* :>> ('/'@mark_start (nonnewline - ws)* '/' @tagend when { stringcmp == 0}) @commit @comment; Now I am able to capture both start and end substring properly and able to do math operation in when condition but it produces as a valid commet in parser for even a non valid statement. like curl comment /abc/ curl comment Some description ……. curl comment /xyz/ I have also tried with removing @enqueue and @commit and still its giving same result. Please provide me any suggestions where I am doing something wrong or is there any other better way to implement the same. [Less]

hardik_parikh  over 4 years ago 2197
Help on Backward Reference concept of Regular Expression ...

Hi I want to use backward reference in ragel regular expression for creating parser for my language. The requirement is kind of begining and end of tag matching where tag can be any arbitary string. ... [More] e.g /test/ this is sample /test/ or it can be 2./hello/ this is test /hello/ and following can be consider as a invalide 3./abc/ this is invalid /xyz/ So as in above example tag can be any arbitary string but requirement is to match begining and ending tag string should be same. To write regular expression for above requirement in ragel language i want to use backward reference as in javascript. So can somebody give valuable suggestion how can we achieve it in ragel or any pointer related to same would be great help Thanks Hardik Parikh [Less]

hardik_parikh  over 4 years ago 2197
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.