]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/mathml_editor/src/ITPushLexer.cc
better dependencies among modules and symlinking of several matitatools to a single...
[helm.git] / helm / DEVEL / mathml_editor / src / ITPushLexer.cc
1 #include <list>
2 #include <string>
3
4 #include "ALogger.hh"
5 #include "TToken.hh"
6 #include "ITPushLexer.hh"
7 #include "APushParser.hh"
8 #include "TDictionary.hh"
9
10 ITPushLexer::ITPushLexer(ALogger& l, APushParser& p, TDictionary& d) : TPushLexer(l, p), dictionary(d)
11 {
12   state = ACCEPT;
13 }
14
15 bool
16 ITPushLexer::complete()
17 {
18   if (state == MACRO)
19     {
20       std::list<std::string> complete_list;
21       std::string new_buffer = dictionary.complete(buffer, complete_list);
22
23       if (!complete_list.size())
24         {
25           // no matching macro
26           logger.warning("wrong prefix: nothing to complete");
27         }
28       else if (complete_list.size() == 1)
29         {
30           // good! we have found the macro
31           buffer = new_buffer;
32         }
33       else
34         {
35           // we have more than one matching macro
36           logger.warning("prefix not sufficient");
37           buffer = new_buffer;
38         }
39
40       displayCursor();
41       return true;
42     }
43   else return false;
44 }