Started work on the CeeV language.
commit
b8d5dd5673
|
@ -0,0 +1,78 @@
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/cmake,c++,visualstudiocode
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=cmake,c++,visualstudiocode
|
||||||
|
|
||||||
|
### C++ ###
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
|
||||||
|
### CMake ###
|
||||||
|
CMakeLists.txt.user
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles
|
||||||
|
CMakeScripts
|
||||||
|
Testing
|
||||||
|
Makefile
|
||||||
|
cmake_install.cmake
|
||||||
|
install_manifest.txt
|
||||||
|
compile_commands.json
|
||||||
|
CTestTestfile.cmake
|
||||||
|
_deps
|
||||||
|
|
||||||
|
### CMake Patch ###
|
||||||
|
# External projects
|
||||||
|
*-prefix/
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Built Visual Studio Code Extensions
|
||||||
|
*.vsix
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/cmake,c++,visualstudiocode
|
||||||
|
|
||||||
|
build/
|
||||||
|
.ccls
|
||||||
|
.ccls-cache/
|
|
@ -0,0 +1,52 @@
|
||||||
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
project(ceev VERSION 0.1.0 DESCRIPTION "The language of the CeeV project")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --short HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND git log -1 --pretty=%B
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT_MSG
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} SHARED src/lang.cc src/lang.h src/colors.cc
|
||||||
|
src/colors.h)
|
||||||
|
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER
|
||||||
|
"src/lang.h;src/colors.h")
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ceevConfig.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/ceevConfig.cmake
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/ceevConfig.cmake
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/ceev
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION /usr/local/lib/
|
||||||
|
PUBLIC_HEADER DESTINATION /usr/local/include/ceev
|
||||||
|
)
|
||||||
|
|
||||||
|
# install(TARGETS ${PROJECT_NAME}
|
||||||
|
# LIBRARY DESTINATION /usr/lib
|
||||||
|
# PUBLIC_HEADER DESTINATION /usr/include/ceev)
|
||||||
|
|
||||||
|
# install(TARGETS ${PROJECT_NAME} LIBRARY)
|
||||||
|
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
|
"-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
||||||
|
|
||||||
|
string(REPLACE "\n" "\\n" GIT_COMMIT_MSG "${GIT_COMMIT_MSG}")
|
||||||
|
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
|
"-DGIT_COMMIT_MSG=\"${GIT_COMMIT_MSG}\"")
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Ceev Lang
|
||||||
|
This is a supplementary to the CeeV project.
|
||||||
|
More to come.
|
|
@ -0,0 +1,6 @@
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
set(ceev_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/ceev")
|
||||||
|
set(ceev_LIBRARIES "@CMAKE_INSTALL_PREFIX@/lib/libceev.so")
|
||||||
|
|
||||||
|
# find_package(ceev)
|
|
@ -0,0 +1,14 @@
|
||||||
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
project(ceevlang-test)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
find_library(CEEV NAMES ceev HINTS "/usr/local/include" REQUIRED)
|
||||||
|
include_directories(${CEEV_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} src/test.cc src/test.h)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${CEEV_LIBRARIES})
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::cout << bg_bright_green(red("Hello World")) << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ceev/colors.h>
|
||||||
|
#include <iostream>
|
|
@ -0,0 +1,4 @@
|
||||||
|
let test = Character("Test")
|
||||||
|
test "Hello World"
|
||||||
|
|
||||||
|
unlet test
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
|
std::string black(std::string input) {return "\x1b[30m" + input + "\x1b[0m";}
|
||||||
|
std::string red(std::string input) {return "\x1b[31m" + input + "\x1b[0m";}
|
||||||
|
std::string green(std::string input) {return "\x1b[32m" + input + "\x1b[0m";}
|
||||||
|
std::string yellow(std::string input) {return "\x1b[33m" + input + "\x1b[0m";}
|
||||||
|
std::string blue(std::string input) {return "\x1b[34m" + input + "\x1b[0m";}
|
||||||
|
std::string magenta(std::string input) {return "\x1b[35m" + input + "\x1b[0m";}
|
||||||
|
std::string cyan(std::string input) {return "\x1b[36m" + input + "\x1b[0m";}
|
||||||
|
std::string white(std::string input) {return "\x1b[37m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_black(std::string input) {return "\x1b[90m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_red(std::string input) {return "\x1b[91m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_green(std::string input) {return "\x1b[92m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_yellow(std::string input) {return "\x1b[93m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_blue(std::string input) {return "\x1b[94m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_magenta(std::string input) {return "\x1b[95m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_cyan(std::string input) {return "\x1b[96m" + input + "\x1b[0m";}
|
||||||
|
std::string bright_white(std::string input) {return "\x1b[97m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_black(std::string input) {return "\x1b[40m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_red(std::string input) {return "\x1b[41m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_green(std::string input) {return "\x1b[42m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_yellow(std::string input) {return "\x1b[43m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_blue(std::string input) {return "\x1b[44m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_magenta(std::string input) {return "\x1b[45m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_cyan(std::string input) {return "\x1b[46m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_white(std::string input) {return "\x1b[47m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_black(std::string input) {return "\x1b[100m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_red(std::string input) {return "\x1b[101m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_green(std::string input) {return "\x1b[102m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_yellow(std::string input) {return "\x1b[103m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_blue(std::string input) {return "\x1b[104m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_magenta(std::string input) {return "\x1b[105m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_cyan(std::string input) {return "\x1b[106m" + input + "\x1b[0m";}
|
||||||
|
std::string bg_bright_white(std::string input) {return "\x1b[107m" + input + "\x1b[0m";}
|
||||||
|
std::string bold(std::string input) {return "\x1b[1m" + input + "\x1b[0m";}
|
||||||
|
std::string underline(std::string input) {return "\x1b[4m" + input + "\x1b[0m";}
|
||||||
|
std::string reverse(std::string input) {return "\x1b[7m" + input + "\x1b[0m";}
|
|
@ -0,0 +1,39 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
std::string black(std::string input);
|
||||||
|
std::string red(std::string input);
|
||||||
|
std::string green(std::string input);
|
||||||
|
std::string yellow(std::string input);
|
||||||
|
std::string blue(std::string input);
|
||||||
|
std::string magenta(std::string input);
|
||||||
|
std::string cyan(std::string input);
|
||||||
|
std::string white(std::string input);
|
||||||
|
std::string bright_black(std::string input);
|
||||||
|
std::string bright_red(std::string input);
|
||||||
|
std::string bright_green(std::string input);
|
||||||
|
std::string bright_yellow(std::string input);
|
||||||
|
std::string bright_blue(std::string input);
|
||||||
|
std::string bright_magenta(std::string input);
|
||||||
|
std::string bright_cyan(std::string input);
|
||||||
|
std::string bright_white(std::string input);
|
||||||
|
std::string bg_black(std::string input);
|
||||||
|
std::string bg_red(std::string input);
|
||||||
|
std::string bg_green(std::string input);
|
||||||
|
std::string bg_yellow(std::string input);
|
||||||
|
std::string bg_blue(std::string input);
|
||||||
|
std::string bg_magenta(std::string input);
|
||||||
|
std::string bg_cyan(std::string input);
|
||||||
|
std::string bg_white(std::string input);
|
||||||
|
std::string bg_bright_black(std::string input);
|
||||||
|
std::string bg_bright_red(std::string input);
|
||||||
|
std::string bg_bright_green(std::string input);
|
||||||
|
std::string bg_bright_yellow(std::string input);
|
||||||
|
std::string bg_bright_blue(std::string input);
|
||||||
|
std::string bg_bright_magenta(std::string input);
|
||||||
|
std::string bg_bright_cyan(std::string input);
|
||||||
|
std::string bg_bright_white(std::string input);
|
||||||
|
std::string bold(std::string input);
|
||||||
|
std::string underline(std::string input);
|
||||||
|
std::string reverse(std::string input);
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "lang.h"
|
||||||
|
|
||||||
|
int read_file(std::deque<std::string> args) {
|
||||||
|
if (args.empty()) {
|
||||||
|
std::cout << bg_red(bold("ERROR")) << ": No file input" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fs::path filename = args[0];
|
||||||
|
args.pop_front();
|
||||||
|
std::ifstream file(filename);
|
||||||
|
if (!file) {
|
||||||
|
std::cout << bg_red(bold("ERROR")) << ": Could not find file" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
std::istringstream stream(line);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
|
#include <deque>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
int read_file(std::deque<std::string> args);
|
Loading…
Reference in New Issue