1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-22 03:40:49 +00:00

added comment token (for use in syntax colouring)

This commit is contained in:
Marc Zinnschlag 2013-04-11 10:50:22 +02:00
parent 74145410f2
commit 6d3a2cd5a0
3 changed files with 20 additions and 1 deletions

View File

@ -148,6 +148,11 @@ namespace Compiler
return false; return false;
} }
bool Parser::parseComment (const std::string& comment, const TokenLoc& loc, Scanner& scanner)
{
return true;
}
// Handle an EOF token. // Handle an EOF token.
// //
// - Default-implementation: Report an error. // - Default-implementation: Report an error.

View File

@ -82,6 +82,13 @@ namespace Compiler
/// ///
/// - Default-implementation: Report an error. /// - Default-implementation: Report an error.
virtual bool parseComment (const std::string& comment, const TokenLoc& loc,
Scanner& scanner);
///< Handle comment token.
/// \return fetch another token?
///
/// - Default-implementation: ignored (and return true).
virtual void parseEOF (Scanner& scanner); virtual void parseEOF (Scanner& scanner);
///< Handle EOF token. ///< Handle EOF token.
/// ///

View File

@ -88,6 +88,10 @@ namespace Compiler
} }
else if (c==';') else if (c==';')
{ {
std::string comment;
comment += c;
while (get (c)) while (get (c))
{ {
if (c=='\n') if (c=='\n')
@ -95,11 +99,14 @@ namespace Compiler
putback (c); putback (c);
break; break;
} }
else
comment += c;
} }
TokenLoc loc (mLoc);
mLoc.mLiteral.clear(); mLoc.mLiteral.clear();
return true; return parser.parseComment (comment, loc, *this);
} }
else if (isWhitespace (c)) else if (isWhitespace (c))
{ {