Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
parser_utils.c File Reference

Low-level parsing helpers and include preprocessor for the Fun parser. More...

#include "parser.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for parser_utils.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  StrBuf
 Simple growable string buffer. More...
struct  NameList
 List of exported symbol names discovered at top level. More...

Macros

#define DEFAULT_LIB_DIR   "/usr/share/fun/lib/"

Functions

char * preprocess_includes (const char *src)
 Public wrapper to preprocess includes without a current path.
char * preprocess_includes_with_path (const char *src, const char *current_path)
 Preprocess includes with a known file path to improve span markers.
int map_expanded_line_to_include_path (const char *path, int line, char *out_path, size_t out_path_cap, int *out_line)
 Map a line number in expanded source back to original include path/line.

Detailed Description

Low-level parsing helpers and include preprocessor for the Fun parser.

This module provides character scanners, token helpers, simple string/number literal readers, a lightweight include preprocessor that can expand include directives, and mapping utilities to translate expanded line numbers back to original files for diagnostics.

Definition in file parser_utils.c.

Macro Definition Documentation

◆ DEFAULT_LIB_DIR

#define DEFAULT_LIB_DIR   "/usr/share/fun/lib/"

Function Documentation

◆ map_expanded_line_to_include_path()

int map_expanded_line_to_include_path(const char *path,
intline,
char *out_path,
size_tout_path_cap,
int *out_line )

Map a line number in expanded source back to original include path/line.

Scans the expanded text for the nearest preceding __include_begin__ marker and computes the corresponding inner line number.

Parameters
pathPath to the original top-level file that was expanded.
line1-based line number in the expanded text.
out_pathOutput buffer for the resolved file path.
out_path_capCapacity of out_path.
out_lineReceives 1-based line number within resolved file.
Returns
1 on success, 0 on failure.

Definition at line 996 of file parser_utils.c.

Here is the call graph for this function:

◆ preprocess_includes()

char * preprocess_includes(const char *src)

Public wrapper to preprocess includes without a current path.

Definition at line 965 of file parser_utils.c.

Here is the caller graph for this function:

◆ preprocess_includes_with_path()

char * preprocess_includes_with_path(const char *src,
const char *current_path )

Preprocess includes with a known file path to improve span markers.

Definition at line 973 of file parser_utils.c.

Here is the caller graph for this function: