Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
26 changes: 13 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
114 changes: 57 additions & 57 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions tools/install-lisp.sh → tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ 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
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"
Expand All @@ -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}"