diff options
author | marha <marha@users.sourceforge.net> | 2011-03-04 11:26:33 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-03-04 11:26:33 +0000 |
commit | dbe1b719f8037dda23279b8bc7d8200578415e15 (patch) | |
tree | 258cd8fc316da25de3df00dc36e00a1f54f0e125 /tools/mhmake/src/mhmakelexer.l | |
parent | d2bdfe9f8d895ac64619f7bc2f7443ce886146e9 (diff) | |
download | vcxsrv-dbe1b719f8037dda23279b8bc7d8200578415e15.tar.gz vcxsrv-dbe1b719f8037dda23279b8bc7d8200578415e15.tar.bz2 vcxsrv-dbe1b719f8037dda23279b8bc7d8200578415e15.zip |
Implement eval sort warning functions (see gnu make manual for description)
Solved errors in if and foreach implementations
Removed message and reparse function (use info and eval instead)
$n can be used to add new line
define can be used to specify multi-line macros
Solved error in argument expansion in call function
Diffstat (limited to 'tools/mhmake/src/mhmakelexer.l')
-rw-r--r-- | tools/mhmake/src/mhmakelexer.l | 115 |
1 files changed, 23 insertions, 92 deletions
diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l index f27fec31a..aa396ceaf 100644 --- a/tools/mhmake/src/mhmakelexer.l +++ b/tools/mhmake/src/mhmakelexer.l @@ -95,7 +95,7 @@ static void ReplaceCurlyBraces(string &String) /* -------------- rules section -------------- */
%x INCLUDE IFDEF IF IFNDEF SKIPUNTILELSEORENDIF QUOTE MAKEEXPRES SINGLEQUOTE COMMANDPARSE
-%x IFEQ IFNEQ ERRORMACRO MESSAGEMACRO REPARSEMACRO LOAD_MAKEFILE
+%x IFEQ IFNEQ LOAD_MAKEFILE
%x DEFINE
%{
@@ -463,7 +463,7 @@ load_makefile { <IF,IFEQ,IFNEQ>\r /* skip */
-<IF,IFEQ,IFNEQ>[^\\\r\n\$]+ |
+<IF,IFEQ,IFNEQ>[^\\\r\n\$#]+ |
<IF,IFEQ,IFNEQ>[\\\$] { m_curtoken += (const char *)yytext; }
/*****************************************************************************/
@@ -608,7 +608,7 @@ load_makefile { }
/*---------------------------------------------------------------------------*/
-[ \t]*#[^\n]* {
+<INITIAL,COMMANDPARSE,IF,IFEQ,IFNEQ>[ \t]*#[^\n]* {
PRINTF(("%s %d: -COMMENT: %s\n",m_InputFileName.c_str(),lineno(),yytext));
}
@@ -678,7 +678,7 @@ export { return yy::mhmakeparser::token::STRING;
}
-([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|]|\\\ |\\#)+ {
+([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|\[\]]|\\\ |\\#)+ {
PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),lineno(),yytext));
yylval->theString=(const char *)yytext;
return yy::mhmakeparser::token::STRING;
@@ -701,6 +701,11 @@ export { m_curtoken+=g_SpaceString;
}
+<DEFINE>\n {
+ inclineno();
+ m_curtoken+=(const char *)yytext;
+}
+
<DEFINE>. {
m_curtoken+=(const char *)yytext;
}
@@ -734,33 +739,6 @@ export { }
/*---------------------------------------------------------------------------*/
-\$[\(\{][ \t]*error[ \t]+ {
- m_BraceIndent++;
- PRINTF(("%s %d: BEGIN ERROR MACRO $(: %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
- BEGIN(ERRORMACRO);
- m_curtoken=g_EmptyString;
- return yy::mhmakeparser::token::NEWLINE; // Make sure that the previous lines are matched by the bison parser (so that all variables until here are defined)
-}
-
- /*---------------------------------------------------------------------------*/
-\$[\(\{][ \t]*(message|info)[ \t]+ {
- m_BraceIndent++;
- PRINTF(("%s %d: BEGIN MESSAGE MACRO $(: %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
- BEGIN(MESSAGEMACRO);
- m_curtoken=g_EmptyString;
- return yy::mhmakeparser::token::NEWLINE; // Make sure that the previous lines are matched by the bison parser (so that all variables until here are defined)
-}
-
- /*---------------------------------------------------------------------------*/
-\$[\(\{][ \t]*reparse[ \t]+ {
- m_BraceIndent++;
- PRINTF(("%s %d: BEGIN REPARSE MACRO $(: %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
- BEGIN(REPARSEMACRO);
- m_curtoken=g_EmptyString;
- return yy::mhmakeparser::token::NEWLINE;
-}
-
- /*---------------------------------------------------------------------------*/
\$[<@/$] {
PRINTF(("%s %d: DOLLAREXPR: %s\n",m_InputFileName.c_str(),lineno(),yytext));
yylval->theString=(const char *)yytext;
@@ -833,11 +811,6 @@ export { m_curtoken+='#';
}
- /*---------------------------------------------------------------------------*/
-<COMMANDPARSE>[ \t]*#[^\n]* {
- PRINTF(("%s %d: -COMMENT: %s\n",m_InputFileName.c_str(),lineno(),yytext));
-}
-
/*****************************************************************************/
<QUOTE>\" {
PRINTF(("%s %d: QUOTEDSTRING: %s\n",m_InputFileName.c_str(),lineno(),yytext));
@@ -875,58 +848,6 @@ export { }
/*****************************************************************************/
-<ERRORMACRO>[\)\}] {
- m_BraceIndent--;
- PRINTF(("%s %d: CLOSE BRACE ERROR MACRO ): %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
- if (!m_BraceIndent)
- {
- PRINTF(("%s %d: ERRORMACRO: %s\n",m_InputFileName.c_str(),lineno(),m_curtoken.c_str()));
- throw string("\n-> ")+m_InputFileName.c_str()+"("+stringify(lineno())+") : "+GetParser()->ExpandExpression(m_curtoken);
- } else {
- m_curtoken+=(const char *)yytext;
-}
-}
-
- /*****************************************************************************/
-<MESSAGEMACRO>[\)\}] {
- m_BraceIndent--;
- PRINTF(("%s %d: CLOSE BRACE MESSAGE MACRO ): %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
- if (!m_BraceIndent)
- {
- PRINTF(("%s %d: MESSAGEMACRO: %s\n",m_InputFileName.c_str(),lineno(),yytext));
- cerr<<m_InputFileName.c_str()<<"("<<stringify(lineno())+") : "<<GetParser()->ExpandExpression(m_curtoken)<<endl;
- BEGIN(INITIAL);
- } else {
- m_curtoken+=(const char *)yytext;
- }
-}
-
- /*****************************************************************************/
-<REPARSEMACRO>[\)\}] {
- m_BraceIndent--;
- PRINTF(("%s %d: CLOSE BRACE REPARSE MACRO ): %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
- if (!m_BraceIndent)
- {
- PRINTF(("%s %d: REPARSEMACRO: %s\n",m_InputFileName.c_str(),lineno(),yytext));
- string Deps=GetParser()->ExpandExpression(m_curtoken);
- PRINTF(("%s %d: REPARSEMACRO expanded: %s\n",m_InputFileName.c_str(),lineno(),Deps.c_str()));
- string::const_reverse_iterator It=Deps.rbegin()+1; // +1 because we don't want the latest brace
- string::const_reverse_iterator ItBeg=Deps.rend();
- while (It!= ItBeg)
- {
- char Char=*It++;
- if (Char==';') Char='\n';
- unput(Char);
- }
- BEGIN(INITIAL);
- }
- else
- {
- m_curtoken+=(const char *)yytext;
- }
-}
-
- /*****************************************************************************/
<MAKEEXPRES>[\)\}] {
m_BraceIndent--;
PRINTF(("%s %d: CLOSE BRACE MAKEEXPRES MACRO ): %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
@@ -945,22 +866,32 @@ export { }
/*---------------------------------------------------------------------------*/
-<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>\$[\(\{] {
+<MAKEEXPRES>\$[\(\{] {
m_BraceIndent++;
PRINTF(("%s %d: MACRO extra $(: %d\n",m_InputFileName.c_str(),lineno(),m_BraceIndent));
m_curtoken+=(const char *)yytext;
}
/*---------------------------------------------------------------------------*/
-<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>[^$\(\)\{\}\r\n\\]+ |
-<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>[\(\$\\\{] {
+<MAKEEXPRES>[\(\{] {
+ m_BraceIndent++;
m_curtoken+=(const char *)yytext;
}
-<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>[ \t\r]*\\[ \t\r]*\n[ \t\r]* {
+
+ /*---------------------------------------------------------------------------*/
+<MAKEEXPRES>[^$\(\)\{\}\r\n\\]+ |
+<MAKEEXPRES>[\(\$\\\{] {
+ m_curtoken+=(const char *)yytext;
+}
+<MAKEEXPRES>[ \t\r]*\\[ \t\r]*\n[ \t\r]* {
inclineno();
m_curtoken+=g_SpaceString;
}
+<MAKEEXPRES>\n {
+ throw m_InputFileName + "(" + stringify(lineno()) + "): End of line inside macro is not allowed";
+}
+
<SKIPUNTILELSEORENDIF><<EOF>> {
throw string("Missing endif or else statement. #else or #endif used?");
}
|