Re: [Doxygen-develop] Adding of new (all) HTML entities? A oneline solution?
Brought to you by:
dimitri
From: Xavier O. <xav...@an...> - 2001-07-24 08:29:02
|
John Olsson wrote: > > doc.l would be modify and this line added: > > <DocScan,Text>"&"[a-zA-Z0-9]{1}";" { outDoc->writeEntity(yytext[1]); } > > <DocScan,Text>"&"[a-zA-Z0-9]{2}";" { outDoc->writeEntity(yytext[2]); } > > <DocScan,Text>"&"[a-zA-Z0-9]{3}";" { outDoc->writeEntity(yytext[3]); } > > <DocScan,Text>"&"[a-zA-Z0-9]{4}";" { outDoc->writeEntity(yytext[4]); } > > > > I have several questions...: > > > > -Q1: Are the following single line could replace the 4 lines? > > <DocScan,Text>"&"[a-zA-Z0-9]{1,4}";" { outDoc->writeEntity(yytext[4]); } > > (I'm very lazy! :-) > > > Why do you have yytext[1] etc. in the above example and only yytext[4] in > your suggested replacement? -1 In the regex, there is [a-zA-Z0-9]{$} where $ is 1,2,3 or 4. I think this means repeat $ times an alphanumeric value. (I'm using Regular Expression syntax of Python 1.5, I hope that's the sames rules Doxygen uses). -2 I have supposed that yytext[1] means one character, yytext[2] ,... But it means, the second character, the third and so on It was alos not correct because α has more than 4 characters! I ha in mind numeric entities like ӝ. Well ... So now, I think that it would be more correct to have: <DocScan,Text>"&"[a-zA-Z0-9]{1,}";" { outDoc->writeEntity(yytext,strlen(yytext)); } void HtmlGenerator::writeEntity(const char* const text, int length) { if (text) { char c; int textlength = length; while (textlength) { c=*text++; t << c; textlength--; } } } > > -Q2: There is a theorical problem: what is the order of scanning? to be > > backward compatible, the added regex should be check if nothing > > else has already matched. > > > If you read the flex manual page everything will be explained. ;) > > The parser generated by flex picks the longest matching rule it can find > of all active rules. One way for a rule to become active is to call for it > explicitly, i.e. BEGIN(DocScan) will activate all rules with DocScan in > them. By longest matching, you certainly means the more restrictive, the more precise. So I think this will work.I will provide changes soon. Sorry for newbie questions. I just wanted to help a little (for my needs first), I'm simply maintainer of the French location of Doxygen. :-) [...] Thanks, Xavier. -- Artificial Anthill Project http://www.aanthill.org/ mailto:aan...@aa... D2SET Non Profit Association http://www.d2set.org/ mailto:d2...@d2... |