Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
split.c
Go to the documentation of this file.
1/*
2 * This file is part of the Fun programming language.
3 * https://fun-lang.xyz/
4 *
5 * Copyright 2025 Johannes Findeisen <you@hanez.org>
6 * Licensed under the terms of the Apache-2.0 license.
7 * https://opensource.org/license/apache-2-0
8 */
9
34
35case OP_SPLIT: {
36 Value sep = pop_value(vm);
37 Value str = pop_value(vm);
38 if (str.type != VAL_STRING || sep.type != VAL_STRING) {
39 fprintf(stderr, "Runtime type error: SPLIT expects (string, string)\n");
40 exit(1);
41 }
42 Value out = bi_split(&str, &sep);
46 break;
47}
Value out
Definition apop.c:38
@ OP_SPLIT
Definition bytecode.h:101
Value str
Definition regex_match.c:41
free_value(str)
push_value(vm, out)
Value bi_split(const Value *str, const Value *sep)
Split a string by a separator into an array Value.
Definition string.c:37
Tagged union representing a Fun value.
Definition value.h:68
ValueType type
Definition value.h:69
@ VAL_STRING
Definition value.h:53
#define fprintf
Definition vm.c:200
#define exit(code)
Definition vm.c:230