aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src/mhmakelexer.l
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-10-22 14:00:01 +0000
committermarha <marha@users.sourceforge.net>2010-10-22 14:00:01 +0000
commitd74d9f4e60e48260ff1fad3ff00aaf000f111a66 (patch)
treefcf6ceee3ec04dc8521bbf12453d95cbe187dc40 /tools/mhmake/src/mhmakelexer.l
parent5a05343a8071f769d092d5bb6bdea9adf65eda9c (diff)
downloadvcxsrv-d74d9f4e60e48260ff1fad3ff00aaf000f111a66.tar.gz
vcxsrv-d74d9f4e60e48260ff1fad3ff00aaf000f111a66.tar.bz2
vcxsrv-d74d9f4e60e48260ff1fad3ff00aaf000f111a66.zip
Increased gnu make compatibility
Optimised
Diffstat (limited to 'tools/mhmake/src/mhmakelexer.l')
-rw-r--r--tools/mhmake/src/mhmakelexer.l61
1 files changed, 49 insertions, 12 deletions
diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l
index 8796e70c4..62df687e1 100644
--- a/tools/mhmake/src/mhmakelexer.l
+++ b/tools/mhmake/src/mhmakelexer.l
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,9 +26,9 @@
#include "rule.h"
#include "util.h"
-static uint32 LoadMakMd5(refptr<fileinfo> &Target)
+static uint32 LoadMakMd5(fileinfo *pTarget)
{
- string FileName=Target->GetFullFileName();
+ string FileName=pTarget->GetFullFileName();
FileName+=".md5_32";
FILE *pFile=fopen(FileName.c_str(),"rb");
if (!pFile)
@@ -36,20 +36,20 @@ static uint32 LoadMakMd5(refptr<fileinfo> &Target)
uint32 Md5_32=0;
fread(&Md5_32,sizeof(Md5_32),1,pFile);
fclose(pFile);
- Target->SetCommandsMd5_32(Md5_32);
+ pTarget->SetCommandsMd5_32(Md5_32);
return Md5_32;
}
-static void SaveMakMd5(refptr<fileinfo> &Target)
+static void SaveMakMd5(fileinfo *pTarget)
{
- string FileName=Target->GetFullFileName();
+ string FileName=pTarget->GetFullFileName();
FileName+=".md5_32";
FILE *pFile=fopen(FileName.c_str(),"wb");
if (!pFile)
{
throw string("Error creating file ")+FileName;
}
- Target->WriteMd5_32(pFile);
+ pTarget->WriteMd5_32(pFile);
fclose(pFile);
}
@@ -83,12 +83,12 @@ static void SaveMakMd5(refptr<fileinfo> &Target)
/* -------------- rules section -------------- */
%x INCLUDE IFDEF IF IFNDEF SKIPUNTILELSEORENDIF QUOTE MAKEEXPRES SINGLEQUOTE COMMANDPARSE
-%x IFEQ IFNEQ ERRORMACRO MESSAGEMACRO REPARSEMACRO LOAD_MAKEFILE
+%x IFEQ IFNEQ ERRORMACRO MESSAGEMACRO MESSAGEINFO MESSAGEERROR REPARSEMACRO LOAD_MAKEFILE
%%
/*---------------------------------------------------------------------------*/
-[ \t\r]*\n[ ][ \t]* |
+[ \t\r]*\n/[ ][ \t]* |
[ \t\r]*\n {
PRINTF(("%s %d: NEWLINE:\n",m_InputFileName.c_str(),m_Line));
m_Line++;
@@ -96,10 +96,12 @@ static void SaveMakMd5(refptr<fileinfo> &Target)
}
/*---------------------------------------------------------------------------*/
-^[s\-]?include {
+^[ \t]*[s\-]?include {
PRINTF(("%s %d: INCLUDE: ",m_InputFileName.c_str(),m_Line));
BEGIN(INCLUDE);
- if (yytext[0]=='-' || yytext[0]=='s')
+ unsigned i=0;
+ while (strchr(" \t",yytext[i])) i++;
+ if (strchr("-s",yytext[i]))
m_IgnoreIncludeError=true;
else
m_IgnoreIncludeError=false;
@@ -123,7 +125,7 @@ static void SaveMakMd5(refptr<fileinfo> &Target)
if (!IncludeFileName.empty())
{
PRINTF(("%s -> %s\n",yytext,IncludeFileName.c_str()));
- refptr<fileinfo> pInclude=GetFileInfo(IncludeFileName,pParser->GetMakeDir());
+ fileinfo *pInclude=GetFileInfo(IncludeFileName,pParser->GetMakeDir());
/* Already build the include file, in case we already have a rule for it. */
if (pInclude->GetRule())
{
@@ -595,6 +597,11 @@ export {
return mhmakeparser::EXPORT;
}
+ /*---------------------------------------------------------------------------*/
+^[ \t]*vpath {
+ PRINTF(("%s %d: vpath\n",m_InputFileName.c_str(),m_Line));
+ return mhmakeparser::VPATH;
+}
/*---------------------------------------------------------------------------*/
[a-zA-Z]:[a-zA-Z0-9\\\._\~\-%\@<&/]+\\[ \t\r]*\n {
@@ -676,6 +683,20 @@ export {
}
/*---------------------------------------------------------------------------*/
+[ \t]*\$\{[ \t]*info[ \t]+ {
+ PRINTF(("%s %d: BEGIN INFO MESSAGE ${: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ BEGIN(MESSAGEINFO);
+ m_curtoken=g_EmptyString;
+}
+
+ /*---------------------------------------------------------------------------*/
+[ \t]*\$\{[ \t]*error[ \t]+ {
+ PRINTF(("%s %d: BEGIN ERROR MESSAGE ${: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ BEGIN(MESSAGEERROR);
+ m_curtoken=g_EmptyString;
+}
+
+ /*---------------------------------------------------------------------------*/
\$\([ \t]*reparse[ \t]+ {
m_BraceIndent++;
PRINTF(("%s %d: BEGIN REPARSE MACRO $(: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
@@ -826,6 +847,22 @@ export {
}
/*****************************************************************************/
+<MESSAGEERROR>[^\}]+ {
+ throw(GetParser()->ExpandExpression((const char*)yytext));
+}
+
+ /*****************************************************************************/
+<MESSAGEINFO>[^\}]+ {
+ cerr<<GetParser()->ExpandExpression((const char*)yytext)<<endl;
+}
+
+ /*****************************************************************************/
+<MESSAGEINFO>\} {
+ PRINTF(("%s %d: MESSAGEINFO: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ BEGIN(INITIAL);
+}
+
+ /*****************************************************************************/
<MESSAGEMACRO>\) {
m_BraceIndent--;
PRINTF(("%s %d: CLOSE BRACE MESSAGE MACRO ): %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));