diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69df6fc..b7d0f83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,16 +35,16 @@ jobs: run: | for file in ${{ github.workspace }}/tests/programs/*.lsp; do echo "Executing $file" - time ${{ github.workspace }}/build/src/lisp $file + time ${{ github.workspace }}/build/src/rst $file done - name: Bundle Release if: github.event_name == 'push' && github.ref == 'refs/heads/master' run: | mkdir -p ${{ github.workspace }}/release - cp -v ${{ github.workspace }}/build/src/lisp ${{ github.workspace }}/release/ + cp -v ${{ github.workspace }}/build/src/rst ${{ github.workspace }}/release/ cp -v -r ${{ github.workspace }}/src/stdlib ${{ github.workspace }}/release/ - tar -czvf lisp-linux-amd64.tar.gz -C ${{ github.workspace }}/release lisp stdlib + tar -czvf redstart-linux-amd64.tar.gz -C ${{ github.workspace }}/release rst stdlib pwd ls -la @@ -56,5 +56,5 @@ jobs: host: ${{ secrets.HOST }} port: ${{ secrets.PORT }} key: ${{ secrets.KEY }} - source: "lisp-linux-amd64.tar.gz" - target: "/var/www/files/lisp/release/latest" + source: "redstart-linux-amd64.tar.gz" + target: "/var/www/files/redstart/release/latest" diff --git a/CMakeLists.txt b/CMakeLists.txt index 669d8bb..d37a879 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,13 @@ -cmake_minimum_required (VERSION 3.8) - -project("lisp") - -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -add_subdirectory(src) - -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libs/googletest/CMakeLists.txt") - add_subdirectory(libs/googletest) - enable_testing() - add_subdirectory(tests) -endif() +cmake_minimum_required (VERSION 3.8) + +project("redstart") + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +add_subdirectory(src) + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libs/googletest/CMakeLists.txt") + add_subdirectory(libs/googletest) + enable_testing() + add_subdirectory(tests) +endif() diff --git a/README.md b/README.md index 678ebb2..f33dece 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,28 @@ -# A Lisp Interpreter for Shell Scripting +# Redstart - A Lisp Interpreter for Shell Scripting ![build workflow status](https://github.com/gue-ni/lisp/actions/workflows/build.yml/badge.svg) -This project is a lightweight Lisp interpreter written in C++ with a focus on -shell scripting. It lets you combine the expressive power of Lisp with the -practicality of the Unix shell: you can run commands, capture output, pipe -between processes, and still use Lisp syntax for logic and structure. Think of -it as writing your shell scripts in Lisp instead of Bash. +Redstart (named after the [bird](https://en.wikipedia.org/wiki/Common_redstart)) is +a lightweight Lisp interpreter written in C++ with a focus on shell scripting. +It lets you combine the expressive power of Lisp with the practicality of the +Unix shell: you can run commands, capture output, pipe between processes, and +still use Lisp syntax for logic and structure. Think of it as writing your shell +scripts in Lisp instead of Bash. ## How to install ```bash -bash <(curl -s https://raw.githubusercontent.com/gue-ni/lisp/refs/heads/master/tools/install-lisp.sh) +bash <(curl -s https://raw.githubusercontent.com/gue-ni/redstart/refs/heads/master/tools/install.sh) +``` + +## Quickstart + +```bash +# Start the REPL +rst + +# Run a script +rst my_script.lsp ``` ## Examples diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fba987b..ce83345 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,58 +1,58 @@ -if(UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -endif() - -set(SRC_FILES "eval.cpp" "builtin.cpp" "expr.cpp" "parser.cpp" "tokenizer.cpp" "gc.cpp" "logger.cpp" ) -set(INC_FILES "eval.h" "builtin.h" "expr.h" "parser.h" "tokenizer.h" "lisp.h" "gc.h" "logger.h" ) - -if(UNIX) - set(SRC_FILES ${SRC_FILES} "shell.cpp") - set(INC_FILES ${INC_FILES} "shell.h") -endif() - -option(ENABLE_LISP_ASAN "Enable AddressSanitizer for lisp" OFF) - -add_library(lisp_lib STATIC ${SRC_FILES} ${INC_FILES}) - -# Get the current git hash -execute_process( - COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -set( GIT_HASH_HEADER "${CMAKE_BINARY_DIR}/version.h" ) - -file(WRITE ${GIT_HASH_HEADER} "#pragma once\n") -file(APPEND ${GIT_HASH_HEADER} "#ifndef GIT_HASH\n") -file(APPEND ${GIT_HASH_HEADER} "#define GIT_HASH \"${GIT_HASH}\"\n") -file(APPEND ${GIT_HASH_HEADER} "#endif\n") - -target_include_directories(lisp_lib PUBLIC ${CMAKE_BINARY_DIR}) - - -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - message(STATUS "Building on Linux, linking with Readline") - target_link_libraries(lisp_lib PUBLIC readline tinfo) -endif() - -target_include_directories(lisp_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - -if (CMAKE_VERSION VERSION_GREATER 3.12) - set_property(TARGET lisp_lib PROPERTY CXX_STANDARD 20) -endif() - -add_executable(lisp "main.cpp") -target_link_libraries(lisp lisp_lib) - -if (ENABLE_LISP_ASAN AND UNIX AND NOT APPLE) - message(STATUS "Building lisp with AddressSanitizer") - - target_compile_options(lisp_lib PRIVATE -fsanitize=address -fno-omit-frame-pointer -g) - target_link_options(lisp_lib PRIVATE -fsanitize=address) - - target_compile_options(lisp PRIVATE -fsanitize=address -fno-omit-frame-pointer -g) - target_link_options(lisp PRIVATE -fsanitize=address) - +if(UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +endif() + +set(SRC_FILES "eval.cpp" "builtin.cpp" "expr.cpp" "parser.cpp" "tokenizer.cpp" "gc.cpp" "logger.cpp" ) +set(INC_FILES "eval.h" "builtin.h" "expr.h" "parser.h" "tokenizer.h" "lisp.h" "gc.h" "logger.h" ) + +if(UNIX) + set(SRC_FILES ${SRC_FILES} "shell.cpp") + set(INC_FILES ${INC_FILES} "shell.h") +endif() + +option(ENABLE_LISP_ASAN "Enable AddressSanitizer for lisp" OFF) + +add_library(lisp_lib STATIC ${SRC_FILES} ${INC_FILES}) + +# Get the current git hash +execute_process( + COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +set( GIT_HASH_HEADER "${CMAKE_BINARY_DIR}/version.h" ) + +file(WRITE ${GIT_HASH_HEADER} "#pragma once\n") +file(APPEND ${GIT_HASH_HEADER} "#ifndef GIT_HASH\n") +file(APPEND ${GIT_HASH_HEADER} "#define GIT_HASH \"${GIT_HASH}\"\n") +file(APPEND ${GIT_HASH_HEADER} "#endif\n") + +target_include_directories(lisp_lib PUBLIC ${CMAKE_BINARY_DIR}) + + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + message(STATUS "Building on Linux, linking with Readline") + target_link_libraries(lisp_lib PUBLIC readline tinfo) +endif() + +target_include_directories(lisp_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +if (CMAKE_VERSION VERSION_GREATER 3.12) + set_property(TARGET lisp_lib PROPERTY CXX_STANDARD 20) +endif() + +add_executable(rst "main.cpp") +target_link_libraries(rst lisp_lib) + +if (ENABLE_LISP_ASAN AND UNIX AND NOT APPLE) + message(STATUS "Building lisp with AddressSanitizer") + + target_compile_options(lisp_lib PRIVATE -fsanitize=address -fno-omit-frame-pointer -g) + target_link_options(lisp_lib PRIVATE -fsanitize=address) + + target_compile_options(rst PRIVATE -fsanitize=address -fno-omit-frame-pointer -g) + target_link_options(rst PRIVATE -fsanitize=address) + endif() \ No newline at end of file diff --git a/src/eval.cpp b/src/eval.cpp index a41cd86..4e438ac 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -673,7 +673,7 @@ std::string get_version_info() void print_repl_header() { - std::cout << "Welcome to my LISP Interpreter! (" << get_version_info() << ")" << std::endl; + std::cout << "Welcome to Redstart! (" << get_version_info() << ")" << std::endl; print_copyright_info(); print_compiler_info(); std::cout << std::endl; diff --git a/tools/install-lisp.sh b/tools/install.sh similarity index 68% rename from tools/install-lisp.sh rename to tools/install.sh index 981cc71..f29d0ae 100755 --- a/tools/install-lisp.sh +++ b/tools/install.sh @@ -12,20 +12,20 @@ elif [ "$ARCH" = "aarch64" ]; then ARCH="arm64" fi -RELEASE="lisp-${OS}-${ARCH}.tar.gz" +RELEASE="redstart-${OS}-${ARCH}.tar.gz" -BINARY_URL="https://www.jakobmaier.at/files/lisp/release/latest/${RELEASE}" +BINARY_URL="https://www.jakobmaier.at/files/redstart/release/latest/${RELEASE}" # Temp directory TMPDIR="$(mktemp -d)" -echo "Downloading lisp interpreter to ${TMPDIR}..." +echo "Downloading interpreter to ${TMPDIR}..." -curl -L "${BINARY_URL}" -o "${TMPDIR}/lisp.tar.gz" +curl -L "${BINARY_URL}" -o "${TMPDIR}/redstart.tar.gz" # Extract -tar -xzf "${TMPDIR}/lisp.tar.gz" -C "${TMPDIR}" +tar -xzf "${TMPDIR}/redstart.tar.gz" -C "${TMPDIR}" -LIBDIR=~/.local/share/lisp/lib/ +LIBDIR=~/.local/share/redstart/lib/ BINDIR=~/.local/bin/ # Install startup script @@ -33,14 +33,14 @@ if [ ! -e ~/.profile.lsp ]; then cp $TMPDIR/stdlib/profile.lsp ~/.profile.lsp fi -# Install lisp libraries (required sudo) +# Install redstart libraries (required sudo) mkdir -p $LIBDIR cp $TMPDIR/stdlib/* $LIBDIR # Install binary (requires sudo) mkdir -p $BINDIR -cp $TMPDIR/lisp $BINDIR -chmod +x $BINDIR/lisp +cp $TMPDIR/redstart $BINDIR +chmod +x $BINDIR/redstart # Cleanup rm -rf "$TMPDIR" @@ -58,4 +58,4 @@ if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" fi -echo "Successfully installed lisp to ${BINDIR}" +echo "Successfully installed redstart to ${BINDIR}"