Skip to content

PromptScript API


Function: parseFileOrThrow()

parseFileOrThrow(filePath, options): Program

Defined in: parser/src/parse.ts:220

Parse a PromptScript file from disk, throwing on error.

Parameters

filePath

string

Path to the .prs file

options

Omit\<ParseOptions, "filename"> = {}

Parsing options

Returns

Program

The parsed Program AST

Throws

If reading or parsing fails

Example

try {
  const ast = parseFileOrThrow('./project.prs');
  console.log(ast.meta?.fields.id);
} catch (error) {
  console.error('Failed:', error);
}