Skip to main content

oak_prolog/ast/
mod.rs

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