From: Paolo Marinelli Date: Thu, 13 Mar 2003 18:20:08 +0000 (+0000) Subject: Added the completion of the macro's name. X-Git-Tag: before_refactoring~120 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=98e5817ce4fa424fb3181d90d327935c1b100ec4;p=helm.git Added the completion of the macro's name. To meet this goal, the abstract lexer has a new method: complete. T(L)PushLexer doesn't implement this method. But there are two additional classes: ITPushLexer and ILPushLexer. These are derived from TPushLexer and LPushLexer. The only difference between the derived classes and their parents is the implementation of the method complete. TDictionary has a new method: complete. It's used by the lexers. Now, in LPushLexer, long identifiers can be composed by these additional character: '-' and '_'. To insert them as part of long identifiers, the user has escape them with '\'. Added a new node in the TML tree. It' name is 's' and represents a space. It can be pushed only with a LPushLexer. --- diff --git a/helm/DEVEL/mathml_editor/Makefile.in b/helm/DEVEL/mathml_editor/Makefile.in new file mode 100644 index 000000000..b66feab8e --- /dev/null +++ b/helm/DEVEL/mathml_editor/Makefile.in @@ -0,0 +1,438 @@ +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EDITEX_VERSION_INFO = @EDITEX_VERSION_INFO@ +EXEEXT = @EXEEXT@ +GDOMEXSLT_CFLAGS = @GDOMEXSLT_CFLAGS@ +GDOMEXSLT_LIBS = @GDOMEXSLT_LIBS@ +GMETADOM_CFLAGS = @GMETADOM_CFLAGS@ +GMETADOM_LIBS = @GMETADOM_LIBS@ +GTKMATHVIEW_CFLAGS = @GTKMATHVIEW_CFLAGS@ +GTKMATHVIEW_LIBS = @GTKMATHVIEW_LIBS@ +HAVE_OCAMLC = @HAVE_OCAMLC@ +HAVE_OCAMLDEP = @HAVE_OCAMLDEP@ +HAVE_OCAMLFIND = @HAVE_OCAMLFIND@ +HAVE_OCAMLMKLIB = @HAVE_OCAMLMKLIB@ +HAVE_OCAMLOPT = @HAVE_OCAMLOPT@ +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MLGDOME_CFLAGS = @MLGDOME_CFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCAMLC = @OCAMLC@ +OCAMLDEP = @OCAMLDEP@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = @OCAMLMKLIB@ +OCAMLOPT = @OCAMLOPT@ +OCAMLSTDLIBDIR = @OCAMLSTDLIBDIR@ +OCAMLSTUBDIR = @OCAMLSTUBDIR@ +OCAML_INCLUDE_DIR = @OCAML_INCLUDE_DIR@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +EXTRA_DIST = BUGS LICENSE aclocal.m4 +SUBDIRS = src test ocaml textomml +CLEANFILES = core + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = editex.pc +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = editex.pc +DATA = $(pkgconfig_DATA) + +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ +Makefile.am Makefile.in NEWS TODO aclocal.m4 config.guess config.h.in \ +config.sub configure configure.ac editex.pc.in install-sh ltmain.sh \ +missing mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.ac + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure.ac $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @echo timestamp > stamp-h 2> /dev/null +$(srcdir)/config.h.in: $(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: +editex.pc: $(top_builddir)/config.status editex.pc.in + cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir) + @list='$(pkgconfig_DATA)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p; \ + else if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p; \ + fi; fi; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + list='$(pkgconfig_DATA)'; for p in $$list; do \ + rm -f $(DESTDIR)$(pkgconfigdir)/$$p; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist + -rm -rf $(distdir) + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +all-recursive-am: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +install-exec-am: +install-exec: install-exec-recursive + +install-data-am: install-pkgconfigDATA +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: uninstall-pkgconfigDATA +uninstall: uninstall-recursive +all-am: Makefile $(DATA) config.h +all-redirect: all-recursive-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir) + + +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-hdr clean-tags clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-hdr distclean-tags distclean-generic clean-am + -rm -f libtool + +distclean: distclean-recursive + -rm -f config.status + +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + -rm -f config.status + +.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +uninstall-pkgconfigDATA install-pkgconfigDATA install-data-recursive \ +uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +backup: + cd ..; tar cvfz @PACKAGE@-@VERSION@-`date|tr ' ' '_'|tr ':' '_'`.tar.gz @PACKAGE@ + +cleanbak: + -rm -f `find . -name "*~"` + +lc: + @( \ + CFILES=`find . -name "*.c"`; \ + HFILES=`find . -name "*.h"`; \ + CCFILES=`find . -name "*.cc"`; \ + HHFILES=`find . -name "*.hh"`; \ + ICCFILES=`find . -name "*.icc"`; \ + wc -l $$CFILES $$HFILES $$CCFILES $$HHFILES $$ICCFILES | tail -n 1 \ + ) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/helm/DEVEL/mathml_editor/TML.dtd b/helm/DEVEL/mathml_editor/TML.dtd index dcff7abad..74760bb45 100644 --- a/helm/DEVEL/mathml_editor/TML.dtd +++ b/helm/DEVEL/mathml_editor/TML.dtd @@ -1,5 +1,5 @@ - + + + diff --git a/helm/DEVEL/mathml_editor/dictionary-test.xml b/helm/DEVEL/mathml_editor/dictionary-test.xml index adbc0dfd3..94190888d 100644 --- a/helm/DEVEL/mathml_editor/dictionary-test.xml +++ b/helm/DEVEL/mathml_editor/dictionary-test.xml @@ -34,5 +34,6 @@ + diff --git a/helm/DEVEL/mathml_editor/src/APushLexer.hh b/helm/DEVEL/mathml_editor/src/APushLexer.hh index 0259ed603..4a2940b4c 100644 --- a/helm/DEVEL/mathml_editor/src/APushLexer.hh +++ b/helm/DEVEL/mathml_editor/src/APushLexer.hh @@ -34,6 +34,7 @@ public: virtual void push(char) = 0; virtual void drop(bool) = 0; + virtual bool complete(void) = 0; virtual void reset(void) = 0; virtual bool error(void) const = 0; diff --git a/helm/DEVEL/mathml_editor/src/ILPushLexer.cc b/helm/DEVEL/mathml_editor/src/ILPushLexer.cc new file mode 100644 index 000000000..8a2777fef --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/ILPushLexer.cc @@ -0,0 +1,45 @@ + +#include +#include + +#include "ALogger.hh" +#include "TToken.hh" +#include "ILPushLexer.hh" +#include "APushParser.hh" +#include "TDictionary.hh" + +ILPushLexer::ILPushLexer(ALogger& l, APushParser& p, TDictionary& d) : LPushLexer(l, p), dictionary(d) +{ + state = ACCEPT; +} + +bool +ILPushLexer::complete() +{ + if (state == MACRO) + { + std::list complete_list; + std::string new_buffer = dictionary.complete(buffer, complete_list); + + if (!complete_list.size()) + { + // no matching macro + logger.warning("wrong prefix: nothing to complete"); + } + else if (complete_list.size() == 1) + { + // good! we have found the macro + buffer = new_buffer; + } + else + { + // we have more than one matching macro + logger.warning("prefix not sufficient"); + buffer = new_buffer; + } + + displayCursor(); + return true; + } + else return false; +} diff --git a/helm/DEVEL/mathml_editor/src/ILPushLexer.hh b/helm/DEVEL/mathml_editor/src/ILPushLexer.hh new file mode 100644 index 000000000..1af6f93ea --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/ILPushLexer.hh @@ -0,0 +1,21 @@ + +#ifndef __ILPushLexer_hh__ +#define __ILPushLexer_hh__ + +#include + +#include "LPushLexer.hh" + +class ILPushLexer : public LPushLexer +{ +public: + ILPushLexer(class ALogger&, class APushParser&, class TDictionary&); + ~ILPushLexer(void) { }; + + virtual bool complete(void); + +protected: + class TDictionary& dictionary; +}; + +#endif diff --git a/helm/DEVEL/mathml_editor/src/ITPushLexer.cc b/helm/DEVEL/mathml_editor/src/ITPushLexer.cc new file mode 100644 index 000000000..b4d1b6c12 --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/ITPushLexer.cc @@ -0,0 +1,44 @@ +#include +#include + +#include "ALogger.hh" +#include "TToken.hh" +#include "ITPushLexer.hh" +#include "APushParser.hh" +#include "TDictionary.hh" + +ITPushLexer::ITPushLexer(ALogger& l, APushParser& p, TDictionary& d) : TPushLexer(l, p), dictionary(d) +{ + state = ACCEPT; +} + +bool +ITPushLexer::complete() +{ + if (state == MACRO) + { + std::list complete_list; + std::string new_buffer = dictionary.complete(buffer, complete_list); + + if (!complete_list.size()) + { + // no matching macro + logger.warning("wrong prefix: nothing to complete"); + } + else if (complete_list.size() == 1) + { + // good! we have found the macro + buffer = new_buffer; + } + else + { + // we have more than one matching macro + logger.warning("prefix not sufficient"); + buffer = new_buffer; + } + + displayCursor(); + return true; + } + else return false; +} diff --git a/helm/DEVEL/mathml_editor/src/ITPushLexer.hh b/helm/DEVEL/mathml_editor/src/ITPushLexer.hh new file mode 100644 index 000000000..5b5ace351 --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/ITPushLexer.hh @@ -0,0 +1,20 @@ + +#ifndef __ITPushLexer_hh__ +#define __ITPushLexer_hh__ + +#include + +#include "TPushLexer.hh" + +class ITPushLexer : public TPushLexer +{ +public: + ITPushLexer(class ALogger&, class APushParser&, class TDictionary&); + ~ITPushLexer(void) { }; + + virtual bool complete(void); +private: + class TDictionary& dictionary; +}; + +#endif diff --git a/helm/DEVEL/mathml_editor/src/LPushLexer.cc b/helm/DEVEL/mathml_editor/src/LPushLexer.cc index c1f8711fa..74cda410a 100644 --- a/helm/DEVEL/mathml_editor/src/LPushLexer.cc +++ b/helm/DEVEL/mathml_editor/src/LPushLexer.cc @@ -23,6 +23,9 @@ * or send an email to */ +#include + +#include "ALogger.hh" #include "TToken.hh" #include "LPushLexer.hh" #include "APushParser.hh" @@ -58,7 +61,7 @@ LPushLexer::transaction(char ch, State newState) case '\r': parser.push(TToken(TToken::EOL, ch)); break; case '^': parser.push(TToken(TToken::SUPERSCRIPT)); break; case '_': parser.push(TToken(TToken::SUBSCRIPT)); break; - case '\t': + case '\t': parser.push(TToken(TToken::IGNORABLE_SPACE, ch)); break; case ' ': parser.push(TToken(TToken::SPACE, ch)); break; case '~': parser.push(TToken(TToken::ACTIVE, ch)); break; case '%': parser.push(TToken(TToken::COMMENT)); break; @@ -81,11 +84,6 @@ LPushLexer::push(char ch) buffer.push_back(ch); state = IDENTIFIER; } - else if (isspace(ch)) - { - // we translate this space in a macro. - parser.push(TToken(TToken::CONTROL, "space")); - } else if (isdigit(ch)) { buffer.push_back(ch); @@ -134,15 +132,12 @@ LPushLexer::push(char ch) state = ACCEPT; } else if (isspace(ch)) - { - parser.push(TToken(TToken::CONTROL, buffer)); - buffer.erase(); - /* - * we comment this line, because a space after a macro - * is useful to exit from a macro - //parser.push(TToken(TToken::CONTROL, ";")); - */ - state = ACCEPT; + { + // we don't call transaction, because a white space is useful to exit from the macro, + // without "side effect". It's the TeX syntax. + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = ACCEPT; } else if (isdigit(ch)) { @@ -177,41 +172,51 @@ LPushLexer::push(char ch) { buffer.push_back(ch); } - else if (isspace(ch)) + else if (ch == '\\') state = ESCAPED_CHARACTER; + else if (ch == '#') { parser.push(TToken(TToken::LETTER, buffer)); buffer.erase(); - parser.push(TToken(TToken::CONTROL, "space")); - state = ACCEPT; + state = PARAMETER; } - else if (ch == '\\') + else { parser.push(TToken(TToken::LETTER, buffer)); buffer.erase(); - state = ESCAPE; + transaction(ch, ACCEPT); } - else if (ch == '#') + break; + case ESCAPED_CHARACTER: + if ((ch == '-') || (ch == '_')) { + buffer.push_back(ch); + state = IDENTIFIER; + } + else if (isalpha(ch)) + { parser.push(TToken(TToken::LETTER, buffer)); buffer.erase(); - state = PARAMETER; + buffer.push_back(ch); + state = MACRO; } - else + else if (ch == -1) error(); + else if (isdigit(ch)) { parser.push(TToken(TToken::LETTER, buffer)); buffer.erase(); - transaction(ch, ACCEPT); + buffer.push_back(ch); + state = NUMBER; } - break; - case NUMBER: - if (isdigit(ch)) buffer.push_back(ch); - else if (isspace(ch)) - { - parser.push(TToken(TToken::DIGIT, buffer)); + else + { + parser.push(TToken(TToken::LETTER, buffer)); buffer.erase(); - parser.push(TToken(TToken::CONTROL, "space")); + parser.push(TToken(TToken::CONTROL, ch)); state = ACCEPT; } + break; + case NUMBER: + if (isdigit(ch)) buffer.push_back(ch); else if (isalpha(ch)) { parser.push(TToken(TToken::DIGIT, buffer)); @@ -249,15 +254,8 @@ LPushLexer::push(char ch) break; } - switch (state) - { - case ESCAPE: parser.setCursorHint("\\"); break; - case MACRO: parser.setCursorHint("\\" + buffer); break; - case PARAMETER: parser.setCursorHint("#"); break; - case IDENTIFIER: parser.setCursorHint(buffer); break; - case NUMBER: parser.setCursorHint(buffer); break; - default: parser.setCursorHint(""); break; - } + displayCursor(); + } void @@ -268,10 +266,40 @@ LPushLexer::drop(bool alt) switch (state) { case ACCEPT: - restore = parser.drop(alt); - if (restore.length() > 0 && restore[0] == '\\') + { + restore = parser.drop(alt); + long bs_pos = restore.find('\\'); + if ((restore.length() > 0) && (bs_pos != std::string::npos)) + { + // in this case we have to control the blackslash's position + if (bs_pos == 0) + { + //logger.debug(restore); + buffer = std::string(restore, 1, restore.length() - 1); + state = (buffer.length() > 0) ? MACRO : ESCAPE; + } + else + { + assert(bs_pos == restore.length() - 1); + buffer = std::string(restore, 0, bs_pos); + state = ESCAPED_CHARACTER; + } + } + else if (restore.length() > 0 && isdigit(restore[0])) + { + buffer = restore; + state = NUMBER; + } + else if (restore.length() > 0 && isalpha(restore[0])) + { + buffer = restore; + state = IDENTIFIER; + } + } + break; +/* if (restore.length() > 0 && restore[0] == '\\') { - cout << restore << endl; + logger.debug(restore); buffer = std::string(restore, 1, restore.length() - 1); state = (buffer.length() > 0) ? MACRO : ESCAPE; } @@ -285,6 +313,9 @@ LPushLexer::drop(bool alt) buffer = restore; state = IDENTIFIER; } + break;*/ + case ESCAPED_CHARACTER: + state = IDENTIFIER; break; case ESCAPE: state = ACCEPT; @@ -295,9 +326,19 @@ LPushLexer::drop(bool alt) if (buffer.length() == 0) state = ESCAPE; break; case IDENTIFIER: - if (alt) buffer.erase(); - else buffer.erase(buffer.length() - 1, 1); - if (buffer.length() == 0) state = ACCEPT; + switch (buffer[buffer.length() - 1]) + { + case '-': + case '_': + buffer.erase(buffer.length() - 1, 1); + if (alt) state = ESCAPED_CHARACTER; + break; + default: + if (alt) buffer.erase(); + else buffer.erase(buffer.length() - 1, 1); + if (buffer.length() == 0) state = ACCEPT; + break; + } break; case NUMBER: if (alt) buffer.erase(); @@ -311,9 +352,17 @@ LPushLexer::drop(bool alt) break; } + displayCursor(); + +} + +void +LPushLexer::displayCursor() +{ switch (state) { case ESCAPE: parser.setCursorHint("\\"); break; + case ESCAPED_CHARACTER: parser.setCursorHint(buffer + "\\"); break; case MACRO: parser.setCursorHint("\\" + buffer); break; case PARAMETER: parser.setCursorHint("#"); break; case IDENTIFIER: parser.setCursorHint(buffer); break; diff --git a/helm/DEVEL/mathml_editor/src/LPushLexer.hh b/helm/DEVEL/mathml_editor/src/LPushLexer.hh index c9b6c91af..a9f95e200 100644 --- a/helm/DEVEL/mathml_editor/src/LPushLexer.hh +++ b/helm/DEVEL/mathml_editor/src/LPushLexer.hh @@ -38,11 +38,12 @@ public: virtual void push(char); virtual void drop(bool); + virtual bool complete(void) {}; virtual void reset(void); virtual void flush(void); virtual bool error(void) const; -private: +protected: enum State { ACCEPT, @@ -50,10 +51,12 @@ private: MACRO, PARAMETER, IDENTIFIER, + ESCAPED_CHARACTER, NUMBER }; void transaction(char, State); + void displayCursor(void); State state; std::string buffer; diff --git a/helm/DEVEL/mathml_editor/src/Makefile.am b/helm/DEVEL/mathml_editor/src/Makefile.am index 65ae4e66e..439f23e52 100644 --- a/helm/DEVEL/mathml_editor/src/Makefile.am +++ b/helm/DEVEL/mathml_editor/src/Makefile.am @@ -10,6 +10,8 @@ libeditex_la_LDADDS = \ libeditex_la_SOURCES = \ Diff.cc \ CLoggerConsole.cc \ + ITPushLexer.cc \ + ILPushLexer.cc \ TPushLexer.cc \ LPushLexer.cc \ APushParser.cc \ @@ -33,6 +35,8 @@ pkginclude_HEADERS = \ CMathMLFactoryXSLTDiff.hh \ TPushLexer.hh \ LPushLexer.hh \ + ITPushLexer.hh \ + ILPushLexer.hh \ TPushParser.hh \ TTokenizer.hh \ TDictionary.hh \ @@ -44,7 +48,6 @@ pkginclude_HEADERS = \ dom.hh INCLUDES = \ - $(GLIB2_CFLAGS) \ $(GMETADOM_CFLAGS) \ $(GDOMEXSLT_CFLAGS) diff --git a/helm/DEVEL/mathml_editor/src/Makefile.in b/helm/DEVEL/mathml_editor/src/Makefile.in new file mode 100644 index 000000000..0863b0101 --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/Makefile.in @@ -0,0 +1,431 @@ +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EDITEX_VERSION_INFO = @EDITEX_VERSION_INFO@ +EXEEXT = @EXEEXT@ +GDOMEXSLT_CFLAGS = @GDOMEXSLT_CFLAGS@ +GDOMEXSLT_LIBS = @GDOMEXSLT_LIBS@ +GMETADOM_CFLAGS = @GMETADOM_CFLAGS@ +GMETADOM_LIBS = @GMETADOM_LIBS@ +GTKMATHVIEW_CFLAGS = @GTKMATHVIEW_CFLAGS@ +GTKMATHVIEW_LIBS = @GTKMATHVIEW_LIBS@ +HAVE_OCAMLC = @HAVE_OCAMLC@ +HAVE_OCAMLDEP = @HAVE_OCAMLDEP@ +HAVE_OCAMLFIND = @HAVE_OCAMLFIND@ +HAVE_OCAMLMKLIB = @HAVE_OCAMLMKLIB@ +HAVE_OCAMLOPT = @HAVE_OCAMLOPT@ +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MLGDOME_CFLAGS = @MLGDOME_CFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCAMLC = @OCAMLC@ +OCAMLDEP = @OCAMLDEP@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = @OCAMLMKLIB@ +OCAMLOPT = @OCAMLOPT@ +OCAMLSTDLIBDIR = @OCAMLSTDLIBDIR@ +OCAMLSTUBDIR = @OCAMLSTUBDIR@ +OCAML_INCLUDE_DIR = @OCAML_INCLUDE_DIR@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +lib_LTLIBRARIES = libeditex.la + +libeditex_la_LDFLAGS = -version-info @EDITEX_VERSION_INFO@ + +libeditex_la_LDADDS = $(GMETADOM_LIBS) $(GDOMEXSLT_LIBS) + + +libeditex_la_SOURCES = Diff.cc CLoggerConsole.cc ITPushLexer.cc ILPushLexer.cc TPushLexer.cc LPushLexer.cc APushParser.cc TPushParser.cc CMathMLFactoryXSLT.cc CMathMLFactoryXSLTDiff.cc TDictionary.cc TDocument.cc TNode.cc TTokenizer.cc + + +pkginclude_HEADERS = Diff.hh ALogger.hh CLoggerConsole.hh APushLexer.hh APushParser.hh AMathMLFactory.hh AMathMLConsumer.hh CMathMLFactoryXSLT.hh CMathMLFactoryXSLTDiff.hh TPushLexer.hh LPushLexer.hh ITPushLexer.hh ILPushLexer.hh TPushParser.hh TTokenizer.hh TDictionary.hh TDocument.hh TNode.hh TListener.hh TToken.hh globals.hh dom.hh + + +INCLUDES = $(GMETADOM_CFLAGS) $(GDOMEXSLT_CFLAGS) + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +LIBS = @LIBS@ +libeditex_la_LIBADD = +libeditex_la_OBJECTS = Diff.lo CLoggerConsole.lo ITPushLexer.lo \ +ILPushLexer.lo TPushLexer.lo LPushLexer.lo APushParser.lo \ +TPushParser.lo CMathMLFactoryXSLT.lo CMathMLFactoryXSLTDiff.lo \ +TDictionary.lo TDocument.lo TNode.lo TTokenizer.lo +CXXFLAGS = @CXXFLAGS@ +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(pkginclude_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/APushParser.P .deps/CLoggerConsole.P \ +.deps/CMathMLFactoryXSLT.P .deps/CMathMLFactoryXSLTDiff.P .deps/Diff.P \ +.deps/ILPushLexer.P .deps/ITPushLexer.P .deps/LPushLexer.P \ +.deps/TDictionary.P .deps/TDocument.P .deps/TNode.P .deps/TPushLexer.P \ +.deps/TPushParser.P .deps/TTokenizer.P +SOURCES = $(libeditex_la_SOURCES) +OBJECTS = $(libeditex_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .cc .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libeditex.la: $(libeditex_la_OBJECTS) $(libeditex_la_DEPENDENCIES) + $(CXXLINK) -rpath $(libdir) $(libeditex_la_LDFLAGS) $(libeditex_la_OBJECTS) $(libeditex_la_LIBADD) $(LIBS) +.cc.o: + $(CXXCOMPILE) -c $< +.cc.obj: + $(CXXCOMPILE) -c `cygpath -w $<` +.cc.lo: + $(LTCXXCOMPILE) -c $< + +install-pkgincludeHEADERS: $(pkginclude_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgincludedir) + @list='$(pkginclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p; \ + done + +uninstall-pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(pkginclude_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(pkgincludedir)/$$p; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = src + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp + +%.o: %.cc + @echo '$(CXXCOMPILE) -c $<'; \ + $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.cc + @echo '$(LTCXXCOMPILE) -c $<'; \ + $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-libLTLIBRARIES +install-exec: install-exec-am + +install-data-am: install-pkgincludeHEADERS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgincludeHEADERS +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(pkgincludedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-libLTLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool uninstall-pkgincludeHEADERS \ +install-pkgincludeHEADERS tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/helm/DEVEL/mathml_editor/src/TDictionary.cc b/helm/DEVEL/mathml_editor/src/TDictionary.cc index b03663388..c1aae5cc1 100644 --- a/helm/DEVEL/mathml_editor/src/TDictionary.cc +++ b/helm/DEVEL/mathml_editor/src/TDictionary.cc @@ -226,11 +226,48 @@ TDictionary::find(const std::string& name) const if (p != entries.end()) return (*p).second; else { - cerr << "ERROR: unknown entry `" << name << "'" << endl; + logger.warning("unknown entry `" + name + "'"); return undefinedEntry; } } +std::string +TDictionary::complete(const std::string prefix, std::list& complete_list) const +{ + bool no_match = true; + std::string new_prefix = ""; + for (Dictionary::const_iterator i = entries.begin(); i != entries.end(); i++) + { + if ((*i).first.find(prefix) == 0) + { + complete_list.push_front((*i).first); + if (no_match) + { + // it's the first match + no_match = false; + new_prefix = (*i).first; + } + else + { + // in this case, new_prefix has been set yet. + std::string s1 = (*i).first.substr(prefix.length()); // s1 is the high part of the matching string + std::string s2 = new_prefix.substr(prefix.length()); // s2 is the high part of new_prefix +#if 0 + long j = 0; // it's the number of common characters + while (s1[j] == s2[j]) j++; +#endif + std::string::const_iterator i1 = s1.begin(); + std::string::const_iterator i2 = s2.begin(); + while (i1 != s1.end() && i2 != s2.end() && *i1 == *i2) i1++, i2++; + new_prefix = prefix + s1.substr(0, i1 - s1.begin()); + //new_prefix = (j) ? prefix + s1.substr(0, i1 - s1.begin()) : prefix; + } + } + } + + return new_prefix; +} + bool TDictionary::Entry::paramDelimited(unsigned i) const { diff --git a/helm/DEVEL/mathml_editor/src/TDictionary.hh b/helm/DEVEL/mathml_editor/src/TDictionary.hh index f3ad19dc1..43c2e51af 100644 --- a/helm/DEVEL/mathml_editor/src/TDictionary.hh +++ b/helm/DEVEL/mathml_editor/src/TDictionary.hh @@ -31,6 +31,7 @@ #include #include #include +#include #include "dom.hh" #include "TToken.hh" @@ -87,6 +88,7 @@ public: void load(const std::string&, const std::string&); void load(const DOM::Document&, const std::string& = ""); const Entry& find(const std::string&) const; + std::string complete(const std::string, std::list&) const; private: struct StringHash : public std::unary_function< std::string, size_t > diff --git a/helm/DEVEL/mathml_editor/src/TDocument.hh b/helm/DEVEL/mathml_editor/src/TDocument.hh index 783fce655..02d1dc38d 100644 --- a/helm/DEVEL/mathml_editor/src/TDocument.hh +++ b/helm/DEVEL/mathml_editor/src/TDocument.hh @@ -43,6 +43,7 @@ public: TNode createI(const std::string& text, unsigned id = 0) const { return createT("i", text, id); }; TNode createN(const std::string& text, unsigned id = 0) const { return createT("n", text, id); }; TNode createO(const std::string& text, unsigned id = 0) const { return createT("o", text, id); }; + TNode createS(unsigned id = 0) const { return createT("s", "", id); }; DOM::Document document(void) const { return doc; }; diff --git a/helm/DEVEL/mathml_editor/src/TNode.hh b/helm/DEVEL/mathml_editor/src/TNode.hh index 1b816570e..adbfe69a6 100644 --- a/helm/DEVEL/mathml_editor/src/TNode.hh +++ b/helm/DEVEL/mathml_editor/src/TNode.hh @@ -96,6 +96,7 @@ public: bool isC(void) const { return is("c"); } bool isC(const std::string& name) const { return isC() && node.getAttribute("name") == name; }; + bool isT(void) const { return (is("o") || is("i") || is("n") || is("s")); }; friend class TDocument; diff --git a/helm/DEVEL/mathml_editor/src/TPushLexer.cc b/helm/DEVEL/mathml_editor/src/TPushLexer.cc index 2411a0e21..f9dc184c2 100644 --- a/helm/DEVEL/mathml_editor/src/TPushLexer.cc +++ b/helm/DEVEL/mathml_editor/src/TPushLexer.cc @@ -23,6 +23,8 @@ * or send an email to */ +#include + #include "TToken.hh" #include "TPushLexer.hh" #include "APushParser.hh" @@ -59,7 +61,7 @@ TPushLexer::transaction(char ch, State newState) case '^': parser.push(TToken(TToken::SUPERSCRIPT)); break; case '_': parser.push(TToken(TToken::SUBSCRIPT)); break; case '\t': - case ' ': parser.push(TToken(TToken::SPACE, ch)); break; + case ' ': parser.push(TToken(TToken::IGNORABLE_SPACE, ch)); break; case '~': parser.push(TToken(TToken::ACTIVE, ch)); break; case '%': parser.push(TToken(TToken::COMMENT)); break; default: @@ -144,13 +146,8 @@ TPushLexer::push(char ch) break; } - switch (state) - { - case ESCAPE: parser.setCursorHint("\\"); break; - case MACRO: parser.setCursorHint("\\" + buffer); break; - case PARAMETER: parser.setCursorHint("#"); break; - default: parser.setCursorHint(""); break; - } + displayCursor(); + } void @@ -183,6 +180,13 @@ TPushLexer::drop(bool alt) break; } + displayCursor(); + +} + +void +TPushLexer::displayCursor() +{ switch (state) { case ESCAPE: parser.setCursorHint("\\"); break; diff --git a/helm/DEVEL/mathml_editor/src/TPushLexer.hh b/helm/DEVEL/mathml_editor/src/TPushLexer.hh index 63ec45450..2aafd6ec9 100644 --- a/helm/DEVEL/mathml_editor/src/TPushLexer.hh +++ b/helm/DEVEL/mathml_editor/src/TPushLexer.hh @@ -38,11 +38,12 @@ public: virtual void push(char); virtual void drop(bool); + virtual bool complete(void) { }; virtual void reset(void); virtual void flush(void); virtual bool error(void) const; -private: +protected: enum State { ACCEPT, @@ -53,9 +54,11 @@ private: }; void transaction(char, State); + void displayCursor(void); State state; std::string buffer; + }; #endif // __TPushLexer_hh__ diff --git a/helm/DEVEL/mathml_editor/src/TPushParser.cc b/helm/DEVEL/mathml_editor/src/TPushParser.cc index 863ca7bb0..433b3fdec 100644 --- a/helm/DEVEL/mathml_editor/src/TPushParser.cc +++ b/helm/DEVEL/mathml_editor/src/TPushParser.cc @@ -437,10 +437,19 @@ TPushParser::do_superscript() } } +bool +TPushParser::do_ignorablespace(const std::string& s) +{ + // At the moment, do nothing +} + bool TPushParser::do_space(const std::string&) { - return false; + TNode elem = doc.createS(nextId++); + cursor.replace(elem); + advance(elem); + return true; } bool @@ -711,7 +720,7 @@ TPushParser::drop_prev_token(bool special) assert(cursor.prev()); assert(cursor.parent()); TNode prev = cursor.prev(); - assert(prev.is("i") || prev.is("o") || prev.is("n")); + assert(prev.isT()); DOM::UCS4String ucs4val = prev.element().getAttribute("val"); bool macro = prev.element().hasAttribute("name"); @@ -731,7 +740,7 @@ TPushParser::drop_prev_token(bool special) frame.pos--; } - if ((ucs4val.length() > 1) && !special) + if ((ucs4val.length() > 1)) { if (!macro) { @@ -739,18 +748,23 @@ TPushParser::drop_prev_token(bool special) // to convert it in a utf8 DOM::GdomeString gdsval(ucs4val); std::string utf8val(gdsval); - utf8val = utf8val.erase(utf8val.length() - 1, 1); - return std::string(utf8val); + switch (utf8val[utf8val.length() - 1]) + { + case '-': + case '_': + return (special) ? std::string(utf8val, 0, utf8val.length() - 1) + "\\" : std::string(utf8val, 0, utf8val.length() - 1); + default: return (special) ? "" : std::string(utf8val, 0, utf8val.length() - 1); + } } else { // in this case, the content of val could be in unicode, - // but we have attribute name, which doesn't contain character not representable + // but we have the attribute name, which doesn't contain character not representable // with a byte. - return "\\" + utf8name.erase(utf8name.length() - 1, 1); + return (special) ? "\\" + utf8name : ""; } } - else if ((ucs4val.length() <= 1) && macro && special) return "\\" + utf8name.erase(utf8name.length() - 1, 1); + else if (macro && special) return "\\" + utf8name; else return ""; } @@ -770,7 +784,7 @@ TPushParser::drop_prev_script(bool special) if (cursor.prev().isG() && !prev.hasId()) { // in this case, the user has inserted the a sequence of '. - // Hence, we force a normal deleting, because the behaviour must be the same + // Hence, we force a normal deleting, because the behavior must be the same // for the two kind of deleting return drop_prev(false); } @@ -788,6 +802,8 @@ TPushParser::drop_prev_group(bool special) if (parent.isC() && prev.hasId()) { + // this previous group is a macro's argument. Entering inside it means that + // this argument becomes incomplete. Hence, we have to decrement the member pos. assert(!frames.empty()); frames.top().pos--; } @@ -817,9 +833,8 @@ TPushParser::drop_prev_macro(bool special) if (!entry.defined()) { - // We can assume that the user wants to completely delete the undefined macro, - // but we can also handle this case as we handle tokens. At the moment, we delete the - // whole macro + // In this case, with a normal deletion, we completely remove the macro. + // With a special deletion, we remove the last character of the macro's name. cursor.remove(); prev.replace(cursor); if (cursor.parent().isC()) @@ -828,7 +843,7 @@ TPushParser::drop_prev_macro(bool special) assert(!frames.empty()); frames.top().pos--; } - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); // we remove the last char, because an undefined macro's name is visible return ""; } else @@ -842,7 +857,7 @@ TPushParser::drop_prev_macro(bool special) if (entry.rightOpen) { // In this fragment of code we also handle the leftOpen && rightOpen MACRO. - // if the control element is rightOpen, the cursor should be placed after + // since the control element is rightOpen, the cursor should be placed after // the last child of the control element's last child, and than, we try to remove something. // A frame MUST be pushed in the stack, because we dont' know if the following actions // will completely remove the MACRO. @@ -868,7 +883,8 @@ TPushParser::drop_prev_macro(bool special) // MACRO immediately, substituting it with the content of the phantom group. // We could remove the last child of the phantom group, but // it's not clear if it's the correct behavior of the graphical deleting. - // At the moment, to give a standard behaviour, we remove the last element. + // At the moment, to give a standard behavior, we remove the last element. + // With a special deletion, we do not remove it. assert(prev.first()); assert(prev.first().isG()); assert(prev.first() == prev.last()); @@ -881,7 +897,7 @@ TPushParser::drop_prev_macro(bool special) g.remove(); prev.replace(g.first(), TNode()); parent.append(cursor); - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name; else return do_drop(special); } else @@ -890,7 +906,7 @@ TPushParser::drop_prev_macro(bool special) cursor.remove(); g.remove(); prev.replace(cursor); - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name; else { // Once removed this empty macro, we could try to remove something else. @@ -921,7 +937,7 @@ TPushParser::drop_prev_macro(bool special) std::string last_del = entry.pattern[entry.pattern.size() - 1].value; - return "\\" + last_del.erase(last_del.length() - 1, 1); + return "\\" + last_del; } else { @@ -937,7 +953,7 @@ TPushParser::drop_prev_macro(bool special) // now, p is the correct value of pos, and we can push the frame. frames.push(Frame(entry, p)); - // To give a standard behaviour to the graphical deleting, we remove the last + // To give a standard behavior to the graphical deleting, we remove the last // element of the macro. Since we are in a phantom group, we can invoke the // do_drop_phantom_group(special). return do_drop_phantom_group(special); @@ -999,12 +1015,12 @@ TPushParser::drop_prev_macro(bool special) frames.top().pos--; } - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name; else return ""; - // now we could start to remove something else. This behaviour would be justified by the + // now we could start to remove something else. This behavior would be justified by the // fact that, generally, an empty MACRO gives no visual information about it. - // To adopt this behaviour, just remove the comment to the following instruction + // To adopt this behavior, just remove the comment to the following instruction // return do_drop(special); } } // end of defined MACRO @@ -1021,7 +1037,7 @@ TPushParser::drop_prev(bool special) TNode prev = cursor.prev(); - if (prev.is("i") || prev.is("o") || prev.is("n")) + if (prev.isT()) { return drop_prev_token(special); } @@ -1120,15 +1136,6 @@ TPushParser::do_drop_script(bool special) // Since we don't know who is cursor's parent, and who is cursor's preceding // element, we invoke the do_drop() return do_drop(special); - - /* - * * the following istructions have sense, only if we remove the preceding one. - * - // if the new parent is a group with Id and the cursor is the only - // element of this group, we have to remove the group. These controls are made - // in the method rgreplace_father(). - if (cursor.parent().isG() && cursor.parent().hasId()) rgreplace_father(); - */ } } else @@ -1142,7 +1149,7 @@ TPushParser::do_drop_script(bool special) if (special) return ""; else { - // to give a standard behaviour, we try to remove the element, which was + // to give a standard behavior, we try to remove the element, which was // the script's base. return do_drop(special); } @@ -1180,31 +1187,12 @@ TPushParser::do_drop_macro(bool special) parent.replace(cursor); frames.pop(); - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name; else { - // Since the macro hadn't no children and this is a graphical deleting, we try + // Since the macro had no children and this is a graphical deleting, we try // to remove something else return do_drop(special); - - /* - * the following block of code has sense only if we remove the preceding instruction - * - // if the new parent is a group with Id, and has no elements other than the - // cursor, we can remove it, because it' a graphical deleting - if (cursor.parent() && cursor.parent().isG() && cursor.parent().hasId()) - rgreplace_father(); - else if (cursor.parent().isC()) - { - // We have assumed that a MACRO cannot be a MACRO's child. - // At the moment, this assumption is valid, but in a future - // it might be false. - assert(!frames.empty()); - Frame& frame = frames.top(); - assert(frame.pos > 0); - frame.pos--; - } - */ } } else @@ -1228,7 +1216,7 @@ TPushParser::do_drop_macro(bool special) // two units: the delimiter and the actual argument std::string last_del = frame.entry.pattern[frame.pos - 1].value; frame.pos = frame.pos - 2; - return "\\" + last_del.erase(last_del.length() - 1, 1); + return "\\" + last_del; } else { @@ -1331,7 +1319,7 @@ TPushParser::do_drop_phantom_group(bool special) { std::string del = frame.entry.pattern[frame.pos].value; frame.pos--; - return "\\" + del.erase(del.length() - 1, 1); + return "\\" + del; } } else @@ -1437,10 +1425,10 @@ TPushParser::do_drop_phantom_group(bool special) // this MACRO no longer exists. frames.pop(); - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name; else { - // to give a standard behaviour to the graphical deleting, we call the do_drop. + // to give a standard behavior to the graphical deleting, we call the do_drop. return do_drop(special); } } @@ -1458,10 +1446,10 @@ TPushParser::do_drop_phantom_group(bool special) // now we have the situation preceding the rightOpen MACRO, so we have to pop the frame frames.pop(); - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name; else { - // to give a standard behaviour to the graphical deleting, we call the do_drop. + // to give a standard behavior to the graphical deleting, we call the do_drop. return do_drop(special); } @@ -1490,7 +1478,7 @@ TPushParser::do_drop_phantom_group(bool special) gfather.replace(cursor); frames.pop(); - if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); + if (special) return "\\" + macro_name; else { // once we have replaced the empty macro with the cursor, we can remove @@ -1514,7 +1502,7 @@ TPushParser::do_drop_phantom_group(bool special) // argument. std::string last_del = frame.entry.pattern[frame.pos - 1].value; frame.pos = frame.pos - 2; - return "\\" + last_del.erase(last_del.length() - 1, 1); + return "\\" + last_del; } else { @@ -1714,21 +1702,22 @@ TPushParser::process(const TToken& token) { switch (token.category) { - case TToken::BEGIN: return do_begin(); break; - case TToken::END: return do_end(); break; - case TToken::SHIFT: return do_shift(); break; - case TToken::ALIGN: return do_align(); break; - case TToken::EOL: return do_eol(); break; - case TToken::PARAMETER: return do_parameter(token.value); break; - case TToken::SUPERSCRIPT: return do_superscript(); break; - case TToken::SUBSCRIPT: return do_subscript(); break; - case TToken::SPACE: return do_space(token.value); break; - case TToken::LETTER: return do_letter(token.value); break; - case TToken::DIGIT: return do_digit(token.value); break; - case TToken::OTHER: return do_other(token.value); break; - case TToken::ACTIVE: return do_active(token.value); break; - case TToken::COMMENT: return do_comment(); break; - case TToken::CONTROL: return do_control(token.value); break; + case TToken::BEGIN: return do_begin(); + case TToken::END: return do_end(); + case TToken::SHIFT: return do_shift(); + case TToken::ALIGN: return do_align(); + case TToken::EOL: return do_eol(); + case TToken::PARAMETER: return do_parameter(token.value); + case TToken::SUPERSCRIPT: return do_superscript(); + case TToken::SUBSCRIPT: return do_subscript(); + case TToken::IGNORABLE_SPACE: return do_ignorablespace(token.value); + case TToken::SPACE: return do_space(token.value); + case TToken::LETTER: return do_letter(token.value); + case TToken::DIGIT: return do_digit(token.value); + case TToken::OTHER: return do_other(token.value); + case TToken::ACTIVE: return do_active(token.value); + case TToken::COMMENT: return do_comment(); + case TToken::CONTROL: return do_control(token.value); } } @@ -1813,7 +1802,7 @@ TPushParser::push(const TToken& token) { // As by the TeX parsing rules of undelimited parameters, // empty spaces are ignored - if (token.category != TToken::SPACE) process(token); + if ((token.category != TToken::SPACE) && (token.category != TToken::IGNORABLE_SPACE)) process(token); } else if (frame.entry.pattern[frame.pos] == token) { diff --git a/helm/DEVEL/mathml_editor/src/TPushParser.hh b/helm/DEVEL/mathml_editor/src/TPushParser.hh index 4192f3831..a94402fbf 100644 --- a/helm/DEVEL/mathml_editor/src/TPushParser.hh +++ b/helm/DEVEL/mathml_editor/src/TPushParser.hh @@ -66,6 +66,7 @@ private: bool do_parameter(const std::string&); bool do_superscript(void); bool do_subscript(void); + bool do_ignorablespace(const std::string&); bool do_space(const std::string&); bool do_letter(const std::string&); bool do_digit(const std::string&); @@ -73,7 +74,6 @@ private: bool do_active(const std::string&); bool do_comment(void); bool do_control(const std::string&); - std::string drop_prev_token(bool); std::string drop_prev_script(bool); diff --git a/helm/DEVEL/mathml_editor/src/TToken.hh b/helm/DEVEL/mathml_editor/src/TToken.hh index a1a1abf56..0ea74e551 100644 --- a/helm/DEVEL/mathml_editor/src/TToken.hh +++ b/helm/DEVEL/mathml_editor/src/TToken.hh @@ -40,6 +40,7 @@ struct TToken PARAMETER, SUPERSCRIPT, SUBSCRIPT, + IGNORABLE_SPACE, SPACE, LETTER, DIGIT, diff --git a/helm/DEVEL/mathml_editor/src/TTokenizer.cc b/helm/DEVEL/mathml_editor/src/TTokenizer.cc index 4b0974a81..143faa80f 100644 --- a/helm/DEVEL/mathml_editor/src/TTokenizer.cc +++ b/helm/DEVEL/mathml_editor/src/TTokenizer.cc @@ -30,7 +30,7 @@ std::vector TTokenizer::tokenize(const std::string& s) -{ +{ TPushLexer lexer(logger, *this); tokens.clear(); diff --git a/helm/DEVEL/mathml_editor/test/Makefile.in b/helm/DEVEL/mathml_editor/test/Makefile.in new file mode 100644 index 000000000..df6bac536 --- /dev/null +++ b/helm/DEVEL/mathml_editor/test/Makefile.in @@ -0,0 +1,396 @@ +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EDITEX_VERSION_INFO = @EDITEX_VERSION_INFO@ +EXEEXT = @EXEEXT@ +GDOMEXSLT_CFLAGS = @GDOMEXSLT_CFLAGS@ +GDOMEXSLT_LIBS = @GDOMEXSLT_LIBS@ +GMETADOM_CFLAGS = @GMETADOM_CFLAGS@ +GMETADOM_LIBS = @GMETADOM_LIBS@ +GTKMATHVIEW_CFLAGS = @GTKMATHVIEW_CFLAGS@ +GTKMATHVIEW_LIBS = @GTKMATHVIEW_LIBS@ +HAVE_OCAMLC = @HAVE_OCAMLC@ +HAVE_OCAMLDEP = @HAVE_OCAMLDEP@ +HAVE_OCAMLFIND = @HAVE_OCAMLFIND@ +HAVE_OCAMLMKLIB = @HAVE_OCAMLMKLIB@ +HAVE_OCAMLOPT = @HAVE_OCAMLOPT@ +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MLGDOME_CFLAGS = @MLGDOME_CFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCAMLC = @OCAMLC@ +OCAMLDEP = @OCAMLDEP@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = @OCAMLMKLIB@ +OCAMLOPT = @OCAMLOPT@ +OCAMLSTDLIBDIR = @OCAMLSTDLIBDIR@ +OCAMLSTUBDIR = @OCAMLSTUBDIR@ +OCAML_INCLUDE_DIR = @OCAML_INCLUDE_DIR@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +noinst_PROGRAMS = editor + +editor_SOURCES = editor.cc guiGTK.c aux.cc + +noinst_HEADERS = guiGTK.h + +LDADDS = $(GMETADOM_LIBS) $(GDOMEXSLT_LIBS) $(GTKMATHVIEW_LIBS) $(top_builddir)/src/.libs/libeditex.a + + +editor_LDADD = $(LDADDS) + +INCLUDES = $(GMETADOM_CFLAGS) $(GDOMEXSLT_CFLAGS) $(GTKMATHVIEW_CFLAGS) -I$(top_srcdir)/src + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +noinst_PROGRAMS = editor$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +LIBS = @LIBS@ +editor_OBJECTS = editor.$(OBJEXT) guiGTK.$(OBJEXT) aux.$(OBJEXT) +editor_DEPENDENCIES = $(top_builddir)/src/.libs/libeditex.a +editor_LDFLAGS = +CXXFLAGS = @CXXFLAGS@ +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/aux.P .deps/editor.P .deps/guiGTK.P +SOURCES = $(editor_SOURCES) +OBJECTS = $(editor_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .cc .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstPROGRAMS: + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +distclean-noinstPROGRAMS: + +maintainer-clean-noinstPROGRAMS: + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +editor$(EXEEXT): $(editor_OBJECTS) $(editor_DEPENDENCIES) + @rm -f editor$(EXEEXT) + $(CXXLINK) $(editor_LDFLAGS) $(editor_OBJECTS) $(editor_LDADD) $(LIBS) +.cc.o: + $(CXXCOMPILE) -c $< +.cc.obj: + $(CXXCOMPILE) -c `cygpath -w $<` +.cc.lo: + $(LTCXXCOMPILE) -c $< + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = test + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu test/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp + +%.o: %.cc + @echo '$(CXXCOMPILE) -c $<'; \ + $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.cc + @echo '$(LTCXXCOMPILE) -c $<'; \ + $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstPROGRAMS distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstPROGRAMS \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \ +clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/helm/DEVEL/mathml_editor/test/editor.cc b/helm/DEVEL/mathml_editor/test/editor.cc index cdf6d51a5..00aa28eb9 100644 --- a/helm/DEVEL/mathml_editor/test/editor.cc +++ b/helm/DEVEL/mathml_editor/test/editor.cc @@ -25,8 +25,11 @@ #include "dom.hh" #include "TPushParser.hh" -#include "TPushLexer.hh" + #include "LPushLexer.hh" + +#include "TPushLexer.hh" +#include "ILPushLexer.hh" #include "TDictionary.hh" #include "CLoggerConsole.hh" #include "CMathMLFactoryXSLT.hh" @@ -35,11 +38,16 @@ #include "guiGTK.h" +typedef ILPushLexer MyPushLexer; + extern void *parseMathMLFile(char *); struct Context { - Context(const std::string& s, APushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) + /* + Context(const std::string& s, TPushLexer& l, TPushParser& p) : buffer(s), i(0), lexer(l), parser(p) { }; + */ + Context(const std::string& s, MyPushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) : buffer(s), i(0), lexer(l), parser(p), texStyle(ts) { }; void send(void) @@ -49,7 +57,8 @@ struct Context std::string buffer; unsigned i; - APushLexer& lexer; + //TPushLexer& lexer; + MyPushLexer& lexer; TPushParser& parser; DOMX::XSLTStylesheet& texStyle; }; @@ -112,8 +121,10 @@ edit_push_string(Context* context, const gchar* s) } extern "C" void -edit_drop(Context* context, gboolean alt) +edit_drop(Context* context, gboolean alt, gboolean control) { + // At the moment, the last parameter is not used, but it will + // be useful when we will handle the "fast" deletion assert(context != NULL); GUI_freeze(); context->lexer.drop(alt); @@ -130,6 +141,15 @@ edit_reset_tex(Context* context) GUI_thaw(); } +extern "C" void +edit_complete(Context* context) +{ + assert(context != NULL); + GUI_freeze(); + if (!context->lexer.complete()) context->lexer.push('\t'); + GUI_thaw(); +} + void main(int argc, char* argv[]) { @@ -138,19 +158,19 @@ main(int argc, char* argv[]) TDictionary dictionary(logger); logger.info("loading the dictionary..."); - dictionary.load("/home/luca/projects/helm/DEVEL/mathml_editor/dictionary-test.xml"); + dictionary.load("./dictionary-test.xml"); logger.info("loading the stylesheet..."); DOM::DOMImplementation di; DOM::Document mmlStyleDoc = di.createDocumentFromURI("./xsl/tml-mmlp.xsl"); DOMX::XSLTStylesheet mmlStyle(mmlStyleDoc); - DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-tex.xsl"); + DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-texid.xsl"); DOMX::XSLTStylesheet texStyle(texStyleDoc); CMathMLFactoryXSLT factory(logger, mmlStyle); TPushParser parser(logger, factory, dictionary); - LPushLexer lexer(logger, parser); + MyPushLexer lexer(logger, parser, dictionary); #if 0 lexer.push('$'); diff --git a/helm/DEVEL/mathml_editor/test/guiGTK.c b/helm/DEVEL/mathml_editor/test/guiGTK.c index 1bcf786ad..01994eaf1 100644 --- a/helm/DEVEL/mathml_editor/test/guiGTK.c +++ b/helm/DEVEL/mathml_editor/test/guiGTK.c @@ -596,10 +596,13 @@ key_press_event(gpointer c, switch (event->keyval) { case GDK_BackSpace: - edit_drop(context, event->state & GDK_MOD1_MASK); + edit_drop(context, event->state & GDK_MOD1_MASK, event->state & GDK_CONTROL_MASK); + break; + case GDK_Tab: + edit_complete(context); break; default: - if ((event->state & (~GDK_SHIFT_MASK)) == 0 && event->keyval < 0x80) + if ((event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0 && event->keyval < 0x80) edit_push_char(context, event->keyval); return FALSE; } diff --git a/helm/DEVEL/mathml_editor/xsl/tml-mmlp.xsl b/helm/DEVEL/mathml_editor/xsl/tml-mmlp.xsl index 7b225f0e3..7b1ad7cb3 100644 --- a/helm/DEVEL/mathml_editor/xsl/tml-mmlp.xsl +++ b/helm/DEVEL/mathml_editor/xsl/tml-mmlp.xsl @@ -96,6 +96,69 @@ + + + + + + + + + + + + + @@ -121,6 +184,28 @@ + + + + + + + + + + + + + + + + + + + + I + + @@ -130,7 +215,7 @@ I - + --> @@ -1037,9 +1122,21 @@ + + + + + + + + + + + + + -