1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 15:53:54 +00:00
openmw/components/compiler/scanner.cpp

696 lines
18 KiB
C++
Raw Normal View History

2010-06-27 17:20:21 +00:00
#include "scanner.hpp"
#include <cassert>
#include <sstream>
2010-06-27 17:20:21 +00:00
#include "errorhandler.hpp"
2022-09-22 18:26:05 +00:00
#include "exception.hpp"
2010-07-03 07:54:01 +00:00
#include "extensions.hpp"
2022-09-22 18:26:05 +00:00
#include "parser.hpp"
2010-06-27 17:20:21 +00:00
#include <components/misc/strings/lower.hpp>
2013-01-09 19:51:52 +00:00
2010-06-27 17:20:21 +00:00
namespace Compiler
{
2022-09-22 18:26:05 +00:00
bool Scanner::get(MultiChar& c)
2010-06-27 17:20:21 +00:00
{
if (!c.getFrom(mStream))
2010-06-27 17:20:21 +00:00
return false;
mPrevLoc = mLoc;
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
if (c == '\n')
2010-06-27 17:20:21 +00:00
{
mStrictKeywords = false;
mTolerantNames = false;
mExpectName = false;
2010-06-27 17:20:21 +00:00
mLoc.mColumn = 0;
++mLoc.mLine;
mLoc.mLiteral.clear();
mIgnoreSpecial = true;
2010-06-27 17:20:21 +00:00
}
else
{
++mLoc.mColumn;
c.appendTo(mLoc.mLiteral);
2010-06-27 17:20:21 +00:00
}
return true;
}
2022-09-22 18:26:05 +00:00
void Scanner::putback(MultiChar& c)
2010-06-27 17:20:21 +00:00
{
c.putback(mStream);
2010-06-27 17:20:21 +00:00
mLoc = mPrevLoc;
}
2022-09-22 18:26:05 +00:00
bool Scanner::scanToken(Parser& parser)
2010-06-27 17:20:21 +00:00
{
switch (mPutback)
{
case Putback_Special:
mPutback = Putback_None;
2022-09-22 18:26:05 +00:00
return parser.parseSpecial(mPutbackCode, mPutbackLoc, *this);
case Putback_Integer:
mPutback = Putback_None;
2022-09-22 18:26:05 +00:00
return parser.parseInt(mPutbackInteger, mPutbackLoc, *this);
case Putback_Float:
mPutback = Putback_None;
2022-09-22 18:26:05 +00:00
return parser.parseFloat(mPutbackFloat, mPutbackLoc, *this);
case Putback_Name:
mPutback = Putback_None;
2022-09-22 18:26:05 +00:00
return parser.parseName(mPutbackName, mPutbackLoc, *this);
case Putback_Keyword:
mPutback = Putback_None;
2022-09-22 18:26:05 +00:00
return parser.parseKeyword(mPutbackCode, mPutbackLoc, *this);
case Putback_None:
break;
}
MultiChar c;
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
if (!get(c))
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
parser.parseEOF(*this);
2010-06-27 17:20:21 +00:00
return false;
}
2022-09-22 18:26:05 +00:00
else if (c == ';')
2010-06-27 17:20:21 +00:00
{
std::string comment;
c.appendTo(comment);
2022-09-22 18:26:05 +00:00
while (get(c))
{
2022-09-22 18:26:05 +00:00
if (c == '\n')
{
2022-09-22 18:26:05 +00:00
putback(c);
break;
}
else
c.appendTo(comment);
}
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
TokenLoc loc(mLoc);
2010-06-27 17:20:21 +00:00
mLoc.mLiteral.clear();
2022-09-22 18:26:05 +00:00
return parser.parseComment(comment, loc, *this);
2010-06-27 17:20:21 +00:00
}
else if (c.isWhitespace())
2010-06-27 17:20:21 +00:00
{
mLoc.mLiteral.clear();
return true;
}
2022-09-22 18:26:05 +00:00
else if (c == ':')
2013-03-31 12:46:46 +00:00
{
// treat : as a whitespace :(
mLoc.mLiteral.clear();
return true;
}
2022-09-22 18:26:05 +00:00
else if (c.isAlpha() || c == '_' || c == '"')
2010-06-27 17:20:21 +00:00
{
mIgnoreSpecial = false;
2010-06-27 17:20:21 +00:00
bool cont = false;
2022-09-22 18:26:05 +00:00
if (scanName(c, parser, cont))
2010-06-27 17:20:21 +00:00
{
mLoc.mLiteral.clear();
return cont;
}
}
else if (c.isDigit())
2010-06-27 17:20:21 +00:00
{
mIgnoreSpecial = false;
2010-06-27 17:20:21 +00:00
bool cont = false;
bool scanned = mExpectName ? scanName(c, parser, cont) : scanInt(c, parser, cont);
if (scanned)
2010-06-27 17:20:21 +00:00
{
mLoc.mLiteral.clear();
return cont;
}
}
2022-09-22 18:26:05 +00:00
else if (c == 13) // linux compatibility hack
2010-06-27 17:20:21 +00:00
{
return true;
}
else
{
bool cont = false;
2022-09-22 18:26:05 +00:00
if (scanSpecial(c, parser, cont))
2010-06-27 17:20:21 +00:00
{
mLoc.mLiteral.clear();
return cont;
}
}
2022-09-22 18:26:05 +00:00
TokenLoc loc(mLoc);
2010-06-27 17:20:21 +00:00
mLoc.mLiteral.clear();
2022-09-22 18:26:05 +00:00
mErrorHandler.error("Syntax error", loc);
2010-06-27 17:20:21 +00:00
throw SourceException();
}
2022-09-22 18:26:05 +00:00
bool Scanner::scanInt(MultiChar& c, Parser& parser, bool& cont)
2010-06-27 17:20:21 +00:00
{
assert(c != '\0');
2010-06-27 17:20:21 +00:00
std::string value;
c.appendTo(value);
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
while (get(c))
2010-06-27 17:20:21 +00:00
{
if (c.isDigit())
2010-06-27 17:20:21 +00:00
{
c.appendTo(value);
2010-06-27 17:20:21 +00:00
}
2022-09-22 18:26:05 +00:00
else if (!c.isMinusSign() && isStringCharacter(c))
{
/// workaround that allows names to begin with digits
return scanName(c, parser, cont, value);
}
2022-09-22 18:26:05 +00:00
else if (c == '.')
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
return scanFloat(value, parser, cont);
2010-06-27 17:20:21 +00:00
}
else
{
2022-09-22 18:26:05 +00:00
putback(c);
2010-06-27 17:20:21 +00:00
break;
}
}
2022-09-22 18:26:05 +00:00
TokenLoc loc(mLoc);
2010-06-27 17:20:21 +00:00
mLoc.mLiteral.clear();
2022-09-22 18:26:05 +00:00
std::istringstream stream(value);
2010-06-27 17:20:21 +00:00
int intValue = 0;
stream >> intValue;
2022-09-22 18:26:05 +00:00
cont = parser.parseInt(intValue, loc, *this);
2010-06-27 17:20:21 +00:00
return true;
}
2022-09-22 18:26:05 +00:00
bool Scanner::scanFloat(const std::string& intValue, Parser& parser, bool& cont)
2010-06-27 17:20:21 +00:00
{
std::string value = intValue + ".";
MultiChar c;
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
bool empty = intValue.empty() || intValue == "-";
2010-06-27 17:20:21 +00:00
bool error = false;
2022-09-22 18:26:05 +00:00
while (get(c))
2010-06-27 17:20:21 +00:00
{
if (c.isDigit())
2010-06-27 17:20:21 +00:00
{
c.appendTo(value);
2010-06-27 17:20:21 +00:00
empty = false;
}
2022-09-22 18:26:05 +00:00
else if (c.isAlpha() || c == '_')
2010-06-27 17:20:21 +00:00
error = true;
else
{
2022-09-22 18:26:05 +00:00
putback(c);
2010-06-27 17:20:21 +00:00
break;
}
}
if (empty || error)
return false;
2022-09-22 18:26:05 +00:00
TokenLoc loc(mLoc);
2010-06-27 17:20:21 +00:00
mLoc.mLiteral.clear();
2022-09-22 18:26:05 +00:00
std::istringstream stream(value);
2010-06-27 17:20:21 +00:00
float floatValue = 0;
stream >> floatValue;
2022-09-22 18:26:05 +00:00
cont = parser.parseFloat(floatValue, loc, *this);
2010-06-27 17:20:21 +00:00
return true;
}
2022-09-22 18:26:05 +00:00
static const char* sKeywords[] = {
"begin",
"end",
"short",
"long",
"float",
"if",
"endif",
"else",
"elseif",
"while",
"endwhile",
2011-01-12 17:24:00 +00:00
"return",
"messagebox",
2022-09-22 18:26:05 +00:00
"set",
"to",
nullptr,
2011-01-12 17:24:00 +00:00
};
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
bool Scanner::scanName(MultiChar& c, Parser& parser, bool& cont, std::string name)
2011-01-12 17:24:00 +00:00
{
c.appendTo(name);
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
if (!scanName(name))
2010-06-27 17:20:21 +00:00
return false;
2022-09-22 18:26:05 +00:00
else if (name.empty())
2020-03-25 18:52:22 +00:00
return true;
2010-06-27 17:20:21 +00:00
2022-09-22 18:26:05 +00:00
TokenLoc loc(mLoc);
2010-06-27 17:20:21 +00:00
mLoc.mLiteral.clear();
2022-09-22 18:26:05 +00:00
if (name.size() >= 2 && name[0] == '"' && name[name.size() - 1] == '"')
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
name = name.substr(1, name.size() - 2);
// allow keywords enclosed in ""
/// \todo optionally disable
if (mStrictKeywords)
{
2022-09-22 18:26:05 +00:00
cont = parser.parseName(name, loc, *this);
return true;
}
2010-06-27 17:20:21 +00:00
}
2010-06-27 17:20:21 +00:00
int i = 0;
2013-01-09 19:51:52 +00:00
std::string lowerCase = Misc::StringUtils::lowerCase(name);
bool isKeyword = false;
2016-08-29 10:20:00 +00:00
for (; sKeywords[i]; ++i)
2022-09-22 18:26:05 +00:00
if (lowerCase == sKeywords[i])
{
isKeyword = true;
2010-06-27 17:20:21 +00:00
break;
}
// Russian localization and some mods use a quirk - add newline character directly
// to compiled bytecode via HEX-editor to implement multiline messageboxes.
// Of course, original editor can not compile such script.
// Allow messageboxes to bypass the "incomplete string or name" error.
if (lowerCase == "messagebox")
enableIgnoreNewlines();
else if (isKeyword)
mIgnoreNewline = false;
2010-06-27 17:20:21 +00:00
2016-08-29 10:20:00 +00:00
if (sKeywords[i])
2010-07-03 07:54:01 +00:00
{
2022-09-22 18:26:05 +00:00
cont = parser.parseKeyword(i, loc, *this);
2010-07-03 07:54:01 +00:00
return true;
}
2010-07-03 07:54:01 +00:00
if (mExtensions)
{
2022-09-22 18:26:05 +00:00
if (int keyword = mExtensions->searchKeyword(lowerCase))
2010-07-03 07:54:01 +00:00
{
2022-09-22 18:26:05 +00:00
cont = parser.parseKeyword(keyword, loc, *this);
return true;
2010-07-03 07:54:01 +00:00
}
}
2022-09-22 18:26:05 +00:00
cont = parser.parseName(name, loc, *this);
2010-06-27 17:20:21 +00:00
return true;
}
2022-09-22 18:26:05 +00:00
bool Scanner::scanName(std::string& name)
2010-06-27 17:20:21 +00:00
{
MultiChar c;
2010-06-27 17:20:21 +00:00
bool error = false;
2022-09-22 18:26:05 +00:00
while (get(c))
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (!name.empty() && name[0] == '"')
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (c == '"')
2010-06-27 17:20:21 +00:00
{
c.appendTo(name);
2010-06-27 17:20:21 +00:00
break;
}
2022-09-22 18:26:05 +00:00
// ignoring escape sequences for now, because they are messing up stupid Windows path names.
// else if (c=='\\')
// {
// if (!get (c))
// {
// error = true;
// mErrorHandler.error ("incomplete escape sequence", mLoc);
// break;
// }
// }
else if (c == '\n')
2010-06-27 17:20:21 +00:00
{
if (mIgnoreNewline)
2022-09-22 18:26:05 +00:00
mErrorHandler.warning("string contains newline character, make sure that it is intended", mLoc);
else
{
2020-03-29 20:29:22 +00:00
bool allWhitespace = true;
for (size_t i = 1; i < name.size(); i++)
{
2022-09-22 18:26:05 +00:00
// ignore comments
2020-03-29 20:29:22 +00:00
if (name[i] == ';')
break;
else if (name[i] != '\t' && name[i] != ' ' && name[i] != '\r')
{
allWhitespace = false;
break;
}
}
if (allWhitespace)
{
name.clear();
mLoc.mLiteral.clear();
2022-09-22 18:26:05 +00:00
mErrorHandler.warning("unterminated empty string", mLoc);
2020-03-29 20:29:22 +00:00
return true;
}
error = true;
2022-09-22 18:26:05 +00:00
mErrorHandler.error("incomplete string or name", mLoc);
break;
}
}
2010-06-27 17:20:21 +00:00
}
2022-09-22 18:26:05 +00:00
else if (!(c == '"' && name.empty()))
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (!isStringCharacter(c) && !(mTolerantNames && (c == '.' || c == '-')))
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
putback(c);
2010-06-27 17:20:21 +00:00
break;
}
}
c.appendTo(name);
2010-06-27 17:20:21 +00:00
}
return !error;
}
2022-09-22 18:26:05 +00:00
bool Scanner::scanSpecial(MultiChar& c, Parser& parser, bool& cont)
2010-06-27 17:20:21 +00:00
{
bool expectName = mExpectName;
mExpectName = false;
2010-06-27 17:20:21 +00:00
int special = -1;
2022-09-22 18:26:05 +00:00
if (c == '\n')
2010-06-27 17:20:21 +00:00
special = S_newline;
else if (mIgnoreSpecial)
{
// Ignore junk special characters
TokenLoc loc = mLoc;
while (get(c))
{
if (c.isAlpha() || c == '_' || c == '"' || c.isDigit() || c == ';' || c == '\n')
{
putback(c);
break;
}
c.appendTo(loc.mLiteral);
}
mErrorHandler.warning("Stray special character at start of line", loc);
cont = true;
return true;
}
2022-09-22 18:26:05 +00:00
else if (c == '(' || c == '[') /// \todo option to disable the use of [ as alias for (
2010-06-27 17:20:21 +00:00
special = S_open;
2022-09-22 18:26:05 +00:00
else if (c == ')' || c == ']') /// \todo option to disable the use of ] as alias for )
2010-06-27 17:20:21 +00:00
special = S_close;
2022-09-22 18:26:05 +00:00
else if (c == '.')
{
MultiChar next;
// check, if this starts a float literal
2022-09-22 18:26:05 +00:00
if (get(next))
{
2022-09-22 18:26:05 +00:00
putback(next);
if (next.isDigit())
2022-09-22 18:26:05 +00:00
return scanFloat("", parser, cont);
}
special = S_member;
}
2022-09-22 18:26:05 +00:00
else if (c == '=')
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (get(c))
2010-06-27 17:20:21 +00:00
{
/// \todo hack to allow a space in comparison operators (add option to disable)
2022-09-22 18:26:05 +00:00
if (c == ' ' && !get(c))
special = S_cmpEQ;
2022-09-22 18:26:05 +00:00
else if (c == '=')
2010-06-27 17:20:21 +00:00
special = S_cmpEQ;
2022-09-22 18:26:05 +00:00
else if (c == '>' || c == '<') // Treat => and =< as ==
{
special = S_cmpEQ;
2022-09-22 18:26:05 +00:00
mErrorHandler.warning(std::string("invalid operator =") + c.data() + ", treating it as ==", mLoc);
}
2010-06-27 17:20:21 +00:00
else
{
special = S_cmpEQ;
2022-09-22 18:26:05 +00:00
putback(c);
// return false;
/// Allow = as synonym for ==. \todo optionally disable for post-1.0 scripting improvements.
2010-06-27 17:20:21 +00:00
}
}
else
{
2022-09-22 18:26:05 +00:00
putback(c);
return false;
2010-06-27 17:20:21 +00:00
}
}
2022-09-22 18:26:05 +00:00
else if (c == '!')
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (get(c))
2010-06-27 17:20:21 +00:00
{
/// \todo hack to allow a space in comparison operators (add option to disable)
2022-09-22 18:26:05 +00:00
if (c == ' ' && !get(c))
return false;
2022-09-22 18:26:05 +00:00
if (c == '=')
2010-06-27 17:20:21 +00:00
special = S_cmpNE;
else
{
2022-09-22 18:26:05 +00:00
putback(c);
2010-06-27 17:20:21 +00:00
return false;
}
}
else
return false;
}
else if (c.isMinusSign())
2010-06-27 17:20:21 +00:00
{
MultiChar next;
2022-09-22 18:26:05 +00:00
if (get(next))
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (next == '>')
2010-06-27 17:20:21 +00:00
special = S_ref;
else
{
2022-09-22 18:26:05 +00:00
putback(next);
2010-06-27 17:20:21 +00:00
special = S_minus;
}
}
else
special = S_minus;
}
2022-09-22 18:26:05 +00:00
else if (c == '<')
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (get(c))
2010-06-27 17:20:21 +00:00
{
/// \todo hack to allow a space in comparison operators (add option to disable)
2022-09-22 18:26:05 +00:00
if (c == ' ' && !get(c))
special = S_cmpLT;
2022-09-22 18:26:05 +00:00
else if (c == '=')
{
2010-06-27 17:20:21 +00:00
special = S_cmpLE;
2022-09-22 18:26:05 +00:00
if (get(c) && c != '=') // <== is a allowed as an alternative to <= :(
putback(c);
}
else if (c == '<' || c == '>') // Treat <> and << as <
{
special = S_cmpLT;
2022-09-22 18:26:05 +00:00
mErrorHandler.warning("Invalid operator, treating it as <", mLoc);
}
2010-06-27 17:20:21 +00:00
else
{
2022-09-22 18:26:05 +00:00
putback(c);
2010-06-27 17:20:21 +00:00
special = S_cmpLT;
}
}
else
special = S_cmpLT;
}
2022-09-22 18:26:05 +00:00
else if (c == '>')
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
if (get(c))
2010-06-27 17:20:21 +00:00
{
/// \todo hack to allow a space in comparison operators (add option to disable)
2022-09-22 18:26:05 +00:00
if (c == ' ' && !get(c))
special = S_cmpGT;
2022-09-22 18:26:05 +00:00
else if (c == '=')
{
2010-06-27 17:20:21 +00:00
special = S_cmpGE;
2022-09-22 18:26:05 +00:00
if (get(c) && c != '=') // >== is a allowed as an alternative to >= :(
putback(c);
}
else if (c == '<' || c == '>') // Treat >< and >> as >
{
special = S_cmpGT;
2022-09-22 18:26:05 +00:00
mErrorHandler.warning("Invalid operator, treating it as >", mLoc);
}
2010-06-27 17:20:21 +00:00
else
{
2022-09-22 18:26:05 +00:00
putback(c);
2010-06-27 17:20:21 +00:00
special = S_cmpGT;
}
}
else
special = S_cmpGT;
}
2022-09-22 18:26:05 +00:00
else if (c == '+')
2010-06-27 17:20:21 +00:00
special = S_plus;
2022-09-22 18:26:05 +00:00
else if (c == '*')
2010-06-27 17:20:21 +00:00
special = S_mult;
2022-09-22 18:26:05 +00:00
else if (c == '/')
2010-06-27 17:20:21 +00:00
special = S_div;
else
return false;
2022-09-22 18:26:05 +00:00
if (special == S_newline)
mLoc.mLiteral = "<newline>";
else if (expectName && (special == S_member || special == S_minus))
{
bool tolerant = mTolerantNames;
mTolerantNames = true;
bool out = scanName(c, parser, cont);
mTolerantNames = tolerant;
return out;
}
2022-09-22 18:26:05 +00:00
TokenLoc loc(mLoc);
2010-06-27 17:20:21 +00:00
mLoc.mLiteral.clear();
2022-09-22 18:26:05 +00:00
cont = parser.parseSpecial(special, loc, *this);
2010-06-27 17:20:21 +00:00
return true;
}
2022-09-22 18:26:05 +00:00
bool Scanner::isStringCharacter(MultiChar& c, bool lookAhead)
{
if (lookAhead && c.isMinusSign())
{
/// \todo disable this when doing more stricter compiling. Also, find out who is
/// responsible for allowing it in the first place and meet up with that person in
/// a dark alley.
MultiChar next;
2022-09-22 18:26:05 +00:00
if (next.peek(mStream) && isStringCharacter(next, false))
return true;
}
2022-09-22 18:26:05 +00:00
return c.isAlpha() || c.isDigit() || c == '_' ||
/// \todo disable this when doing more stricter compiling
2022-09-22 18:26:05 +00:00
c == '`' || c == '\'';
2010-06-27 17:20:21 +00:00
}
// constructor
2022-09-22 18:26:05 +00:00
Scanner::Scanner(ErrorHandler& errorHandler, std::istream& inputStream, const Extensions* extensions)
: mErrorHandler(errorHandler)
, mStream(inputStream)
, mExtensions(extensions)
, mPutback(Putback_None)
, mPutbackCode(0)
, mPutbackInteger(0)
, mPutbackFloat(0)
, mStrictKeywords(false)
, mTolerantNames(false)
, mIgnoreNewline(false)
, mExpectName(false)
, mIgnoreSpecial(true)
2010-06-27 17:20:21 +00:00
{
}
2022-09-22 18:26:05 +00:00
void Scanner::scan(Parser& parser)
2010-06-27 17:20:21 +00:00
{
2022-09-22 18:26:05 +00:00
while (scanToken(parser))
;
mExpectName = false;
2010-06-27 17:20:21 +00:00
}
2022-09-22 18:26:05 +00:00
void Scanner::putbackSpecial(int code, const TokenLoc& loc)
{
mPutback = Putback_Special;
mPutbackCode = code;
mPutbackLoc = loc;
}
2022-09-22 18:26:05 +00:00
void Scanner::putbackInt(int value, const TokenLoc& loc)
{
mPutback = Putback_Integer;
mPutbackInteger = value;
mPutbackLoc = loc;
}
2022-09-22 18:26:05 +00:00
void Scanner::putbackFloat(float value, const TokenLoc& loc)
{
mPutback = Putback_Float;
mPutbackFloat = value;
mPutbackLoc = loc;
}
2022-09-22 18:26:05 +00:00
void Scanner::putbackName(const std::string& name, const TokenLoc& loc)
{
mPutback = Putback_Name;
mPutbackName = name;
mPutbackLoc = loc;
}
2022-09-22 18:26:05 +00:00
void Scanner::putbackKeyword(int keyword, const TokenLoc& loc)
{
mPutback = Putback_Keyword;
mPutbackCode = keyword;
mPutbackLoc = loc;
}
2011-01-12 17:24:00 +00:00
2022-09-22 18:26:05 +00:00
void Scanner::listKeywords(std::vector<std::string>& keywords)
2011-01-12 17:24:00 +00:00
{
2022-09-22 18:26:05 +00:00
for (int i = 0; Compiler::sKeywords[i]; ++i)
2020-10-17 08:26:35 +00:00
keywords.emplace_back(Compiler::sKeywords[i]);
2011-01-12 17:24:00 +00:00
if (mExtensions)
2022-09-22 18:26:05 +00:00
mExtensions->listKeywords(keywords);
2011-01-12 17:24:00 +00:00
}
void Scanner::enableIgnoreNewlines()
{
mIgnoreNewline = true;
}
void Scanner::enableStrictKeywords()
{
mStrictKeywords = true;
}
void Scanner::enableTolerantNames()
{
mTolerantNames = true;
}
void Scanner::enableExpectName()
{
mExpectName = true;
}
2010-06-27 17:20:21 +00:00
}