summary refs log tree commit diff stats
path: root/lib/token.cpp
blob: facab8ad10ea1817067f3290add2c13a5e843937 (plain) (blame)
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
#include "verbly.h"

namespace verbly {
  
  token::token(token::type _type) : _type(_type)
  {
    
  }
  
  token::type token::token_type() const
  {
    return _type;
  }
  
  verb_token::verb_token(const verb& _verb) : token(token::type::verb), _verb(&_verb)
  {
    
  }
  
  const verb& verb_token::get_verb() const
  {
    return *_verb;
  }
  
  verb_token& verb_token::inflect(verb_token::inflection infl)
  {
    _inflection = infl;
    return *this;
  }
  
  bool verb_token::complete() const
  {
    return true;
  }
  
  std::string verb_token::compile() const
  {
    switch (_inflection)
    {
      case inflection::infinitive: return _verb->infinitive_form();
      case inflection::past_tense: return _verb->past_tense_form();
      case inflection::past_participle: return _verb->past_participle_form();
      case inflection::ing_form: return _verb->ing_form();
      case inflection::s_form: return _verb->s_form();
    }
  }
  
  token* verb_token::copy() const
  {
    return new verb_token(*this);
  }
  
};