pub struct Parser<'a> { /* private fields */ }Expand description
Parser for Edinburgh Prolog syntax. Parses tokens into Terms and Clauses, with variable scoping per clause.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn parse_program_cg(
input: &str,
interner: &'a mut StringInterner,
file_id: FileId,
) -> Result<(Vec<CgClause>, ProgramDirectives), ParseError>
pub fn parse_program_cg( input: &str, interner: &'a mut StringInterner, file_id: FileId, ) -> Result<(Vec<CgClause>, ProgramDirectives), ParseError>
Parse a complete program for codegen, stamping file_id on every body
goal span (SPANS.md Layer 3). Mirrors parse_program_with_directives;
only the body representation differs.
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn parse_program(
input: &str,
interner: &mut StringInterner,
) -> Result<Vec<Clause>, ParseError>
pub fn parse_program( input: &str, interner: &mut StringInterner, ) -> Result<Vec<Clause>, ParseError>
Parse a complete program (multiple clauses) from source text.
Directives (:- ...) are recognized and skipped — use
parse_program_with_directives to capture them.
Sourcepub fn parse_program_with_directives(
input: &str,
interner: &mut StringInterner,
) -> Result<(Vec<Clause>, ProgramDirectives), ParseError>
pub fn parse_program_with_directives( input: &str, interner: &mut StringInterner, ) -> Result<(Vec<Clause>, ProgramDirectives), ParseError>
Parse a complete program, returning both clauses and any directives
(currently :- dynamic(F/A).). The compile pipeline uses this so the
directive information reaches the database.
Sourcepub fn parse_program_with_spans(
input: &str,
interner: &mut StringInterner,
) -> Result<(Vec<Clause>, ProgramDirectives, Vec<CallSite>), ParseError>
pub fn parse_program_with_spans( input: &str, interner: &mut StringInterner, ) -> Result<(Vec<Clause>, ProgramDirectives, Vec<CallSite>), ParseError>
Like parse_program_with_directives, but also returns the atom-functor
call-site occurrences (see super::CallSite) for the LSP to map
undefined-predicate warnings onto precise source ranges.
Sourcepub fn parse_query(
input: &str,
interner: &mut StringInterner,
) -> Result<Vec<Term>, ParseError>
pub fn parse_query( input: &str, interner: &mut StringInterner, ) -> Result<Vec<Term>, ParseError>
Parse a single query (goal list) from source text, e.g. “parent(tom, X)”. Does NOT require a trailing dot.
Sourcepub fn parse_query_with_vars(
input: &str,
interner: &mut StringInterner,
) -> Result<(Vec<Term>, HashMap<String, VarId>), ParseError>
pub fn parse_query_with_vars( input: &str, interner: &mut StringInterner, ) -> Result<(Vec<Term>, HashMap<String, VarId>), ParseError>
Parse a query and also return the variable name mapping.