Fixed header duplicate symbols
This commit is contained in:
parent
92cd4e542a
commit
b38f6bff25
@ -4,7 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
std::vector<std::string> splitString(const std::string& input, std::string delimiter) {
|
inline std::vector<std::string> splitString(const std::string& input, std::string delimiter) {
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
std::string token;
|
std::string token;
|
||||||
size_t start = 0;
|
size_t start = 0;
|
||||||
@ -24,7 +24,7 @@ std::vector<std::string> splitString(const std::string& input, std::string delim
|
|||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string trim(const std::string& str) {
|
inline std::string trim(const std::string& str) {
|
||||||
// Find the first non-whitespace character
|
// Find the first non-whitespace character
|
||||||
size_t start = str.find_first_not_of(" \t\n\r");
|
size_t start = str.find_first_not_of(" \t\n\r");
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ std::string trim(const std::string& str) {
|
|||||||
return str.substr(start, end - start + 1);
|
return str.substr(start, end - start + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string replaceSubstring(const std::string& str, const std::string& findSubstring, const std::string& replacement) {
|
inline std::string replaceSubstring(const std::string& str, const std::string& findSubstring, const std::string& replacement) {
|
||||||
std::string result = str;
|
std::string result = str;
|
||||||
size_t startPos = result.find(findSubstring);
|
size_t startPos = result.find(findSubstring);
|
||||||
|
|
||||||
@ -52,11 +52,11 @@ std::string replaceSubstring(const std::string& str, const std::string& findSubs
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isHexDigit(char c) {
|
inline bool isHexDigit(char c) {
|
||||||
return (std::isdigit(c) || (std::isxdigit(c) && std::islower(c)));
|
return (std::isdigit(c) || (std::isxdigit(c) && std::islower(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
u_long binaryStringToLong(const std::string& binaryString) {
|
inline u_long binaryStringToLong(const std::string& binaryString) {
|
||||||
std::string binaryDigits = binaryString.substr(2); // Remove the '0b' prefix
|
std::string binaryDigits = binaryString.substr(2); // Remove the '0b' prefix
|
||||||
u_long result = 0;
|
u_long result = 0;
|
||||||
for (char ch : binaryDigits) {
|
for (char ch : binaryDigits) {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "../headers/Lexer.h"
|
#include "../headers/Lexer.h"
|
||||||
|
#include "../headers/helperFunctions/HelperFunctions.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -202,7 +204,7 @@ std::vector<Token> Lexer::Tokenize(std::string source){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!src.empty() && ishexnumber(src[0]))
|
if(!src.empty() && (src[0]))
|
||||||
{
|
{
|
||||||
if(notationChar == 'b') {
|
if(notationChar == 'b') {
|
||||||
while (!src.empty() && (src[0] == '0' || src[0] == '1')) {
|
while (!src.empty() && (src[0] == '0' || src[0] == '1')) {
|
||||||
@ -212,7 +214,7 @@ std::vector<Token> Lexer::Tokenize(std::string source){
|
|||||||
}
|
}
|
||||||
else if(notationChar == 'x')
|
else if(notationChar == 'x')
|
||||||
{
|
{
|
||||||
while (!src.empty() && ishexnumber(src[0])) {
|
while (!src.empty() && std::isxdigit(src[0])) {
|
||||||
|
|
||||||
num += src[0];
|
num += src[0];
|
||||||
advance();
|
advance();
|
||||||
|
|||||||
@ -4,51 +4,12 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "../headers/bob.h"
|
#include "../headers/bob.h"
|
||||||
#include "../headers/Expression.h"
|
|
||||||
#include "../headers/Lexer.h"
|
|
||||||
#include "../headers/ASTPrinter.h"
|
|
||||||
#include "../headers/TypeWrapper.h"
|
|
||||||
int main(){
|
int main(){
|
||||||
Bob bobLang;
|
Bob bobLang;
|
||||||
|
|
||||||
//bobLang.runFile("source.bob");
|
//bobLang.runFile("source.bob");
|
||||||
bobLang.runPrompt();
|
bobLang.runPrompt();
|
||||||
|
|
||||||
//ASTPrinter printer;
|
|
||||||
//
|
|
||||||
// std::shared_ptr<Expr<std::shared_ptr<Object>>> expression = std::make_shared<BinaryExpr<std::shared_ptr<Object>> >(
|
|
||||||
// std::make_shared<UnaryExpr<std::shared_ptr<Object>>>(
|
|
||||||
// Token{MINUS, "-", 1},
|
|
||||||
// std::make_shared<LiteralExpr<std::shared_ptr<Object>>>("123", true)
|
|
||||||
// ),
|
|
||||||
// Token{MINUS, "-", 1},
|
|
||||||
// std::make_shared<GroupingExpr<std::shared_ptr<Object>>>(
|
|
||||||
// std::make_shared<LiteralExpr<std::shared_ptr<Object>>>("45.67", true)
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
//// Expr<std::string>* e = new BinaryExpr<std::string>(
|
|
||||||
//// new UnaryExpr<std::string>(Token{MINUS, "-", 0}, new LiteralExpr<std::string>("123")),
|
|
||||||
//// Token{STAR, "*", 0},
|
|
||||||
//// new UnaryExpr<std::string>(Token{PLUS, "+", 0}, new LiteralExpr<std::string>("535"))
|
|
||||||
//// );
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// std::cout << std::dynamic_pointer_cast<String>(printer.print(expression.get()))->value;
|
|
||||||
//
|
|
||||||
// std::cout << std::endl;
|
|
||||||
|
|
||||||
//bobLang.runPrompt();
|
|
||||||
|
|
||||||
// std::shared_ptr<Object> object = std::make_shared<String>(String{"Hi"});
|
|
||||||
//
|
|
||||||
// if(auto num = std::dynamic_pointer_cast<Number>(object))
|
|
||||||
// {
|
|
||||||
// std::cout << num->value << std::endl;
|
|
||||||
// }else if(auto str = std::dynamic_pointer_cast<String>(object))
|
|
||||||
// {
|
|
||||||
// std::cout << str->value << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user