2025-09-16 02:11:22 +02:00
|
|
|
/**
|
|
|
|
|
* This file is part of the Fun programming language.
|
2025-10-09 01:59:19 +02:00
|
|
|
* https://fun-lang.xyz/
|
2025-09-16 02:11:22 +02:00
|
|
|
*
|
|
|
|
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
2025-09-30 22:52:12 +02:00
|
|
|
* Licensed under the terms of the Apache-2.0 license.
|
|
|
|
|
* https://opensource.org/license/apache-2-0
|
2025-09-16 02:11:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-13 23:50:01 +02:00
|
|
|
* Parse a .fun source file and compile it into entry bytecode.
|
|
|
|
|
* Minimal support:
|
|
|
|
|
* - Optional shebang on the first line.
|
|
|
|
|
* - Optional single function wrapper: fun <ident>() { ... }
|
|
|
|
|
* - print("...") statements inside function or at top-level.
|
2025-09-30 22:52:12 +02:00
|
|
|
* Produces bytecode that executes all dApache-2.0overed print statements and halts.
|
2025-09-13 23:50:01 +02:00
|
|
|
*
|
|
|
|
|
* Returns: newly allocated Bytecode*, or NULL on error.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef FUN_PARSER_H
|
|
|
|
|
#define FUN_PARSER_H
|
|
|
|
|
|
|
|
|
|
#include "bytecode.h"
|
|
|
|
|
|
|
|
|
|
Bytecode *parse_file_to_bytecode(const char *path);
|
|
|
|
|
|
2025-09-14 18:42:23 +02:00
|
|
|
/* Parse source provided as a single string buffer (for REPL, tests, etc.). */
|
|
|
|
|
Bytecode *parse_string_to_bytecode(const char *source);
|
|
|
|
|
|
2025-09-14 22:35:23 +02:00
|
|
|
/* Query the last parser error (1 if present, 0 if none). */
|
|
|
|
|
int parser_last_error(char *msgBuf, unsigned long msgCap, int *outLine, int *outCol);
|
|
|
|
|
|
2025-09-13 23:50:01 +02:00
|
|
|
#endif
|