Let's clean up the block comment parsing to be a bit more lex-like.
This commit was SVN r6695.
Этот коммит содержится в:
родитель
50545ef082
Коммит
0c32f34cb7
@ -46,42 +46,22 @@ WHITE [\f\t\v ]
|
|||||||
CHAR [A-Za-z0-9_\-\.]
|
CHAR [A-Za-z0-9_\-\.]
|
||||||
|
|
||||||
%x VALUE
|
%x VALUE
|
||||||
|
%x comment
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
{WHITE}*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
{WHITE}*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
||||||
#.*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
#.*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
||||||
"//".*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
"//".*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
||||||
"/*" {
|
|
||||||
register int c;
|
|
||||||
for ( ; ; ) {
|
|
||||||
/* Eat up characters till we hit the
|
|
||||||
* end of file or *
|
|
||||||
*/
|
|
||||||
while ( (c = input()) != '*' && c != EOF){
|
|
||||||
if(c == '\n')
|
|
||||||
mca_base_yynewlines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we reach a *, then look for the
|
"/*" { BEGIN(comment);
|
||||||
* matching /
|
return MCA_BASE_PARSE_NEWLINE; }
|
||||||
*/
|
<comment>[^*\n]* ; /* Eat up non '*'s */
|
||||||
if ( c == '*') {
|
<comment>"*"+[^*/\n]* ; /* Eat '*'s not followed by a '/' */
|
||||||
while ( (c = input()) == '*' ) {
|
<comment>\n { mca_base_yynewlines++;
|
||||||
if(c == '\n')
|
return MCA_BASE_PARSE_NEWLINE; }
|
||||||
mca_base_yynewlines++;
|
<comment>"*"+"/" { BEGIN(INITIAL); /* Done with Block Comment */
|
||||||
}
|
return MCA_BASE_PARSE_NEWLINE; }
|
||||||
|
|
||||||
if ( c == '/' )
|
|
||||||
break; /* End of Comment */
|
|
||||||
}
|
|
||||||
else if ( c == EOF ) {
|
|
||||||
/* EOF in comment :( */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return MCA_BASE_PARSE_NEWLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
{WHITE}*"="{WHITE}* { BEGIN(VALUE); return MCA_BASE_PARSE_EQUAL; }
|
{WHITE}*"="{WHITE}* { BEGIN(VALUE); return MCA_BASE_PARSE_EQUAL; }
|
||||||
{WHITE}+ ; /* whitespace */
|
{WHITE}+ ; /* whitespace */
|
||||||
|
@ -39,6 +39,8 @@ bool orte_rds_hostfile_done = false;
|
|||||||
|
|
||||||
WHITE [\f\t\v ]
|
WHITE [\f\t\v ]
|
||||||
|
|
||||||
|
%x comment
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
{WHITE}*\n { orte_rds_hostfile_line++;
|
{WHITE}*\n { orte_rds_hostfile_line++;
|
||||||
@ -47,36 +49,15 @@ WHITE [\f\t\v ]
|
|||||||
return ORTE_RDS_HOSTFILE_NEWLINE; }
|
return ORTE_RDS_HOSTFILE_NEWLINE; }
|
||||||
"//".*\n { orte_rds_hostfile_line++;
|
"//".*\n { orte_rds_hostfile_line++;
|
||||||
return ORTE_RDS_HOSTFILE_NEWLINE; }
|
return ORTE_RDS_HOSTFILE_NEWLINE; }
|
||||||
"/*" {
|
|
||||||
register int c;
|
|
||||||
for ( ; ; ) {
|
|
||||||
/* Eat up characters till we hit the
|
|
||||||
* end of file or *
|
|
||||||
*/
|
|
||||||
while ( (c = input()) != '*' && c != EOF){
|
|
||||||
if(c == '\n')
|
|
||||||
orte_rds_hostfile_line++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we reach a *, then look for the
|
"/*" { BEGIN(comment);
|
||||||
* matching /
|
return ORTE_RDS_HOSTFILE_NEWLINE; }
|
||||||
*/
|
<comment>[^*\n]* ; /* Eat up non '*'s */
|
||||||
if ( c == '*') {
|
<comment>"*"+[^*/\n]* ; /* Eat '*'s not followed by a '/' */
|
||||||
while ( (c = input()) == '*' ) {
|
<comment>\n { orte_rds_hostfile_line++;
|
||||||
if(c == '\n')
|
return ORTE_RDS_HOSTFILE_NEWLINE; }
|
||||||
orte_rds_hostfile_line++;
|
<comment>"*"+"/" { BEGIN(INITIAL); /* Done with Block Comment */
|
||||||
}
|
return ORTE_RDS_HOSTFILE_NEWLINE; }
|
||||||
|
|
||||||
if ( c == '/' )
|
|
||||||
break; /* End of Comment */
|
|
||||||
}
|
|
||||||
else if ( c == EOF ) {
|
|
||||||
/* EOF in comment :( */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ORTE_RDS_HOSTFILE_NEWLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
\"[^\"]*\" { orte_rds_hostfile_value.sval = yytext;
|
\"[^\"]*\" { orte_rds_hostfile_value.sval = yytext;
|
||||||
return ORTE_RDS_HOSTFILE_QUOTED_STRING; }
|
return ORTE_RDS_HOSTFILE_QUOTED_STRING; }
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user