diff options
author | marha <marha@users.sourceforge.net> | 2010-09-01 15:05:15 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-09-01 15:05:15 +0000 |
commit | a1c59d04b8d5ce972c34bd1e5abd941b55655029 (patch) | |
tree | bb62b1ec94277a10de7bc22bba9ac62e74878b5d /tools/mhmake/src/mhmakelexer.l | |
parent | e09e8cbeb878fc881b6987280e18ce5430318451 (diff) | |
download | vcxsrv-a1c59d04b8d5ce972c34bd1e5abd941b55655029.tar.gz vcxsrv-a1c59d04b8d5ce972c34bd1e5abd941b55655029.tar.bz2 vcxsrv-a1c59d04b8d5ce972c34bd1e5abd941b55655029.zip |
Make it possible to use more complicated expressions in if statements
Diffstat (limited to 'tools/mhmake/src/mhmakelexer.l')
-rw-r--r-- | tools/mhmake/src/mhmakelexer.l | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l index d64d7cc5c..59aaad0ca 100644 --- a/tools/mhmake/src/mhmakelexer.l +++ b/tools/mhmake/src/mhmakelexer.l @@ -337,11 +337,13 @@ load_makefile { ^[ \t]*if[ \t]*\\[ \t\r]*\n[ \t]* {
BEGIN(IF);
m_Line++;
+ m_curtoken=g_EmptyString;
return mhmakeparser::NEWLINE;
}
^[ \t]*if[ \t]+ {
BEGIN(IF);
+ m_curtoken=g_EmptyString;
return mhmakeparser::NEWLINE;
}
@@ -417,12 +419,12 @@ load_makefile { }
}
-<IFEQ,IFNEQ>[ \t]*\\[ \t\r]*\n[ \t]* { m_Line++; m_curtoken += g_SpaceString;}
+<IF,IFEQ,IFNEQ>[ \t]*\\[ \t\r]*\n[ \t]* { m_Line++; m_curtoken += g_SpaceString;}
-<IFEQ,IFNEQ>\r /* skip */
+<IF,IFEQ,IFNEQ>\r /* skip */
-<IFEQ,IFNEQ>[^\\\r\n]+ |
-<IFEQ,IFNEQ>\\ { m_curtoken += (const char *)yytext; }
+<IF,IFEQ,IFNEQ>[^\\\r\n]+ |
+<IF,IFEQ,IFNEQ>\\ { m_curtoken += (const char *)yytext; }
/*****************************************************************************/
<IFNEQ>\n {
@@ -442,10 +444,8 @@ load_makefile { }
/*****************************************************************************/
-<IF,IFDEF,IFNDEF>[ \t\r]* /* skip */
-
- /*---------------------------------------------------------------------------*/
-<IF>[a-zA-Z0-9_]+ {
+<IF>[ \t\r]*[a-zA-Z0-9_]+[ \t\r]*\n {
+ unput( '\n' );
m_IndentStack.push(0);
string Val=GetParser()->ExpandVar((const char *)yytext);
if (Val.empty() || Val=="0")
@@ -462,6 +462,26 @@ load_makefile { }
/*---------------------------------------------------------------------------*/
+<IF>\n {
+ unput( yytext[0] );
+ m_IndentStack.push(0);
+ if (GetParser()->IsExprTrue(m_curtoken))
+ {
+ PRINTF(("%s %d: Not Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ BEGIN(INITIAL);
+ }
+ else
+ {
+ PRINTF(("%s %d: Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ m_IndentSkip=m_IndentStack.size();
+ BEGIN(SKIPUNTILELSEORENDIF);
+ }
+}
+
+ /*****************************************************************************/
+<IFDEF,IFNDEF>[ \t\r]* /* skip */
+
+ /*---------------------------------------------------------------------------*/
<IFDEF>[a-zA-Z0-9_]+ {
m_IndentStack.push(0);
if (GetParser()->IsDefined((const char *)yytext))
@@ -523,7 +543,7 @@ load_makefile { }
/*---------------------------------------------------------------------------*/
-<SKIPUNTILELSEORENDIF>\n[ ]*if(def|ndef|eq|neq) {
+<SKIPUNTILELSEORENDIF>\n[ ]*if(def|ndef|eq|neq)? {
m_Line++;
m_IndentStack.push(0);
PRINTF(("%s %d: %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext+1,m_IndentStack.size()));
|