Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement stdout and stderr #959

Merged
merged 1 commit into from
Nov 15, 2024
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
20 changes: 20 additions & 0 deletions alan/src/compile/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,26 @@ test_full!(print_compile_time_string => r#"
}"#;
stdout "FooBar\n";
);
test_full!(stdout_and_stderr => r#"
export fn main {
let hello = 'Hello';
let goodbye = 'Goodbye';
let comma = ', ';
let world = 'World';
let end = '!\n';

stdout(hello);
stdout(comma);
stdout(world);
stdout(end);
goodbye.stderr;
comma.stderr;
world.stderr;
end.stderr;
}"#;
stdout "Hello, World!\n";
stderr "Goodbye, World!\n";
);

// Basic Math Tests

Expand Down
5 changes: 5 additions & 0 deletions alan/src/std/root.ln
Original file line number Diff line number Diff line change
Expand Up @@ -4892,6 +4892,11 @@ export fn{Rs} eprint{T}(v: T!) = if({T}(v).exists,
fn = v.getOrExit.eprint,
fn = v.Error.getOrExit.eprint);

export fn{Rs} stdout "print!" :: ("{}", string);
export fn{Js} stdout "((s) => process.stdout.write(s.val))" :: string;
export fn{Rs} stderr "eprint!" :: ("{}", string);
export fn{Js} stderr "((s) => process.stderr.write(s.val))" :: string;

/// Built-in operator definitions
export infix add as + precedence 3;
export infix sub as - precedence 3;
Expand Down
Loading