vos_ast/ast/table/
mod.rs

1use super::*;
2
3impl Default for TableKind {
4    fn default() -> Self {
5        Self::Table
6    }
7}
8
9impl Default for GenericStatement {
10    fn default() -> Self {
11        Self::Nothing
12    }
13}
14
15impl TableStatement {
16    pub fn add_field(&mut self, field: FieldStatement) -> Result<(), FieldStatement> {
17        match self.fields.insert(field.name.to_string(), field) {
18            None => Ok(()),
19            Some(s) => Err(s),
20        }
21    }
22    pub fn add_constraint(&mut self, constraint: ConstraintStatement) {
23        self.constraints.insert(constraint.name.to_string(), constraint);
24    }
25}
26
27impl FieldStatement {}
28
29impl GenericStatement {
30    pub fn operator(order: Ordering, inclusive: bool) -> char {
31        match order {
32            Ordering::Less if inclusive => '⩽',
33            Ordering::Less => '<',
34            Ordering::Equal => '=',
35            Ordering::Greater if inclusive => '⩾',
36            Ordering::Greater => '>',
37        }
38    }
39}
40
41impl Namespace {
42    pub fn new(name: String, range: Range<u32>) -> Self {
43        Self { scope: vec![Identifier { id: name, range }] }
44    }
45    pub fn push_identifier(&mut self, name: String, range: Range<u32>) {
46        self.scope.push(Identifier { id: name, range })
47    }
48}
49
50impl Identifier {}