All pastes #566889 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-14 17:48 UTC
rendered paste body
/****************************************************************************
**
** 	Created using Edyuk IDE 0.6.0
**
** File : qmakeparser.h
** Date : dim. sept. 17 18:41:23 2006
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef _QMAKE_PARSER_H_
#define _QMAKE_PARSER_H_

#include "qmake.h"

/*!
	\file qmakeparser.h
	
	\brief Definition of the QMakeParser class.
*/

#include "qprojectparser.h"

#include <QHash>
#include <QPair>
#include <QStack>
#include <QStringList>

class QMakeScope;
class QMakeProject;

struct QParenthesisChar
{
	QParenthesisChar() : escape(0) {}
	QParenthesisChar(QChar o, QChar c, int e) : open(o), close(c), escape(e) {}
	
	QChar open;
	QChar close;
	int escape;
};

class QMAKE_EXPORT QMakeParser : public QProjectParser
{
	friend class QMakeVariable;
	
	public:
		QMakeParser(QObject *p = 0);
		virtual ~QMakeParser();
		
	protected:
		virtual QProjectNode* parse(const QString& s);
		
	private:
		enum LexerFlag
		{
			None			= 0x00,		//nothing special
			
			//<First Step values>
			SingleLine		= 0x01,		//
			MultiLine		= 0x02,		//
			
			AntiSlash		= 0x04,		//
			Parenthesis		= 0x08,		//
			//<First Step>
			
			//<Second Step values>
			Scope			= 0x08,		//
			
			SingleLineScope	= SingleLine | Scope,
			MultiLineScope	= MultiLine | Scope,
			//<Second Step>
			
		};
		
		typedef QFlags<LexerFlag> LexerState;
		
		void parse(QStringList::iterator t, int max);
		void parse(const QChar* l, int max, QStringList& d, bool bRecurse = false);
		
		inline bool flag(LexerFlag f)		{ return (state & f);}
		
		inline void flagOn(LexerFlag f)	{ state |= f; }
		inline void flagOff(LexerFlag f)	{ state &= ~f; }
		
		inline void setFlag(LexerFlag f, bool s)
			{ if ( s ) flagOn(f); else flagOff(f); }
		
		virtual void update(QProjectNode *p, const QString& s);
		
		// "temporary"
		int coms;
		LexerState state;
		QStack<QParenthesisChar> cMulti;
		QMakeScope *pScope, *pPrev;
		
		// "persistent"
		int inVar;
		QStack<QMakeScope*> nest;
		QStack< QPair<int, QChar> > varStack;
};

#endif // _QMAKE_PARSER_H_