Apply clang-format to code base

This commit is contained in:
clang-format-bot 2022-09-22 21:26:05 +03:00 committed by ζeh Matt
parent f37d0be806
commit ddb0522bbf
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0
2199 changed files with 118692 additions and 114392 deletions

View file

@ -1,24 +1,25 @@
#include "fileparser.hpp"
#include "tokenloc.hpp"
#include "scanner.hpp"
#include "tokenloc.hpp"
namespace Compiler
{
FileParser::FileParser (ErrorHandler& errorHandler, Context& context)
: Parser (errorHandler, context),
mScriptParser (errorHandler, context, mLocals, true),
mState (BeginState)
{}
FileParser::FileParser(ErrorHandler& errorHandler, Context& context)
: Parser(errorHandler, context)
, mScriptParser(errorHandler, context, mLocals, true)
, mState(BeginState)
{
}
std::string FileParser::getName() const
{
return mName;
}
void FileParser::getCode (std::vector<Interpreter::Type_Code>& code) const
void FileParser::getCode(std::vector<Interpreter::Type_Code>& code) const
{
mScriptParser.getCode (code);
mScriptParser.getCode(code);
}
const Locals& FileParser::getLocals() const
@ -26,21 +27,20 @@ namespace Compiler
return mLocals;
}
bool FileParser::parseName (const std::string& name, const TokenLoc& loc,
Scanner& scanner)
bool FileParser::parseName(const std::string& name, const TokenLoc& loc, Scanner& scanner)
{
if (mState==NameState)
if (mState == NameState)
{
mName = name;
mState = BeginCompleteState;
return true;
}
if (mState==EndNameState)
if (mState == EndNameState)
{
// optional repeated name after end statement
if (mName!=name)
reportWarning ("Names for script " + mName + " do not match", loc);
if (mName != name)
reportWarning("Names for script " + mName + " do not match", loc);
mState = EndCompleteState;
return false; // we are stopping here, because there might be more garbage on the end line,
@ -49,25 +49,25 @@ namespace Compiler
/// \todo allow this workaround to be disabled for newer scripts
}
if (mState==BeginCompleteState)
if (mState == BeginCompleteState)
{
reportWarning ("Stray string (" + name + ") after begin statement", loc);
reportWarning("Stray string (" + name + ") after begin statement", loc);
return true;
}
return Parser::parseName (name, loc, scanner);
return Parser::parseName(name, loc, scanner);
}
bool FileParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
bool FileParser::parseKeyword(int keyword, const TokenLoc& loc, Scanner& scanner)
{
if (mState==BeginState && keyword==Scanner::K_begin)
if (mState == BeginState && keyword == Scanner::K_begin)
{
mState = NameState;
scanner.enableTolerantNames(); /// \todo disable
return true;
}
if (mState==NameState)
if (mState == NameState)
{
// keywords can be used as script names too. Thank you Morrowind for another
// syntactic perversity :(
@ -76,11 +76,11 @@ namespace Compiler
return true;
}
if (mState==EndNameState)
if (mState == EndNameState)
{
// optional repeated name after end statement
if (mName!=loc.mLiteral)
reportWarning ("Names for script " + mName + " do not match", loc);
if (mName != loc.mLiteral)
reportWarning("Names for script " + mName + " do not match", loc);
mState = EndCompleteState;
return false; // we are stopping here, because there might be more garbage on the end line,
@ -89,46 +89,46 @@ namespace Compiler
/// \todo allow this workaround to be disabled for newer scripts
}
return Parser::parseKeyword (keyword, loc, scanner);
return Parser::parseKeyword(keyword, loc, scanner);
}
bool FileParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
bool FileParser::parseSpecial(int code, const TokenLoc& loc, Scanner& scanner)
{
// Ignore any junk special characters
if (mState == BeginState)
{
if (code != Scanner::S_newline)
reportWarning ("Stray special character before begin statement", loc);
reportWarning("Stray special character before begin statement", loc);
return true;
}
if (code==Scanner::S_newline)
if (code == Scanner::S_newline)
{
if (mState==BeginCompleteState)
if (mState == BeginCompleteState)
{
// parse the script body
mScriptParser.reset();
scanner.scan (mScriptParser);
scanner.scan(mScriptParser);
mState = EndNameState;
return true;
}
if (mState==EndCompleteState || mState==EndNameState)
if (mState == EndCompleteState || mState == EndNameState)
{
// we are done here -> ignore the rest of the script
return false;
}
}
return Parser::parseSpecial (code, loc, scanner);
return Parser::parseSpecial(code, loc, scanner);
}
void FileParser::parseEOF (Scanner& scanner)
void FileParser::parseEOF(Scanner& scanner)
{
if (mState!=EndNameState && mState!=EndCompleteState)
Parser::parseEOF (scanner);
if (mState != EndNameState && mState != EndCompleteState)
Parser::parseEOF(scanner);
}
void FileParser::reset()