GNU TeXmacsUser manualReferenceAboutEnglish
The experimental style rewriter

1.Introduction

The directory

src/src/Style/

contains a second, independent implementation of the evaluation of TeXmacs documents. Its goal is to compute the style rewriting of a whole document, that is the tree obtained by expanding all macros and evaluating all primitives, incrementally: after a small change of the document, only the computations which depend on the change should be redone. To this end it combines three ideas:

The code is a prototype. It is not compiled by default, it is not used by the typesetter, and in its present state it does not even compile when it is enabled (see pitfalls). The short overview in the experimental evaluator in

Style/
describes the design; this chapter documents the code in more detail, so that it can be repaired, evaluated or removed with full knowledge of what it does. The semantics of the primitives themselves are those of the real evaluator described in macro expansion and evaluation.

File names below are relative to

src/src/

.

2.Status

Build

Off by default. The CMake option ENABLE_EXPERIMENTAL (

CMakeLists.txt:466

) adds all of Style/*.cpp to the sources and defines EXPERIMENTAL; without it, TeXmacs_Style_SRCS is empty. With the autotools build, configure --enable-experimental sets CONFIG_EXPERIMENTAL to "Memorizer Environment Evaluate" and defines EXPERIMENTAL;

makefile.in

then compiles those three subdirectories (style_src). In a default build, no file of

Style/

is compiled at all.

Use

When enabled, the editor maintains a clean copy of its document and re-evaluates it after every change, but the result is only printed on the console; nothing in the typesetter, the editor or Scheme reads it. See integration with the editor.

Completeness

The evaluator handles 126 of the 175 primitives known to edit_env_rep::exec. Several of the handled ones are placeholders (fixed lengths, drd-props, bindings). See the evaluator.

Health

Three files of

Style/Evaluate/

no longer compile, because functions they use have moved to headers they do not include. Every call of the main routines also prints a trace on the console.

3.Overview

   editor (EXPERIMENTAL)
     et[rp]    --- edit_done / copy_announce --->  cct  (clean copy)
     typesetting env --- environment_update / primitive ---> ste
     apply_changes:   mem= evaluate (ste, cct)

   evaluate (env, t)                       Style/Evaluate/evaluate_main.cpp
     |-- memorizer lookup by (env pointer, tree pointer)
     |-- evaluate_impl: dispatch on the label    evaluate_*.cpp
     |-- assign / begin_with / end_with        std_environment.cpp
     |    (new persistent environments, memoized too)
     ‘-- result tree + output environment stored in the memorizer

   memorizers: hash-consed in a global table   Style/Memorizer/memorizer.cpp

4.Source files

Style/Environment/environment.hpp

The abstract environment_rep (integer keys obtained with make_tree_label), the handle environment, the identity functions weak_hash and weak_equal for trees and environments, and the choice ALTERNATIVE_MACRO_EXPANSION versus CLASSICAL_MACRO_EXPANSION.

assoc_environment.*, basic_environment.*, list_environment.*

Small association arrays, open hash tables, and linked lists of hash tables with automatic compression.

std_environment.*

The environment used by the evaluator, primitive, and the memoized operations assign, begin_with, end_with (and macro_down, macro_redown, macro_up for the classical macro expansion).

Style/Memorizer/memorizer.*

The memorizer classes, the global hash-consing table and the stack of sub-computations.

Style/Memorizer/clean_copy.*

Maintenance of the clean copy: copy_ip and copy_announce.

Style/Evaluate/evaluate_main.*

The memoized evaluate, the dispatcher evaluate_impl and the declarations of all evaluate_* routines.

evaluate_macro.cpp

Assignments, with, values, macro application by substitution (expand), drd-props.

Other evaluate_*.cpp

The families of primitives:

evaluate_control.cpp

,

evaluate_boolean.cpp

,

evaluate_numeric.cpp

,

evaluate_textual.cpp

,

evaluate_length.cpp

and

evaluate_quote.cpp

.

evaluate_rewrite.cpp
,
evaluate_inactive.cpp

The memoized rewriting of extern, include, with-package and the rendering of inactive markup.

evaluate_misc.cpp

Formatting tags, tables, hard-id, scripts, bindings, patterns and points.

The hooks in the editor are in

Edit/editor.hpp

,

Edit/Editor/edit_main.cpp

,

Edit/Editor/edit_typeset.cpp

,

Edit/Modify/edit_modify.cpp

and

Edit/Interface/edit_interface.cpp

, all under #ifdef EXPERIMENTAL.

5.Contents of this chapter

6.Pitfalls and known bugs

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".