]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/mathml_editor/src/TPushParser.hh
ocaml 3.09 transition
[helm.git] / helm / DEVEL / mathml_editor / src / TPushParser.hh
1 /* This file is part of EdiTeX, an editor of mathematical
2  * expressions based on TeX syntax.
3  * 
4  * Copyright (C) 2002-2003 Luca Padovani <lpadovan@cs.unibo.it>,
5  *                    2003 Paolo Marinelli <pmarinel@cs.unibo.it>.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  * For more information, please visit the project's home page
22  * http://helm.cs.unibo.it/editex/
23  * or send an email to <lpadovan@cs.unibo.it>
24  */
25
26 #ifndef __TPushParser_hh__
27 #define __TPushParser_hh__
28
29 #include <list>
30 #include <stack>
31 #include "TToken.hh"
32 #include "APushParser.hh"
33 #include "TDictionary.hh"
34 #include "TDocument.hh"
35 #include "TNode.hh"
36
37 class TPushParser : public APushParser
38 {
39 public:
40   TPushParser(class ALogger&, const class TDictionary&);
41   TPushParser(class ALogger&, class AMathMLFactory&, const class TDictionary&);
42   virtual ~TPushParser();
43
44   virtual void reset(void);
45   virtual void push(const TToken&);
46   virtual std::string drop(bool);
47   virtual void setCursorHint(const std::string&);
48   virtual bool hideCursor(void);
49   virtual bool showCursor(void);
50
51   virtual bool thaw(void);
52
53   DOM::Document document(void) const { return doc.document().cloneNode(true); }
54
55 private:
56   void init(void);
57
58   TNode PRIME(void);
59   bool isPrimes(const TNode&) const;
60   
61   bool do_begin(void);
62   bool do_end(void);
63   bool do_shift(void);
64   bool do_align(void);
65   bool do_eol(void);
66   bool do_parameter(const std::string&);
67   bool do_superscript(void);
68   bool do_subscript(void);
69   bool do_ignorablespace(const std::string&);
70   bool do_space(const std::string&);
71   bool do_letter(const std::string&);
72   bool do_digit(const std::string&);
73   bool do_other(const std::string&);
74   bool do_active(const std::string&);
75   bool do_comment(void);
76   bool do_control(const std::string&);
77   
78   std::string drop_prev_token(bool);
79   std::string drop_prev_script(bool);
80   std::string drop_prev_group(bool);
81   std::string drop_prev_macro(bool);
82   std::string drop_prev(bool);
83   void rgreplace_father(void);
84   std::string do_drop_script(bool);
85   std::string do_drop_macro(bool);
86   std::string do_drop_groupId(bool);
87   std::string do_drop_phantom_group(bool);
88   std::string do_drop(bool);
89
90   bool do_cr(void);
91   bool do_apostrophe(void);
92   void advance(const TNode&);
93   bool correctBrace(void);
94
95   bool process(const TToken&);
96
97   struct Frame
98   {
99     Frame(const TDictionary::Entry& e) : entry(e), pos(0) { };
100     Frame(const TDictionary::Entry&e, unsigned p) : entry(e), pos(p) { };
101     const TDictionary::Entry& entry;
102     unsigned pos;
103   };
104
105   std::stack<Frame> frames;
106   unsigned  nextId;
107   TDocument doc;
108   TNode     cursor;
109   unsigned  hiddenCursor;
110   const class TDictionary& dictionary;
111 };
112
113 #endif // __TPushParser_hh__