Skip to main content

oak_prolog/ast/
mod.rs

1#![doc = include_str!("readme.md")]
2#[derive(Debug, Clone)]
3pub struct PrologRoot;
4
5pub type PrologToken = crate::lexer::PrologTokenType;
6
7#[derive(Debug, Clone)]
8pub struct SourceFile {
9    pub clauses: Vec<Clause>,
10}
11
12#[derive(Debug, Clone)]
13pub enum Clause {
14    Rule(Rule),
15    Fact(Fact),
16    Query(Query),
17    Directive(Directive),
18}
19
20#[derive(Debug, Clone)]
21pub struct Rule {
22    pub head: Term,
23    pub body: Term,
24}
25
26#[derive(Debug, Clone)]
27pub struct Fact {
28    pub term: Term,
29}
30
31#[derive(Debug, Clone)]
32pub struct Query {
33    pub term: Term,
34}
35
36#[derive(Debug, Clone)]
37pub struct Directive {
38    pub term: Term,
39}
40
41#[derive(Debug, Clone)]
42pub enum Term {
43    Atom(String),
44    Variable(String),
45    Number(String),
46    String(String),
47    Compound { functor: String, args: Vec<Term> },
48    List(Vec<Term>),
49}