From 55abb4f6f81fc370e349385b38dffb05fa9d5dcb Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Sat, 19 Apr 2025 20:36:38 +0000
Subject: [PATCH] add vscodium / vscode and vim syntax highlight
---
src/VoidScript.hpp | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/VoidScript.hpp b/src/VoidScript.hpp
index ab472bb..96cc277 100644
--- a/src/VoidScript.hpp
+++ b/src/VoidScript.hpp
@@ -3,6 +3,8 @@
#include <filesystem>
#include <fstream>
#include <string>
+#include <iostream>
+#include <iterator>
#include "Interpreter/Interpreter.hpp"
#include "Lexer/Lexer.hpp"
@@ -32,15 +34,18 @@
std::shared_ptr<Parser::Parser> parser = nullptr;
static std::string readFile(const std::string & file) {
+ // Read from stdin if '-' is specified
+ if (file == "-") {
+ return std::string(std::istreambuf_iterator<char>(std::cin), std::istreambuf_iterator<char>());
+ }
if (!std::filesystem::exists(file)) {
- throw std::runtime_error("File " + file + " does not exits");
+ throw std::runtime_error("File " + file + " does not exist");
}
std::ifstream input(file, std::ios::in);
if (!input.is_open()) {
throw std::runtime_error("Could not open file " + file);
- return "";
}
- std::string content = std::string((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
+ std::string content((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
input.close();
return content;
}
--
Gitblit v1.9.3