Skip to content

Commit 7bf8cdf

Browse files
feat: add conditional logic, CLI versioning, LLVM 21 integration, and CI release workflow
1 parent 34b4674 commit 7bf8cdf

13 files changed

Lines changed: 461 additions & 121 deletions

File tree

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release SimpleScript
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
name: Build for ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
artifact_name: simplescript-linux
17+
asset_name: simplescript-v0.5.0-linux-x86_64.tar.gz
18+
- os: windows-latest
19+
artifact_name: simplescript.exe
20+
asset_name: simplescript-v0.5.0-windows-x86_64.zip
21+
- os: macos-latest
22+
artifact_name: simplescript
23+
asset_name: simplescript-v0.5.0-macos-arm64.tar.gz
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Zig
30+
uses: goto-bus-stop/setup-zig@v2
31+
with:
32+
version: 0.15.2
33+
34+
- name: Install LLVM 21 (Linux)
35+
if: matrix.os == 'ubuntu-latest'
36+
run: |
37+
wget https://apt.llvm.org/llvm.sh
38+
chmod +x llvm.sh
39+
sudo ./llvm.sh 21
40+
sudo apt-get install -y llvm-21-dev libclang-21-dev
41+
42+
- name: Install LLVM 21 (Windows)
43+
if: matrix.os == 'windows-latest'
44+
run: |
45+
choco install llvm --version=21.1.8 -y
46+
echo "C:\Program Files\LLVM\bin" >> $GITHUB_PATH
47+
48+
- name: Install LLVM 21 (macOS)
49+
if: matrix.os == 'macos-latest'
50+
run: |
51+
brew install llvm@21
52+
echo "/opt/homebrew/opt/llvm@21/bin" >> $GITHUB_PATH
53+
54+
- name: Build SimpleScript
55+
run: zig build -Doptimize=ReleaseSafe
56+
57+
- name: Package Release (Linux/macOS)
58+
if: matrix.os != 'windows-latest'
59+
run: |
60+
mkdir -p dist/bin
61+
cp zig-out/bin/simplescript dist/bin/
62+
cp -r examples dist/
63+
tar -czvf ${{ matrix.asset_name }} -C dist .
64+
65+
- name: Package Release (Windows)
66+
if: matrix.os == 'windows-latest'
67+
run: |
68+
mkdir dist\bin
69+
copy zig-out\bin\simplescript.exe dist\bin\
70+
xcopy /E /I examples dist\examples
71+
powershell Compress-Archive -Path dist\* -DestinationPath ${{ matrix.asset_name }}
72+
73+
- name: Upload Release Assets
74+
uses: softprops/action-gh-release@v2
75+
with:
76+
files: ${{ matrix.asset_name }}
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,28 @@
1+
# Compiled files
2+
*
3+
!*/
4+
!*.ss
5+
!*.zig
6+
!*.zig.zon
7+
!*.md
8+
!*.txt
9+
!*.yml
10+
!.gitignore
11+
!build.zig
12+
!LICENSE
13+
114
# Zig build artifacts
215
zig-cache/
316
zig-out/
17+
.zig-out/
418
.zig-cache/
519

6-
# Compiled files
7-
*.o
8-
*.obj
9-
*.exe
10-
*.out
11-
*.so
12-
*.dylib
13-
*.dll
14-
*.a
15-
*.lib
16-
17-
# Executables generated by SimpleScript
18-
saida.o
19-
benchmark
20-
teste
21-
hello
22-
loops
23-
fibonacci
24-
25-
# Backup files
26-
src_backup/
27-
src_backup_*/
28-
*.bak
29-
*.swp
30-
*.swo
31-
*~
32-
3320
# IDEs and Editors
3421
.vscode/
3522
.idea/
3623
*.sublime-*
3724
*.code-workspace
3825

39-
# macOS
40-
.DS_Store
41-
.AppleDouble
42-
.LSOverride
43-
44-
# Linux
45-
.directory
46-
.Trash-*
47-
48-
# Windows
49-
Thumbs.db
50-
ehthumbs.db
51-
Desktop.ini
52-
$RECYCLE.BIN/
53-
54-
# Logs
26+
# Temp/Logs
5527
*.log
56-
57-
# Temps
5828
tmp/
59-
temp/
60-
*.tmp
61-
62-
# Archives
63-
*.zip
64-
*.tar.gz
65-
*.rar
66-
67-
# Profiling
68-
*.prof
69-
callgrind.out.*
70-
perf.data*

build.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ pub fn build(b: *std.Build) void {
1313
}),
1414
});
1515

16+
const llvm_config = "llvm-config-21";
17+
18+
const include_path = b.run(&[_][]const u8{ llvm_config, "--includedir" });
19+
const lib_path = b.run(&[_][]const u8{ llvm_config, "--libdir" });
20+
21+
exe.addIncludePath(.{ .cwd_relative = std.mem.trim(u8, include_path, " \n\r") });
22+
exe.addLibraryPath(.{ .cwd_relative = std.mem.trim(u8, lib_path, " \n\r") });
23+
1624
exe.linkLibC();
1725
exe.linkSystemLibrary("c++");
18-
exe.linkSystemLibrary("LLVM-18");
26+
exe.linkSystemLibrary("LLVM-21");
1927

2028
if (target.result.os.tag == .linux) exe.linkSystemLibrary("z");
2129

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = .simplescript,
3-
.version = "0.4.0",
3+
.version = "0.5.0",
44
.fingerprint = 0x24ab81ec52649174,
55
.minimum_zig_version = "0.15.2",
66
.dependencies = .{},

examples/conditions.ss

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Conditional Logic and Comparisons
2+
// Supports if, else if, and else blocks with boolean expressions
3+
4+
var age: int = 18
5+
6+
say('Checking age status...')
7+
if age >= 18 {
8+
say('Status: You are an adult')
9+
} else if age >= 0 {
10+
say('Status: You are a minor')
11+
} else {
12+
say('ERROR: Invalid age value')
13+
}
14+
15+
// Boolean literals usage
16+
say('Boolean testing:')
17+
if true {
18+
say('True branch works')
19+
} else {
20+
say('This should not print')
21+
}
22+
23+
// String comparisons
24+
var name: str = "Victor Francelino"
25+
say('Checking identity for:', name)
26+
27+
if name != "SimpleScript" {
28+
say('The strings are different')
29+
} else {
30+
say('The strings are equal')
31+
}
32+
33+
// Integer equality check
34+
var target: int = 16
35+
36+
if target == 16 {
37+
say('Target confirmed: 16')
38+
} else {
39+
say('Target mismatch')
40+
}

examples/hello.ss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
// Hello World in SimpleScript
22
// Showcases basic types and the 'say' function
33

4+
// The 'say' function can print multiple arguments separated by spaces
45
say('--- Welcome to SimpleScript ---')
56

7+
// Constants are immutable after initialization
68
const language: str = 'SimpleScript'
7-
const version: float = 0.4
9+
const version: float = 0.5
810

911
say('Language:', language)
1012
say('Version:', version)
1113

14+
// Variables can be reassigned
1215
var a: int = 10
1316
var b: int = 20
17+
18+
// SimpleScript supports standard operator precedence
1419
var result: int = (a + b) * 2
1520

1621
say('Expression result (10 + 20) * 2:', result)

examples/loops.ss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
// Demonstrates loops with static and dynamic ranges
1+
// Loops with Static and Dynamic Ranges
22

33
say('Counting 0 to 4:')
44
for i in 0..5 {
5-
say(i)
5+
say('Number:', i)
66
}
77

88
say('Using variables for range (5 to 9):')
99
var start: int = 0
10-
var end: int = 5
10+
var end: int = 10
1111
for i in start..end {
12-
say(i)
12+
say('Dynamic index:', i)
1313
}
1414

1515
say('Calculating sum of 0 to 9:')
1616
var sum: int = 0
1717
for i in 0..10 {
18+
// Variables can be updated using their current value
1819
sum = sum + i
1920
}
2021

21-
say('Total sum:', sum)
22+
say('Total sum of 0..9 is:', sum)

examples/swap.ss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
// The magic of Multiple Assignment (Swap)
2-
// No temporary variables needed!
1+
// Multiple Assignment and Value Swapping
2+
// In SimpleScript, you don't need temporary variables to swap values!
33

44
var player_1: int = 500
55
var player_2: int = 1000
66

7-
say('Initial Scores:', player_1, player_2)
7+
say('Initial Scores -> P1:', player_1, '| P2:', player_2)
88

99
say('Swapping scores...')
10+
11+
// Multiple values are evaluated and assigned simultaneously
1012
player_1, player_2 = player_2, player_1
1113

12-
say('New Scores:', player_1, player_2)
14+
say('New Scores -> P1:', player_1, '| P2:', player_2)
1315

14-
// Triple swap showcase
16+
// It also works for rotating multiple values
1517
var r: int = 255
1618
var g: int = 128
1719
var b: int = 0
1820

1921
say('RGB values:', r, g, b)
20-
2122
say('Rotating RGB values...')
2223

2324
r, g, b = g, b, r

src/compiler.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub const Variable = struct {
3737
pub const Compiler = struct {
3838
allocator: std.mem.Allocator,
3939
locals: std.StringHashMap(Variable),
40+
scope_level: u32 = 0,
4041

4142
context: llvm.LLVMContextRef,
4243
module: llvm.LLVMModuleRef,
@@ -129,6 +130,14 @@ pub const Compiler = struct {
129130
_ = llvm.LLVMBuildRet(self.builder, zero);
130131
}
131132

133+
pub fn enterScope(self: *Compiler) void {
134+
self.scope_level += 1;
135+
}
136+
137+
pub fn exitScope(self: *Compiler) void {
138+
self.scope_level -= 1;
139+
}
140+
132141
pub fn printString(self: *Compiler, str_value: llvm.LLVMValueRef) !void {
133142
const fmt_str = llvm.LLVMBuildGlobalStringPtr(self.builder, "%s", "fmt.str");
134143
var args = [_]llvm.LLVMValueRef{ fmt_str, str_value };

0 commit comments

Comments
 (0)