Revert "Add a "SEPARATOR" token type"

This reverts commit 47478173
This commit is contained in:
Username404 2021-09-11 11:35:22 +02:00
parent 84b9f9de73
commit bfa8f50ad9
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
5 changed files with 12 additions and 13 deletions

View File

@ -9,7 +9,7 @@ tok::type getIdentifierCharType(const char& Char) {
else return UNEXPECTED;
}
vector<tok> lex(const string& in, const char separatorCharacter)
vector<tok> lex(const string& in)
{
vector<tok> resVal;
unsigned long lineNumber = 1;
@ -21,9 +21,9 @@ vector<tok> lex(const string& in, const char separatorCharacter)
case LBRACE: case RBRACE: case LBRACKET: case RBRACKET:
case PLUS: case HYPHEN: case LCOMP: case RCOMP:
case DOT: case DOLLAR_SIGN: case SQUOTE:
resVal.emplace_back(static_cast<tok::type>(current), string(1, current), lineNumber); break;
[[likely]] case '\n': ++lineNumber; case ';': resVal.emplace_back(SEPARATOR, string(1, separatorCharacter), lineNumber);
resVal.emplace_back(static_cast<tok::type>(current), string(1, current), lineNumber);
[[likely]] case ' ': case '\t': [[unlikely]] case '\r': break;
[[likely]] case '\n': ++lineNumber; break;
default: {
tok::type type = getIdentifierCharType(current);
bool isTypeString = (type == STRING);

View File

@ -11,7 +11,7 @@ struct tok {
using Yerbacon::Exception::Exception;
};
enum type: const unsigned short {
UNEXPECTED = std::numeric_limits<unsigned char>::max() + 1, IDENTIFIER, NUMBER, ALPHACHAR, SEPARATOR,
UNEXPECTED = std::numeric_limits<unsigned char>::max() + 1, IDENTIFIER, NUMBER, ALPHACHAR,
DEFINE = '=', TAG = '#', DOLLAR_SIGN = '$', DOT = '.',
PLUS = '+', LPAR = '(', LBRACE = '{', LBRACKET = '[', RPAR = ')',
RBRACE = '}', RBRACKET = ']',
@ -22,9 +22,9 @@ struct tok {
const type toktype;
const std::string toktext;
const unsigned long line = 0;
tok(type Type, std::string_view Text, decltype(line) line): toktype(Type), toktext(Text), line(line) {}
tok(type Type, std::string_view Text, auto line): toktype(Type), toktext(Text), line(line) {}
friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; }
};
std::vector<tok> lex(const std::string& in, char separatorCharacter);
std::vector<tok> lex(const std::string& in);
#endif //YERBACON_TEST_H

View File

@ -6,6 +6,6 @@ void outputFileContent(const string& file, string_view content);
#include "lex.hpp"
#include "parsing/Parser.hpp"
inline auto parseString(const string& toParse, const char lineSeparator) { return Parser::parseVector(lex(toParse, lineSeparator)); }
inline auto parseString(const string& toParse) { return Parser::parseVector(lex(toParse)); }
#endif //YERBACON_MISC_HPP

View File

@ -100,7 +100,7 @@ shared_ptr<Target> Target::forName(string_view name) {
}
}
shared_ptr<Target> target;
#define ADDTARGET(X) target = shared_ptr<X>(new (X));
#define ADDTARGET(X) target = make_shared<X>(X());
switch (selected) {
#ifdef LUA_HPP
case LUA: ADDTARGET(LUA_HPP); break;

View File

@ -14,7 +14,6 @@ int main(int argc, char* argv[]) {
string target = ".lua";
bool printResult = false;
bool parallel = false;
bool newLinesSeparator = true;
if (argc > 0) {
vector<string_view> files;
@ -23,15 +22,15 @@ int main(int argc, char* argv[]) {
const string_view currentArg (argv[i]);
if (currentArg == ArgumentShort("printresult")) printResult = true;
else if (currentArg == ArgumentAssignable("target")) {
const string value = ArgumentAssignable::getValueFor(currentArg.data());
target.clear();
string value = ArgumentAssignable::getValueFor(currentArg.data());
if (!value.empty()) (target = '.') += value;
}
else if (currentArg == Argument("parallel")) parallel = true;
else if (currentArg.ends_with(".ybcon")) files.push_back(currentArg);
else if (currentArg == Argument("newlinesoff")) newLinesSeparator = true;
}
const auto compile = [&target, &newLinesSeparator](string_view name) {
string transpiledString = transpile(parseString(getFileContent(name.data()), newLinesSeparator ? ';' : '\n'), target);
const auto compile = [&target](string_view name) {
string transpiledString = transpile(parseString(getFileContent(name.data())), target);
name.remove_suffix(6);
string outputFile;
(outputFile = name).append(target);