From f761deff2f2f8c0cce674d2885b22a94a972ea85 Mon Sep 17 00:00:00 2001 From: Paolo Marinelli Date: Thu, 9 Jan 2003 16:13:59 +0000 Subject: [PATCH] * code cleanup * removed useless source files --- helm/DEVEL/mathml_editor/src/Ptr.hh | 53 -------- helm/DEVEL/mathml_editor/src/TCharStream.hh | 20 --- .../mathml_editor/src/TCharStreamString.hh | 22 ---- helm/DEVEL/mathml_editor/src/TLexerPull.cc | 35 ------ helm/DEVEL/mathml_editor/src/TLexerPush.cc | 82 ------------- helm/DEVEL/mathml_editor/src/TLexerPush.hh | 31 ----- helm/DEVEL/mathml_editor/src/TObject.hh | 16 --- helm/DEVEL/mathml_editor/src/TPushParser.cc | 2 +- helm/DEVEL/mathml_editor/src/TPushParser.hh | 2 +- helm/DEVEL/mathml_editor/src/domnav.cc | 115 ------------------ helm/DEVEL/mathml_editor/src/special.cc | 62 ---------- helm/DEVEL/mathml_editor/src/texlexer.cc | 26 ---- helm/DEVEL/mathml_editor/src/tokenizer.hh | 10 -- helm/DEVEL/mathml_editor/test/guiGTK.c | 2 +- helm/DEVEL/mathml_editor/test/guiGTK.h | 2 +- 15 files changed, 4 insertions(+), 476 deletions(-) delete mode 100644 helm/DEVEL/mathml_editor/src/Ptr.hh delete mode 100644 helm/DEVEL/mathml_editor/src/TCharStream.hh delete mode 100644 helm/DEVEL/mathml_editor/src/TCharStreamString.hh delete mode 100644 helm/DEVEL/mathml_editor/src/TLexerPull.cc delete mode 100644 helm/DEVEL/mathml_editor/src/TLexerPush.cc delete mode 100644 helm/DEVEL/mathml_editor/src/TLexerPush.hh delete mode 100644 helm/DEVEL/mathml_editor/src/TObject.hh delete mode 100644 helm/DEVEL/mathml_editor/src/domnav.cc delete mode 100644 helm/DEVEL/mathml_editor/src/special.cc delete mode 100644 helm/DEVEL/mathml_editor/src/texlexer.cc delete mode 100644 helm/DEVEL/mathml_editor/src/tokenizer.hh diff --git a/helm/DEVEL/mathml_editor/src/Ptr.hh b/helm/DEVEL/mathml_editor/src/Ptr.hh deleted file mode 100644 index 9330c96cf..000000000 --- a/helm/DEVEL/mathml_editor/src/Ptr.hh +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2000-2002, Luca Padovani . -// -// This file is part of GtkMathView, a Gtk widget for MathML. -// -// GtkMathView is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// GtkMathView is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GtkMathView; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// For details, see the GtkMathView World-Wide-Web page, -// http://www.cs.unibo.it/helm/mml-widget, or send a mail to -// - -#ifndef Ptr_hh -#define Ptr_hh - -template -class Ptr -{ -public: - Ptr(P* p = 0) : ptr(p) { if (ptr != 0) ptr->ref(); } - Ptr(const Ptr& p) : ptr(p.ptr) { if (ptr != 0) ptr->ref(); } - ~Ptr() { if (ptr != 0) ptr->unref(); } - - P* operator->() const { assert(ptr != 0); return ptr; } - Ptr& operator=(const Ptr& p) - { - if (ptr == p.ptr) return *this; - if (p.ptr != 0) p.ptr->ref(); - if (ptr != 0) ptr->unref(); - ptr = p.ptr; - return *this; - } - - operator P*() const { return ptr; } - template friend Ptr smart_cast(const Ptr& p) { return Ptr(dynamic_cast(p.ptr)); } - template friend bool is_a(const Ptr& p) { return dynamic_cast(p.ptr) != 0; } - template operator Ptr() const { return Ptr(ptr); } - -private: - P* ptr; -}; - -#endif // Ptr_hh diff --git a/helm/DEVEL/mathml_editor/src/TCharStream.hh b/helm/DEVEL/mathml_editor/src/TCharStream.hh deleted file mode 100644 index 47b01ffe7..000000000 --- a/helm/DEVEL/mathml_editor/src/TCharStream.hh +++ /dev/null @@ -1,20 +0,0 @@ - -#ifndef __TCharStream_hh__ -#define __TCharStream_hh__ - -#include "dom.hh" - -class TCharStream -{ -public: - TCharStream(void) { }; - virtual ~TCharStream() { }; - - virtual bool more(void) const = 0; - virtual TChar look(void) const = 0; - virtual TChar next(void) = 0; - - class EmptyStream { }; -}; - -#endif // __TCharStream_hh__ diff --git a/helm/DEVEL/mathml_editor/src/TCharStreamString.hh b/helm/DEVEL/mathml_editor/src/TCharStreamString.hh deleted file mode 100644 index 36306272b..000000000 --- a/helm/DEVEL/mathml_editor/src/TCharStreamString.hh +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef __TCharStreamString_hh__ -#define __TCharStreamString_hh__ - -#include "TCharStream.hh" - -class TCharStreamString : public TCharStream -{ -public: - TCharStreamString(const TString& s) : buffer(s), idx(0) { }; - virtual ~TCharStreamString() { }; - - virtual bool more(void) const { return idx < buffer.length(); }; - virtual TChar look(void) const { if (more()) return buffer[idx]; else throw EmptyStream(); }; - virtual TChar next(void) { if (more()) return buffer[idx++]; else throw EmptyStream(); }; - -private: - unsigned long idx; - TString buffer; -}; - -#endif // __TCharStreamString_hh__ diff --git a/helm/DEVEL/mathml_editor/src/TLexerPull.cc b/helm/DEVEL/mathml_editor/src/TLexerPull.cc deleted file mode 100644 index 0eb3a3c5a..000000000 --- a/helm/DEVEL/mathml_editor/src/TLexerPull.cc +++ /dev/null @@ -1,35 +0,0 @@ - -#include "TCharStream.hh" -#include "TCharStreamString.hh" - -TToken -TLexerPull::pop(TCharStream& stream) -{ - if (stream.more()) - { - TChar ch = stream.next(); - if (ch == '\\') - { - if (stream.more()) - { - if (isUnicodeAlpha(stream.look())) - { - TString s; - while (stream.more() && isUnicodeAlpha(stream.look())) - s.push_back(stream.next()); - TToken res(TToken::CONTROL, s); - while (stream.more() && isUnicodeSpace(stream.look())) - stream.next(); - return res; - } - else - return TToken(TToken::CONTROL, TString(1, stream.next())); - } - else - return TToken(TToken::INVALID_CHAR, TString(1, ch)); - } - else return TToken(ch); - } - else return TToken(TToken::END_OF_BUFFER); -} - diff --git a/helm/DEVEL/mathml_editor/src/TLexerPush.cc b/helm/DEVEL/mathml_editor/src/TLexerPush.cc deleted file mode 100644 index 6b2acae7c..000000000 --- a/helm/DEVEL/mathml_editor/src/TLexerPush.cc +++ /dev/null @@ -1,82 +0,0 @@ - -#include "TLexerPush.hh" - -TLexerPush::TLexerPush() -{ - state = ACCEPT; -} - -TToken -TLexerPush::pop() -{ - if (tokens.empty()) throw EmptyBuffer(); - else - { - TToken res = tokens.front(); - tokens.pop_front(); - if (tokens.size() == 1 && state == CONTROL) state = ACCEPT; - return res; - } -} - -TToken -TLexerPush::front() const -{ - if (tokens.empty()) throw EmptyBuffer(); - else return tokens.front(); -} - -bool -TLexerPush::empty() const -{ - return tokens.empty(); -} - -bool -TLexerPush::pending() const -{ - return state == ESCAPE; -} - -bool -TLexerPush::ambiguous() const -{ - return tokens.size() == 1 && state == CONTROL; -} - -void -TLexerPush::push(TChar ch) -{ - switch (state) - { - case ACCEPT: - if (ch == '\\') state = ESCAPE; - else tokens.push_back(TToken(ch)); - break; - case ESCAPE: - tokens.push_back(TToken(TToken::CONTROL, std::string(1, ch))); - if (isUnicodeAlpha(ch)) state = CONTROL; - else state = ACCEPT; - break; - case CONTROL: - if (ch == '\\') state = ESCAPE; - else if (isUnicodeAlpha(ch)) - { - assert(!tokens.empty()); - TToken& tok = tokens.back(); - tok.value.push_back(ch); - } - else if (isUnicodeSpace(ch)) state = IGNORE_SPACE; - else - { - tokens.push_back(TToken(ch)); - state = ACCEPT; - } - break; - case IGNORE_SPACE: - if (ch == '\\') state = ESCAPE; - else if (isUnicodeSpace(ch)) ; - else tokens.push_back(TToken(ch)); - break; - } -} diff --git a/helm/DEVEL/mathml_editor/src/TLexerPush.hh b/helm/DEVEL/mathml_editor/src/TLexerPush.hh deleted file mode 100644 index f47def495..000000000 --- a/helm/DEVEL/mathml_editor/src/TLexerPush.hh +++ /dev/null @@ -1,31 +0,0 @@ - -#include - -#include "TToken.hh" - -class TLexerPush -{ -public: - TLexerPush(void); - - void push(TChar); - TToken pop(void); - TToken front(void) const; - bool ambiguous(void) const; - bool pending(void) const; - bool empty(void) const; - - class EmptyBuffer { }; - -private: - enum State - { - ACCEPT, - ESCAPE, - CONTROL, - IGNORE_SPACE - }; - - State state; - std::deque tokens; -}; diff --git a/helm/DEVEL/mathml_editor/src/TObject.hh b/helm/DEVEL/mathml_editor/src/TObject.hh deleted file mode 100644 index c4b4e9e3f..000000000 --- a/helm/DEVEL/mathml_editor/src/TObject.hh +++ /dev/null @@ -1,16 +0,0 @@ - -#ifndef __TObject_hh__ -#define __TObject_hh__ - -class TObject -{ -protected: - TObject(void) { refCounter = 1; }; - virtual ~TObject() { }; - -public: - void ref(coid) const { refCounter++; }; - void unref(void) const { if (--refCounter) delete this; }; -}; - -#endif // __TObject_hh__ diff --git a/helm/DEVEL/mathml_editor/src/TPushParser.cc b/helm/DEVEL/mathml_editor/src/TPushParser.cc index ea82cf379..20bb897b7 100644 --- a/helm/DEVEL/mathml_editor/src/TPushParser.cc +++ b/helm/DEVEL/mathml_editor/src/TPushParser.cc @@ -254,7 +254,7 @@ TPushParser::do_space(const std::string&) void TPushParser::do_letter(const std::string& s) { - TNode parent = cursor.parent(); + //TNode parent = cursor.parent(); TNode elem = doc.createI(s, nextId++); cursor.replace(elem); advance(elem); diff --git a/helm/DEVEL/mathml_editor/src/TPushParser.hh b/helm/DEVEL/mathml_editor/src/TPushParser.hh index bb659c3d2..c104eb28c 100644 --- a/helm/DEVEL/mathml_editor/src/TPushParser.hh +++ b/helm/DEVEL/mathml_editor/src/TPushParser.hh @@ -58,7 +58,7 @@ private: }; std::stack frames; - std::list buffer; + //std::list buffer; unsigned nextId; TDocument doc; TNode cursor; diff --git a/helm/DEVEL/mathml_editor/src/domnav.cc b/helm/DEVEL/mathml_editor/src/domnav.cc deleted file mode 100644 index 720aeb952..000000000 --- a/helm/DEVEL/mathml_editor/src/domnav.cc +++ /dev/null @@ -1,115 +0,0 @@ - -DOM::Element -getRightmostChild(const DOM::Element& p) -{ - if (p) - { - if (DOM::Element last = g.get_lastChild()) - if (last.get_nodeName() == "g" && last.get_firstChild()) - return getRightmostChild(last); - else - return last; - else - return 0; - } - else - return 0; -} - -DOM::Element -prevLinearSibling(const DOM::Element& p) -{ - if (p) - { - DOM::Element prev = p.get_prevSibling(); - if (!prev) return 0; - else if (prev.get_nodeName() != "g" && prev.get_firstChild()) return prev; - else return prevLinearSibling(prev.get_lastChild()); - } - else - return 0; -} - -DOM::Element -getCore(const DOM::Element& p) -{ - if (p) - { - if (p.get_nodeName() == "sb" || p.get_nodeName() == "sp") - return getCore(p.get_firstChild()); - else return p; - } - else - return 0; -} - -void -replace(const DOM::Element& p0, const DOM::Element& p1) -{ - if (DOM::Element parent = p0.get_parentNode()) - parent.replaceChild(p0, p1); -} - -bool -isInferred(const DOM::Element& p) -{ - if (p) return p.hasAttribute("id"); - else return false; -} - -bool -isMacro(const DOM::Element& p, const TString& s) -{ - return p && p.get_nodeName() == "m" && p.getAttribute("name") == s; -} - -bool -isGroup(const DOM::Element& p) -{ - return p && p.get_nodeName() == "g"; -} - -bool -isSb(const DOM::Element& p) -{ - return p && p.get_nodeName() == "sb"; -} - -bool -isSp(const DOM::Element& p) -{ - return p && p.get_nodeName() == "sp"; -} - -bool -isPrimes(const DOM::Element& p) -{ - return isGroup(p) && isMacro(p.get_lastChild, "prime"); -} - -bool -isOperator(const DOM::Element& p) -{ - if (DOM::Element core = getCore(p)) - return dictionary.isOperator(core.get_nodeName()); - else - return false; -} - -bool -isDelimiter(const DOM::Element& p) -{ - if (DOM::Element core = getCore(p)) - return dictionary.isDelimiter(core.get_nodeName()); - else - return false; -} - -bool -isFunction(const DOM::Element& p) -{ - if (DOM::Element core = getCore(p)) - return dictionary.isFunction(core.get_nodeName()); - else - return false; -} diff --git a/helm/DEVEL/mathml_editor/src/special.cc b/helm/DEVEL/mathml_editor/src/special.cc deleted file mode 100644 index d794ffd81..000000000 --- a/helm/DEVEL/mathml_editor/src/special.cc +++ /dev/null @@ -1,62 +0,0 @@ - -#include - -#include "dom.hh" -#include "globals.hh" -#include "TNode.hh" -#include "TToken.hh" - -void finishG(const TNode&); - -void -do_bgroup(const TNode& cursor) -{ - TNode parent = cursor.parent(); - if (parent.isM("matrix") || parent.isM("pmatrix") || - parent.isM("bordermatrix") || parent.isM("cases")) - { - TNode row = cursor.create("row"); - TNode cell = cursor.create("cell"); - TNode g = cursor.createG(); - row.append(cell); - cell.append(g); - g.append(cursor); - parent.append(row); - } - else - { - TNode g = cursor.createG(); - cursor.replace(g); - g.append(cursor); - } -} - - - - -void -do_apostrophe(const TNode& cursor) -{ -} - -void -do_control(const TNode& cursor, const std::string& name) -{ -} - -void -do_other(const TNode& cursor, const std::string& s) -{ - switch (s[0]) - { - case '\'': do_apostrophe(cursor); break; - default: - if (isUnicodeDigit(s[0])) do_number(cursor, s); - else do_control(cursor, s); - } -} - -void -dispatch(const TNode& cursor, const TToken& token) -{ - diff --git a/helm/DEVEL/mathml_editor/src/texlexer.cc b/helm/DEVEL/mathml_editor/src/texlexer.cc deleted file mode 100644 index f06273214..000000000 --- a/helm/DEVEL/mathml_editor/src/texlexer.cc +++ /dev/null @@ -1,26 +0,0 @@ - -#include "dom.hh" -#include "TLexerPush.hh" - -main() -{ - std::string s; - while (getline(std::cin, s)) - { - TLexerPush lexer; - for (unsigned long i = 0; i < s.length(); i++) - { - lexer.push(s[i]); - cout << "pending: " << lexer.pending() - << " amb: " << lexer.ambiguous(); - if (!lexer.empty()) - { - TToken tok = lexer.front(); - DOM::GdomeString v(tok.value); - cout << " cat: " << tok.category << " value: " << v << " length: " << v.length(); - if (!lexer.ambiguous()) lexer.pop(); - } - cout << endl; - } - } -} diff --git a/helm/DEVEL/mathml_editor/src/tokenizer.hh b/helm/DEVEL/mathml_editor/src/tokenizer.hh deleted file mode 100644 index 06731b91f..000000000 --- a/helm/DEVEL/mathml_editor/src/tokenizer.hh +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef __tokenzier_hh__ -#define __tokenzier_hh__ - -#include -#include - -std::vector tokenize(const std::string&); - -#endif // __tokenzier_hh__ diff --git a/helm/DEVEL/mathml_editor/test/guiGTK.c b/helm/DEVEL/mathml_editor/test/guiGTK.c index 53bbd7410..7b58ffbe8 100644 --- a/helm/DEVEL/mathml_editor/test/guiGTK.c +++ b/helm/DEVEL/mathml_editor/test/guiGTK.c @@ -3,7 +3,7 @@ #include #include -#include "gtkmathview.h" +#include #include "guiGTK.h" #define XLINK_NS_URI "http://www.w3.org/1999/xlink" diff --git a/helm/DEVEL/mathml_editor/test/guiGTK.h b/helm/DEVEL/mathml_editor/test/guiGTK.h index 71475541c..61f802272 100644 --- a/helm/DEVEL/mathml_editor/test/guiGTK.h +++ b/helm/DEVEL/mathml_editor/test/guiGTK.h @@ -27,7 +27,7 @@ #include -#include "gtkmathview.h" +#include #ifdef __cplusplus extern "C" { -- 2.39.2