Home
ZapoTEX: User`s Manual (EARLY DRAFT)
Contents
1. gt Q gPhi gt QD gPi II gPsi V gSigma X gTheta gUpsilon gt Y gxi amp gamma y gimel J iota 1 kappa x lambda gt A mho gt U mu gt p nabla gt V nu gt v omega gt w partial gt phi pi gt m psi 9 w rho gt p sigma gt o tau gt T theta 0 upsilon v varepsilon gt varphi gt varpi gt varrho gt varsigma vartheta gt 9 xi gt zeta gt G Generalised Aliases three bindings math MATHCAL cc C A Z V mathcal 1 math MATHBB bb NC A Z ND mathbb 1 bmath MATHFRAK ff N A Za z 0 mathfrak 1 7 Planned Features change UI to style cmd in out instead of cmd in gt out building on that add make that compiles all ZapoTgx files and all source files in the directory option recursively Aim make it easy to handle large projects Even better using shell escape to do that directly on the fly from within LaTeX That is to say write TEX package so that markup such as executes ZapoTpx appropriately fake TEX version of markup to compile ZapoTgx files with TEX even without ZapoTgX on the system Translators fake e real markups Even better write BIEX package so that markup such as starts verbatim modes This can be a fall back to the ideal case on the fly 13 Zapo pX if shell escape cannot be
2. In practice we have used this to define a few simple default generalised aliases which provide easy access to special math fonts For instance x x X x X x X x xX xXxkX Those default generalised aliases are listed in Section 6 5 Supported Languages At the time of writing ZapoTpX supports the following languages OCaml Prolog B code m1 pl b inline pl b display IHR 4 PL B command pl Hb comms 8 where code corresponds to the vocabulary code used in dump commands see Section 6 inline is the ZapoTpX markup for inline mode where represents the actual source code display is the markup for display centred mode and command is the markup for ZapoTEX commands Note that kind definitions aliases generalised aliases etc are specific to a given language For instance the aliases of OCaml don t mix with those of Prolog They have no reason to Collectively this is called the vocabulary of a language Com mands which affect a vocabulary for instance by creating a new alias will only deal with the vocabulary corresponding to the command environment they are invoked in For instance keyword foo will only add the keyword foo for the OCaml language and pl keyword foo will do the same thing exclusively for Prolog Instances of 7o are ignored while in command mode treated as whitespace so you can keep all th
3. MITEX code appears as special comments in the source Refer to section 3 12 Example Rendered Code Some types val fold a gt B gt a gt amp gt P list a val fold a gt f gt P gt a list gt B gt p type a seq Nil Cons of a x seq This is a documentation comment let rec fold f accu function accu some regular comment a 1 fold f f accu a 1 nested comments are cool but should not be abused let rec fold f 1 accu match 1 with accu a 1 f a fold f 1 accu 16 i let some aliases x X List find fun gt x amp amp amp zZ x 2 X 13 Help Page of the ZapoTgeX Program ZapoTeX zapotex by Vincent HUGOT email vincent hugot gmail com web vincent hugot com Usage source code LaTeX prettifier tex file z tex file tex Takes a LaTeX file containing code formulae and outputs a pure LaTeX file on the standard output which can then be compiled by LaTeX The code is prettified according to the customisable definitions in zapoml tex ml file ml file tex Takes a Caml source file and outputs corresponding prettified LaTeX version which can then be input into a LaTeX document pl file pl file tex Same for Prolog sources b file B file tex Same for B sources Usage miscellaneous euroZone e filel tex fileN tex Removes all deprecated ma
4. enabled strict optional mode for evaluation of commands literate programming Make generalised aliases more powerful by adding recursive calls That way indices and primes can be handled in all generality for all languages by a couple of generaliases instead of an ugly kludge in decorate Avoids n plication of the kludge for n languages and lets the user remove alter this behaviour on the fly 14
5. ER gt f NAT gt Nrep NATI gt Ni NATURAL gt IN NATURALI gt N PT gt POW gt P POW1 Pi SIGMA gt D STRING gt S UNION gt V gt U WUZ gt J 4 7 5 aleph gt N alpha gt a beta f beth 2 chi gt x daleth 7 delta 6 ell gt epsilon gt e eta gt n eth gDelta A gGamma T gLambda A gOmega gt Q gPhi CO gPi II gPsi W gSigma L gTheta gt gUpsilon gt Y gXi E gamma gt y gimel gt inter iota 1 kappa x lambda A mho gt U mu u nabla gt V not gt a nu gt v omega gt w or V partial gt phi pi gt m psi gt i rho p sigma gt o tau gt T theta 0 union gt upsilon v varepsilon varphi gt q varpi gt varrho gt varsigma gt vartheta 98 xi 7 etd 55 tbe es Slt lee es eS rs mei IH l Generalised Aliases no binding Language OCaml Kinds assignment 79 definitions flow failwith exit raise invalid arg type array list ref open flag format int64 float char out channel unit fp class in channel int option int32 bool format4 exn string keyword functor when while initializer mutable struct land downto ref match rec try done object as mod fun type val new false function true asr external to lxor module exception inherit begin in if constraint 11 include l
6. ZapoTpX User s Manual EARLY DRAFT Vincent Hucor November 3 2011 Note this is a very early draft of a very experimental program Contents 1 Introduction LI Use Cases 4 ik Bk a ew cede 12 Example Rendered Code 1533 Help Page of the ZapoTgpX Program Code as equations Literate programming Kinds aliases and other beautifications ZI Kinds ss ota oes a Me ken 4 2 Basic Beautification 43 Simple Aliases 4 665208 44 Generalised Aliases Supported Languages 5 1 Sample Prolog Code 2 4 4 44 5 2 wemple Code iaciaisso pansa Default Vocabularies Planned Features 10 13 1 Introduction ZapoTpX is essentially a pretty printer which takes OCaml Prolog or B specification source code as input and outputs corresponding LTpEX It is highly customisable and supports extensive syntax highlighting and on the fly definition of TEX aliases for common identifiers operators etc Most of this manual focuses on OCam1 because it is the first language which was implemented in ZapoTpEX However the same mechanisms apply to any supported language 1 1 Use Cases Writing articles and or reports which present algorithms written in Caml or simply code snippets In this case the code is embedded in the document in the same way mathematical expressions are and ZapoTpx acts as a preprocessor for the TEX document See section 2 Limited literate programming in OCaml in that case
7. a question cannot be decided at the lexical level in general ZapoTgX acts as a lexer not as a parser This a single identifier having two kinds may seem a very special case but in fact it arises frequently even within just out of the box OCaml For instance consider the declaration let a int ref ref 0 We see here that ref appears once as a type an another time as the function ref a a ref except that it is typeset as a keyword instead of a lowercase identifier I chose to consider it a keyword because of its special status as sole constructor of the built in reference type a ref Thus ZapoTpx predefines ref as having the two kinds type and keyword If you don t like this do rm kind ref type ref lident ref and then in the expression let a int ref ref 0 ref appears asa simple identifier instead of a keyword when it is not a type Or you could only define it as a type let a int ref ref 0 or only as a lowercase identifier let a int ref ref 0 which is equivalent to giving no kind definition for it Of course this digression on ref merely serves to illustrate kinds the default settings for ref type or keyword are quite good in my opinion and I recommend you leave them alone 4 2 Basic Beautification Patterns for primes and subscripts in lowercase identifiers are detected and rendered adequately by ZapoTpx SEX y X y X yz X 1 x 23 long x long 80 long 42 other text x
8. commend the following naming convention A 1px file containing ZapoTlpX Caml code should have the extension z tex and the product of a run of ZapoTgX on it should be named the same without the z So a typical ZapoTpX run should follow the pattern zapotex tex X z tex X tex Note that ZapoTpx is perfectly compatible with both ATEX and PDFHETEX ZapoTpX s running time is completely negligible before that of TEX Note that you cannot have your LEX document d input other docu ments dy k 1 n containing ZapoTpEX markup In that case you need to run ZapoTgX on each of the external documents d first yielding say zy and make it so that the main document d inputs the z instead 4 of the d This remark is of course irrelevant if you are preparing a short exam subject as you probably have only a single z tex file but in a more complex project you will need to take that into account I recommend writing a small shell script to automate the build process It is also possible to write a TEX package using shell escape to run ZapoTgxX on the fly I might do it if I ever need that but that s probably not anytime soon See Section 7 for related planned features 3 Literate programming In that case I simply mean the ability to write TEX into source code comments and have it render correctly This was supported by DumBeX and PLTeX but I have not rewritten those features yet Simply because I have not needed them aga
9. ct nobreak db btrees format trap heap findall save msgrecv fail chain insertz not write readterm error code printermenu chain inserta assertz retractall retract term replace check determ asserta writef assert chain insertafter term bin config bgifont bound chain terms diagnostics db chains ref term gstacksize consult nowarnings bgidriver type C ulong ushort ref byte word char real integer sbyte dword symbol string long unsigned short binary keyword SINGLE implement STATIC multi OR endclass struct DETERM REFERENCE database elsedef FACTS protected NOCOPY erroneous object as procedure failure ifndef language global abstract IMPLEMENT false enddef ALIGN DOMAINS facts true AS single CLASS CLAUSES static PROTECTED is ERRONEOUS determ goal this if PROCEDURE ENDCLASS IFDEF PREDICATES include DATABASE 12 ELSEDEF nocopy align class predicates nondeterm FAILURE STRUCT constants IF LANGUAGE ABSTRACT ifdef OBJECT MULTI reference IFNDEF or GLOBAL GOAL THIS domains AND ENDDEF and NONDETERM clauses CONSTANTS INCLUDE Simple Aliases 70 bindings We cy Oe is 5 h hi t FrF 5c kee qose E gt oo mo Pci o mg jc jc mq ANE OHS ODS gt o 2 0 0 5 5 54 Q5 5 24 N z Nv gt aleph gt N alpha gt a beta gt B beth gt I chi gt x daleth gt 7 delta ell epsilon gt e eta gt eth gt gDelta A gGamma T gLambda gt A gOmega
10. e commands commented from LTEX s point of view This is sometimes convenient if you work in an editor which does syntactic coloration for TEX code The same applies when command mode is accessed through command comments Those are comments of a special form see table embedded within source code which are not rendered as TEX by Zapo pX but instead are interpreted as ZapoTEX commands Not that this applies regardless of whether the comment appears in a stand alone source file or within code embedded in a ZapoTpx TpEX file For instance B alias math test ds int_a b x textrm d x A gt lt B test Renders the following utterly nonsensical B code b ABBE fa dx This is functionally equivalent to 9683 alias math test ds int_a b x textrm d x B A gt lt B test 5 1 Sample Prolog Code Zpl a b c d e blah some comment ord intersect H1 T1 H2 T2 ord intersect T2 H1 T1 a b c d e blah some comment ord_intersect__ gt H1 T1 H2 T2 ord intersect T2 H1 T1 5 2 Sample B Code b transitive_reflexive_closure closure relation closure Relation amp transitive closure closurel relation closurel Relation amp X direct gt lt product lt gt x parallel product amp lambda_expression x x 1 n A K L x 2 Y x amp 21 22 23 24 transitive reflexive closure relati
11. in If you need them drop me an email 4 Kinds aliases and other beautifications Keywords of the language and type constructors for instance are different objects and should be displayed differently Furthermore some identifiers and operators are crude ASCII replacements for Greek letters mathematical symbols and so on For instance a should really be a and lt gt stands for ZapoTgx defines a number of standard aliases such as these and enables the user to define her own easily 4 1 Kinds Each lexical construct of the language is associated to a kind for instance it can be a keyword a variable a type constructor etc Depending on its kind a lexical element can be typeset differently by ZapoTgX For instance by default Caml keywords such as open are typeset in black bold face whereas a type such as float is written in a blue italic sans serif font Most of Caml s keywords and types are predefined but the user can of course add her own using ZapoTpX commands Consider let foo x return x keyword return let foo x return x let foo x return x let foo x return x Or type valuation lident valuation let eval valuation valuation etc let eval valuation valuation etc Note that here we defined valuation to be both a declared type and a lowercase identifier and ZapoTpX used a heuristic to decide which instance was which even though such
12. on U Relation transitive closure relation U Relation x direct amp product x parallel product lambda expression A x x 1 n n K L Ix Y A 6 Default Vocabularies Here is the complete list of default predefined vocabularies that is to say kind definitions aliases and generalised aliases as generated by the dump vocabularies ZapoTlpX command switch Of course the user is free to remove any and all aliases she does not like please refer to sections 4 3 and 4 4 for more information Note that similar dumps can be effected at any place within a document by using the dump command For instance dump b pl will dump the current vocabularies for B and Prolog 10 Language B Kinds assignment 31 definitions keyword VARIANT VARIABLES OR VAR ELSE BEGIN INVARIANT THEN BE skip SELECT WHEN MODEL WHERE PRE CHOICE SETS IN MACHINE END IF ELSIF INITIALISATION DEFINITIONS CONSTRAINTS ANY LET OPERATIONS PROPERTIES EITHER CONSTANTS Simple Aliases 117 bindings 5 V 595 d gt A amp gt 9X 4 5 p i vt 3 0j ij gt g gt t Ai gt E ASi ANANS AGN T Sess Se hee Sy w gt lt gt e lt o gt lc i lllo 5C 5C i o lt 4 lt gt lt Io S nl oS oS 4 5 oa nao a gt S D gt 3 gt to S vx gt t gt gt S 2 l D GK aS gt gt 2 BOOL B FIN gt F FIN1 F INT Zrep INTEGER gt Z INT
13. sr 1sl class virtual end assert for with else lazy private let or then sig do of lor open method and Simple Aliases 95 bindings l gt 44 3 ae pba Py c gt y Vd OG ee GCP eo d rgo CS Aa aS gS a gO Se Ub m3 n gt n ee MS ae I rq sg v E 3 wus o0 voDLIU wo x0 y z5m5 x xX 74 54 D 5 70 53 5 5 55 9 Lila gt h yso ee eoe 3 Og ee a Rope 94 gt gt gt 3 gt gt 2 delta gt A gamma T lambda A omega gt Q phi 40D pi II psi V signa E theta gt upsilon Y xi gt E aleph gt N alpha gt beta f beth gt 2 chi x daleth gt 7 delta ell 0 epsilon gt e eta gt n eth fold left fold fold right fold gamma gt y gimel J iota 1 kappa x lambda gt A mho gt U mu gt u nabla gt V nu gt v omega gt w partial gt phi gt pi gt n gt psi gt y rho p sigma gt o tau gt T theta gt 0 upsilon v varepsilon varphi varpi varrho varsigma vartheta 9 xi amp zeta gt Generalised Aliases three bindings math MATHCAL N A Z D mathcal 1 math MATHBB N A Z D mathbb 1 bmath MATHFRAK N A Za z 0 mathfrak 1 Language Prolog Kinds assignment 137 definitions flow nl term str msgsend free errorlevel proje
14. th constructs in each file and replaces them by A backup of each file is made before this operation If inline is passed before also does inline replace x gt x accents a BROKEN IMPLEMENTATION DO NOT USE dump vocabularies file tex Outputs LaTeX code detailing the list of all kind definitions aliases and generaliases predefined in ZapoTeX for each supported language strict Non strict mode don t exit on ZapoTeX command error help Displays this help page 2 Code as equations To use Zapo TgX in that way you only need to keep three things in mind Your document must input the file zapoml tex which defines how lexical constructs of Caml code such as types keywords operators etc should be rendered This file can be tweaked to the user s liking Enclose Caml code between tags in the same way that display math is between in TEX If the opening tag is instead of the code is centred the closing tag is always Tocompile pre process your document say doc z tex using Zapo TEX zapotex tex doc z tex gt doc tex The generated document doc tex is then a perfectly ordinary TEX file which can be compiled as usual Example the following TEX code E dots note that the type constructor Cons of a a seq is generally denoted dots is rendered note that the type constructor Cons of a x a seq is generally de noted Practical notes Ire
15. us have fun and say that x n should be translated into x for any letter x and any number n 7 galias math POWERS NCLA Za z V NCE9 9 890 EMITIR HHHH something other x other 3 x 3 y 5 A 67 B C is rendered as something other x other 3 x y A7 B C In a nutshell anything that matches the pattern is translated while the rest is simply dealt with as usual Just as with simple aliases generalised aliases can be removed The only difference is that instead of using simply the left part of the binding which was practical for simple aliases as it was a single identifier but is not practical here as we have a nasty regular expression we will refer to a generalised alias binding by its given identifier which in this case is POWERS X 8H rm galias POWERS TEX 8H Yields X x 8 In general I recommend the convention of always naming generalised aliases in FULL CAPS Let us now look at another fun possibility list enumerations The aim here is to define a shorthand naming convention for lists whose elements are named and enumerated Consider the following code and its ZapoTExX rendering galias ENUM C A Za z CLA Za z0 9 CLA Za z0 9 1 _ text 2 dots text 1 _ text 3 HHHH Let us see q 1 n and p 1 n and something foo bar Letussee qi dn and pj pn and something oo somethingpar
16. x x x X o harra o harra o harra o harra _X _X X _X alpha alpha alpha X y Xy X yz Xi X23 long longs longa other text x x x x x o harra o harra o harra o harra xX x x x a a a Note that this integrates with aliases see below simple or generalised for instance there is an alias for alpha but not for alpha So ZapoTpx tries to find an alias for alpha finds none isolates the primes and tries to find an alias for the prime less alpha succeeds and thus renders a Thus there is no need to define primed versions of your aliases the base symbol suffices 43 Simple Aliases With simple aliases a given identifier is automatically replaced by some specific TEX code Aliases are defined using the ZapoTEX command alias in special comments HHHH alias x newN x y newN y alias math a a b b alias math square x42 alias bold math cube x 3 HEHH x y a b square cube is rendered new x new y a b x x Note that aliases can be removed if they become inappropriate in another part of the document rm alias square The same code is now rendered new x new y a b square x There are about ninety predefined aliases in ZapoTpx they are all listed in section 6 510 4 4 Generalised Aliases Generalised aliases enable the user to define whole families of aliases in one command This is done using regular expressions Let
Download Pdf Manuals
Related Search
Related Contents
DC950 ILLUMINATOR Samsung MR103/BWT Инструкция по использованию Etiquette PHYTOCAO 40 EC (Lecture seule) - phytochem-ci DV0P001 en/Drive composer start-up and maintenance PC tool user`s manual PDFファイル User manual PEC Saver user manual SBRP 136 - Brasforma 2 エクスポストアメリカンタイプ・縦型ポスト Copyright © All rights reserved.
Failed to retrieve file