-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- WASM - Fixes
- Loading branch information
Showing
15 changed files
with
306 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*/.vscode | ||
/target | ||
/release | ||
*fplc* | ||
*fplc* | ||
/pkg |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} |
Oops, something went wrong.