From 4aa4e498d10e343b3b2a49e06195f62a49120002 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 15 Oct 2021 11:15:28 +0900 Subject: Imported Upstream version 1.9.0 --- src/commentcnv.l | 80 ++++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 43 deletions(-) (limited to 'src/commentcnv.l') diff --git a/src/commentcnv.l b/src/commentcnv.l index a7d74ef..036f830 100644 --- a/src/commentcnv.l +++ b/src/commentcnv.l @@ -142,12 +142,44 @@ MAILADR ("mailto:")?[a-z_A-Z0-9.+-]+"@"[a-z_A-Z0-9-]+("."[a-z_A-Z0-9\-]+)+[a-z %x CondLine %x ReadAliasArgs + //- start: NUMBER ------------------------------------------------------------------------- + // Note same defines in code.l: keep in sync +DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]? +HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]? +OCTAL_INTEGER "0"[0-7][0-7']+[0-7]? +BINARY_INTEGER "0"[bB][01][01']*[01]? +INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER} + +FP_SUF [fFlL] + +DIGIT_SEQ [0-9][0-9']*[0-9]? +FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ} +FP_EXP [eE][+-]?{DIGIT_SEQ} +DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}? +DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF} + +HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]? +HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ} +BIN_EXP [pP][+-]?{DIGIT_SEQ} +HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}? +HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}? + +FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2} +FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2} +FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL} +NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} + //- end: NUMBER --------------------------------------------------------------------------- + %% -[^"'!\/\n\\#,\-]* { /* eat anything that is not " / , or \n */ +{NUMBER} { //Note similar code in code.l + if (yyextra->lang!=SrcLangExt_Cpp) REJECT; + copyToOutput(yyscanner,yytext,(int)yyleng); + } +[^"'!\/\n\\#,\-=; \t]* { /* eat anything that is not " / , or \n */ copyToOutput(yyscanner,yytext,(int)yyleng); } -[,] { /* eat , so we have a nice separator in long initialization lines */ +[,= ;\t] { /* eat , so we have a nice separator in long initialization lines */ copyToOutput(yyscanner,yytext,(int)yyleng); } "\"\"\""! { /* start of python long comment */ @@ -1076,45 +1108,6 @@ static void replaceComment(yyscan_t yyscanner,int offset) } } -// simplified way to know if this is fixed form -// duplicate in fortrancode.l -static bool recognizeFixedForm(const char* contents) -{ - int column=0; - bool skipLine=FALSE; - - for(int i=0;;i++) { - column++; - - switch(contents[i]) { - case '\n': - column=0; - skipLine=FALSE; - break; - case ' ': - break; - case '\000': - return FALSE; - case 'C': - case 'c': - case '*': - if(column==1) return TRUE; - if(skipLine) break; - return FALSE; - case '!': - if(column>1 && column<7) return FALSE; - skipLine=TRUE; - break; - default: - if(skipLine) break; - if(column==7) return TRUE; - return FALSE; - } - } - return FALSE; -} - - /*! This function does three things: * -# It converts multi-line C++ style comment blocks (that are aligned) * to C style comment blocks (if MULTILINE_CPP_IS_BRIEF is set to NO). @@ -1151,7 +1144,8 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const char *fileName) yyextra->isFixedForm = FALSE; if (yyextra->lang==SrcLangExt_Fortran) { - yyextra->isFixedForm = recognizeFixedForm(inBuf->data()); + FortranFormat fmt = convertFileNameFortranParserCode(fileName); + yyextra->isFixedForm = recognizeFixedForm(inBuf->data(),fmt); } if (yyextra->lang==SrcLangExt_Markdown) @@ -1173,7 +1167,7 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const char *fileName) warn(yyextra->fileName,ctx->lineNr,"Conditional section%sdoes not have " "a corresponding \\endcond command within this file.",sectionInfo.data()); } - if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt_Markdown) + if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt_Markdown && yyextra->lang!=SrcLangExt_Fortran) { QCString tmp= "(probable line reference: "; bool first = TRUE; -- cgit v1.2.3