Skip to content

Commit

Permalink
Change ParserImpl back to mixin style.
Browse files Browse the repository at this point in the history
We have more flexibility if we don't directly derive this from Parser.
  • Loading branch information
PeterJohnson committed Sep 8, 2012
1 parent de6722d commit 6f99046
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
6 changes: 3 additions & 3 deletions include/yasmx/Parse/ParserImpl.h
Expand Up @@ -63,7 +63,7 @@ class YASM_LIB_EXPORT ParseExprTerm
= 0;
};

class YASM_LIB_EXPORT ParserImpl : public Parser
class YASM_LIB_EXPORT ParserImpl
{
public:
Preprocessor& m_preproc;
Expand All @@ -76,10 +76,10 @@ class YASM_LIB_EXPORT ParserImpl : public Parser
unsigned short m_paren_count, m_bracket_count;

public:
ParserImpl(const ParserModule& module, Preprocessor& preproc);
ParserImpl(Preprocessor& preproc);
virtual ~ParserImpl();

virtual Preprocessor& getPreprocessor() const;
Preprocessor& getPreprocessor() const { return m_preproc; }

/// Return true if the cur token is '(' or ')'.
bool isTokenParen() const
Expand Down
11 changes: 2 additions & 9 deletions lib/yasmx/Parse/ParserImpl.cpp
Expand Up @@ -42,9 +42,8 @@ ParseExprTerm::~ParseExprTerm()
{
}

ParserImpl::ParserImpl(const ParserModule& module, Preprocessor& preproc)
: Parser(module)
, m_preproc(preproc)
ParserImpl::ParserImpl(Preprocessor& preproc)
: m_preproc(preproc)
, m_paren_count(0)
, m_bracket_count(0)
{
Expand All @@ -55,12 +54,6 @@ ParserImpl::~ParserImpl()
{
}

Preprocessor&
ParserImpl::getPreprocessor() const
{
return m_preproc;
}

SourceLocation
ParserImpl::MatchRHSPunctuation(unsigned int rhs_tok, SourceLocation lhs_loc)
{
Expand Down
9 changes: 8 additions & 1 deletion modules/parsers/gas/GasParser.cpp
Expand Up @@ -44,7 +44,8 @@ GasParser::GasParser(const ParserModule& module,
DiagnosticsEngine& diags,
SourceManager& sm,
HeaderSearch& headers)
: ParserImpl(module, m_gas_preproc)
: Parser(module)
, ParserImpl(m_gas_preproc)
, m_gas_preproc(diags, sm, headers)
, m_intel(false)
, m_reg_prefix(true)
Expand Down Expand Up @@ -225,6 +226,12 @@ GasParser::AddDirectives(Directives& dirs, StringRef parser)
}
}

Preprocessor&
GasParser::getPreprocessor() const
{
return ParserImpl::getPreprocessor();
}

void
yasm_parser_gas_DoRegister()
{
Expand Down
4 changes: 3 additions & 1 deletion modules/parsers/gas/GasParser.h
Expand Up @@ -72,7 +72,7 @@ struct GasDirLookup
unsigned int param;
};

class YASM_STD_EXPORT GasParser : public ParserImpl
class YASM_STD_EXPORT GasParser : public Parser, public ParserImpl
{
public:
GasParser(const ParserModule& module,
Expand All @@ -83,6 +83,8 @@ class YASM_STD_EXPORT GasParser : public ParserImpl

void AddDirectives(Directives& dirs, StringRef parser);

Preprocessor& getPreprocessor() const;

static StringRef getName() { return "GNU AS (GAS)-compatible parser"; }
static StringRef getKeyword() { return "gas"; }

Expand Down
9 changes: 8 additions & 1 deletion modules/parsers/nasm/NasmParser.cpp
Expand Up @@ -91,7 +91,8 @@ NasmParser::NasmParser(const ParserModule& module,
DiagnosticsEngine& diags,
SourceManager& sm,
HeaderSearch& headers)
: ParserImpl(module, m_nasm_preproc)
: Parser(module)
, ParserImpl(m_nasm_preproc)
, m_nasm_preproc(diags, sm, headers)
{
}
Expand Down Expand Up @@ -258,6 +259,12 @@ NasmParser::AddDirectives(Directives& dirs, StringRef parser)
}
}

Preprocessor&
NasmParser::getPreprocessor() const
{
return ParserImpl::getPreprocessor();
}

void
yasm_parser_nasm_DoRegister()
{
Expand Down
4 changes: 3 additions & 1 deletion modules/parsers/nasm/NasmParser.h
Expand Up @@ -64,7 +64,7 @@ class YASM_STD_EXPORT NasmParseDataExprTerm : public ParseExprTerm
bool operator() (Expr& e, ParserImpl& parser, bool* handled) const;
};

class YASM_STD_EXPORT NasmParser : public ParserImpl
class YASM_STD_EXPORT NasmParser : public Parser, public ParserImpl
{
public:
NasmParser(const ParserModule& module,
Expand All @@ -75,6 +75,8 @@ class YASM_STD_EXPORT NasmParser : public ParserImpl

void AddDirectives(Directives& dirs, StringRef parser);

Preprocessor& getPreprocessor() const;

static StringRef getName() { return "NASM-compatible parser"; }
static StringRef getKeyword() { return "nasm"; }

Expand Down

0 comments on commit 6f99046

Please sign in to comment.