2014-02-14 10:15:16 +00:00
|
|
|
#include "quickfileparser.hpp"
|
|
|
|
|
|
|
|
#include "scanner.hpp"
|
2022-09-22 18:26:05 +00:00
|
|
|
#include "skipparser.hpp"
|
2014-02-14 10:15:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
Compiler::QuickFileParser::QuickFileParser(ErrorHandler& errorHandler, const Context& context, Locals& locals)
|
|
|
|
: Parser(errorHandler, context)
|
|
|
|
, mDeclarationParser(errorHandler, context, locals)
|
|
|
|
{
|
|
|
|
}
|
2014-02-14 10:15:16 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
bool Compiler::QuickFileParser::parseName(const std::string& name, const TokenLoc& loc, Scanner& scanner)
|
2014-02-14 10:15:16 +00:00
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
SkipParser skip(getErrorHandler(), getContext());
|
|
|
|
scanner.scan(skip);
|
2014-02-14 10:15:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
bool Compiler::QuickFileParser::parseKeyword(int keyword, const TokenLoc& loc, Scanner& scanner)
|
2014-02-14 10:15:16 +00:00
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
if (keyword == Scanner::K_end)
|
2014-02-14 10:15:16 +00:00
|
|
|
return false;
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
if (keyword == Scanner::K_short || keyword == Scanner::K_long || keyword == Scanner::K_float)
|
2014-02-14 10:15:16 +00:00
|
|
|
{
|
|
|
|
mDeclarationParser.reset();
|
2022-09-22 18:26:05 +00:00
|
|
|
scanner.putbackKeyword(keyword, loc);
|
|
|
|
scanner.scan(mDeclarationParser);
|
2014-02-14 10:15:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
SkipParser skip(getErrorHandler(), getContext());
|
|
|
|
scanner.scan(skip);
|
2014-02-14 10:15:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
bool Compiler::QuickFileParser::parseSpecial(int code, const TokenLoc& loc, Scanner& scanner)
|
2014-02-14 10:15:16 +00:00
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
if (code != Scanner::S_newline)
|
2014-02-14 10:15:16 +00:00
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
SkipParser skip(getErrorHandler(), getContext());
|
|
|
|
scanner.scan(skip);
|
2014-02-14 10:15:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void Compiler::QuickFileParser::parseEOF(Scanner& scanner) {}
|