-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcompile-scheme.sh
More file actions
executable file
·77 lines (68 loc) · 1.66 KB
/
compile-scheme.sh
File metadata and controls
executable file
·77 lines (68 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# VeloxVM Scheme Compiler Wrapper Script
# Copyright (c) 2025, RISE Research Institutes of Sweden AB
set -e
# Configuration
RACKET_COMPILER="languages/scheme/main.rkt"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Check if racket is installed
if ! command -v racket &> /dev/null; then
echo "Error: Racket is not installed"
echo "Please install Racket from https://racket-lang.org/"
exit 1
fi
# Check if source file provided
if [ $# -lt 1 ]; then
echo "Usage: $0 <source.scm> [output.vm]"
echo ""
echo "Compile Scheme source to VeloxVM bytecode"
echo ""
echo "Options:"
echo " -v, --verbose Verbose output"
echo " --debug Debug mode"
echo ""
echo "Examples:"
echo " $0 apps/hello.scm"
echo " $0 apps/math.scm apps/math.vm"
echo " $0 --verbose apps/test.scm"
exit 1
fi
# Parse arguments
VERBOSE=""
DEBUG=""
SOURCE=""
OUTPUT=""
while [[ $# -gt 0 ]]; do
case $1 in
-v|--verbose)
VERBOSE="--verbose"
shift
;;
--debug)
DEBUG="--debug"
shift
;;
-o|--output)
OUTPUT="--output $2"
shift 2
;;
*)
if [ -z "$SOURCE" ]; then
SOURCE="$1"
else
OUTPUT="--output $1"
fi
shift
;;
esac
done
# Check source file exists
if [ ! -f "$SOURCE" ]; then
echo "Error: Source file not found: $SOURCE"
exit 1
fi
# Compile
cd "$SCRIPT_DIR"
echo "Compiling $SOURCE..."
racket "$RACKET_COMPILER" $VERBOSE $DEBUG $OUTPUT "$SOURCE"
echo "Compilation successful!"