![]() | Fun 0.41.5 The programming language that makes You have fun |
Public API for parsing Fun source into bytecode. More...
#include "bytecode.h"

Go to the source code of this file.
Functions | |
| Bytecode * | parse_file_to_bytecode (const char *path) |
| Parse a .fun source file and compile it into a bytecode chunk. | |
| Bytecode * | parse_string_to_bytecode (const char *source) |
| Parse source from a provided string buffer (REPL/tests helper). | |
| int | parser_last_error (char *msgBuf, unsigned long msgCap, int *outLine, int *outCol) |
| Retrieve information about the last parser error, if any. | |
Public API for parsing Fun source into bytecode.
Definition in file parser.h.
| Bytecode * parse_file_to_bytecode | ( | const char * | path | ) |
Parse a .fun source file and compile it into a bytecode chunk.
The parser accepts an optional shebang on the first line and supports a minimal top-level or single-function program model. The returned bytecode will execute discovered statements (e.g., print) and then halt.
| path | Filesystem path to the .fun source file. Must be a null-terminated UTF-8 string. |
Parse a .fun source file and compile it into a bytecode chunk.
Reads the file, preprocesses includes (tracking original file paths), resets the global error state, and compiles to Bytecode while attaching source metadata (name, source_file).
| path | Filesystem path to the source file. |
Definition at line 7529 of file parser.c.


| Bytecode * parse_string_to_bytecode | ( | const char * | source | ) |
Parse source from a provided string buffer (REPL/tests helper).
| source | Null-terminated Fun program text. |
Parse source from a provided string buffer (REPL/tests helper).
Suitable for REPL or tests. Performs include preprocessing with no base path, compiles, and attaches generic source metadata.
| source | NUL-terminated source code string. |
Definition at line 7714 of file parser.c.


| int parser_last_error | ( | char * | msgBuf, |
| unsigned long | msgCap, | ||
| int * | outLine, | ||
| int * | outCol ) |
Retrieve information about the last parser error, if any.
| msgBuf | Output buffer to receive a human-readable error message. |
| msgCap | Capacity of msgBuf in bytes. |
| outLine | Optional output: 1-based line number where the error occurred. |
| outCol | Optional output: 1-based column number where the error occurred. |
Retrieve information about the last parser error, if any.
Copies the error message into msgBuf (truncated to msgCap-1), and returns the one-based line and column where available. If no error is pending, returns 0 and leaves outputs unchanged.
| msgBuf | Destination buffer for the error message (may be NULL). |
| msgCap | Capacity of msgBuf in bytes. |
| outLine | Optional out param for one-based line number. |
| outCol | Optional out param for one-based column number. |
Definition at line 7770 of file parser.c.
