1 /*++
2 Copyright (c) 2011 Microsoft Corporation
3
4 Module Name:
5
6 ast_lt.h
7
8 Abstract:
9
10 Total order on ASTs that does not depend on the internal ids.
11
12 Author:
13
14 Leonardo de Moura (leonardo) 2011-04-08
15
16 Revision History:
17
18 --*/
19 #pragma once
20
21 class ast;
22
23 bool lt(ast * n1, ast * n2);
24 bool is_sorted(unsigned num, expr * const * ns);
25
26 struct ast_to_lt {
operatorast_to_lt27 bool operator()(ast * n1, ast * n2) const { return lt(n1, n2); }
28 };
29
30 struct ast_lt {
operatorast_lt31 bool operator()(ast * n1, ast * n2) const { return n1->get_id() < n2->get_id(); }
32 };
33
34 bool lex_lt(unsigned num, ast * const * n1, ast * const * n2);
lex_lt(unsigned num,expr * const * n1,expr * const * n2)35 inline bool lex_lt(unsigned num, expr * const * n1, expr * const * n2) {
36 return lex_lt(num, reinterpret_cast<ast*const*>(n1), reinterpret_cast<ast*const*>(n2));
37 }
38
39