1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use crate::syntax;
use super::*;

type Result = crate::syntax::display::Result;

impl syntax::Display for Model {
	fn fmt(&self, f: &mut syntax::Formatter) -> Result {
		f.tabulated_list(&self.definitions)
	}
}

impl syntax::Display for Definition {
	fn fmt(&self, f: &mut syntax::Formatter) -> Result {
		f.comments(&self.comments)?;
		f.begin()?;

		if self.rec {
			if self.declarations.len() == 1 {
				f.keyword("define-fun-rec")?;
				let decl = &self.declarations[0];

				f.symbol(&decl.id)?;
				f.list(&decl.args)?;
				decl.return_sort.fmt(f)?;

				let body = &self.bodies[0];
				body.fmt(f)?;
			} else {
				f.keyword("define-funs-rec")?;

				f.tabulated_list(&self.declarations)?;
				f.tabulated_list(&self.bodies)?;
			}
		} else {
			f.keyword("define-fun")?;

			let decl = &self.declarations[0];

			f.symbol(&decl.id)?;
			f.list(&decl.args)?;
			decl.return_sort.fmt(f)?;

			let body = &self.bodies[0];
			body.fmt(f)?;
		}

		f.end()
	}
}

impl syntax::Display for Declaration {
	fn fmt(&self, f: &mut syntax::Formatter) -> Result {
		f.begin()?;
		f.symbol(&self.id)?;
		f.list(&self.args)?;
		self.return_sort.fmt(f)?;
		f.end()
	}
}