Skip to content

Commit

Permalink
0.9.500
Browse files Browse the repository at this point in the history
- WASM
- Fixes
  • Loading branch information
RobbyV2 committed Nov 27, 2024
1 parent 03b0420 commit 0ad82fd
Show file tree
Hide file tree
Showing 15 changed files with 306 additions and 119 deletions.
43 changes: 41 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
target:
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-gnu
- wasm32-unknown-unknown
- wasm32-wasip1

steps:
- uses: actions/checkout@v3
Expand All @@ -51,10 +53,31 @@ jobs:
target: ${{ matrix.target }}

- name: Install Cross
if: matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'wasm32-wasip1'
run: cargo install cross

- name: Build Release
run: cross build --release --target ${{ matrix.target }}
- name: Install wasm-pack
if: matrix.target == 'wasm32-unknown-unknown'
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Install wasm32-wasip1 target
if: matrix.target == 'wasm32-wasip1'
run: rustup target add wasm32-wasip1

- name: Build Native
if: matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'wasm32-wasip1'
run: cross build --release --target ${{ matrix.target }} --features native

- name: Build WASM
if: matrix.target == 'wasm32-unknown-unknown'
run: |
wasm-pack build --target web --release -- --features wasm
mkdir -p release/wasm
cp pkg/* release/wasm/
- name: Build for WASI target
if: matrix.target == 'wasm32-wasip1'
run: cargo build --release --target wasm32-wasip1 --features wasi

- name: Prepare Artifacts
run: |
Expand Down Expand Up @@ -99,6 +122,22 @@ jobs:
retention-days: 7
if-no-files-found: error

- name: Upload WASM Artifacts
if: matrix.target == 'wasm32-unknown-unknown'
uses: actions/upload-artifact@v4
with:
name: pseudolang-wasm
path: pkg/*
retention-days: 7
if-no-files-found: error

- name: Upload WASI artifact
if: matrix.target == 'wasm32-wasip1'
uses: actions/upload-artifact@v4
with:
name: fplc-wasi
path: target/wasm32-wasip1/release/fplc.wasm

publish:
name: Publish Release
needs: build
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*/.vscode
/target
/release
*fplc*
*fplc*
/pkg
42 changes: 41 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

[package]
name = "fplc"
version = "0.9.498"
version = "0.9.500"
edition = "2021"
description = "A pseudolang interpreter written in Rust"
repository = "https://github.com/PseudoLang-Software-Foundation/Pseudolang"
license = "MIT"

[lib]
name = "fplc"
path = "src/lib.rs"
crate-type = ["cdylib", "rlib", "staticlib"]

[package.metadata.wasm-pack]
profile.release.wasm-opt = ["-Oz"]

[profile.dev]
panic = "abort"
Expand All @@ -22,6 +26,12 @@ strip = true

[dependencies]
rand = "0.8.5"
chrono = { version = "0.4", optional = true }
chrono-tz = { version = "0.10.0", optional = true }
wasm-bindgen = "0.2"
console_error_panic_hook = "0.1"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
chrono = "0.4"
chrono-tz = "0.10.0"

Expand All @@ -33,3 +43,17 @@ libc = "0.2"

[target.'cfg(target_os = "macos")'.dependencies]
libc = "0.2"

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"
console_error_panic_hook = "0.1"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", features = ["console"] }
getrandom = { version = "0.2", features = ["js"] }
wasi = "0.11"

[features]
default = ["native"]
native = ["chrono", "chrono-tz"]
wasm = []
wasi = []
5 changes: 5 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main"

[target.x86_64-pc-windows-gnu]
image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:main"
48 changes: 37 additions & 11 deletions build_release.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
#!/bin/bash

set -e

chmod +x build_release.sh

mkdir -p release/installer

echo "Building for Windows..."
cross build --target x86_64-pc-windows-gnu --release

echo "Building for Linux..."
cross build --target x86_64-unknown-linux-gnu --release
mkdir -p release/wasm
mkdir -p release/wasi

echo "Building native targets..."

echo "Building Windows target..."
cross build --release --target x86_64-pc-windows-gnu --features native || {
echo "Windows build failed but continuing..."
}

echo "Building Linux target..."
cross build --release --target x86_64-unknown-linux-gnu --features native || {
echo "Linux build failed but continuing..."
}

echo "Building WASM target..."
if command -v wasm-pack >/dev/null 2>&1; then
wasm-pack build --target web --release -- --features wasm
cp pkg/* release/wasm/
else
echo "wasm-pack not found, skipping WASM build"
fi

echo "Building WASI target..."
rustup target add wasm32-wasip1
cargo build --release --target wasm32-wasip1 --features wasi
cp target/wasm32-wasip1/release/fplc.wasm release/wasi/

echo "Copying binaries to release folder..."

cp target/x86_64-pc-windows-gnu/release/fplc.exe release/fplc-x64.exe
cp release/fplc-x64.exe installer/fplc.exe

cp target/x86_64-unknown-linux-gnu/release/fplc release/fplc-linux-x64
if [ -f "target/x86_64-pc-windows-gnu/release/fplc.exe" ]; then
cp target/x86_64-pc-windows-gnu/release/fplc.exe release/fplc-x64.exe
cp release/fplc-x64.exe installer/fplc.exe
fi

chmod +x release/fplc-linux-*
if [ -f "target/x86_64-unknown-linux-gnu/release/fplc" ]; then
cp target/x86_64-unknown-linux-gnu/release/fplc release/fplc-linux-x64
chmod +x release/fplc-linux-x64
fi

echo "Build complete! Binaries are in the release folder."
4 changes: 2 additions & 2 deletions installer/pseudolang.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

!define MUI_ICON "Pseudolang-Logo.ico"

Name "PseudoLang Installer v0.9.498"
Name "PseudoLang Installer v0.9.500"
InstallDir "$PROGRAMFILES\PseudoLang\"
OutFile "../release/installer/pseudolang-setup-x64.exe"
BrandingText "(c) 2024 PseudoLang Software Foundation"
Expand Down Expand Up @@ -33,7 +33,7 @@ Section ""
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$INSTDIR;$R0"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayName" "Pseudolang"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayVersion" "0.9.498"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayVersion" "0.9.500"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "Publisher" "Pseudolang Software Foundation"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pseudolang" "DisplayIcon" "$INSTDIR\Pseudolang-Logo.ico"

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div align="center">
<p>
<img src="https://github.com/PseudoLang-Software-Foundation/Pseudolang/actions/workflows/build.yml/badge.svg" alt="Build and Test Pseudolang">
<img src="https://img.shields.io/badge/Version-0.9.498-green" alt="Version">
<img src="https://img.shields.io/badge/Version-0.9.500-green" alt="Version">
<a href="https://nightly.link/PseudoLang-Software-Foundation/Pseudolang/workflows/build/main"><img src="https://img.shields.io/badge/Nightly-Releases-purple" alt="Nightly Releases"></a>
</p>
</div>
Expand Down
77 changes: 77 additions & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
use crate::{interpreter, lexer::Lexer, parser};

pub fn execute_code(input: &str, debug: bool, return_output: bool) -> Result<String, String> {
let mut lexer = Lexer::new(input);
let tokens = lexer.tokenize();

if debug {
println!("\n=== Lexer Output ===");
println!("Tokens: {:?}", tokens);
println!("\n=== Parser Starting ===");
}

let ast = parser::parse(tokens, debug)?;

if debug {
println!("\n=== Parser Output ===");
println!("AST: {:#?}", ast);
println!("\n=== Starting Execution ===");
}

let output = interpreter::run(ast)?;
if !return_output && !output.is_empty() {
print!("{}", output);
}
Ok(output)
}

pub const HELP_MESSAGE: &str = r#"PseudoLang Usage:
fplc [OPTIONS] COMMAND [ARGS]
COMMANDS:
run <input_file.psl> Execute a PseudoLang program
OPTIONS:
-h, --help Display this help message
-v, --version Display version information
-d, --debug Enable debug output during execution
Examples:
fplc run program.psl
fplc run --debug source.psl
"#;

pub const UNKNOWN_OPTION_ERROR: &str = "Unknown option: {}";
pub const UNKNOWN_COMMAND_ERROR: &str = "Unknown command: {}";
pub const MISSING_INPUT_ERROR: &str = "Missing required argument: input_file";
pub const NO_COMMAND_ERROR: &str = "No command provided";
pub const INVALID_EXTENSION_ERROR: &str = "Input file must have .psl extension, got: {}";
pub const USAGE_TIP: &str = "\n\nTip: Use -h or --help for detailed usage information.";

pub fn format_unknown_option_error(option: &str) -> String {
format!(
"{}{}",
UNKNOWN_OPTION_ERROR.replace("{}", option),
USAGE_TIP
)
}

pub fn format_unknown_command_error(cmd: &str) -> String {
format!("{}{}", UNKNOWN_COMMAND_ERROR.replace("{}", cmd), USAGE_TIP)
}

pub fn format_missing_input_error() -> String {
format!("{}{}", MISSING_INPUT_ERROR, USAGE_TIP)
}

pub fn format_no_command_error() -> String {
format!("{}{}", NO_COMMAND_ERROR, USAGE_TIP)
}

pub fn format_invalid_extension_error(file: &str) -> String {
format!(
"{}{}",
INVALID_EXTENSION_ERROR.replace("{}", file),
USAGE_TIP
)
}
Loading

0 comments on commit 0ad82fd

Please sign in to comment.