libtemplates-parser-11.6.orig/0000755000175000017500000000000011637171004016217 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/.gitignore0000644000175000017500000000107411637170655020224 0ustar lbrentalbrenta*~ .build config/setup/*.ali config/setup/*.o config/tp_config.gpr docs/ada.sed docs/demo* docs/genout docs/if_inline* docs/matrix* docs/table* docs/table_if* docs/table_inline* docs/table_section* docs/templates_parser-debug.ads.texi docs/templates_parser-utils.ads.texi docs/templates_parser-xml.ads.texi docs/templates_parser.ads.texi docs/templates_parser.dvi docs/templates_parser.html docs/templates_parser.info docs/templates_parser.pdf docs/templates_parser.txt docs/user.tmplt.texi docs/user1* docs/user2* makefile.setup tp_xmlada.gpr regtests/out regtests/*.pyc libtemplates-parser-11.6.orig/README0000644000175000017500000000210711637170655017112 0ustar lbrentalbrenta Templates_Parser ---------------- Some make variables can be adjusted to change the default setup: DEFAULT_LIBRARY_TYPE=[static|relocatable] (default is static) prefix= (default to compiler root directory) ENABLE_SHARED=[true|false] (default yes on platforms supporting shared libraries) DEBUG=[true|false] (default false) PROCESSORS=N Number of parallel compilations (default 2) To build both the static and shared version (if supported) using the default setup: $ make To setup the default library as relocatable and change the installation directory: $ make DEFAULT_LIBRARY_TYPE=relocatable prefix=/opt/templates_parser setup $ make To install: $ make install Note that the installation will be done into your current GNAT root directory by default. It is possible to change this default by setting the prefix make variable, for example: $ make prefix=/opt/templates_parser install or using the setup step: $ make prefix=/opt/templates_parser setup $ make && make install libtemplates-parser-11.6.orig/config/0000755000175000017500000000000011637170657017501 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/config/setup/0000755000175000017500000000000011637170657020641 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/config/setup/foo.ads0000644000175000017500000000003011637170655022104 0ustar lbrentalbrentapackage Foo is end Foo; libtemplates-parser-11.6.orig/config/setup/test_shared.gpr0000644000175000017500000000025211637170655023655 0ustar lbrentalbrentaproject Test_Shared is for Source_Dirs use ("."); for Library_Dir use "lib"; for Library_Name use "lib"; for Library_Kind use "relocatable"; end Test_Shared; libtemplates-parser-11.6.orig/config/setup/test_xmlada.gpr0000644000175000017500000000320011637170655023651 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "xmlada"; project Test_XMLAda is for Source_Dirs use (); end Test_XMLAda; libtemplates-parser-11.6.orig/config/templates_parser.gpr0000644000175000017500000000406711637170655023572 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2008 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser/tp_shared"; with "templates_parser/tp_config"; project Templates_Parser is for Source_Dirs use ("../../include/templates_parser"); for Library_Dir use "../../lib/templates_parser/" & TP_Shared.Library_Type; for Library_Name use "templates_parser"; for Library_Kind use TP_Shared.Library_Type; for Externally_Built use "true"; package Naming renames TP_Shared.Naming; end Templates_Parser; libtemplates-parser-11.6.orig/config/tp_shared.gpr0000644000175000017500000000516211637170655022166 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2008 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "tp_config"; project TP_Shared is for Source_Dirs use (); type Tasking_Type is ("No_Tasking", "Standard_Tasking"); Tasking : Tasking_Type := TP_Config.Tasking; type Library_Kind is ("relocatable", "static"); Library_Type : Library_Kind := external ("LIBRARY_TYPE", TP_Config.Default_Library_Type); ------------ -- Naming -- ------------ package Naming is for Specification ("Templates_Parser.Configuration") use "templates_parser-configuration__standalone.ads"; for Implementation ("Templates_Parser.Input") use "templates_parser-input__standalone.adb"; case Tasking is when "No_Tasking" => for Implementation ("Templates_Parser_Tasking") use "templates_parser_tasking__no_tasking.adb"; when "Standard_Tasking" => for Implementation ("Templates_Parser_Tasking") use "templates_parser_tasking__standard_tasking.adb"; end case; end Naming; end TP_Shared; libtemplates-parser-11.6.orig/config/tp_xmlada_dummy.gpr0000644000175000017500000000327311637170655023402 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2007 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ project TP_XMLAda is for Source_Dirs use (); end TP_XMLAda; libtemplates-parser-11.6.orig/config/tp_xmlada_installed.gpr0000644000175000017500000000331311637170655024221 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2007 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "xmlada"; project TP_XMLAda is for Source_Dirs use (); end TP_XMLAda; libtemplates-parser-11.6.orig/docs/0000755000175000017500000000000011637170657017164 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/docs/.cvsignore0000755000175000017500000000132511637170655021166 0ustar lbrentalbrentaada.sed demo.adb demo.adb.res demo.adb.texi demo.tmplt.texi if_inline.adb if_inline.adb.res if_inline.adb.texi if_inline.tmplt.texi matrix.adb matrix.adb.res matrix.adb.texi matrix.tmplt.texi table.adb table.adb.res table.adb.texi table.tmplt.texi table_block.tmplt.texi table_if.adb table_if.adb.res table_if.adb.texi table_if.tmplt.texi table_inline.adb table_inline.adb.res table_inline.adb.texi table_inline.tmplt.texi table_section.adb table_section.adb.res table_section.adb.texi table_section.tmplt.texi templates_parser-debug.ads.texi templates_parser-utils.ads.texi templates_parser-xml.ads.texi templates_parser.ads.texi user.tmplt.texi user1.adb user1.adb.res user1.adb.texi user2.adb user2.adb.res user2.adb.texi libtemplates-parser-11.6.orig/docs/all_sources.ada0000644000175000017500000001167011637170655022151 0ustar lbrentalbrentawith Ada.Text_IO; with Templates_Parser; procedure Demo is Translations : constant Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("NAME", "Ada")); begin Ada.Text_IO.Put_Line (Templates_Parser.Parse ("demo.tmplt", Translations)); end Demo; with Ada.Text_IO; with Templates_Parser; procedure User1 is Translations : constant Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("USER", True)); begin Ada.Text_IO.Put_Line (Templates_Parser.Parse ("user.tmplt", Translations)); end User1; with Ada.Text_IO; with Templates_Parser; procedure User2 is Translations : constant Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("USER", False)); begin Ada.Text_IO.Put_Line (Templates_Parser.Parse ("user.tmplt", Translations)); end User2; with Ada.Text_IO; with Templates_Parser; procedure Table is use type Templates_Parser.Vector_Tag; Names : constant Templates_Parser.Vector_Tag := +"Bob" & "Bill" & "Toto"; Ages : constant Templates_Parser.Vector_Tag := +"10" & "30" & "5"; Translations : constant Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("NAME", Names), 2 => Templates_Parser.Assoc ("AGE", Ages)); begin Ada.Text_IO.Put_Line (Templates_Parser.Parse ("table.tmplt", Translations)); end Table; with Ada.Text_IO; with Templates_Parser; procedure Table_Inline is use type Templates_Parser.Vector_Tag; Colors : constant Templates_Parser.Vector_Tag := +"Red" & "Green" & "Blue"; Translations : constant Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("COLORS", Colors)); begin Ada.Text_IO.Put_Line (Templates_Parser.Parse ("table_inline.tmplt", Translations)); end Table_Inline; with Ada.Text_IO; with Templates_Parser; procedure If_Inline is use type Templates_Parser.Vector_Tag; Translations : constant Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("COND", True)); begin Ada.Text_IO.Put_Line (Templates_Parser.Parse ("if_inline.tmplt", Translations)); end If_Inline; with Ada.Text_IO; with Templates_Parser; procedure Table_Section is use type Templates_Parser.Vector_Tag; Devices : constant Templates_Parser.Vector_Tag := +"Screen" & "Keyboard" & "Mouse" & "Hard Drive"; Prices : constant Templates_Parser.Vector_Tag := +"$500" & "$20" & "$15" & "$140"; Translations : constant Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("DEVICES", Devices), 2 => Templates_Parser.Assoc ("PRICES", Prices)); begin Ada.Text_IO.Put_Line (Templates_Parser.Parse ("table_section.tmplt", Translations)); end Table_Section; with Ada.Text_IO; with Templates_Parser; procedure Table_If is use type Templates_Parser.Vector_Tag; function In_Stock (Device : in String) return Boolean; -- Complex function. Does a SQL access to the right database to know if -- the Device is available and thus can be ordered. procedure Add (Device, Price : in String); -- Add the device into the list to be displayed Devices : Templates_Parser.Tag; Prices : Templates_Parser.Tag; Available : Templates_Parser.Tag; --------- -- Add -- --------- procedure Add (Device, Price : in String) is begin Devices := Devices & Device; Prices := Prices & Price; Available := Available & In_Stock (Device); end Add; -------------- -- In_Stock -- -------------- function In_Stock (Device : in String) return Boolean is begin if Device = "Keyboard" then return True; else return False; end if; end In_Stock; Translations : Templates_Parser.Translate_Table (1 .. 3); begin Add ("Screen", "$500"); Add ("Keyboard", "$15"); Add ("Mouse", "$15"); Add ("Hard Drive", "$140"); Translations := (Templates_Parser.Assoc ("DEVICES", Devices), Templates_Parser.Assoc ("PRICES", Prices), Templates_Parser.Assoc ("AVAILABLE", Available)); Ada.Text_IO.Put_Line (Templates_Parser.Parse ("table_if.tmplt", Translations)); end Table_If; with Ada.Text_IO; with Templates_Parser; procedure Matrix is package TP renames Templates_Parser; use type TP.Tag; V1 : constant TP.Vector_Tag := +"A1.1" & "A1.2"; V2 : constant TP.Vector_Tag := +"A2.1" & "A2.2"; V3 : constant TP.Vector_Tag := +"A3.1" & "A3.2"; M : constant TP.Matrix_Tag := +V1 & V2 & V3; begin Ada.Text_IO.Put_Line (TP.Parse ("matrix.tmplt", TP.Translate_Table'(1 => TP.Assoc ("MAT", M)))); end Matrix; with Ada.Text_IO; with Templates_Parser; procedure Macro is use type Templates_Parser.Vector_Tag; Translations : Templates_Parser.Translate_Set; begin Templates_Parser.Insert (Translations, Templates_Parser.Assoc ("VAR", "Templates_Parser")); Ada.Text_IO.Put_Line (Templates_Parser.Parse ("macro.tmplt", Translations)); end Macro; libtemplates-parser-11.6.orig/docs/demo.tmplt0000755000175000017500000000002211637170655021165 0ustar lbrentalbrenta

Hello @_NAME_@ libtemplates-parser-11.6.orig/docs/docs.gpr0000755000175000017500000000360011637170655020626 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "../templates_parser"; with "../tp_shared.gpr"; project Docs is for Languages use ("Ada", "Project file"); for Object_Dir use "../" & TP_Shared'Exec_Dir & "/dobj"; for Exec_Dir use "."; for Main use ("build.adb"); package Compiler is for Default_Switches ("Ada") use ("-gnat05"); end Compiler; end Docs; libtemplates-parser-11.6.orig/docs/genout0000644000175000017500000001022611637170655020407 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004 - 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- $Id: genout 307 2005-02-16 10:34:47Z obry $ -- This API provides a way to save a Translate_Set as an XML document. -- There is special rules to know about composite tags. -- -- Composite tags : -- -- If a tag named TAG exists, then the name TAG_DESCRIPTION is used as a -- description for this specific tag. -- -- Composite tags (more than one nested level) -- -- If a tag named TAG exists, then the names TAG_DIM[n]_LABELS is used as -- a set of labels for the tag's nth axis. In this case TAG_DIM[n]_LABELS -- must be a vector tag, each entry corresponds to a label on this -- axis. Also TAG_DIM[n]_DESCRIPTION is used as a description for this -- axis. -- -- Here is the DTD : -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- package Templates_Parser.XML is function Image (Translations : in Translate_Set) return Unbounded_String; -- Returns a string representation encoded in XML for this -- translate table. function Value (Translations : in String) return Translate_Set; -- Returns a translate set for this string representation function Value (Translations : in Unbounded_String) return Translate_Set; -- Save as above but based on an Ubounded_String function Load (Filename : in String) return Translate_Set; -- Read XML document Filename and create the corresponding Translate_set procedure Save (Filename : in String; Translations : in Translate_Set); -- Write the translate table into filename end Templates_Parser.XML; libtemplates-parser-11.6.orig/docs/gentexifile0000755000175000017500000000317511637170655021421 0ustar lbrentalbrenta#!/bin/sh if [ $# = 0 ]; then echo "Usage: $0 " exit 0 fi # Check if ada.sed file is present, if not generate it ADA_KW="use package is in out exception function with type constant \ private of return range procedure begin end array record \ subtype generic limited access all tagged abstract renames \ pragma new case when null" if [ ! -f ada.sed ]; then printf 's/\([^@_]\)@\([^@_]\)/\\1@@\\2/\n' > ada.sed printf 's/-- \(.*\)$/-- @i{\\1}/\n' >> ada.sed printf '/--/!s/\([^-][^-][^"]*\)"\([^"]*\)"/\\1"@i{\\2}"/g\n' >> ada.sed printf 's/@@/@@@@/g\n' >> ada.sed printf 's/@_/@@_/g\n' >> ada.sed printf 's/_@/_@@/g\n' >> ada.sed for kw in $ADA_KW; do printf 's/^\([^-]* \)%s/\\1@b{%s}/g\n' $kw $kw >> ada.sed printf 's/^\([^-]* \)%s/\\1@b{%s}/g\n' $kw $kw >> ada.sed printf 's/^\( *\)%s /\\1@b{%s} /g\n' $kw $kw >> ada.sed printf 's/^%s$/@b{%s}/g\n' $kw $kw >> ada.sed done fi SOURCE=$1 TARGET=`basename ${SOURCE}`.texi TMPTAR=${TARGET}.tmp awk=`type gawk 2>/dev/null` if [ x"$awk" = x ]; then awk="awk" else awk="gawk" fi $awk 'BEGIN{out=1}$1=="end"&&substr($0,1,1)=="e"{out=1}out==1{print}$1=="private"&&$2!="with"&&out==1{out=0; print " -- implementation removed"}' ${SOURCE} > genout rm -f ${TMPTAR} if [ $# = 1 ]; then echo "@TPEXP{" >>${TMPTAR} sed -f ada.sed genout >>${TMPTAR} echo "}" >>${TMPTAR} else echo "@smallexample" >>${TMPTAR} sed -f ada.sed genout >>${TMPTAR} echo "@end smallexample" >>${TMPTAR} fi cat ${TMPTAR} | tr -d '\r' > ${TARGET} rm ${TMPTAR} libtemplates-parser-11.6.orig/docs/if_inline.tmplt0000755000175000017500000000012511637170655022201 0ustar lbrentalbrenta@@INLINE@@ A @@IF@@ @_COND_@ big @@ELSE@@ small @@END_IF@@ car. @@END_INLINE@@ libtemplates-parser-11.6.orig/docs/macro.tmplt0000644000175000017500000000023411637170655021344 0ustar lbrentalbrenta@@MACRO(SOMETEXT)@@ Some text, first parameter is @_$1_@ and the second is @_$2_@. @@END_MACRO@@ @@-- @_SOMETEXT(12,@_VAR_@)_@ @_UPPER:SOMETEXT(Ada,GNAT)_@ libtemplates-parser-11.6.orig/docs/makefile0000755000175000017500000001217311637170655020671 0ustar lbrentalbrenta############################################################################ # Templates_Parser # # # # Copyright (C) 2003-2010, AdaCore # # # # This library is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or (at # # your option) any later version. # # # # This library is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this library; if not, write to the Free Software Foundation, # # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # # ############################################################################ .SILENT: doc clean MAKEINFO = $(shell which makeinfo 2> /dev/null) TEXI2DVI = $(shell which texi2dvi 2> /dev/null) PDFTEX = $(shell which pdftex 2> /dev/null) TMPLT = demo.tmplt user.tmplt table.tmplt table_section.tmplt \ table_if.tmplt matrix.tmplt table_block.tmplt table_inline.tmplt \ if_inline.tmplt macro.tmplt TMPLTTEXI = $(TMPLT:=.texi) ADBFILES = demo.adb user1.adb user2.adb table.adb table_section.adb \ table_if.adb matrix.adb table_inline.adb if_inline.adb macro.adb EXEFILES = $(ADBFILES:.adb=) ADAFILES = $(ADBFILES) ALIFILES = $(ADSFILES:.ads=.ali) $(ADBFILES:.adb=.ali) RESFILES = $(ADBFILES:=.res) TEXIFILES = $(ADBFILES:=.texi) $(ADSFILES:=.texi) $(ADAFILES_NORUN:=.texi) \ $(TMPLTTEXI) GFLAGS = -I../src -I../include DOCS = templates_parser.info templates_parser.html \ templates_parser.txt templates_parser.pdf APIFILES = ../src/templates_parser.ads.texi \ ../src/templates_parser-debug.ads.texi \ ../src/templates_parser-utils.ads.texi \ ../xsrc/templates_parser-xml.ads.texi ALLDEPS = $(ADBFILES) $(ADSFILES) $(EXEFILES) $(TEXIFILES) $(TMPLTTEXI) \ $(RESFILES) $(APIFILES) doc: $(ALLDEPS) $(DOCS) %.pdf: %.texi $(ADBFILES) ifneq (${TEXI2DVI},) ifneq (${PDFTEX},) echo Building $@ ${TEXI2DVI} -p --expand --clean --quiet $< else @echo "-----------------------------------------------" @echo "pdftex not fond, cannot build PDF documentation" @echo "-----------------------------------------------" endif else @echo "--------------------------------------------------" @echo "texi2dvi not found, cannot build PDF documentation" @echo "--------------------------------------------------" endif %.info: %.texi $(ADBFILES) ifneq (${MAKEINFO},) echo Building $@ -${MAKEINFO} $< else @echo "---------------------------------------------------" @echo "makeinfo not found, cannot build INFO documentation" @echo "---------------------------------------------------" endif %.html: %.texi $(ADBFILES) ifneq (${MAKEINFO},) echo Building $@ -${MAKEINFO} --html --no-split --css-include=tp.css --ifinfo $< else @echo "---------------------------------------------------" @echo "makeinfo not found, cannot build HTML documentation" @echo "---------------------------------------------------" endif %.txt: %.texi $(ADBFILES) ifneq (${MAKEINFO},) echo Building $@ -${MAKEINFO} --plaintext --no-headers $< --output $@ else @echo "---------------------------------------------------" @echo "makeinfo not found, cannot build TEXT documentation" @echo "---------------------------------------------------" endif $(ADBFILES) $(ADSFILES): all_sources.ada $(GNAT) chop -w all_sources.ada ../tp_xmlada.gpr: cp ../config/tp_xmlada_dummy.gpr ../tp_xmlada.gpr $(EXEFILES): ../tp_xmlada.gpr $(ADBFILES) $(ADSFILES) $(GNAT) make -p -q -XLIBRARY_TYPE=static -XPRJ_BUILD=$(PRJ_BUILD) \ -XTP_XMLADA=Disabled -Pdocs $(EXEFILES) %.adb.res: %.adb echo "@TPEXP{" > $<.res ./`basename $@ .adb.res` >> $<.res echo "}" >> $<.res %.adb.html: %.adb `basename $@ .adb.html` >> $<.html %.ads.texi: %.ads gentexifile ./gentexifile $< NOGROUP %.adb.texi: %.adb %.adb.res gentexifile ./gentexifile $< %.tmplt.texi: %.tmplt gentexifile ./gentexifile $< force: clean: ifeq ($(AWS),) -$(GNAT) clean -q -XLIBRARY_TYPE=static -XPRJ_BUILD=$(PRJ_BUILD) \ -Pdocs $(EXEFILES) endif -rm -f $(EXEFILES) $(ADAFILES) $(TEXIFILES) *.res *.o *.ali genout \ *.aux *.cp* *.fn *.ky *.pg *.toc *.tp *.vr *.dvi *.log \ *.exe templates_parser*.ads.texi ada.sed \ templates_parser.tar.gz -rm -f templates_parser.html templates_parser.pdf \ templates_parser.info* templates_parser.txt libtemplates-parser-11.6.orig/docs/matrix.tmplt0000755000175000017500000000037111637170655021554 0ustar lbrentalbrentaA matrix inside a table of level 2: @@TABLE@@ @@TABLE@@ @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ The same matrix inside a single table: @@TABLE@@ @_MAT_@ @@END_TABLE@@ The same matrix outside a table: @_MAT_@ libtemplates-parser-11.6.orig/docs/table.tmplt0000755000175000017500000000016611637170655021341 0ustar lbrentalbrenta

Here is the ages of some peoples: @@TABLE@@
@_NAME_@ @_AGE_@ @@END_TABLE@@
libtemplates-parser-11.6.orig/docs/table_block.tmplt0000644000175000017500000000033111637170655022502 0ustar lbrentalbrenta

Here are some available computer devices: @@TABLE@@
@_DEVICES_@ @_PRICES_@ @@END_TABLE@@
libtemplates-parser-11.6.orig/docs/table_if.tmplt0000755000175000017500000000037711637170655022023 0ustar lbrentalbrentaHello here is a list of devices: @@END_IF@@ @@SECTION@@ @@IF@@ ((@_DEPTH_@ = "+1"))
Device Name Price Order @@TABLE@@
@_DEVICES_@ @_PRICES_@ @@IF@@ @_AVAILABLE_@ Order @@ELSE@@ Sorry, not available @@END_IF@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/docs/table_inline.tmplt0000755000175000017500000000013211637170655022670 0ustar lbrentalbrenta@@INLINE(colors=")(, )(")@@ @@TABLE@@ @_COLORS_@ @@END_TABLE@@ @@END_INLINE@@ libtemplates-parser-11.6.orig/docs/table_section.tmplt0000755000175000017500000000072711637170655023070 0ustar lbrentalbrenta

Here are some available computer devices: @@TABLE@@
@_DEVICES_@ @_PRICES_@ @@SECTION@@
@_DEVICES_@ @_PRICES_@ @@END_TABLE@@
@@TABLE@@ @@TERMINATE_SECTIONS@@
@_DEVICES_@ @@SECTION@@ @_DEVICES_@ @@SECTION@@ @_DEVICES_@ @@END_TABLE@@
libtemplates-parser-11.6.orig/docs/templates_parser.texi0000644000175000017500000020304611637170655023434 0ustar lbrentalbrenta\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename templates_parser.info @settitle Templates Parser User's Guide @setchapternewpage off @syncodeindex fn cp @iftex @afourpaper @end iftex @c ----------------------------------------- MACRO @c Macro used for all Templates_Parser examples @c No cartouche on HTML as this is part of the css @macro TPEXP{TXT} @ifhtml @smallexample @group \TXT\ @end group @end smallexample @end ifhtml @ifnothtml @cartouche @smallexample @group \TXT\ @end group @end smallexample @end cartouche @end ifnothtml @end macro @c ----------------------------------------- END MACRO @titlepage @title Templates Parser User's Guide @subtitle Date: @today{} @author AdaCore @sp 1 @url{http://libre.act-europe.fr/aws} @vskip 0pt plus 1filll @page Copyright @copyright{} 1999-2004, Pascal Obry Copyright @copyright{} 2005-2010, AdaCore @* This document may be copied, in whole or in part, in any form or by any means, as is or with alterations, provided that (1) alterations are clearly marked as alterations and (2) this copyright notice is included unmodified in any copy. @end titlepage @ifhtml @c title page for the HTML documentation @html

Document revision level $Revision$

Date: @today{}

AdaCore

@url{http://libre.act-europe.fr/aws} @page @end html @end ifhtml @finalout @contents @ifinfo @node Top @top Templates Parser @menu * Introduction:: * Tags:: * Template statements:: * Macros:: * Other services:: * Templates_Parser API Reference:: * Index:: @end menu @end ifinfo @c ---------------------------------------------------------------------- @node Introduction @chapter Introduction @c ---------------------------------------------------------------------- @noindent The templates parser package has been designed to parse files and to replace some specific tags into these files by some specified values. @noindent The main goal was to ease the development of Web servers. In CGI (@i{Common Gateway Interface}) mode you have to write the HTML page in the program (in Ada or whatever other languages) by using some specific libraries or by using only basic output functions like Ada @code{Put_Line} for example. This is of course not mandatory but by lack of a good library every Web development end up doing just that. @noindent The main problems with this approach are: @itemize @bullet @item It is painful to have to recompile the program each time you have a slight change to do in the design (center an image, change the border width of a table...) @item You have the design and the program merged together. It means that to change the design you must know the Ada language. And to change the Ada program you need to understand what is going on with all these inline HTML command. @item You can't use the nice tools to generate your HTML. @end itemize @noindent With the templates parser package these problems are gone. The code and the design is @b{completely} separated. This is a very important point. PHP or JSP have tried this but most of the time you have the script embedded into the Web template. And worst you need to use another language just for your Web development. @itemize @bullet @item The HTML page is separated from the program code. Then you can change the design without changing the code. Moreover when you fix the code you don't have to handle all the specific HTML output. And you do not risk to break the design. @item It is easier to work on the design and the program at the same time using the right people for the job. @item It reduces the number of @i{edit/build/test} cycles. Writing HTML code from a program is error prone. @item It is possible to use standard tools to produce the HTML. @item You don't have to learn a new language. @item The script is Ada, so here you have the benefit of all the Ada power. @end itemize @noindent In fact, the Ada program now simply computes some values, gets some data from a database or whatever and then calls the templates parser to output a page with the data displayed. To the templates parser you just pass the template file name and an associative table. @noindent It is even more convenient to have different displays with the same set of data. You just have to provide as many templates as you like. @c ---------------------------------------------------------------------- @node Tags @chapter Tags @c ---------------------------------------------------------------------- @menu * Tags in template files:: * Translations:: * Discrete Boolean Composite values:: * Filters:: * Attributes:: * Predefined tags:: * Dynamic tags:: @end menu @c ----------------------------------------------------------------------- @node Tags in template files @section Tags in template files @c ----------------------------------------------------------------------- @noindent A tag is a string found in the template page and surrounded by a specific set of characters. The default is @b{@@_} at the start and @b{_@@} at the end of the tag. This default can be changed using @code{Set_Tag_Separators} routine, @pxref{Templates_Parser API Reference}. Note that it must be changed as the first API call and should not be changed after that. The tag will be replaced by a value specified in the Ada code. In this context, the role of the Ada code is therefore to prepare what is known as a translation, and then pass it to the templates parser, along with the name of the template file to parse. This results in an expanded version of the templates file, where all tags have been replaced by the value given in the Ada code. Let's start with a simple example. Here is the contents of the file @file{demo.tmplt}, which is a very basic template file: @include demo.tmplt.texi @noindent On its own, this template has little interest. However, it is used from some Ada code similar to the following @file{demo.adb} file: @include demo.adb.texi @noindent Compile this program, link with the templates parser, and when you run it, the output will be: @include demo.adb.res @noindent As you can imagine, this is a bare bone example. More complex structures are of course possible. One thing to note, though, is that the template file requires no Ada knowledge for editing, and is strongly related to your application domain. One of the main usage for such templates is to generate web pages. This can be done by a designer that knows nothing of how your Ada code works. But you can use templates in other domains, including to generate Ada code. @c ---------------------------------------------------------------------- @node Translations @section Translations @c ---------------------------------------------------------------------- @noindent In your Ada code, you can associate one or more values with a name, and then reference that name in the template file as we just saw above. Associating the value(s) with the name is done through one of the @code{Assoc} constructors, @pxref{Templates_Parser API Reference}. Ada's overloading resolution mechanism will take care of calling the appropriate constructor automatically. These associations are then grouped into a dictionary. This dictionary is passed along with the name of the template file to the @code{Parse} routine itself, which generates the final expanded representation of the template. In fact, you will almost never have to manipulate an association directly, since as soon as it is created you store it in the dictionary. There are two types of dictionaries in the templates parser: @table @code @item Translate_Table @cindex Translate_Table This is an array of associations. If you know the exact number of associations when you write your code, this will generally provide a very readable code. The array can be initialized as soon as it is declared. @TPEXP{ @b{declare} T : @b{constant} Translate_Table := (1 => Assoc ("NAME1", Value1), 2 => Assoc ("NAME2", Value2)); @b{begin} Put_Line (Parse ("demo.tmplt", T)); @b{end};} @item Translate_Set @cindex Translate_Set If, on the other hand, you do not know statically the number of associations, it is generally a lot more flexible to use another type of dictionary, which isn't limited in size. It is also better to use this type of dictionary if you need extra code to compute the values. @TPEXP{ @b{declare} T : Translate_Set @b{begin} Insert (T, Assoc ("NAME1", Value1)); Insert (T, Assoc ("NAME2", Value2)); @b{end};} @end table @noindent Internally, the templates parser will always convert all dictionaries to a @code{Translate_Set}, which is much more efficient when we need to look values up. @c ---------------------------------------------------------------------- @node Discrete Boolean Composite values @section Discrete, Boolean and Composite values @c ---------------------------------------------------------------------- @noindent As we just saw, the values by which a tag is replaced must be provided by the Ada code. Such values can be provided in different formats, depending on the intended use. The three kinds of tags are @b{discrete}, @b{Boolean} and @b{composite} tags. These are all ways to associate one or more value to a name, which is the name used in the template file. @table @b @item discrete values @cindex Tag, discrete This represents a single value associated with a name. The types of value currently supported are String, Unbounded_String and Integer. @TPEXP{ Insert (T, Assoc ("NAME", 2)); Insert (T, Assoc ("NAME", "VALUE"));} @item Boolean values @cindex Tag, Boolean These are similar to discrete values. However, they are more convenient to manipulate within @code{@@@@IF@@@@} statements in the template. When outside an @code{IF} statement, such values are represented as TRUE or FALSE. @TPEXP{Insert (T, Assoc ("NAME", True));} @item composite values @cindex Tag, composite A composite tag is a variable which contains a set of values. In terms of programming languages, these would generally be called vectors. Since each value within that can itself be a composite tag, you can therefore build multi-dimensional arrays. These kind of variables will be used with the @code{TABLE} tag statement @pxref{TABLE statement}. Outside a table statement, the tag is replaced by all values concatenated with a specified separator. See @code{Set_Separator} routine. Such tag are variables declared in the Ada program a @code{Templates_Parser.Tag} type. There are many overloaded constructors to build a composite tags (see "+" operators). The "+" operators are used to build a Tag item from standard types like String, Unbounded_String, Character, Integer and Boolean. To add items to a Tag many overloaded operators are provided (see "&" operators). The "&" operators add one item at the start or the end of the tag. It is possible to directly add String, Unbounded_String, Character, Integer and Boolean items using one of the overloaded operator. A tag composed of only Boolean values TRUE or FALSE is called a Boolean composite tag. This tag is to be used with a @code{IF} tag statement inside a @code{TABLE} tag statement. It is possible to build a composite tag having any number of nested level. A vector is a composite tag with only one level, a matrix is a composite tag with two level (a Tag with a set of vector tag). Two aliases exists for composite tags with one or two nested level, they are named @code{Vector_Tag} and @code{Matrix_Tag}. In the suite of the document, we call @i{vector tag} a tag with a single nested level and @i{matrix tag} a tag with two nested level. @TPEXP{ @i{-- Building a composite tag} @i{-- Then add it into a translate set} @b{declare} V : Tag; T : Translate_Set; @b{begin} @b{for} Index @b{in} 1 .. 10 @b{loop} V := V & I; @b{end loop}; Insert (T, Assoc ("VECTOR", V)); @b{end};} @end table @c -------------------------------------------------------------------------- @node Filters @section Filters @cindex Filters @c -------------------------------------------------------------------------- @menu * Predefined filters:: * User defined filters:: @end menu @noindent Within the template file, functions can be applied to tags. Such functions are called @code{filters}. These filters might require one or more parameters, see the documentation for each filter. The syntax is: @TPEXP{ @code{@@_[[FILTER1_NAME[(parameter)]:]FILTER2_NAME[(parameter)]:]SOME_VAR_@@}. } When multiple filters are associated to a tag, they are evaluated from right to left. In the example above, @code{FILTER1_NAME} is applied to the result of applying @code{FILTER2_NAME} to @code{SOME_VAR}. Remember that one of the goals in using templates is to remove as much hard-coded information from the actual Ada source, and move it into easily editable external files. Using filters is a convenient way to give the template designer the power to specify the exact output he wants, even without changing the Ada code. For instance, imagine that one suddenly decides that some names should be capitalized in a template. There are two solutions to such a change in design: @itemize @bullet @item Modify the Ada code to capitalize strings before storing them in a tag variable. What if, in the template, we need the name once capitalized, and once with its original casing ? This means the Ada code would have to create two tags. @item Modify the template itself, and use a filter. A single tag is required on the Ada side, which doesn't even have to be changed in fact. The template would for instance become: @TPEXP{@@_CAPITALIZE:VAR_@@ : constant String := "@@_VAR_@@";} @end itemize The templates parser comes with a number of predefined filters, that can be used in various situations. Some of these are highly specialized, but most of them are fairly general. You can also define your own filters, adapted to specific needs you might have. Here are some more examples using the predefined filters: @TPEXP{If VAR is set to "@i{vector_tag}", ONE to "1" and TWO to "2" then: @@_VAR_@@ -> vector_tag @@_UPPER:VAR_@@ -> VECTOR_TAG @@_CAPITALIZE:VAR_@@ -> Vector_Tag @@_EXIST:VAR_@@ -> TRUE @@_UPPER:REVERSE:VAR_@@ -> GAT_ROTCEV @@_MATCH(VEC.*):UPPER:VAR_@@ -> TRUE @@_SLICE(1..6):VAR_@@ -> vector @@_REPLACE(([^_]+)):VAR_@@ -> vector @@_REPLACE(([a-z]+)_([a-z]+)/\\2_\\1):VAR_@@ -> tag_vector @@_"+"(TWO):ONE_@@ -> 3 @@_"-"(TWO):ONE_@@ -> -1} @c ---------------------------------------------------------------------------- @c -- Predefined filters @c ---------------------------------------------------------------------------- @node Predefined filters @subsection Predefined filters Here is the complete list of predefined filters that come with the templates parser. @table @code @item "+"(@i{N}) or ADD(@i{N}) @cindex Filter, "+" Add N to variable and return the result. If the current variable value is not a number it returns the empty string. N must be a number or a discrete tag variable whose value is a number. @item "-"(@i{N}) or SUB(@i{N}) @cindex Filter, "-" Subtract N to variable and return the result. If the current variable value is not a number it returns the empty string. N must be a number or a discrete tag variable whose value is a number. @item "*"(@i{N}) or MULT(@i{N}) @cindex Filter, "*" Multiply N with variable and return the result. If the current variable value is not a number it returns the empty string. N must be a number or a discrete tag variable whose value is a number. @item "/"(@i{N}) or DIV(@i{N}) @cindex Filter, "/" Divide variable by N and return the result. If the current variable value is not a number it returns the empty string. N must be a number or a discrete tag variable whose value is a number. @item ABS @cindex Filter, ABS Returns the absolute value. @item ADD_PARAM(@i{NAME[=VALUE]}) @cindex Filter, ADD_PARAM Add a parameter into an URL. This routine adds the '?' and '&' character if needed. @i{VALUE} can be a tag variable name. @item BR_2_EOL(@i{EOL}) @cindex Filter, BR_2_EOL Replaces all occurrences of the @code{
} HTML tag by a line terminator determined by EOL. EOL must be either CR (Carriage-Return), LF (Line-Feed), LFCR (Line-Feed followed by Carriage-Return) or CRLF (Carriage-Return followed by Line-Feed). @item BR_2_LF @cindex Filter, BR_2_LF Shortcut for BR_2_EOL(LF). @item CAPITALIZE @cindex Filter, CAPITALIZE Put all characters in the variable in lower case except characters after a space or an underscore which are set in upper-case. @item CLEAN_TEXT @cindex Filter, CLEAN_TEXT Keep only letters and digits all others characters are changed to spaces. @item COMA_2_POINT @cindex Filter, COMA_2_POINT Replaces all comas by points. @item CONTRACT @cindex Filter, CONTRACT Converts any suite of spaces by a single space character. @item DEL_PARAM(@i{NAME}) @cindex Filter, DEL_PARAM Delete parameter NAME from the URL. This routine removes the '?' and '&' character if needed. Returns the input string as-is if the parameter is not found. @item EXIST @cindex Filter, EXIST Returns @b{True} if variable is set and has a value different that the null string and @b{False} otherwise. @item FILE_EXISTS @cindex Filter, FILE_EXISTS Returns @b{True} if variable is set and has a value that corresponds to a file name present on the file system and @b{False} otherwise. @item FORMAT_DATE(@b{FORMAT}) @cindex Filter, FORMAT_DATE Returns the date with the given format. The date must be in the ISO format (YYYY-MM-DD) eventually followed by a space and the time with the format HH:MM:SS. If the date is not given in the right format it returns the date as-is. The format is using the GNU/date description patterns as also implemented in @code{GNAT.Calendar.Time_IO}. @itemize @bullet @item @i{Characters}: @itemize @item @b{%}: a literal % @item @b{n}: a newline @item @b{t}: a horizontal tab @end itemize @item @i{Time fields}: @itemize @item @b{%H}: hour (00..23) @item @b{%I}: hour (01..12) @item @b{%k}: hour ( 0..23) @item @b{%l}: hour ( 1..12) @item @b{%M}: minute (00..59) @item @b{%p}: locale's AM or PM @item @b{%r}: time, 12-hour (hh:mm:ss [AP]M) @item @b{%s}: seconds since 1970-01-01 00:00:00 UTC (a nonstandard extension) @item @b{%S}: second (00..59) @item @b{%T}: time, 24-hour (hh:mm:ss) @end itemize @item @i{Date fields}: @itemize @item @b{%a}: locale's abbreviated weekday name (Sun..Sat) @item @b{%A}: locale's full weekday name, variable length (Sunday..Saturday) @item @b{%b}: locale's abbreviated month name (Jan..Dec) @item @b{%B}: locale's full month name, variable length (January..December) @item @b{%c}: locale's date and time (Sat Nov 04 12:02:33 EST 1989) @item @b{%d}: day of month (01..31) @item @b{%D}: date (mm/dd/yy) @item @b{%h}: same as %b @item @b{%j}: day of year (001..366) @item @b{%m}: month (01..12) @item @b{%U}: week number of year with Sunday as first day of week (00..53) @item @b{%w}: day of week (0..6) with 0 corresponding to Sunday @item @b{%W}: week number of year with Monday as first day of week (00..53) @item @b{%x}: locale's date representation (mm/dd/yy) @item @b{%y}: last two digits of year (00..99) @item @b{%Y}: year with four digits (1970...) @end itemize @item @i{Padding}: By default, date pads numeric fields with zeroes. GNU date recognizes the following nonstandard numeric modifiers: @itemize @item @b{-} (hyphen): do not pad the field @item @b{_} (underscore): pad the field with spaces @end itemize @end itemize @item FORMAT_NUMBER([@i{DIGITSEP}]) @cindex Filter, FORMAT_NUMBER Returns the number with a separator added between each 3 digits blocks. The decimal part is not transformed. If the data is not a number nothing is done. The default separator is a space, although you can specify any separator (a single character) you wish. DIGITSEP can also be the name of another tag, whose value (or the first character of it) will be used as a separator. @item IS_EMPTY @cindex Filter, IS_EMPTY Returns @b{True} if variable is the empty string and @b{False} otherwise. @item LF_2_BR @cindex Filter, LF_2_BR Replaces all occurrences of the character LF (Line-Feed) by a @code{
} HTML tag. @item LOWER @cindex Filter, LOWER Put all characters in the variable in lower-case. @item MATCH(@i{REGEXP}) @cindex Filter, MATCH Returns @b{True} if variable match the regular expression passed as filter's parameter. The regular expression is using a format as found in @file{gawk}, @file{sed} or @file{grep} tools. @item MAX(@i{N}) @cindex Filter, MAX Returns the maximum value between the variable and the parameter. @item MIN(@i{N}) @cindex Filter, MIN Returns the minimum value between the variable and the parameter. @item MOD(@i{N}) @cindex Filter, MOD Returns variable modulo N. If the current variable value is not a number it returns the empty string. N must be a number or a discrete tag variable whose value is a number. @item NEG @cindex Filter, NEG Change the sign of the value. @item NO_DYNAMIC @cindex Filter, NO_DYNAMIC This is a special command filter which indicates that the tag must not be searched in the dynamic tags. See @pxref{Lazy_Tag}. @code{NO_DYNAMIC} must be the first filter. This filter returns the value as-is. @item NO_DIGIT @cindex Filter, NO_DIGIT Replaces all digits by spaces. @item NO_LETTER @cindex Filter, NO_LETTER Replaces all letters by spaces. @item NO_SPACE @cindex Filter, NO_SPACE Removes all spaces in the variable. @item OUI_NON @cindex Filter, OUI_NON If variable value is @b{True} it returns @b{Oui}, if @b{False} it returns @b{Non}, otherwise does nothing. It keeps the way @b{True/False} is capitalized (all upper, all lower or first letter capital). @item POINT_2_COMA @cindex Filter, POINT_2_COMA Replaces all comas by points. @item REPEAT(@i{N}) @cindex Filter, REPEAT Returns @i{N} times the variable, @i{N} being passed as filter's parameter. @i{N} must be a number or a discrete tag variable whose value is a number. @item REPEAT(@i{STR}) @cindex Filter, REPEAT This is the second @code{REPEAT} form. In this case @i{STR} is repeated a number of time corresponding to the variable value which must be a number. @item REPLACE(@i{REGEXP}[/@i{STR}]) @cindex Filter, REPLACE This filter replaces @b{\n} (where @i{n} is a number) @i{STR}'s occurrences by the corresponding match from @i{REGEXP}. The first match in @i{REGEXP} will replace @b{\1}, the second match @b{\2} and so on. Each match in @i{REGEXP} must be parenthesized. It replaces only the first match. @i{STR} is an optional parameter, its default value is @b{\1}. It is possible to space characters in @i{STR} to avoid parsing confusions. This is required if you need to have @b{@@_} or @b{_@@} or a parenthesis in @i{STR} for example. @i{STR} can be a tag variable name. @i{STR} can contain the following escaped characters : @b{\n} Carriage Return, @b{\r} Line Feed and @b{\t} for Horizontal Tabulation. @item REPLACE_ALL(@i{REGEXP}[/@i{STR}]) @cindex Filter, REPLACE_ALL Idem as above but replaces all occurrences. @item REPLACE_PARAM(@i{NAME[=VALUE]}) @cindex Filter, REPLACE_PARAM This is filter is equivalent to ADD_PARAM(@i{NAME[=VALUE]}):DEL_PARAM(@i{NAME}). @i{VALUE} can be a tag variable name. @item REVERSE @cindex Filter, REVERSE Reverse the string. @item SIZE @cindex Filter, SIZE Returns the size (number of characters) of the string value. @item SLICE(@i{x .. y}) @cindex Filter, SLICE Returns the sub-string starting from position x and ending to position y. Note that the string to slice always start from position 1. If x or y are negative, they are counted from the end of the string, so that 0 matches the last character of the string, -1 matches the character just before,... @item TRIM @cindex Filter, TRIM Removes leading and trailing spaces. @item UPPER @cindex Filter, UPPER Put all characters in the variable in upper-case. @item WEB_ENCODE @cindex Filter, WEB_ENCODE As WEB_ESCAPE and also encodes all non 7-bit characters and non printable characters using @b{&#xxx;} HTML encoding. @item WEB_ESCAPE @cindex Filter, WEB_ESCAPE Replaces characters '<', '>', '"' and '&' by corresponding HTML sequences: < > " and & @item WEB_NBSP @cindex Filter, WEB_NBSP Replaces all spaces by an HTML non breaking space. @item WRAP(@i{N}) @cindex Filter, WRAP Wraps lines having more N characters. @item YES_NO @cindex Filter, YES_NO If variable value is @b{True} it returns @b{Yes}, if @b{False} it returns @b{No}, otherwise does nothing. It keeps the way @b{True/False} is capitalized (all upper, all lower or first letter capital). @end table @c --------------------------------------------------------------------------- @node User defined filters @subsection User defined filters @c --------------------------------------------------------------------------- @noindent It is also possible to define a new filter by registering a callback routine associated with the filter name. You can define three kinds of filters: filters that take no argument, and are therefore simply used as in @@_FILTER:TAG_@@, filters that take one or more arguments, used as in @@_FILTER(param1,param2):TAG_@@, and filters that are implemented as tagged objects, and take the same form as the filters with arguments described above. The latter form of filters (using tagged types) provides slightly more flexibility, as you can store your own user data in the filter when it is registered. Among other things, this makes it possible to share filters between various applications, when the filter needs to access some application-specific variable as well. The templates parser will not try to interpret the parameters for you, and will simply return the string representation of the list of parameters, for instance @code{"param1,param2"} in the example above. This provides enhanced flexibility, since you are free to use any parameter-separator you want, and to interpret parameters as integer, strings, references to other tags,@dots{} The templates parser doesn't support tag substitution within the parameter list, but this is trivial to implement in your own code. For instance, if the user has used @@_FILTER(REFTAG):TAG_@@, you are free to either take @code{REFTAG} as a constant string, or as a reference to another tag, to be looked up in a translation table. You should of course properly document the behavior of your filter. Here is the templates parser API for defining your own custom filters: @TPEXP{ @b{type} Filter_Context @b{is record} Translations : Translate_Set; Lazy_Tag : Dynamic.Lazy_Tag_Access; @b{end record}; @b{type} Callback @b{is access function} (Value : @b{in} String; Parameters : @b{in} String; Context : @b{in} Filter_Context) @b{return} String; @i{-- User's filter callback} @b{type} Callback_No_Param @b{is access function} (Value : @b{in} String; Context : @b{in} Filter_Context) @b{return} String; @i{-- User's filter callback} @b{procedure} Register_Filter (Name : @b{in} String; Handler : @b{in} Callback); @i{-- Register user's filter Name using the specified Handler} @b{procedure} Register_Filter (Name : @b{in} String; Handler : @b{in} Callback_No_Param); @i{-- Register user's filter Name using the specified Handler}} In the above calls, Value is the value of the tag on which the filter applies. In the examples above, that would be the value of @code{TAG} as looked up in the translation table. Context contains the the translation table and the current lazy tag object you can use if you need to look up other tags. Here is a simple example of a custom filter, which can be used to generate HTML forms. In such a form, it is common to have some @code{} tags that need a @code{selected='selected'} attribute if the toggle button should be selected. This can be done without the use of a filter, of course, using a simple @code{@@@@IF@@@@} statement, but that makes the template less readable. The custom filter below behaves as such: it takes one argument, and compares the value of the tag on which the filter is applied to that argument. If they are equal, the string @code{selected='selected'} will be substituted. As a special case, if the argument to the filter starts with a @code{'@@'} character, the argument is interpreted as the name of a tag to look up first. @TPEXP{ @b{function} Custom_Select_Filter (Value : @b{in} String; Parameters : @b{in} String; Context : @b{in} Filter_Context) @b{return} String @b{is} begin @b{if} Parameters /= "" @b{and then} Parameters (Parameters'First) = '@@' @b{then} @b{if} Get (Get (Context.Translations, Parameters (Parameters'First + 1 .. Parameters'Last))) = Value @b{then} return "selected='selected'"; @b{end if}; @b{elsif} Value = Parameters @b{then} return "selected='selected'"; @b{end if}; @b{return} ""; @b{end} Custom_Select_Filter; Register_Filter ("SELECTED", Custom_Select_Filter'Access); } and a template would look like: @TPEXP{

Client @@_CID_@@ ...} @c ----------------------------------------------------------------------- @node INCLUDE statement @section INCLUDE statement @cindex Command, INCLUDE @c ----------------------------------------------------------------------- @noindent This statement is used to include another template file. This is useful if you have the same header and/or footer in all your HTML pages. For example: @TPEXP{@@@@INCLUDE@@@@ header.tmplt

This is by Web page @@@@INCLUDE@@@@ footer.tmplt} @noindent It is also possible to pass arguments to the include file. These parameters are given after the include file name. It is possible to reference these parameters into the included file with the special variable names @code{@@_$_@@}, where @i{n} is the include's parameter index (0 is the include file name, 1 the first parameter and so on). @TPEXP{@@@@INCLUDE@@@@ another.tmplt @@_VAR_@@ azerty} @noindent In file @file{another.tmplt} @table @code @item @@_$0_@@ is another.tmplt @item @@_$1_@@ is the variable @@_VAR_@@ @item @@_$2_@@ is the string "azerty" @end table If an include variable references a non existing include parameter the tag is kept as-is. Note that it is possible to pass the include parameters using names, a set of positional parameters can be pass first, so all following include commands are identical: @TPEXP{@@@@INCLUDE@@@@ another.tmplt one two three four "a text" @@@@INCLUDE@@@@ another.tmplt (one, two, 3 => three, 4 => four, 5 => "a text") @@@@INCLUDE@@@@ another.tmplt (one, 5 => "a text", 3 => three, 2 => two, 4 => four)} @noindent The file name can also be a tag. In this case the file loading is deferred at the parsing time. @noindent For security reasons the filename can't be a full pathname. If a full pathname is passed then the leading directory separator is removed. @c ----------------------------------------------------------------------- @node IF statement @section IF statement @cindex Command, IF @c ----------------------------------------------------------------------- @noindent This is the conditional statement. The complete form is: @TPEXP{@@@@IF@@@@ part1 @@@@ELSIF@@@@ part2 @@@@ELSE@@@@ part3 @@@@END_IF@@@@} @noindent is TRUE if it evaluates to one of "TRUE", "T" or "1" and FALSE otherwise. Note that the test is not case sensitive. @noindent The part1 one will be parsed if expression1 evaluate to TRUE, part2 will be parsed if expression2 evaluate to TRUE and the part3 will be parse in any other case. The @code{ELSIF} and @code{ELSE} parts are optional. The expression here is composed of Boolean variables and/or Boolean expression. Recognized operators are: @cindex Command, IF expression @table @code @item A = B Returns TRUE if A equal B @item A /= B Returns TRUE if A is not equal B @item A > B Returns TRUE if A greater than B. If A and B are numbers it returns the the number comparison (5 > 003 = TRUE) otherwise it returns the string comparison (``5'' > ``003'' = FALSE). @item A >= B Returns TRUE if A greater than or equal to B. See above for rule about numbers. @item A < B Returns TRUE if A lesser than B. See above for rule about numbers. @item A <= B Returns TRUE if A lesser than or equal to B. See above for rule about numbers. @item A and B Returns TRUE if A and B is TRUE and FALSE otherwise. @item A or B Returns TRUE if A or B is TRUE and FALSE otherwise. @item A xor B Returns TRUE if either A or B (but not both) is TRUE and FALSE otherwise. @item A in B Returns TRUE if A is found into the composite tag B and FALSE otherwise. B must be a tag. If B contains a single value then this expression is equivalent to (A = B). @item not A Returns TRUE if either A is FALSE and FALSE otherwise. @end table The default evaluation order is done from left to right, all operators having the same precedence. To build an expression it is possible to use parenthesis to change the evaluation order. A value with spaces must be quoted as a string. So valid expressions could be: @TPEXP{@@@@IF@@@@ (@@_VAR1_@@ > 3) or (@@_COND1_@@ and @@_COND2_@@) @@@@IF@@@@ not (@@_VAR1_@@ > 3) or (@@_COND1_@@ and @@_COND2_@@) @@@@IF@@@@ (@@_VAR1_@@ > 3) and not @@_COND1_@@ @@@@IF@@@@ @@_VAR1_@@ = "a value"} @noindent Note also that variables and values can be surrounded by quotes if needed. Quotes are needed if a value contain spaces. Let's see an example using an @code{IF} tag statement. With the following template: @include user.tmplt.texi @noindent The following program: @include user1.adb.texi @noindent Will display: @include user1.adb.res @noindent But the following program: @include user2.adb.texi @noindent Will display: @include user2.adb.res @c ----------------------------------------------------------------------- @node TABLE statement @section TABLE statement @cindex Command, TABLE @c ----------------------------------------------------------------------- @noindent Table tags are useful to generate @code{HTML} tables for example. Basically the code between the @code{@@@@TABLE@@@@} and @code{@@@@END_TABLE@@@@} will be repeated as many times as the vector tag has values. If many vector tags are specified in a table statement, the code between the table will be repeated a number of times equal to the maximum length of all vector tags in the @code{TABLE} tag statement. A @code{TABLE} tag statement is a kind of implicit iterator. This is a very important concept to build HTML tables. Using a composite tag variable in a @code{@@@@TABLE@@@@} tag statement it is possible to build very complex Web pages. Syntax: @cindex Command, TERMINATE_SECTIONS @cindex Command, REVERSE @cindex Command, TERSE @TPEXP{@@@@TABLE['REVERSE]['TERMINATE_SECTIONS]['TERSE]@@@@ ... [@@@@BEGIN@@@@] ... [@@@@SECTION@@@@] ... [@@@@END@@@@] ... @@@@END_TABLE@@@@} @noindent Let's have an example. With the following template: @include table.tmplt.texi @noindent And the following program: @include table.adb.texi @noindent The following output will be generated: @include table.adb.res @noindent Note that we use vector tag variables here. A discrete variable tag in a table will be replaced by the same (the only one) value for each row. A vector tag outside a table will be displayed as a list of values, each value being separated by a specified separator. The default is a comma and a space ", ". The complete prototype for the @code{Tag} Assoc function is: @TPEXP{@b{function} Assoc (Variable : @b{in} String; Value : @b{in} Tag; Separator : @b{in} String := Default_Separator) @b{return} Association; @i{-- Build an Association (Variable = Value) to be added to Translate_Table.} @i{-- This is a tag association. Separator will be used when outputting the} @i{-- a flat representation of the Tag (outside a table statement).}} @noindent A table can contain many sections. The section to use will be selected depending on the current line. For example, a table with two sections will use different data on even and odd lines. This is useful when you want to alternate the line background color for a better readability when working on HTML pages. @noindent A table with sections can have attributes: @table @code @item REVERSE The items will be displayed in the reverse order. @item TERMINATE_SECTIONS This ensure that the table output will end with the last section. If the number of data in the vector variable tag is not a multiple of the number of sections then the remaining section will be complete with empty tag value. @item TERSE Empty lines won't be output. If the composite tag used into the table has an empty value then the corresponding line won't be output. This is especially important to avoid empty ending lines for table containing vector of different size. @end table @include table_section.tmplt.texi @noindent And the following program: @include table_section.adb.texi @noindent The following output will be generated: @include table_section.adb.res @noindent It is important to note that it is possible to avoid code duplication by using the @code{@@@@BEGIN@@@@} and @code{@@@@END@@@@} block statements. In this case only the code inside the block is part of the section, the code outside is common to all sections. Here is an example to generate an HTML table with different colors for each line: @noindent The template file above can be written this way: @include table_block.tmplt.texi @noindent Into a table construct there are some additional variable tags available: @table @code @item @@_UP_TABLE_LINE_@@ @cindex @@_UP_TABLE_LINE_@@ This tag will be replaced by the table line number of the upper table statement. It will be set to 0 outside a table statement or inside a single table statement. @item @@_TABLE_LINE_@@ @cindex @@_TABLE_LINE_@@ This tag will be replaced by the current table line number. It will be replaced by 0 outside a table statement. @item @@_NUMBER_LINE_@@ @cindex @@_NUMBER_LINE_@@ This is the number of line displayed in the table. It will be replaced by 0 outside a table statement. @item @@_TABLE_LEVEL_@@ @cindex @@_TABLE_LEVEL_@@ This is the table level number. A table construct declared in a table has a level value of 2. It will be replaced by 0 outside a table statement. @end table @noindent Let's have a look at a more complex example with mixed IF and TABLE statements. @noindent Here is the template: @include table_if.tmplt.texi @noindent And the following program: @include table_if.adb.texi @noindent The following output will be generated: @include table_if.adb.res @noindent Table tag statements can also be used with matrix tag or more nested tag variables. In this case, for a tag variable with N nested levels, the Nth closest enclosing @code{TABLE} tag statement will be used for the corresponding index. If there are not enough indexes, the last axis are just streamed as a single text value. @noindent Let's see what happens for a matrix tag: @enumerate @item Inside a table of level 2 (a TABLE statement inside a TABLE statement). @noindent In this case the first @code{TABLE} iterates through the matrix lines. First iteration will use the first matrix's vector, second iteration will use the second matrix's vector and so on. And the second @code{TABLE} will be used to iterate through the vector's values. @item Inside a table of level 1. @noindent In this case the @code{TABLE} iterates through the matrix lines. First iteration will use the first matrix's vector, second iteration will use the second matrix's vector and so on. Each vector is then converted to a string by concatenating all values using the specified separator (see Assoc constructor for Tag or @code{Set_Separator} routine). @item Outside a table statement. @noindent In this case the matrix is converted to a string. Each line represents a vector converted to a string using the supplied separator (see point 2 above), and each vector is separated by an ASCII.LF character. The separators to use for each level can be specified using @code{Set_Separator}. @end enumerate @noindent Let's look at an example, with the following template: @include matrix.tmplt.texi @noindent Using the program: @include matrix.adb.texi @noindent We get the following result: @include matrix.adb.res @c --------------------------------------------------------------------------- @node SET statement @section SET statement @cindex Command, SET @c --------------------------------------------------------------------------- @noindent The @code{SET} command tag can be used to define a constant or an alias for an include file parameter. This is especially important in the context of reusable template files. For example, instead of having many references to the @b{red} color in an HTML document, it is better to define a constant @var{COLOR} with the value @b{red} and use @var{COLOR} everywhere. It is then easier to change the color afterward. @noindent The first form, to define a simple constant that can be used as any other variable in a template file, is: @TPEXP{@@@@SET@@@@ = } @noindent The second form, to define an alias for a template file parameter, is: @TPEXP{@@@@SET@@@@ = $n [| ]} @noindent In this case is an alias for the Nth include parameter. In this form it is also possible to define a default value that would be used if the Nth include parameter is not specified. Some examples: @TPEXP{@@@@SET@@@@ COLOR = red @@@@SET@@@@ SIZE = $1 @@@@SET@@@@ COLOR = $4 | green} @noindent It is important to note that a variable is set global to a template file. It means that constants set into an include file are visible into the parent template. This is an important feature to be able to have a "theme" like include template file for example. @c --------------------------------------------------------------------------- @node INLINE statement @section INLINE statement @cindex Command, INLINE @c --------------------------------------------------------------------------- @noindent The @code{INLINE} statement can be used to better control the result's layout. For example it is not possible to have the results of a vector tag on the same line, also it is not possible to have a conditional output in the middle of a line. The @code{INLINE} block tag statement can be used to achieve that. Elements in an inlined block are separated by a single space by default. It is possible to specify any string as the separator. The text layout on an @code{INLINE} block has no meaning (the lines are trimmed on both side). As part of the inline command it is possible to specify texts to output before and after the block. @noindent Syntax: @TPEXP{@@@@INLINE[()()()]@@@@ ... @@@@END_INLINE@@@@} @noindent There are three supported uses: @table @code @item @@@@INLINE@@@@ In this case there is no text before and after the block and the separator is a single space. @item @@@@INLINE()@@@@ In this case there is no text before and after the block and the separator is the string given as parameter @i{}. @item @@@@INLINE()()()@@@@ In this case all three values are explicitly given. @end table @noindent @i{}, @i{} and @i{} may contain control characters: @table @code @item \n To insert a new-line (CR+LF or LF depending on the Operation System) @item \r To insert a line-feed @item \\ To insert a single backslash @end table @noindent Let's look at an example, with the following template: @include table_inline.tmplt.texi @noindent Using the program: @include table_inline.adb.texi @noindent We get the following result: @include table_inline.adb.res @noindent Another example with an @code{IF} tag statement: @include if_inline.tmplt.texi @noindent Using the program: @include if_inline.adb.texi @noindent We get the following result: @include if_inline.adb.res @c --------------------------------------------------------------------------- @node MACRO statement @section MACRO statement @cindex Command, MACRO @c --------------------------------------------------------------------------- @noindent The @code{MACRO} statement is used to defined macros that can be used in other places in the template. The macro statement takes a single parameter which is the name of the macro. @noindent Syntax: @TPEXP{@@@@MACRO(NAME)@@@@ ... @@@@END_MACRO@@@@} @noindent The code inside the macro can be anything supported by the templates engine. There is no restriction. The parameters inside the macro are referenced as @@_$N_@@ (where N is a number and corresponds to the Nth parameter passed to the macro). There is no maximum number of parameters. A reference to a parameter that has no corresponding formal parameter at the call point is ignored (the value will be the empty string). @noindent For example: @include macro.tmplt.texi For using macros @pxref{Macros}. @c ---------------------------------------------------------------------- @node Macros @chapter Macros @c ---------------------------------------------------------------------- @noindent A macro usage is like a tag but with a set of parameters passed inside parenthesis. Macros support all filters but attributes can't be used. It is important to note that macros are expanded at the point of their calls. This implementation maximizes speed but uses more memory as the definition is not shared. If the code is large it may be better to use an @@@@INCLUDE@@@@ as the code is not expanded. @noindent Syntax: @TPEXP{ @code{@@_[[FILTER[(parameter)]:]MACRO_NAME([PARAM1][,N=>PARAMN])_@@}. } @noindent A macro call can have positional parameters (like @code{PARAM1} above) or named (where the name is a number corresponding to the actual parameter position) parameters (like @code{PARAMN} above). @noindent With the following definition: @include macro.tmplt.texi @noindent Using the program: @include macro.adb.texi @noindent We get the following result: @include macro.adb.res @c ---------------------------------------------------------------------- @node Other services @chapter Other services @menu * Tag utils:: * XML representation:: * Templates2Ada:: * Templatespp:: * Debug:: @end menu @node Tag utils @section Tag utils @cindex Tag utils @noindent The child package @code{Utils}, @pxref{Templates_Parser.Utils} contains a routine to encode a Tag variable into a string and the inverse routine that build a Tag given it's string representation. This is useful for example, in the context of AWS to store a Tag into a session variable. See the AWS project. @node XML representation @section XML representation @cindex XML @noindent The child package @code{XML}, @pxref{Templates_Parser.XML} contains routines to save a @code{Translation_Set} into an XML document or to create a @code{Translation_Set} by loading an XML document. The XML document must conform to a specific @code{DTD} (see the Ada spec file). @c -------------------------------------------------------------------------- @c -- Templates2Ada @c -------------------------------------------------------------------------- @node Templates2Ada @section Templates2Ada @cindex templates2ada @noindent @code{templates2ada} is a tool that will generate a set of Ada packages from a templates file. These Ada packages can then be used in your application to avoid hard-coded strings, and help maintain the templates and the code synchronized. One of its goal is to ensure that you are only setting tags that actually exist in the template (and thus prevent, as much as possibly, typos in the name of tags); also, when combined with other tools, to help ensure that all tags needed by the template are properly set. Templates2ada also has special knowledge about HTTP constructs and will generate Ada constants for the HTTP parameters you might receive in return. Once more the goal is to help avoid typos in the Ada code. For instance, we will consider a simple template file, found in a local file @file{resources/block1.thtml}. This template contains the following simple html code: @TPEXP{

} When you run @file{templates2ada} (as described in the following subsection), the following Ada package will be generated. Note that this is only the default output of @file{templates2ada}, which can be fully tailored to your needs. @TPEXP {@b{package} Templates.Block1 @b{is} pragma Style_Checks (Off); Template : constant string := "resources/block1.thtml"; Tag1 : constant String := "TAG1"; Tag2 : constant String := "TAG2"; @b{package} Http @b{is} Param1 : constant String := "PARAM1"; Param2 : constant String := "PARAM2"; @b{end} Http; @b{end} Templates.Block1;} @code{templates2ada} knows about special constructs in the template file. Such templates are generally associated with html pages. It is possible to specify within the template itself what the url associated with the template is, so that it provides a convenient link between the two. Likewise, you can also define explicitly what the possible HTTP parameters are when loading that page. This is mostly useful when those parameters do not correspond to some form fields within the page itself. The syntax for these two is the following: @TPEXP{ @@-- HTTP_URL(the_url): any comment you want @@-- HTTP_GET(param1_name): description of the parameter @@-- HTTP_GET(param2_name): description of the parameter } and that results in the following constants in the generated Ada package: @TPEXP{ @b{package} Templates.Block1 @b{is} URL : constant String := "the_url"; @b{package} Http @b{is} Param1_Name : constant String := "param1_name"; Param2_Name : constant String := "param2_name"; @b{end} Http; @b{end} Templates.Block1;} The templates parser API lets you define your own custom filters. It is often useful for those filters to take parameters, just like the predefined filters do. However, it is also useful for these parameters to be able to check the value of other tags. One convention for doing this is to start the name of the parameter with "@". See for example the example in @pxref{User defined filters}. As a reminder, the template would look like @TPEXP{
} @noindent and this ensures the link is valid. @file{templates2ada} supports a number of command line switches: @itemize @bullet @item -d This switch specifies the directory in which the templates file are searched for. @item -o This switch specifies the output file name @item -e This file specifies the file name extension for template files. All files in the directory that have this extension will be processed by templates2ada. @item -t This file specifies the template file to be used for the output file. The templates parser comes with an example for such a file, called @file{templates.tads}, that you can adapt to your own needs. @item -r Sub directories of the one specified by @code{-d} will also be searched. @item -v Activate the verbose mode. This will output a warning when an http parameter has a name made only of template parser tags, since no matching entry can then be created for it in the output file. @end itemize @c --------------------------------------------------------------------------- @c -- Templates2ada -- customizing @c --------------------------------------------------------------------------- @subsection Customizing templates2ada @noindent As was mentioned before, the output of templates2ada is a single file that results from parsing a template file. An example of such a file is provided in the templates2ada distribution, as @file{templates.tads}. You are strongly encouraged to modify this file to adapt it to your needs, and then use the @code{-t} switch to @file{templates2ada} to make use of your modified file. This file contains extensive comments on how to make use, and customize, it. This documentation is not duplicated here @c -------------------------------------------------------------------------- @c -- Templatespp @c -------------------------------------------------------------------------- @node Templatespp @section Templatespp @cindex templatespp @noindent @code{templatespp} is a pre-processor based on the template parser. It is generally used from scripts to process files and generate other files. One of the possible uses, for instance, is to write the CSS (style-sheet) of a web site as a template file (for instance @file{mycss.tcss}), and use template parser structures in there. This is a good way to share colors for instance, or to name constants, as is often done in Ada code. Here is a small example of such a CSS: @TPEXP{ @@@@SET@@@@ COLOR1=blue @@@@SET@@@@ COLOR2=red @@@@SET@@@@ LENGTH1=10 body @{background:@@_COLOR1_@@@} div @{background:@@_COLOR2_@@@} ul.class @{background:@@_COLOR1_@@@} /* same color as body */ ul @{width:@@_ADD(3):LENGTH1_@@px@} /* ul 3 pixels wider than li */ li @{width:@@_LENGTH1_@@px@} } Such a file would be processed with the following command line: @TPEXP{ templatespp -o mycss.css mycss.tcss } @c --------------------------------------------------------------------------- @c -- Debug @c --------------------------------------------------------------------------- @node Debug @section Debug @cindex Debug @noindent A set of routines to help to debug the @code{Templates_Parser} engine, @pxref{Templates_Parser.Debug}. For example, @code{Debug.Print_Tree} will display, to the standard output, a representation of the internal semantic tree for a template file. @c ---------------------------------------------------------------------- @node Templates_Parser API Reference @appendix Templates_Parser API Reference @c ---------------------------------------------------------------------- @menu Templates_Parser User's API * Templates_Parser:: * Templates_Parser.Debug:: * Templates_Parser.Utils:: * Templates_Parser.XML:: @end menu @page @node Templates_Parser @appendixsec Templates_Parser @cindex Templates_Parser @include templates_parser.ads.texi @page @node Templates_Parser.Debug @appendixsec Templates_Parser.Debug @cindex Templates_Parser.Debug @include templates_parser-debug.ads.texi @page @node Templates_Parser.Utils @appendixsec Templates_Parser.Utils @cindex Templates_Parser.Utils @include templates_parser-utils.ads.texi @page @node Templates_Parser.XML @appendixsec Templates_Parser.XML @cindex Templates_Parser.XML @include templates_parser-xml.ads.texi @c ---------------------------------------------------------------------- @node Index @unnumbered Index @printindex cp @bye libtemplates-parser-11.6.orig/docs/tp.css0000644000175000017500000000160511637170655020321 0ustar lbrentalbrenta pre.smallexample {background-color:rgb(240,240,240); font-family: courier new,courier,fixed; font-size: 14px; margin: 0px 40px 0px 40px; border-width: 1px 2px 2px 1px; border-top-style: dotted; border-left-style: dotted; border-right-style: solid; border-bottom-style: solid; border-color: black;} code {color:black; font-family: courier new,courier,fixed; font-size: 14px;} body {font-family: arial,helvetica,sans-serif; font-size: 16px; width: 800px; text-align: justify} samp {font-family: courier new,courier,fixed; font-size: 14px} libtemplates-parser-11.6.orig/docs/user.tmplt0000755000175000017500000000024011637170655021221 0ustar lbrentalbrenta@@IF@@ @_USER_@

As a user you have a restricted access to this server. @@ELSE@@

As an administrator you have full access to this server. @@END_IF@@ libtemplates-parser-11.6.orig/makefile0000755000175000017500000001410211637170655017733 0ustar lbrentalbrenta############################################################################ # Ada Web Server # # # # Copyright (C) 2003-2011, AdaCore # # # # This library is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or (at # # your option) any later version. # # # # This library is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this library; if not, write to the Free Software Foundation, # # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # # ############################################################################ .SILENT: VERSION = 11.6 GNAT = gnat DEBUG = false TP_TASKING = Standard_Tasking LIBRARY_TYPE = static PROCESSORS = 2 PLATFORM = native TR = $(shell if [ -f /usr/bin/tr ]; then echo /usr/bin/tr; \ else echo tr; fi) DR_BUILD = $(shell echo $(PRJ_BUILD) | $(TR) "[[:upper:]]" "[[:lower:]]") BDIR = .build/$(PLATFORM)/$(DR_BUILD) prefix = $(dir $(shell which gnatls)).. ENABLE_SHARED=$(shell $(GNAT) make -c -q -p \ -Pconfig/setup/test_shared 2>/dev/null && echo "true") TP_XMLADA = $(shell $(GNAT) make -c -q -p \ -Pconfig/setup/test_xmlada 2>/dev/null \ && echo "Installed") -include makefile.setup I_BIN = $(prefix)/bin I_INC = $(prefix)/include/templates_parser I_LIB = $(prefix)/lib/templates_parser I_GPR = $(prefix)/lib/gnat I_TGP = $(prefix)/lib/gnat/templates_parser I_DOC = $(prefix)/share/doc/templates_parser CP = cp -p MKDIR = mkdir -p ifeq (${OS}, Windows_NT) EXEEXT = .exe SOEXT = .dll LN = cp -p else ifeq ($(UNAME), Darwin) SOEXT = .dylib else ifeq ($(UNAME), HP-UX) SOEXT = .sl else SOEXT = .so endif endif EXEEXT = LN = ln -s endif CONFGPR = config/tp_config.gpr ifeq ($(DEFAULT_LIBRARY_TYPE),) DEFAULT_LIBRARY_TYPE=static endif ifeq ($(LIBRARY_TYPE),) LIBRARY_TYPE=static endif ifeq ($(DEBUG), true) PRJ_BUILD=Debug else PRJ_BUILD=Release endif ifeq ($(TP_XMLADA),) TP_XMLADA=Disabled endif ALL_OPTIONS = INCLUDES="$(INCLUDES)" LIBS="$(LIBS)" PRJ_BUILD="$(PRJ_BUILD)" \ TP_XMLADA="$(TP_XMLADA)" GNAT="$(GNAT)" \ PRJ_BUILD="$(PRJ_BUILD)" LIBRARY_TYPE="$(LIBRARY_TYPE)" \ BDIR="$(BDIR)" DEFAULT_LIBRARY_TYPE="$(DEFAULT_LIBRARY_TYPE)" \ ENABLE_SHARED="$(ENABLE_SHARED)" AWS="$(AWS)" GPROPTS = -XPRJ_BUILD=$(PRJ_BUILD) -XTP_XMLADA=$(TP_XMLADA) \ -XPROCESSORS=$(PROCESSORS) build: setup_config tp_xmlada.gpr $(GNAT) make -p $(GPROPTS) -XLIBRARY_TYPE=static \ -Ptools/tools ifeq ($(ENABLE_SHARED), true) $(GNAT) make -p $(GPROPTS) -XLIBRARY_TYPE=relocatable \ -Ptemplates_parser endif tp_xmlada.gpr: setup run_regtests test: build $(MAKE) -C regtests $(ALL_OPTIONS) test doc: $(MAKE) -C docs $(ALL_OPTIONS) doc echo Templates_Parser Documentation built with success. setup: ifeq ($(TP_XMLADA), Installed) cp config/tp_xmlada_installed.gpr tp_xmlada.gpr else cp config/tp_xmlada_dummy.gpr tp_xmlada.gpr endif $(MKDIR) -p $(BDIR)/static/obj $(MKDIR) -p $(BDIR)/static/lib ifeq ($(ENABLE_SHARED), true) $(MKDIR) -p $(BDIR)/relocatable/obj $(MKDIR) -p $(BDIR)/relocatable/lib endif echo "prefix=$(prefix)" > makefile.setup echo "DEFAULT_LIBRARY_TYPE=$(DEFAULT_LIBRARY_TYPE)" >> makefile.setup echo "ENABLE_SHARED=$(ENABLE_SHARED)" >> makefile.setup echo "DEBUG=$(DEBUG)" >> makefile.setup echo "PROCESSORS=$(PROCESSORS)" >> makefile.setup echo "TP_XMLADA=$(TP_XMLADA)" >> makefile.setup setup_config: echo 'project TP_Config is' > $(CONFGPR) echo ' for Source_Dirs use ();' >> $(CONFGPR) echo ' Default_Library_Type := "$(DEFAULT_LIBRARY_TYPE)";' \ >> $(CONFGPR) echo ' Tasking := "$(TP_TASKING)";' >> $(CONFGPR) echo 'end TP_Config;' >> $(CONFGPR) install_dirs: $(MKDIR) -p $(I_BIN) $(MKDIR) -p $(I_INC) $(MKDIR) -p $(I_LIB)/static ifeq ($(ENABLE_SHARED), true) $(MKDIR) -p $(I_LIB)/relocatable endif $(MKDIR) -p $(I_GPR) $(MKDIR) -p $(I_TGP) $(MKDIR) -p $(I_DOC) install: install_dirs $(CP) src/*.ad* $(I_INC) $(CP) $(BDIR)/static/lib/* $(I_LIB)/static ifeq ($(ENABLE_SHARED), true) $(CP) $(BDIR)/relocatable/lib/* $(I_LIB)/relocatable endif $(CP) $(BDIR)/static/bin/* $(I_BIN) $(CP) config/templates_parser.gpr $(I_GPR) $(CP) config/tp_shared.gpr $(I_TGP) $(CP) tp_xmlada.gpr $(I_TGP) $(CP) $(CONFGPR) $(I_TGP) ifeq ($(TP_XMLADA), Installed) $(CP) xsrc/*.ad* $(I_INC) endif $(RM) -f $(I_LIB)/../libtemplates_parser$(SOEXT) ifeq ($(ENABLE_SHARED), true) ifeq ($(OS), Windows_NT) $(LN) $(I_LIB)/relocatable/libtemplates_parser$(SOEXT) $(I_BIN) endif endif -$(CP) docs/templates_parser*html $(I_DOC) -$(CP) docs/templates_parser*pdf $(I_DOC) -$(CP) docs/templates_parser*info* $(I_DOC) clean: ifeq ($(AWS),) -$(GNAT) clean -XLIBRARY_TYPE=static $(GPROPTS) \ -Ptemplates_parser -$(GNAT) clean -XLIBRARY_TYPE=static $(GPROPTS) \ -Ptools/tools ifeq ($(ENABLE_SHARED), true) -$(GNAT) clean -XLIBRARY_TYPE=relocatable $(GPROPTS) \ -Ptemplates_parser endif endif -$(MAKE) -C docs clean $(ALL_OPTIONS) -$(MAKE) -C regtests clean $(ALL_OPTIONS) $(RM) -fr .build makefile.setup distrib: -rm templates_parser-?.?.tar* tar cf templates_parser-$(VERSION).tar src/templates_parser*ad[sb] \ config tools docs xsrc/*.ad* tp_shared.gpr \ makefile \ templates_parser.gpr gzip -9 templates_parser-$(VERSION).tar libtemplates-parser-11.6.orig/regtests/0000755000175000017500000000000011637170657020074 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/3l1.tmplt0000755000175000017500000000003711637170655021556 0ustar lbrentalbrenta@@INCLUDE@@ 3l2.tmplt 3level-1 libtemplates-parser-11.6.orig/regtests/3l2.tmplt0000755000175000017500000000002711637170655021556 0ustar lbrentalbrentaThis is 3 level 2 - v3 libtemplates-parser-11.6.orig/regtests/3level.tmplt0000755000175000017500000000003511637170655022347 0ustar lbrentalbrenta@@INCLUDE@@ 3l1.tmplt 3level libtemplates-parser-11.6.orig/regtests/a.tmplt0000755000175000017500000000006411637170655021377 0ustar lbrentalbrenta@@INCLUDE@@ head.tmplt New A @@INCLUDE@@ foot.tmplt libtemplates-parser-11.6.orig/regtests/b.tmplt0000755000175000017500000000006011637170655021374 0ustar lbrentalbrenta@@INCLUDE@@ head.tmplt B @@INCLUDE@@ foot.tmplt libtemplates-parser-11.6.orig/regtests/c.tmplt0000755000175000017500000000006011637170655021375 0ustar lbrentalbrenta@@INCLUDE@@ head.tmplt C @@INCLUDE@@ foot.tmplt libtemplates-parser-11.6.orig/regtests/context.adb0000644000175000017500000000410311637170655022224 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- $Id: context.adb 308 2005-02-16 10:43:11Z obry $ with Ada.Text_IO; with Templates_Parser; with Test_Callback; procedure Context is use Ada; Context : aliased Test_Callback.Log_Context; Translations : Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("NAME", "Ada")); begin Text_IO.Put_Line (Templates_Parser.Parse ("context.tmplt", Translations, Context => Context'Unchecked_Access)); end Context; libtemplates-parser-11.6.orig/regtests/context.out0000644000175000017500000000005111637170655022303 0ustar lbrentalbrentaTag VAR missing. Table level: 0 Ada libtemplates-parser-11.6.orig/regtests/context.tmplt0000755000175000017500000000021311637170655022637 0ustar lbrentalbrenta Table level: @_TABLE_LEVEL_@ @_NAME_@ @@IF@@ @_EXIST:VAR_@ @_VAR_@ @@END_IF@@ @@IF@@ @_EXIST:NO_CONTEXT:VAR_@ @_VAR_@ @@END_IF@@ libtemplates-parser-11.6.orig/regtests/dir/0000755000175000017500000000000011637170657020652 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/dir/subdir/0000755000175000017500000000000011637170654022137 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/foot.tmplt0000755000175000017500000000001211637170655022117 0ustar lbrentalbrentafooting 2 libtemplates-parser-11.6.orig/regtests/head.tmplt0000755000175000017500000000001011637170655022047 0ustar lbrentalbrentaheading libtemplates-parser-11.6.orig/regtests/incl.tmplt0000755000175000017500000000003111637170655022076 0ustar lbrentalbrentaagain a new include file libtemplates-parser-11.6.orig/regtests/main.tmplt0000755000175000017500000000004511637170655022102 0ustar lbrentalbrenta@@INCLUDE@@ incl.tmplt new main file libtemplates-parser-11.6.orig/regtests/makefile0000644000175000017500000000334511637170655021577 0ustar lbrentalbrenta############################################################################ # Ada Web Server # # # # Copyright (C) 2003-2010, AdaCore # # # # This library is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or (at # # your option) any later version. # # # # This library is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this library; if not, write to the Free Software Foundation, # # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # # ############################################################################ .SILENT: build: $(GNAT) make -q -p -XLIBRARY_TYPE=static \ -XPRJ_BUILD=$(PRJ_BUILD) -Pregtests test: build ./testsuite.py --jobs=4 clean: -$(GNAT) clean -XLIBRARY_TYPE=static \ -XPRJ_BUILD=$(PRJ_BUILD) -Pregtests libtemplates-parser-11.6.orig/regtests/regtests.gpr0000755000175000017500000000441211637170655022450 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "../templates_parser"; with "../tp_shared"; project Regtests is for Languages use ("Ada", "Project file"); for Source_Dirs use ("src"); for Object_Dir use "../" & TP_Shared'Exec_Dir & "/robj"; for Exec_Dir use "../" & TP_Shared'Exec_Dir & "/rbin"; for Main use ("testme.adb", "print_tree.adb"); -------------- -- Compiler -- -------------- package Compiler is for Default_Switches ("Ada") use ("-gnat05", "-g"); end Compiler; ------------- -- Builder -- ------------- package Builder is for Default_Switches ("Ada") use ("-m"); end Builder; --------- -- Ide -- --------- package Ide is for Vcs_Kind use "Subversion"; end Ide; end Regtests; libtemplates-parser-11.6.orig/regtests/run-test0000755000175000017500000000156411637170655021607 0ustar lbrentalbrenta#!/usr/bin/env gnatpython """Usage: run-test [options] test_dir Run a test located in test_dir """ from gnatpython.main import Main from gnatpython.testdriver import TestRunner, add_run_test_options import sys def main(): """Run a single test""" m = Main(add_targets_options=True) add_run_test_options(m) m.parse_args() if not m.args: sys.exit("Error: 1 argument expected. See -h") if m.options.restricted_discs is not None: m.options.restricted_discs = m.options.restricted_discs.split(',') t = TestRunner(m.args[0], m.options.discs, m.options.output_dir, m.options.tmp, m.options.enable_cleanup, m.options.restricted_discs, len(m.args) > 1 and m.args[1:] or None) t.execute() if __name__ == '__main__': main() libtemplates-parser-11.6.orig/regtests/src/0000755000175000017500000000000011637170657020663 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/src/print_tree.adb0000644000175000017500000000454211637170655023511 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Command_Line; with Ada.Text_IO; with Templates_Parser.Debug; procedure Print_Tree is use Ada; use Templates_Parser; begin if Command_Line.Argument_Count = 1 then Debug.Print_Tree (Command_Line.Argument (1)); elsif Command_Line.Argument_Count = 2 and then Command_Line.Argument (1) = "-M" then Debug.Print_Tree (Command_Line.Argument (2), Expand_Macro => True); elsif Command_Line.Argument_Count = 2 and then Command_Line.Argument (1) = "-m" then Debug.Print_Tree (Command_Line.Argument (2)); Debug.Print_Defined_Macros; else Text_IO.New_Line; Text_IO.Put_Line ("Usage: print_tree [-m] "); Text_IO.New_Line; Text_IO.Put_Line (" -m : print defined macros"); Text_IO.New_Line; end if; end Print_Tree; libtemplates-parser-11.6.orig/regtests/src/test_callback.adb0000644000175000017500000001063111637170655024125 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; package body Test_Callback is --------------- -- Dimension -- --------------- overriding function Dimension (C : not null access Cursor_Tag; Var : String) return Natural is begin if Var = "CURSOR" then return 2; elsif Var = "C_MAT3" then return 3; else return 0; end if; end Dimension; ------------ -- Length -- ------------ overriding function Length (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return Natural is begin if Var = "CURSOR" then if Path'Length = 1 then return 3; elsif Path'Length /= 2 then raise Constraint_Error; else return Path (Path'Last); end if; elsif Var = "C_MAT3" then if Path'Length = 1 then return 3; elsif Path'Length = 2 then return 2; elsif Path'Length /= 3 then raise Constraint_Error; else return Path (Path'Last) + 2; end if; else return 0; end if; end Length; -------------- -- Callback -- -------------- overriding procedure Value (L : not null access Lazy_Tag; Var : String; S : in out Templates_Parser.Translate_Set) is use Templates_Parser; begin if Var = "VAR1" then Insert (S, Assoc ("VAR1", "Callback value")); elsif Var = "DYNAMIC" then Insert (S, Assoc ("DYNAMIC", "This is a dynamic tag")); elsif Var = "N" then Insert (S, Assoc ("N", Integer'Image (L.N))); L.N := L.N + 1; elsif Var = "DYN_VECT" then Insert (S, Assoc ("DYN_VECT", +"12" & "89" & "90" & "2")); elsif Var = "TMPLT_NAME" then Insert (S, Assoc (Var, +"incl.tmplt")); end if; end Value; overriding procedure Value (L : not null access Log_Context; Var : String; S : in out Templates_Parser.Translate_Set) is pragma Unreferenced (L, S); begin Ada.Text_IO.Put_Line ("Tag " & Var & " missing."); end Value; overriding function Value (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return String is begin if Var = "CURSOR" then if Path'Length = 2 then return "CT" & Path (Path'First)'Img & Path (Path'First + 1)'Img; else raise Constraint_Error; end if; elsif Var = "C_MAT3" then if Path'Length = 3 then return "CMAT" & Path (Path'First)'Img & Path (Path'First + 1)'Img & Path (Path'First + 2)'Img; else raise Constraint_Error; end if; else raise Constraint_Error; end if; end Value; end Test_Callback; libtemplates-parser-11.6.orig/regtests/src/test_callback.ads0000644000175000017500000000521611637170655024151 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Templates_Parser; package Test_Callback is type Lazy_Tag is new Templates_Parser.Dynamic.Lazy_Tag with private; overriding procedure Value (L : not null access Lazy_Tag; Var : String; S : in out Templates_Parser.Translate_Set); type Log_Context is new Templates_Parser.Dynamic.Lazy_Tag with null record; overriding procedure Value (L : not null access Log_Context; Var : String; S : in out Templates_Parser.Translate_Set); type Cursor_Tag is new Templates_Parser.Dynamic.Cursor_Tag with null record; overriding function Dimension (C : not null access Cursor_Tag; Var : String) return Natural; overriding function Length (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return Natural; overriding function Value (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return String; private type Lazy_Tag is new Templates_Parser.Dynamic.Lazy_Tag with record N : Natural := 0; end record; end Test_Callback; libtemplates-parser-11.6.orig/regtests/src/testme.adb0000644000175000017500000001571311637170655022641 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- Procedure to test the template_parser with Ada.Text_IO; with Ada.Command_Line; with Templates_Parser; with Test_Callback; procedure Testme is use Ada; package TP renames Templates_Parser; use type TP.Vector_Tag; use type TP.Matrix_Tag; L_Tag : aliased Test_Callback.Lazy_Tag; C_Tag : aliased Test_Callback.Cursor_Tag; KUT : Boolean := False; -- Keep Unknown Tags Cached : Boolean := False; -- Set to true if cache must be activated S1 : constant TP.Vector_Tag := +"single_value"; V1 : constant TP.Vector_Tag := +"A1.1" & "A1.2" & "A1.3"; V2 : constant TP.Vector_Tag := +"A2.1" & "A2.2" & "A2.3"; V3 : constant TP.Vector_Tag := +"A3.1" & "A3.2" & "A3.3"; V4 : constant TP.Vector_Tag := +"A4.1" & "A4.2" & "A4.3"; M : constant TP.Matrix_Tag := +V1 & V2 & V3 & V4; V5 : constant TP.Vector_Tag := +"one" & "two" & "three"; V6 : constant TP.Vector_Tag := +"(one)" & "(two)"; M2 : constant TP.Matrix_Tag := +V5 & V6; I1 : constant TP.Vector_Tag := +"1"; I2 : constant TP.Vector_Tag := "2" & I1; I3 : constant TP.Vector_Tag := "3" & I2; VB0 : TP.Tag; VB1 : constant TP.Tag := +"B1.1" & "B1.2" & "B1.3"; VB2 : constant TP.Tag := +"B2.1" & "B2.2" & "B2.3"; VB3 : constant TP.Tag := +"B3.1" & "B3.2" & "B3.3"; VB4 : constant TP.Tag := +"B4.1" & "B4.2" & "B4.3"; MB : constant TP.Tag := +VB1 & VB2 & VB3 & VB4; Nested_3 : constant TP.Tag := +M & MB; C : constant TP.Tag := +"Class1" & "Class2"; Mx : constant TP.Tag := +"Member1.1" & "Member1.2"; My : constant TP.Tag := +"Member2.1" & "Member2.2" & "Member2.3"; MF : constant TP.Tag := +Mx & My; M11 : constant TP.Tag := +"M 1 1 1" & "M 1 1 2" & "M 1 1 3"; M12 : constant TP.Tag := +"M 1 2 1" & "M 1 2 2" & "M 1 2 3" & "M 1 2 4"; M21 : constant TP.Tag := +"M 2 1 1" & "M 2 1 2" & "M 2 1 3"; M22 : constant TP.Tag := +"M 2 2 1" & "M 2 2 2" & "M 2 2 3" & "M 2 2 4"; M31 : constant TP.Tag := +"M 3 1 1" & "M 3 1 2" & "M 3 1 3"; M32 : constant TP.Tag := +"M 3 2 1" & "M 3 2 2" & "M 3 2 3" & "M 3 2 4"; MC1 : constant TP.Tag := +M11 & M12; MC2 : constant TP.Tag := +M21 & M22; MC3 : constant TP.Tag := +M31 & M32; CM3 : constant TP.Tag := +MC1 & MC2 & MC3; FA : constant TP.Tag := +"FA1" & "FA2" & "FA3"; RT : constant TP.Tag := +"RT1" & "RT2" & "RT3"; RA : constant TP.Tag := +"RA1" & "RA2" & "RA3"; Translations : TP.Translate_Table := (TP.Assoc ("VAR1", "a value"), TP.Assoc ("VAR2", +"a table" & "with" & "many" & "values" & "to" & "be" & "displayed" & "one" & "by" & "one"), TP.Assoc ("VAR3", +"one" & "two" & "three"), TP.Assoc ("VAR4", ""), TP.Assoc ("VAR5", "T R uE"), TP.Assoc ("VAR6", "A"), TP.Assoc ("VAR7", +"ZZ" & "A3.4" & "A4.2" & "again!" & "A2.2" & "!"), TP.Assoc ("CLASS", C), TP.Assoc ("MEMBER", MF), TP.Assoc ("COND1", False), TP.Assoc ("COND2", True), TP.Assoc ("LABELS", +"lab1" & "lab2" & "lab3" & "lab4"), TP.Assoc ("MATDSIZE", M2), TP.Assoc ("SIZE0", VB0), TP.Assoc ("V5", V5), TP.Assoc ("V6", V6), TP.Assoc ("INV", I3), TP.Assoc ("MAT", M), TP.Assoc ("ONE", 1), TP.Assoc ("TWO", 2), TP.Assoc ("THREE", 3), TP.Assoc ("NUM0", 123456), TP.Assoc ("NUM1", "1234567.98765"), TP.Assoc ("NUM2", "12.98765"), TP.Assoc ("NUM3", "123.9"), TP.Assoc ("NUM4", "1234.98"), TP.Assoc ("NUM5", ".98"), TP.Assoc ("TEST_VAR", "Test"), TP.Assoc ("FILTER", " a text with < 6 words & good 92 chars like + > "), TP.Assoc ("TEXT", "toto titi tata tata titi toto tata titi toto titi titi"), TP.Assoc ("REPL", "[_\1_]"), TP.Assoc ("WITHLF", "First line" & ASCII.LF & "Second line"), TP.Assoc ("WITHBR", "First line
Second line"), TP.Assoc ("VT", "vector_tag"), TP.Assoc ("DATE1", "1967-09-09"), TP.Assoc ("DATE2", "2003-12-12 13:34:12"), TP.Assoc ("URL1", "http://host:port/"), TP.Assoc ("URL2", "http://host/"), TP.Assoc ("URL3", "http://host/?"), TP.Assoc ("URL4", "http://host/?param1=un"), TP.Assoc ("URL5", "http://host:port/?param1=un¶m2=deux"), TP.Assoc ("URL6", "http://host?param1=un¶m2=deux¶m3=trois"), TP.Assoc ("NESTED_3", Nested_3), TP.Assoc ("FILE", "/home/user"), TP.Assoc ("FILE2", "test.out"), TP.Assoc ("S1", S1), TP.Assoc ("QUOTE", """"""), TP.Assoc ("MAT3", CM3), TP.Assoc ("ACCENTS", "<été ça être paramètre à paraître> & """), TP.Assoc ("FOREIGN_ATTRS", FA), TP.Assoc ("REFERENCED_TABLES", RT), TP.Assoc ("REFERENCED_ATTRS", RA) ); begin if Command_Line.Argument_Count = 2 then if Command_Line.Argument (2) = "kut" then KUT := True; elsif Command_Line.Argument (2) = "cache" then Cached := True; end if; end if; declare Result : constant String := TP.Parse (Command_Line.Argument (1), Translations, Cached => Cached, Keep_Unknown_Tags => KUT, Lazy_Tag => L_Tag'Unchecked_Access, Cursor_Tag => C_Tag'Unchecked_Access); begin Text_IO.Put (Result); end; end Testme; libtemplates-parser-11.6.orig/regtests/test_support.py0000644000175000017500000000136111637170655023220 0ustar lbrentalbrenta""" This module contains support functions for all test.py """ import os import sys # Change directory TEST = sys.modules['__main__'] TESTDIR = os.path.dirname(TEST.__file__) TEST_NAME = os.path.basename(TESTDIR) os.chdir(TESTDIR) from gnatpython.ex import Run def gnatmake(prj): """Compile a project with gnatmake""" cmd = ["gnatmake", "-p", "-gnat05", "-P" + prj, "-bargs", "-E"] process = Run(cmd) if process.status: print process.out def run(bin, options=None, output_file=None): """Run a test""" if options is None: options = [] if "TIMEOUT" in os.environ: timeout = int(os.environ["TIMEOUT"]) else: timeout = 300 Run([bin] + options, output=output_file, timeout=timeout) libtemplates-parser-11.6.orig/regtests/tests/0000755000175000017500000000000011637170657021236 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0001_tag_demo/0000755000175000017500000000000011637170657023455 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0001_tag_demo/gtag.tmplt0000755000175000017500000000131711637170655025464 0ustar lbrentalbrenta GTAG ---------------------------- 0 : @_GTAG_@ ---------------------------- @@TABLE@@ 1 : @_GTAG_@ @@END_TABLE@@ ---------------------------- @@TABLE@@ @@TABLE@@ 2 : @_GTAG_@ @@END_TABLE@@ @@END_TABLE@@ ---------------------------- M0 : @_MTAG_@ @@TABLE@@ M1 : @_MTAG_@ @@END_TABLE@@ @@TABLE@@ @@TABLE@@ M2 : @_MTAG_@ @@END_TABLE@@ @@END_TABLE@@ ============================ VTAG ---------------------------- 0 : @_VTAG_@ ---------------------------- @@TABLE@@ 1 : @_VTAG_@ @@END_TABLE@@ ---------------------------- @@TABLE@@ [ @@TABLE@@ V2 : @_VTAG_@ 2 : @_GTAG_@ @@END_TABLE@@ ] @@END_TABLE@@ @@TABLE@@ [ @@TABLE@@ O2 : @_OTAG_@ M2 : @_MTAG_@ @@END_TABLE@@ ] @@END_TABLE@@ ---------------------------- libtemplates-parser-11.6.orig/regtests/tests/0001_tag_demo/tag_demo.adb0000644000175000017500000000652611637170655025713 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser; with Templates_Parser.Debug; with Templates_Parser.Utils; procedure Tag_Demo is use Ada.Text_IO; use Templates_Parser; procedure Check_IV (Name : String; T : Tag); -- Check Image/Value convertion -------------- -- Check_IV -- -------------- procedure Check_IV (Name : String; T : Tag) is Img : constant String := Utils.Image (T); NT : constant Tag := Utils.Value (Img); begin Put_Line (Name & "=>" & Img); Put_Line (Name & " " & Utils.Image (NT)); if Img = Utils.Image (NT) then Put_Line (" Ok"); else Put_Line (" NOk"); end if; end Check_IV; T1 : Tag; T2 : Tag; T : Tag; VT1 : Vector_Tag; VT2 : Vector_Tag; MT : Matrix_Tag; I1 : constant Vector_Tag := +"1"; I2 : constant Vector_Tag := "2" & I1; I3 : constant Vector_Tag := "3" & I2; M : Tag; QT : Tag; begin T1 := T1 & "first" & "1_1_1"; T2 := T2 & "second"; T := T & T1 & T2; M := +T & T & T; Put_Line ("T1"); Debug.Print (T1); Put_Line ("T2"); Debug.Print (T2); Put_Line ("T"); Debug.Print (T); Put_Line ("I3"); Debug.Print (Tag (I3)); Put_Line ("M"); Debug.Print (M); Set_Separator (T, (1 => ASCII.LF)); VT1 := VT1 & "first" & "1_1_1"; VT2 := VT2 & "second"; MT := +VT1 & VT2; Put_Line (Parse ("gtag.tmplt", Translate_Table' (Assoc ("GTAG", T), Assoc ("VTAG", T1), Assoc ("MTAG", MT), Assoc ("OTAG", VT1)))); Put_Line ("-----------------------"); Check_IV ("T1", T1); Check_IV ("T2", T2); Check_IV ("T ", T); QT := QT & "un essai" & "with "" a quote" & "and ( and )"; T := T & QT; Check_IV ("T", T); end Tag_Demo; libtemplates-parser-11.6.orig/regtests/tests/0001_tag_demo/tag_demo.gpr0000644000175000017500000000325311637170655025747 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project Tag_Demo is for Source_Dirs use ("."); for Main use ("tag_demo.adb"); end Tag_Demo; libtemplates-parser-11.6.orig/regtests/tests/0001_tag_demo/test.out0000644000175000017500000000363211637170655025167 0ustar lbrentalbrentaT1 (N= 2, Min= 1, Max= 1, Nested_Level= 1 first 1_1_1 ) T2 (N= 1, Min= 1, Max= 1, Nested_Level= 1 second ) T (N= 2, Min= 1, Max= 2, Nested_Level= 2 (N= 2, Min= 1, Max= 1, Nested_Level= 1 first 1_1_1 ) (N= 1, Min= 1, Max= 1, Nested_Level= 1 second ) ) I3 (N= 3, Min= 1, Max= 1, Nested_Level= 1 3 2 1 ) M (N= 3, Min= 2, Max= 2, Nested_Level= 3 (N= 2, Min= 1, Max= 2, Nested_Level= 2 (N= 2, Min= 1, Max= 1, Nested_Level= 1 first 1_1_1 ) (N= 1, Min= 1, Max= 1, Nested_Level= 1 second ) ) (N= 2, Min= 1, Max= 2, Nested_Level= 2 (N= 2, Min= 1, Max= 1, Nested_Level= 1 first 1_1_1 ) (N= 1, Min= 1, Max= 1, Nested_Level= 1 second ) ) (N= 2, Min= 1, Max= 2, Nested_Level= 2 (N= 2, Min= 1, Max= 1, Nested_Level= 1 first 1_1_1 ) (N= 1, Min= 1, Max= 1, Nested_Level= 1 second ) ) ) GTAG ---------------------------- 0 : first, 1_1_1 second ---------------------------- 1 : first, 1_1_1 1 : second ---------------------------- 2 : first 2 : 1_1_1 2 : second 2 : ---------------------------- M0 : first, 1_1_1 second M1 : first, 1_1_1 M1 : second M2 : first M2 : 1_1_1 M2 : second M2 : ============================ VTAG ---------------------------- 0 : first, 1_1_1 ---------------------------- 1 : first 1 : 1_1_1 ---------------------------- [ V2 : first 2 : first V2 : 1_1_1 2 : 1_1_1 ] [ V2 : first 2 : second V2 : 1_1_1 2 : ] [ O2 : first M2 : first O2 : 1_1_1 M2 : 1_1_1 ] [ O2 : first M2 : second O2 : 1_1_1 M2 : ] ---------------------------- ----------------------- T1=>("first","1_1_1") T1 ("first","1_1_1") Ok T2=>("second") T2 ("second") Ok T =>(("first","1_1_1")("second")) T (("first","1_1_1")("second")) Ok T=>(("first","1_1_1")("second")("un essai","with "" a quote","and ( and )")) T (("first","1_1_1")("second")("un essai","with "" a quote","and ( and )")) Ok libtemplates-parser-11.6.orig/regtests/tests/0001_tag_demo/test.py0000644000175000017500000000010111637170655024774 0ustar lbrentalbrentafrom test_support import * gnatmake('tag_demo') run('tag_demo') libtemplates-parser-11.6.orig/regtests/tests/0002_testme/0000755000175000017500000000000011637170657023200 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0002_testme/test.out0000644000175000017500000001060711637170655024712 0ustar lbrentalbrenta This is a test template for Templates_Parser A single value : a value Should be 0 : 0 Should be 0 : 0 A table : a table with many values to be displayed one by one OK: test passed OK: test passed ligne: {1 of 10} [a table] ligne: Another section 2 [with] Well a another one [many] ligne: {4 of 10} [values] ligne: Another section 5 [to] Well a another one [be] ligne: {7 of 10} [displayed] ligne: Another section 8 [one] Well a another one [by] ligne: {10 of 10} [one] ligne: {1 of 10} [a table] ligne: Another section 2 [with] Well a another one [many] ligne: {4 of 10} [values] ligne: Another section 5 [to] Well a another one [be] ligne: {7 of 10} [displayed] ligne: Another section 8 [one] Well a another one [by] ligne: {10 of 10} [one] ligne: Another section 11 [] Well a another one [] A| 1 a table (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 2 with (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 3 many (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 4 values (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 5 to (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 6 be (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 7 displayed (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 8 one (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 9 by (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) A| 10 one (1) B| 1 one (2) B| {2 of 3} another table C| 1 one (3) C| 2 two (3) C| 3 three (3) B| 3 three (2) Cond1: FALSE - NO - NON Cond2: TRUE - YES - OUI Should be 0 : 0 Should be 0 : 0 [INFO] testme.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] This is a test template for Templates_Parser [TEXT] [TEXT] A single value : @_VAR1_@ [TEXT] [TEXT] Should be 0 : @_NUMBER_LINE_@ [TEXT] Should be 0 : @_TABLE_LEVEL_@ [TEXT] [TEXT] A table : [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_VAR2_@ [END_BLOCK] [END_TABLE] [TEXT] [IF] @_COND1_@ [TEXT] ERROR: test is not correct [ELSE] [TEXT] OK: test passed [END_IF] [TEXT] [IF] @_COND2_@ [TEXT] OK: test passed [ELSE] [TEXT] ERROR: test is not correct [END_IF] [TEXT] [IF] @_COND2_@ [TABLE] [BLOCK] [SECTION] [TEXT] ligne: {@_TABLE_LINE_@ of @_NUMBER_LINE_@} [@_VAR2_@] [SECTION] [TEXT] ligne: Another section @_TABLE_LINE_@ [@_VAR2_@] [SECTION] [TEXT] Well a another one [@_VAR2_@] [END_BLOCK] [END_TABLE] [END_IF] [TEXT] [TABLE] TERMINATE_SECTIONS [BLOCK] [SECTION] [TEXT] ligne: {@_TABLE_LINE_@ of @_NUMBER_LINE_@} [@_VAR2_@] [SECTION] [TEXT] ligne: Another section @_TABLE_LINE_@ [@_VAR2_@] [SECTION] [TEXT] Well a another one [@_VAR2_@] [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] A| @_TABLE_LINE_@ @_VAR2_@ (@_TABLE_LEVEL_@) [TABLE] [BLOCK] [SECTION] [TEXT] B| @_TABLE_LINE_@ @_VAR3_@ (@_TABLE_LEVEL_@) [SECTION] [TEXT] B| {@_TABLE_LINE_@ of @_NUMBER_LINE_@} another table [TABLE] [BLOCK] [COMMON] [TEXT] C| @_TABLE_LINE_@ @_VAR3_@ (@_TABLE_LEVEL_@) [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Cond1: @_COND1_@ - @_YES_NO:COND1_@ - @_OUI_NON:COND1_@ [TEXT] Cond2: @_COND2_@ - @_YES_NO:COND2_@ - @_OUI_NON:COND2_@ [TEXT] [TEXT] Should be 0 : @_NUMBER_LINE_@ [TEXT] Should be 0 : @_TABLE_LEVEL_@ libtemplates-parser-11.6.orig/regtests/tests/0002_testme/test.py0000644000175000017500000000014011637170655024522 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme.tmplt"]) run('print_tree', ["testme.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0002_testme/testme.tmplt0000755000175000017500000000242211637170655025564 0ustar lbrentalbrenta This is a test template for Templates_Parser A single value : @_VAR1_@ Should be 0 : @_NUMBER_LINE_@ Should be 0 : @_TABLE_LEVEL_@ A table : @@TABLE@@ @_VAR2_@ @@END_TABLE@@ @@IF@@ @_COND1_@ ERROR: test is not correct @@ELSE@@ OK: test passed @@END_IF@@ @@IF@@ @_COND2_@ OK: test passed @@ELSE@@ ERROR: test is not correct @@END_IF@@ @@IF@@ @_COND2_@ @@TABLE@@ ligne: {@_TABLE_LINE_@ of @_NUMBER_LINE_@} [@_VAR2_@] @@SECTION@@ ligne: Another section @_TABLE_LINE_@ [@_VAR2_@] @@SECTION@@ Well a another one [@_VAR2_@] @@END_TABLE@@ @@END_IF@@ @@TABLE@@ @@TERMINATE_SECTIONS@@ ligne: {@_TABLE_LINE_@ of @_NUMBER_LINE_@} [@_VAR2_@] @@SECTION@@ ligne: Another section @_TABLE_LINE_@ [@_VAR2_@] @@SECTION@@ Well a another one [@_VAR2_@] @@END_TABLE@@ @@TABLE@@ A| @_TABLE_LINE_@ @_VAR2_@ (@_TABLE_LEVEL_@) @@TABLE@@ B| @_TABLE_LINE_@ @_VAR3_@ (@_TABLE_LEVEL_@) @@SECTION@@ B| {@_TABLE_LINE_@ of @_NUMBER_LINE_@} another table @@TABLE@@ C| @_TABLE_LINE_@ @_VAR3_@ (@_TABLE_LEVEL_@) @@END_TABLE@@ @@END_TABLE@@ @@END_TABLE@@ Cond1: @_COND1_@ - @_YES_NO:COND1_@ - @_OUI_NON:COND1_@ Cond2: @_COND2_@ - @_YES_NO:COND2_@ - @_OUI_NON:COND2_@ Should be 0 : @_NUMBER_LINE_@ Should be 0 : @_TABLE_LEVEL_@ libtemplates-parser-11.6.orig/regtests/tests/0003_testme/0000755000175000017500000000000011637170657023201 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0003_testme/test.out0000644000175000017500000000341311637170655024710 0ustar lbrentalbrenta one A Value two A Value three A Value ONE TWO THREE atable with many values to be displayed one by one ok, VAR1 exist. ok, VAR1 exist. ok, VARx does not exist. ok, VARx does not exist. ok, VARx does not exist. ok, VARx does not exist. ok, VARx does not exist. ok, VAR1 exist. A List : one, two, three [INFO] testme2.tmplt [C_INFO] 1 FALSE [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_VAR_DOES_NOT_EXIST_@ [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_VAR3_@ @_CAPITALIZE:VAR1_@ [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_UPPER:VAR3_@ @_VAR4_@ [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_NO_SPACE:VAR2_@ [END_BLOCK] [END_TABLE] [TEXT] [IF] @_EXIST:VAR1_@ [TEXT] ok, VAR1 exist. [ELSE] [TEXT] error, VAR1 exist. [END_IF] [TEXT] [IF] (@_EXIST:VAR1_@ = TRUE) [TEXT] ok, VAR1 exist. [ELSE] [TEXT] error, VAR1 exist. [END_IF] [TEXT] [IF] @_EXIST:VARx_@ [TEXT] nok, VARx does not exist. [ELSE] [TEXT] ok, VARx does not exist. [END_IF] [TEXT] [IF] (@_EXIST:VARx_@ = TRUE) [TEXT] nok, VARx does not exist. [ELSE] [TEXT] ok, VARx does not exist. [END_IF] [TEXT] [IF] (@_EXIST:VARx_@ = FALSE) [TEXT] ok, VARx does not exist. [ELSE] [TEXT] nok, VARx does not exist. [END_IF] [TEXT] [IF] (@_IS_EMPTY:VARx_@ = TRUE) [TEXT] ok, VARx does not exist. [ELSE] [TEXT] nok, VARx does not exist. [END_IF] [TEXT] [IF] @_IS_EMPTY:VARx_@ [TEXT] ok, VARx does not exist. [ELSE] [TEXT] nok, VARx does not exist. [END_IF] [TEXT] [IF] @_IS_EMPTY:VAR1_@ [TEXT] nok, VAR1 exist. [ELSE] [TEXT] ok, VAR1 exist. [END_IF] [TEXT] [TEXT] A List : @_VAR3_@ libtemplates-parser-11.6.orig/regtests/tests/0003_testme/test.py0000644000175000017500000000014211637170655024525 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme2.tmplt"]) run('print_tree', ["testme2.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0003_testme/testme2.tmplt0000644000175000017500000000174511637170655025653 0ustar lbrentalbrenta @@TABLE@@ @_VAR_DOES_NOT_EXIST_@ @@END_TABLE@@ @@TABLE@@ @_VAR3_@ @_CAPITALIZE:VAR1_@ @@END_TABLE@@ @@TABLE@@ @_UPPER:VAR3_@ @_VAR4_@ @@END_TABLE@@ @@TABLE@@ @_NO_SPACE:VAR2_@ @@END_TABLE@@ @@IF@@ @_EXIST:VAR1_@ ok, VAR1 exist. @@ELSE@@ error, VAR1 exist. @@END_IF@@ @@IF@@ @_EXIST:VAR1_@ = TRUE ok, VAR1 exist. @@ELSE@@ error, VAR1 exist. @@END_IF@@ @@IF@@ @_EXIST:VARx_@ nok, VARx does not exist. @@ELSE@@ ok, VARx does not exist. @@END_IF@@ @@IF@@ @_EXIST:VARx_@ = TRUE nok, VARx does not exist. @@ELSE@@ ok, VARx does not exist. @@END_IF@@ @@IF@@ @_EXIST:VARx_@ = FALSE ok, VARx does not exist. @@ELSE@@ nok, VARx does not exist. @@END_IF@@ @@IF@@ @_IS_EMPTY:VARx_@ = TRUE ok, VARx does not exist. @@ELSE@@ nok, VARx does not exist. @@END_IF@@ @@IF@@ @_IS_EMPTY:VARx_@ ok, VARx does not exist. @@ELSE@@ nok, VARx does not exist. @@END_IF@@ @@IF@@ @_IS_EMPTY:VAR1_@ nok, VAR1 exist. @@ELSE@@ ok, VAR1 exist. @@END_IF@@ A List : @_VAR3_@ libtemplates-parser-11.6.orig/regtests/tests/0004_testme/0000755000175000017500000000000011637170657023202 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0004_testme/test.out0000644000175000017500000000422611637170655024714 0ustar lbrentalbrenta Some text here. one A Value two A Value three A Value ONE TWO THREE atable with many values to be displayed one by one ok, VAR1 exist. ok, VAR1 exist. ok, VARx does not exist. ok, VARx does not exist. ok, VARx does not exist. ok, VARx does not exist. ok, VARx does not exist. ok, VAR1 exist. A List : one, two, three Some text after the include. [INFO] testme5.tmplt -> testme2.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] Some text here. [TEXT] [INCLUDE] testme2.tmplt $0 = testme2.tmplt [INFO] testme2.tmplt [C_INFO] 1 FALSE [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_VAR_DOES_NOT_EXIST_@ [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_VAR3_@ @_CAPITALIZE:VAR1_@ [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_UPPER:VAR3_@ @_VAR4_@ [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_NO_SPACE:VAR2_@ [END_BLOCK] [END_TABLE] [TEXT] [IF] @_EXIST:VAR1_@ [TEXT] ok, VAR1 exist. [ELSE] [TEXT] error, VAR1 exist. [END_IF] [TEXT] [IF] (@_EXIST:VAR1_@ = TRUE) [TEXT] ok, VAR1 exist. [ELSE] [TEXT] error, VAR1 exist. [END_IF] [TEXT] [IF] @_EXIST:VARx_@ [TEXT] nok, VARx does not exist. [ELSE] [TEXT] ok, VARx does not exist. [END_IF] [TEXT] [IF] (@_EXIST:VARx_@ = TRUE) [TEXT] nok, VARx does not exist. [ELSE] [TEXT] ok, VARx does not exist. [END_IF] [TEXT] [IF] (@_EXIST:VARx_@ = FALSE) [TEXT] ok, VARx does not exist. [ELSE] [TEXT] nok, VARx does not exist. [END_IF] [TEXT] [IF] (@_IS_EMPTY:VARx_@ = TRUE) [TEXT] ok, VARx does not exist. [ELSE] [TEXT] nok, VARx does not exist. [END_IF] [TEXT] [IF] @_IS_EMPTY:VARx_@ [TEXT] ok, VARx does not exist. [ELSE] [TEXT] nok, VARx does not exist. [END_IF] [TEXT] [IF] @_IS_EMPTY:VAR1_@ [TEXT] nok, VAR1 exist. [ELSE] [TEXT] ok, VAR1 exist. [END_IF] [TEXT] [TEXT] A List : @_VAR3_@ [TEXT] [TEXT] Some text after the include. libtemplates-parser-11.6.orig/regtests/tests/0004_testme/test.py0000644000175000017500000000014211637170655024526 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme5.tmplt"]) run('print_tree', ["testme5.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0004_testme/testme2.tmplt0000755000175000017500000000174511637170655025657 0ustar lbrentalbrenta @@TABLE@@ @_VAR_DOES_NOT_EXIST_@ @@END_TABLE@@ @@TABLE@@ @_VAR3_@ @_CAPITALIZE:VAR1_@ @@END_TABLE@@ @@TABLE@@ @_UPPER:VAR3_@ @_VAR4_@ @@END_TABLE@@ @@TABLE@@ @_NO_SPACE:VAR2_@ @@END_TABLE@@ @@IF@@ @_EXIST:VAR1_@ ok, VAR1 exist. @@ELSE@@ error, VAR1 exist. @@END_IF@@ @@IF@@ @_EXIST:VAR1_@ = TRUE ok, VAR1 exist. @@ELSE@@ error, VAR1 exist. @@END_IF@@ @@IF@@ @_EXIST:VARx_@ nok, VARx does not exist. @@ELSE@@ ok, VARx does not exist. @@END_IF@@ @@IF@@ @_EXIST:VARx_@ = TRUE nok, VARx does not exist. @@ELSE@@ ok, VARx does not exist. @@END_IF@@ @@IF@@ @_EXIST:VARx_@ = FALSE ok, VARx does not exist. @@ELSE@@ nok, VARx does not exist. @@END_IF@@ @@IF@@ @_IS_EMPTY:VARx_@ = TRUE ok, VARx does not exist. @@ELSE@@ nok, VARx does not exist. @@END_IF@@ @@IF@@ @_IS_EMPTY:VARx_@ ok, VARx does not exist. @@ELSE@@ nok, VARx does not exist. @@END_IF@@ @@IF@@ @_IS_EMPTY:VAR1_@ nok, VAR1 exist. @@ELSE@@ ok, VAR1 exist. @@END_IF@@ A List : @_VAR3_@ libtemplates-parser-11.6.orig/regtests/tests/0004_testme/testme5.tmplt0000755000175000017500000000011211637170655025645 0ustar lbrentalbrenta Some text here. @@INCLUDE@@ testme2.tmplt Some text after the include. libtemplates-parser-11.6.orig/regtests/tests/0005_testme/0000755000175000017500000000000011637170657023203 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0005_testme/test.out0000644000175000017500000001255611637170655024722 0ustar lbrentalbrenta This is a test for the matrix feature: Table1: 0 1 4 1 Table2: 1 1 3 2 A1.1 Table2: 1 2 3 2 A1.2 Table2: 1 3 3 2 A1.3 --- [A1.1, A1.2, A1.3] Table1: 0 2 4 1 Table2: 2 1 3 2 A2.1 Table2: 2 2 3 2 A2.2 Table2: 2 3 3 2 A2.3 --- [A2.1, A2.2, A2.3] Table1: 0 3 4 1 Table2: 3 1 3 2 A3.1 Table2: 3 2 3 2 A3.2 Table2: 3 3 3 2 A3.3 --- [A3.1, A3.2, A3.3] Table1: 0 4 4 1 Table2: 4 1 3 2 A4.1 Table2: 4 2 3 2 A4.2 Table2: 4 3 3 2 A4.3 --- [A4.1, A4.2, A4.3] ====================================================================== A table with labels (vector): Label: lab1 Table1: 0 1 4 1 Table2: 1 1 3 2 A1.1 Table2: 1 2 3 2 A1.2 Table2: 1 3 3 2 A1.3 Label: lab2 Table1: 0 2 4 1 Table2: 2 1 3 2 A2.1 Table2: 2 2 3 2 A2.2 Table2: 2 3 3 2 A2.3 Label: lab3 Table1: 0 3 4 1 Table2: 3 1 3 2 A3.1 Table2: 3 2 3 2 A3.2 Table2: 3 3 3 2 A3.3 Label: lab4 Table1: 0 4 4 1 Table2: 4 1 3 2 A4.1 Table2: 4 2 3 2 A4.2 Table2: 4 3 3 2 A4.3 ====================================================================== A matrix inside a table with labels (vectors): Label: lab1 Table1: 1 1 4 2 Table2: 1 1 3 3 A1.1 Table2: 1 2 3 3 A1.2 Table2: 1 3 3 3 A1.3 Table1: 1 2 4 2 Table2: 2 1 3 3 A2.1 Table2: 2 2 3 3 A2.2 Table2: 2 3 3 3 A2.3 Table1: 1 3 4 2 Table2: 3 1 3 3 A3.1 Table2: 3 2 3 3 A3.2 Table2: 3 3 3 3 A3.3 Table1: 1 4 4 2 Table2: 4 1 3 3 A4.1 Table2: 4 2 3 3 A4.2 Table2: 4 3 3 3 A4.3 Label: lab2 Table1: 2 1 4 2 Table2: 1 1 3 3 A1.1 Table2: 1 2 3 3 A1.2 Table2: 1 3 3 3 A1.3 Table1: 2 2 4 2 Table2: 2 1 3 3 A2.1 Table2: 2 2 3 3 A2.2 Table2: 2 3 3 3 A2.3 Table1: 2 3 4 2 Table2: 3 1 3 3 A3.1 Table2: 3 2 3 3 A3.2 Table2: 3 3 3 3 A3.3 Table1: 2 4 4 2 Table2: 4 1 3 3 A4.1 Table2: 4 2 3 3 A4.2 Table2: 4 3 3 3 A4.3 Label: lab3 Table1: 3 1 4 2 Table2: 1 1 3 3 A1.1 Table2: 1 2 3 3 A1.2 Table2: 1 3 3 3 A1.3 Table1: 3 2 4 2 Table2: 2 1 3 3 A2.1 Table2: 2 2 3 3 A2.2 Table2: 2 3 3 3 A2.3 Table1: 3 3 4 2 Table2: 3 1 3 3 A3.1 Table2: 3 2 3 3 A3.2 Table2: 3 3 3 3 A3.3 Table1: 3 4 4 2 Table2: 4 1 3 3 A4.1 Table2: 4 2 3 3 A4.2 Table2: 4 3 3 3 A4.3 Label: lab4 Table1: 4 1 4 2 Table2: 1 1 3 3 A1.1 Table2: 1 2 3 3 A1.2 Table2: 1 3 3 3 A1.3 Table1: 4 2 4 2 Table2: 2 1 3 3 A2.1 Table2: 2 2 3 3 A2.2 Table2: 2 3 3 3 A2.3 Table1: 4 3 4 2 Table2: 3 1 3 3 A3.1 Table2: 3 2 3 3 A3.2 Table2: 3 3 3 3 A3.3 Table1: 4 4 4 2 Table2: 4 1 3 3 A4.1 Table2: 4 2 3 3 A4.2 Table2: 4 3 3 3 A4.3 ====================================================================== A matrix outside a table: A1.1, A1.2, A1.3 A2.1, A2.2, A2.3 A3.1, A3.2, A3.3 A4.1, A4.2, A4.3 ====================================================================== A matrix with section: S1) A1.1 S2) A1.2 S1) A1.3 S1) A2.1 S2) A2.2 S1) A2.3 S1) A3.1 S2) A3.2 S1) A3.3 S1) A4.1 S2) A4.2 S1) A4.3 Idem with @@TERMINATE_SECTIONS@@ S1) A1.1 S2) A1.2 S1) A1.3 S2) S1) A2.1 S2) A2.2 S1) A2.3 S2) S1) A3.1 S2) A3.2 S1) A3.3 S2) S1) A4.1 S2) A4.2 S1) A4.3 S2) [INFO] testme6.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] This is a test for the matrix feature: [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] Table1: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ [TABLE] [BLOCK] [COMMON] [TEXT] Table2: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ [TEXT] @_MAT_@ [END_BLOCK] [END_TABLE] [TEXT] --- [TEXT] [@_MAT_@] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] ====================================================================== [TEXT] [TEXT] A table with labels (vector): [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] [TEXT] Label: @_LABELS_@ [TEXT] [TEXT] Table1: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ [TABLE] [BLOCK] [COMMON] [TEXT] Table2: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ [TEXT] @_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] ====================================================================== [TEXT] [TEXT] A matrix inside a table with labels (vectors): [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] [TEXT] Label: @_LABELS_@ [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] [TEXT] Table1: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ [TABLE] [BLOCK] [COMMON] [TEXT] Table2: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ [TEXT] @_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] ====================================================================== [TEXT] [TEXT] A matrix outside a table: [TEXT] [TEXT] @_MAT_@ [TEXT] [TEXT] ====================================================================== [TEXT] [TEXT] A matrix with section: [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [SECTION] [TEXT] S1) @_MAT_@ [SECTION] [TEXT] S2) @_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Idem with @@TERMINATE_SECTIONS@@ [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] TERMINATE_SECTIONS [BLOCK] [SECTION] [TEXT] S1) @_MAT_@ [SECTION] [TEXT] S2) @_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0005_testme/test.py0000644000175000017500000000014211637170655024527 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme6.tmplt"]) run('print_tree', ["testme6.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0005_testme/testme6.tmplt0000755000175000017500000000254611637170655025664 0ustar lbrentalbrenta This is a test for the matrix feature: @@TABLE@@ Table1: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ @@TABLE@@ Table2: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ @_MAT_@ @@END_TABLE@@ --- [@_MAT_@] @@END_TABLE@@ ====================================================================== A table with labels (vector): @@TABLE@@ Label: @_LABELS_@ Table1: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ @@TABLE@@ Table2: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ ====================================================================== A matrix inside a table with labels (vectors): @@TABLE@@ Label: @_LABELS_@ @@TABLE@@ Table1: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ @@TABLE@@ Table2: @_UP_TABLE_LINE_@ @_TABLE_LINE_@ @_NUMBER_LINE_@ @_TABLE_LEVEL_@ @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ @@END_TABLE@@ ====================================================================== A matrix outside a table: @_MAT_@ ====================================================================== A matrix with section: @@TABLE@@ @@TABLE@@ S1) @_MAT_@ @@SECTION@@ S2) @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ Idem with @@TERMINATE_SECTIONS@@ @@TABLE@@ @@TABLE@@ @@TERMINATE_SECTIONS@@ S1) @_MAT_@ @@SECTION@@ S2) @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0006_testme/0000755000175000017500000000000011637170657023204 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0006_testme/test.out0000644000175000017500000000167411637170655024722 0ustar lbrentalbrenta 1 [one] 2 [two] 3 [three] 1 [(one)] 2 [(two)] 3 [] 1 [one] 2 [two] 3 [three] 1 [(one)] 2 [(two)] >one >(one) >two >(two) >three > >one >(one) >two >(two) [INFO] testme7.tmplt [C_INFO] 1 FALSE [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [TEXT] @_TABLE_LINE_@ [TEXT] [@_MATDSIZE_@] [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [IF] @_EXIST:MATDSIZE_@ [TEXT] @_TABLE_LINE_@ [TEXT] [@_MATDSIZE_@] [END_IF] [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] >@_V5_@ [TEXT] >@_V6_@ [END_BLOCK] [END_TABLE] [TEXT] [TABLE] [BLOCK] [COMMON] [IF] @_EXIST:V6_@ [TEXT] >@_V5_@ [TEXT] >@_V6_@ [END_IF] [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0006_testme/test.py0000644000175000017500000000014211637170655024530 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme7.tmplt"]) run('print_tree', ["testme7.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0006_testme/testme7.tmplt0000755000175000017500000000046411637170655025663 0ustar lbrentalbrenta @@TABLE@@ @@TABLE@@ @_TABLE_LINE_@ [@_MATDSIZE_@] @@END_TABLE@@ @@END_TABLE@@ @@TABLE@@ @@TABLE@@ @@IF@@ @_EXIST:MATDSIZE_@ @_TABLE_LINE_@ [@_MATDSIZE_@] @@END_IF@@ @@END_TABLE@@ @@END_TABLE@@ @@TABLE@@ >@_V5_@ >@_V6_@ @@END_TABLE@@ @@TABLE@@ @@IF@@ @_EXIST:V6_@ >@_V5_@ >@_V6_@ @@END_IF@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0007_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0007_testme/test.out0000644000175000017500000000374411637170655024723 0ustar lbrentalbrenta Test for complex condition: 1) OK 2) OK 3) OK 4) OK 5) OK 6) OK 7) OK 8) OK 8) OK 9) OK 10) OK 11) OK 12) OK 13) one This is value two ! three 14) OK 15) OK 16) OK [INFO] testme8.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] Test for complex condition: [TEXT] [TEXT] 1) [IF] (@_COND1_@ or @_COND2_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 2) [IF] (@_COND1_@ and @_COND2_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [TEXT] 3) [IF] (@_ONE_@ > @_TWO_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [TEXT] 4) [IF] (@_ONE_@ >= @_TWO_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [TEXT] 5) [IF] (@_ONE_@ < @_TWO_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 6) [IF] (@_ONE_@ <= @_TWO_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 7) [IF] (@_ONE_@ = @_TWO_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [TEXT] 8) [IF] (@_THREE_@ = @_THREE_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 8) [IF] ((@_THREE_@ = @_THREE_@) and @_COND2_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 9) [IF] ((@_THREE_@ = @_THREE_@) or @_COND1_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 10) [IF] ((@_ONE_@ <= @_TWO_@) and (@_THREE_@ > @_TWO_@)) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 11) [IF] (((@_ONE_@ <= @_TWO_@) and (@_THREE_@ > @_TWO_@)) and @_COND1_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [TEXT] 12) [IF] (@_COND2_@ or (((@_ONE_@ <= @_TWO_@) and (@_THREE_@ > @_TWO_@)) and @_COND1_@)) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 13) [TABLE] [BLOCK] [COMMON] [IF] (@_UPPER:VAR3_@ = TWO) [TEXT] This is value two ! [ELSE] [TEXT] @_VAR3_@ [END_IF] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] 14) [IF] (@_COND1_@ xor @_COND2_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [TEXT] 15) [IF] (@_COND1_@ xor @_COND1_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [TEXT] 16) [IF] (@_COND2_@ xor @_COND2_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0007_testme/test.py0000644000175000017500000000014211637170655024531 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme8.tmplt"]) run('print_tree', ["testme8.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0007_testme/testme8.tmplt0000755000175000017500000000233511637170655025664 0ustar lbrentalbrenta Test for complex condition: 1) @@IF@@ @_COND1_@ or @_COND2_@ OK @@ELSE@@ NOK @@END_IF@@ 2) @@IF@@ @_COND1_@ and @_COND2_@ NOK @@ELSE@@ OK @@END_IF@@ 3) @@IF@@ @_ONE_@ > @_TWO_@ NOK @@ELSE@@ OK @@END_IF@@ 4) @@IF@@ @_ONE_@ >= @_TWO_@ NOK @@ELSE@@ OK @@END_IF@@ 5) @@IF@@ @_ONE_@ < @_TWO_@ OK @@ELSE@@ NOK @@END_IF@@ 6) @@IF@@ @_ONE_@ <= @_TWO_@ OK @@ELSE@@ NOK @@END_IF@@ 7) @@IF@@ @_ONE_@ = @_TWO_@ NOK @@ELSE@@ OK @@END_IF@@ 8) @@IF@@ @_THREE_@ = @_THREE_@ OK @@ELSE@@ NOK @@END_IF@@ 8) @@IF@@ (@_THREE_@ = @_THREE_@) and @_COND2_@ OK @@ELSE@@ NOK @@END_IF@@ 9) @@IF@@ (@_THREE_@ = @_THREE_@) or @_COND1_@ OK @@ELSE@@ NOK @@END_IF@@ 10) @@IF@@ (@_ONE_@ <= @_TWO_@) and (@_THREE_@ > @_TWO_@) OK @@ELSE@@ NOK @@END_IF@@ 11) @@IF@@ (@_ONE_@ <= @_TWO_@) and (@_THREE_@ > @_TWO_@) and (@_COND1_@) NOK @@ELSE@@ OK @@END_IF@@ 12) @@IF@@ @_COND2_@ or ((@_ONE_@ <= @_TWO_@) and (@_THREE_@ > @_TWO_@) and (@_COND1_@)) OK @@ELSE@@ NOK @@END_IF@@ 13) @@TABLE@@ @@IF@@ @_UPPER:VAR3_@ = TWO This is value two ! @@ELSE@@ @_VAR3_@ @@END_IF@@ @@END_TABLE@@ 14) @@IF@@ @_COND1_@ xor @_COND2_@ OK @@ELSE@@ NOK @@END_IF@@ 15) @@IF@@ @_COND1_@ xor @_COND1_@ NOK @@ELSE@@ OK @@END_IF@@ 16) @@IF@@ @_COND2_@ xor @_COND2_@ NOK @@ELSE@@ OK @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0008_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0008_testme/test.out0000644000175000017500000000042411637170655024714 0ustar lbrentalbrenta ok1 ok cond2 [INFO] testme11.tmplt [C_INFO] 1 FALSE [TEXT] [IF] @_COND1_@ [TEXT] nok1 [ELSE] [IF] @_COND2_@ [TEXT] ok1 [ELSE] [TEXT] else part [END_IF] [END_IF] [TEXT] [IF] @_COND2_@ [TEXT] ok cond2 [ELSE] [TEXT] nok cond2 [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0008_testme/test.py0000644000175000017500000000014411637170655024534 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme11.tmplt"]) run('print_tree', ["testme11.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0008_testme/testme11.tmplt0000755000175000017500000000032511637170655025734 0ustar lbrentalbrenta @@IF@@ @_COND1_@ nok1 @@ELSIF@@ false nok2 @@ELSIF@@ 8 nok3 @@ELSIF@@ sze nok4 @@ELSIF@@ @_COND2_@ ok1 @@ELSE@@ else part @@END_IF@@ @@IF@@ @_COND2_@ ok cond2 @@ELSE@@ nok cond2 @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0009_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0009_testme/test.out0000644000175000017500000000014511637170655024715 0ustar lbrentalbrenta here [INFO] testme15.tmplt [C_INFO] 1 FALSE [TEXT] [IF] (@_TWO_@ > 0) [TEXT] here [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0009_testme/test.py0000644000175000017500000000014411637170655024535 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme15.tmplt"]) run('print_tree', ["testme15.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0009_testme/testme15.tmplt0000755000175000017500000000010411637170655025734 0ustar lbrentalbrenta @@IF@@ @_TWO_@ > 0 @@-- this is a comment here @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0010_testme/0000755000175000017500000000000011637170657023177 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0010_testme/test.out0000644000175000017500000000267611637170655024720 0ustar lbrentalbrenta OK 2 OK 2 OK 2 OK OK OK OK OK OK OK OK OK OK OK [INFO] testme16.tmplt [C_INFO] 1 FALSE [TEXT] [IF] (@_TWO_@ = 2) [TEXT] OK 2 [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] (@_TWO_@ /= 3) [TEXT] OK 2 [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] (not (@_TWO_@ = 3)) [TEXT] OK 2 [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ((@_ONE_@ = 1) or (not (@_TWO_@ = 3))) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ((@_ONE_@ = 2) or (not (@_TWO_@ = 3))) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ((@_ONE_@ = 2) and (not (@_TWO_@ = 3))) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [IF] ((@_ONE_@ = 1) and (not (@_TWO_@ = 3))) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ((not (@_TWO_@ = 3)) and (not (@_ONE_@ = 2))) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ((not (@_TWO_@ = 3)) and (not (@_ONE_@ = 2))) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ((not (@_TWO_@ = 3)) and (not (@_ONE_@ = 1))) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [IF] ((not (@_TWO_@ = 3)) and (not (@_ONE_@ = 1))) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [IF] (not @_COND2_@) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [IF] ((@_ONE_@ = 1) and (not @_COND2_@)) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [IF] ((@_ONE_@ = 1) and (not @_COND2_@)) [TEXT] NOK [ELSE] [TEXT] OK [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0010_testme/test.py0000644000175000017500000000014411637170655024525 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme16.tmplt"]) run('print_tree', ["testme16.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0010_testme/testme16.tmplt0000755000175000017500000000176111637170655025737 0ustar lbrentalbrenta @@IF@@ @_TWO_@ = 2 OK 2 @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_TWO_@ /= 3 OK 2 @@ELSE@@ NOK @@END_IF@@ @@IF@@ not (@_TWO_@ = 3) OK 2 @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_ONE_@ = 1 or not (@_TWO_@ = 3) OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_ONE_@ = 2 or not (@_TWO_@ = 3) OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_ONE_@ = 2 and not (@_TWO_@ = 3) NOK @@ELSE@@ OK @@END_IF@@ @@IF@@ @_ONE_@ = 1 and not (@_TWO_@ = 3) OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ (not (@_TWO_@ = 3)) and (not (@_ONE_@ = 2)) OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ not (@_TWO_@ = 3) and (not (@_ONE_@ = 2)) OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ (not (@_TWO_@ = 3)) and (not (@_ONE_@ = 1)) NOK @@ELSE@@ OK @@END_IF@@ @@IF@@ not (@_TWO_@ = 3) and (not (@_ONE_@ = 1)) NOK @@ELSE@@ OK @@END_IF@@ @@IF@@ not @_COND2_@ NOK @@ELSE@@ OK @@END_IF@@ @@IF@@ (@_ONE_@ = 1) and (not @_COND2_@) NOK @@ELSE@@ OK @@END_IF@@ @@IF@@ (@_ONE_@ = 1) and not @_COND2_@ NOK @@ELSE@@ OK @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0011_testme/0000755000175000017500000000000011637170657023200 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0011_testme/test.out0000644000175000017500000000073211637170655024710 0ustar lbrentalbrenta OK OK OK OK OK [INFO] testme17.tmplt [C_INFO] 1 FALSE [TEXT] [IF] (@_VAR1_@ = "a value") [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] (@_VAR1_@ /= value) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] (@_VAR1_@ /= value) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ("a value" = @_VAR1_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] ("toto value" /= @_VAR1_@) [TEXT] OK [ELSE] [TEXT] NOK [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0011_testme/test.py0000644000175000017500000000014411637170655024526 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme17.tmplt"]) run('print_tree', ["testme17.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0011_testme/testme17.tmplt0000755000175000017500000000045411637170655025737 0ustar lbrentalbrenta @@IF@@ @_VAR1_@ = "a value" OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_VAR1_@ /= value OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_VAR1_@ /= "value" OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ "a value" = @_VAR1_@ OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ "toto value" /= @_VAR1_@ OK @@ELSE@@ NOK @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0012_testme/0000755000175000017500000000000011637170657023201 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0012_testme/test.out0000644000175000017500000001347511637170655024721 0ustar lbrentalbrenta Test for table attributes Level 0 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 Level 1 (no expand var) Level 1 (with expand var) => (one) MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => (two) MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 Level 2 (no expand var) Level 2 (with expand var) - vector level 1 => (one) => (two) Level 2 (with expand var) - vector level 2 Level 2 (with expand var) - matrix level 1 => A1.1, A1.2, A1.3 => A2.1, A2.2, A2.3 => A3.1, A3.2, A3.3 => A4.1, A4.2, A4.3 Level 2 (with expand var) - matrix level 2 => A1.1 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A1.2 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A1.3 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 ---- => A2.1 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A2.2 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A2.3 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 ---- => A3.1 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A3.2 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A3.3 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 ---- => A4.1 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A4.2 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 => A4.3 MAT 4 3 3 MATDSIZE 2 2 3 VAR2 10 V6 2 ---- [INFO] testme18.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] Test for table attributes [TEXT] [TEXT] Level 0 [TEXT] [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [TEXT] [TEXT] Level 1 (no expand var) [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Level 1 (with expand var) [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] => @_V6_@ [TEXT] [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Level 2 (no expand var) [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Level 2 (with expand var) - vector level 1 [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] => @_V6_@ [TABLE] [BLOCK] [COMMON] [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Level 2 (with expand var) - vector level 2 [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [TEXT] => @_V6_@ [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Level 2 (with expand var) - matrix level 1 [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] => @_MAT_@ [TABLE] [BLOCK] [COMMON] [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] Level 2 (with expand var) - matrix level 2 [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [TEXT] => @_MAT_@ [TEXT] MAT [TEXT] @_MAT'Line_@ [TEXT] @_MAT'Min_Column_@ [TEXT] @_MAT'Max_Column_@ [TEXT] [TEXT] MATDSIZE [TEXT] @_MATDSIZE'Line_@ [TEXT] @_MATDSIZE'Min_Column_@ [TEXT] @_MATDSIZE'Max_Column_@ [TEXT] [TEXT] VAR2 [TEXT] @_VAR2'Length_@ [TEXT] [TEXT] V6 [TEXT] @_V6'Length_@ [END_BLOCK] [END_TABLE] [TEXT] ---- [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0012_testme/test.py0000644000175000017500000000014411637170655024527 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme18.tmplt"]) run('print_tree', ["testme18.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0012_testme/testme18.tmplt0000755000175000017500000000373311637170655025744 0ustar lbrentalbrenta Test for table attributes Level 0 MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ Level 1 (no expand var) @@TABLE@@ MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ @@END_TABLE@@ Level 1 (with expand var) @@TABLE@@ => @_V6_@ MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ @@END_TABLE@@ Level 2 (no expand var) @@TABLE@@ @@TABLE@@ MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ @@END_TABLE@@ @@END_TABLE@@ Level 2 (with expand var) - vector level 1 @@TABLE@@ => @_V6_@ @@TABLE@@ MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ @@END_TABLE@@ @@END_TABLE@@ Level 2 (with expand var) - vector level 2 @@TABLE@@ @@TABLE@@ => @_V6_@ MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ @@END_TABLE@@ @@END_TABLE@@ Level 2 (with expand var) - matrix level 1 @@TABLE@@ => @_MAT_@ @@TABLE@@ MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ @@END_TABLE@@ @@END_TABLE@@ Level 2 (with expand var) - matrix level 2 @@TABLE@@ @@TABLE@@ => @_MAT_@ MAT @_MAT'Line_@ @_MAT'Min_Column_@ @_MAT'Max_Column_@ MATDSIZE @_MATDSIZE'Line_@ @_MATDSIZE'Min_Column_@ @_MATDSIZE'Max_Column_@ VAR2 @_VAR2'Length_@ V6 @_V6'Length_@ @@END_TABLE@@ ---- @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0013_testme/0000755000175000017500000000000011637170657023202 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0013_testme/test.out0000644000175000017500000000113011637170656024704 0ustar lbrentalbrenta 2 11 2 11 1 -1 1 -1 6 2 6 2 1 0 1 0 1 0 1 5 [INFO] testme24.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_"+"(1):ONE_@ [TEXT] @_"+"(10):ONE_@ [TEXT] @_"+"(1):ONE_@ [TEXT] @_"+"(10):ONE_@ [TEXT] [TEXT] @_"-"(2):THREE_@ [TEXT] @_"-"(2):ONE_@ [TEXT] @_"-"(2):THREE_@ [TEXT] @_"-"(2):ONE_@ [TEXT] [TEXT] @_"*"(2):THREE_@ [TEXT] @_"*"(1):TWO_@ [TEXT] @_"*"(2):THREE_@ [TEXT] @_"*"(1):TWO_@ [TEXT] [TEXT] @_"/"(3):THREE_@ [TEXT] @_"/"(3):ONE_@ [TEXT] @_"/"(3):THREE_@ [TEXT] @_"/"(3):ONE_@ [TEXT] [TEXT] @_MOD(2):ONE_@ [TEXT] @_MOD(2):TWO_@ [TEXT] @_MOD(2):THREE_@ [TEXT] [TEXT] @_"+"(2):V5'Length_@ libtemplates-parser-11.6.orig/regtests/tests/0013_testme/test.py0000644000175000017500000000014411637170656024531 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme24.tmplt"]) run('print_tree', ["testme24.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0013_testme/testme24.tmplt0000755000175000017500000000051211637170656025733 0ustar lbrentalbrenta @_"+"(1):ONE_@ @_"+"(10):ONE_@ @_ADD(1):ONE_@ @_ADD(10):ONE_@ @_"-"(2):THREE_@ @_"-"(2):ONE_@ @_SUB(2):THREE_@ @_SUB(2):ONE_@ @_"*"(2):THREE_@ @_"*"(1):TWO_@ @_MULT(2):THREE_@ @_MULT(1):TWO_@ @_"/"(3):THREE_@ @_"/"(3):ONE_@ @_DIV(3):THREE_@ @_DIV(3):ONE_@ @_MOD(2):ONE_@ @_MOD(2):TWO_@ @_MOD(2):THREE_@ @_ADD(2):V5'Length_@ libtemplates-parser-11.6.orig/regtests/tests/0014_testme/0000755000175000017500000000000011637170657023203 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0014_testme/test.out0000644000175000017500000000077511637170656024723 0ustar lbrentalbrenta First line
Second line First line Second line First line Second line First line
Second line First line Second line First line Second line First line Second line First line Second line [INFO] testme25.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_LF_2_BR:WITHLF_@ [TEXT] @_BR_2_LF:WITHBR_@ [TEXT] [TEXT] @_BR_2_LF:LF_2_BR:WITHLF_@ [TEXT] @_LF_2_BR:BR_2_LF:WITHBR_@ [TEXT] [TEXT] @_BR_2_EOL(LF):WITHBR_@ [TEXT] @_BR_2_EOL(CRLF):WITHBR_@ [TEXT] @_BR_2_EOL(CR):WITHBR_@ [TEXT] @_BR_2_EOL(LFCR):WITHBR_@ libtemplates-parser-11.6.orig/regtests/tests/0014_testme/test.py0000644000175000017500000000014411637170656024532 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme25.tmplt"]) run('print_tree', ["testme25.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0014_testme/testme25.tmplt0000755000175000017500000000030311637170656025733 0ustar lbrentalbrenta @_LF_2_BR:WITHLF_@ @_BR_2_LF:WITHBR_@ @_BR_2_LF:LF_2_BR:WITHLF_@ @_LF_2_BR:BR_2_LF:WITHBR_@ @_BR_2_EOL(LF):WITHBR_@ @_BR_2_EOL(CRLF):WITHBR_@ @_BR_2_EOL(CR):WITHBR_@ @_BR_2_EOL(LFCR):WITHBR_@ libtemplates-parser-11.6.orig/regtests/tests/0015_testme/0000755000175000017500000000000011637170657023204 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0015_testme/include.tmplt0000755000175000017500000000044611637170656025717 0ustar lbrentalbrenta @@-- Include file @_$0_@ 1> @_$1_@ 2> @_$2_@ 3> @_WEB_NBSP:$2_@ 4> @_WEB_NBSP:$1_@ @@IF@@ @_$2_@ = toto 5> @_$1_@ @@END_IF@@ @@IF@@ @_WEB_NBSP:$2_@ = toto or @_WEB_NBSP:$1_@ = "xx yy" 6> @_$2_@ @@END_IF@@ @@TABLE@@ 7> @_VAR3_@ 8> @_$1_@ @@SECTION@@ 9> @_$2_@ @@END_TABLE@@ ---------- libtemplates-parser-11.6.orig/regtests/tests/0015_testme/test.out0000644000175000017500000000475611637170656024727 0ustar lbrentalbrenta First include: include.tmplt 1> a value 2> 3> 4> a value 7> one 8> a value 9> 7> three 8> a value ---------- Second include: include.tmplt 1> a value 2> toto 3> toto 4> a value 5> a value 6> toto 7> one 8> a value 9> toto 7> three 8> a value ---------- Third include: include.tmplt 1> a value 2> toto titi 3> toto titi 4> a value 7> one 8> a value 9> toto titi 7> three 8> a value ---------- [INFO] testme26.tmplt -> include.tmplt -> include.tmplt -> include.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] [TEXT] First include: [INCLUDE] include.tmplt $0 = include.tmplt $1 = @_VAR1_@ [INFO] include.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_$0_@ [TEXT] 1> @_$1_@ [TEXT] [TEXT] 2> @_$2_@ [TEXT] [TEXT] 3> @_WEB_NBSP:$2_@ [TEXT] 4> @_WEB_NBSP:$1_@ [TEXT] [IF] (@_$2_@ = toto) [TEXT] 5> @_$1_@ [END_IF] [TEXT] [IF] ((@_WEB_NBSP:$2_@ = toto) or (@_WEB_NBSP:$1_@ = "xx yy")) [TEXT] 6> @_$2_@ [END_IF] [TEXT] [TABLE] [BLOCK] [SECTION] [TEXT] 7> @_VAR3_@ [TEXT] 8> @_$1_@ [SECTION] [TEXT] 9> @_$2_@ [END_BLOCK] [END_TABLE] [TEXT] ---------- [TEXT] [TEXT] [TEXT] Second include: [INCLUDE] include.tmplt $0 = include.tmplt $1 = @_VAR1_@ $2 = toto [INFO] include.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_$0_@ [TEXT] 1> @_$1_@ [TEXT] [TEXT] 2> @_$2_@ [TEXT] [TEXT] 3> @_WEB_NBSP:$2_@ [TEXT] 4> @_WEB_NBSP:$1_@ [TEXT] [IF] (@_$2_@ = toto) [TEXT] 5> @_$1_@ [END_IF] [TEXT] [IF] ((@_WEB_NBSP:$2_@ = toto) or (@_WEB_NBSP:$1_@ = "xx yy")) [TEXT] 6> @_$2_@ [END_IF] [TEXT] [TABLE] [BLOCK] [SECTION] [TEXT] 7> @_VAR3_@ [TEXT] 8> @_$1_@ [SECTION] [TEXT] 9> @_$2_@ [END_BLOCK] [END_TABLE] [TEXT] ---------- [TEXT] [TEXT] Third include: [INCLUDE] include.tmplt $0 = include.tmplt $1 = @_VAR1_@ $2 = toto titi $3 = tutu tata [INFO] include.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_$0_@ [TEXT] 1> @_$1_@ [TEXT] [TEXT] 2> @_$2_@ [TEXT] [TEXT] 3> @_WEB_NBSP:$2_@ [TEXT] 4> @_WEB_NBSP:$1_@ [TEXT] [IF] (@_$2_@ = toto) [TEXT] 5> @_$1_@ [END_IF] [TEXT] [IF] ((@_WEB_NBSP:$2_@ = toto) or (@_WEB_NBSP:$1_@ = "xx yy")) [TEXT] 6> @_$2_@ [END_IF] [TEXT] [TABLE] [BLOCK] [SECTION] [TEXT] 7> @_VAR3_@ [TEXT] 8> @_$1_@ [SECTION] [TEXT] 9> @_$2_@ [END_BLOCK] [END_TABLE] [TEXT] ---------- libtemplates-parser-11.6.orig/regtests/tests/0015_testme/test.py0000644000175000017500000000014411637170656024533 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme26.tmplt"]) run('print_tree', ["testme26.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0015_testme/testme26.tmplt0000755000175000017500000000035411637170656025743 0ustar lbrentalbrenta @@-- A comment for the template First include: @@INCLUDE@@ include.tmplt @_VAR1_@ @@-- Another one Second include: @@INCLUDE@@ include.tmplt @_VAR1_@ toto Third include: @@INCLUDE@@ include.tmplt "@_VAR1_@" "toto titi" "tutu tata" libtemplates-parser-11.6.orig/regtests/tests/0016_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0016_testme/include2.tmplt0000644000175000017500000000025011637170656025770 0ustar lbrentalbrenta @@-- Include file @_$0_@ 1> @_$1_@ 2> @_$2'Length_@ 3> @_$3'Line_@ 4> @_$3'Min_Column_@ 5> @_$3'Max_Column_@ @@IF@@ @_$2'Length_@ > 1 ok @@ELSE@@ nok @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0016_testme/test.out0000644000175000017500000000107311637170656024715 0ustar lbrentalbrenta include2.tmplt 1> a value 2> 3 3> 4 4> 3 5> 3 ok [INFO] testme27.tmplt -> include2.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] [INCLUDE] include2.tmplt $0 = include2.tmplt $1 = @_VAR1_@ $2 = @_VAR3_@ $3 = @_MAT_@ [INFO] include2.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_$0_@ [TEXT] [TEXT] 1> @_$1_@ [TEXT] [TEXT] 2> @_$2'Length_@ [TEXT] [TEXT] 3> @_$3'Line_@ [TEXT] [TEXT] 4> @_$3'Min_Column_@ [TEXT] [TEXT] 5> @_$3'Max_Column_@ [TEXT] [IF] (@_$2'Length_@ > 1) [TEXT] ok [ELSE] [TEXT] nok [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0016_testme/test.py0000644000175000017500000000014411637170656024534 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme27.tmplt"]) run('print_tree', ["testme27.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0016_testme/testme27.tmplt0000755000175000017500000000012711637170656025743 0ustar lbrentalbrenta @@-- A comment for the template @@INCLUDE@@ include2.tmplt @_VAR1_@ @_VAR3_@ @_MAT_@ libtemplates-parser-11.6.orig/regtests/tests/0017_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0017_testme/test.out0000644000175000017500000000112411637170656024713 0ustar lbrentalbrenta Test slice 12 = 12 12 = 12 23 = 23 23 = 23 = 6 = 6 = = 2345 = 2345 456 = 456 45 = 45 = [INFO] testme30.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] [TEXT] Test slice [TEXT] [TEXT] 12 = @_SLICE(1 .. 2):NUM0_@ [TEXT] 12 = @_SLICE(1 .. 2):NUM0_@ [TEXT] 23 = @_SLICE(2 .. 3):NUM0_@ [TEXT] 23 = @_SLICE(2 .. 3):NUM0_@ [TEXT] = @_SLICE(2 .. 1):NUM0_@ [TEXT] 6 = @_SLICE(6 .. 10):NUM0_@ [TEXT] = @_SLICE(8 .. 15):NUM0_@ [TEXT] = @_SLICE(18 .. 15):NUM0_@ [TEXT] 2345 = @_SLICE(2 .. 5):NUM0_@ [TEXT] 456 = @_SLICE(-2 .. 0):NUM0_@ [TEXT] 45 = @_SLICE(-2 .. -1):NUM0_@ [TEXT] = @_SLICE(-10 .. -9):NUM0_@ libtemplates-parser-11.6.orig/regtests/tests/0017_testme/test.py0000644000175000017500000000014411637170656024535 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme30.tmplt"]) run('print_tree', ["testme30.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0017_testme/testme30.tmplt0000755000175000017500000000065211637170656025741 0ustar lbrentalbrenta @@-- test for SLICE() Test slice 12 = @_SLICE(1..2):NUM0_@ 12 = @_SLICE("1..2"):NUM0_@ 23 = @_SLICE( 2 .. 3 ):NUM0_@ 23 = @_SLICE(" 2 .. 3 "):NUM0_@ = @_SLICE(2..1):NUM0_@ 6 = @_SLICE("6 ..10"):NUM0_@ @@-- slice test = @_SLICE("8 ..15"):NUM0_@ = @_SLICE("18 ..15"):NUM0_@ 2345 = @_SLICE(2..5):NUM0_@ 456 = @_SLICE(-2..0):NUM0_@ 45 = @_SLICE(-2..-1):NUM0_@ = @_SLICE(-10..-9):NUM0_@ @@-- test for SLICE() libtemplates-parser-11.6.orig/regtests/tests/0018_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0018_testme/base.tmplt0000755000175000017500000000000611637170656025201 0ustar lbrentalbrentabase! libtemplates-parser-11.6.orig/regtests/tests/0018_testme/dir/0000755000175000017500000000000011637170657023765 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0018_testme/dir/file.tmplt0000755000175000017500000000010211637170656025761 0ustar lbrentalbrenta @@INCLUDE@@ header.tmplt Hello @@INCLUDE@@ subdir/footer.tmplt libtemplates-parser-11.6.orig/regtests/tests/0018_testme/dir/header.tmplt0000755000175000017500000000001011637170656026270 0ustar lbrentalbrenta Header libtemplates-parser-11.6.orig/regtests/tests/0018_testme/dir/subdir/0000755000175000017500000000000011637170657025255 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0018_testme/dir/subdir/footer.tmplt0000755000175000017500000000004111637170656027632 0ustar lbrentalbrenta Footer @@INCLUDE@@ /base.tmplt libtemplates-parser-11.6.orig/regtests/tests/0018_testme/test.out0000644000175000017500000000132011637170656024712 0ustar lbrentalbrenta Header Hello Footer base! [INFO] testme31.tmplt -> dir/file.tmplt [C_INFO] 1 FALSE [TEXT] [INCLUDE] dir/file.tmplt $0 = dir/file.tmplt [INFO] dir/file.tmplt -> dir/subdir/footer.tmplt -> dir/header.tmplt [C_INFO] 1 FALSE [TEXT] [INCLUDE] dir/header.tmplt $0 = header.tmplt [INFO] dir/header.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] Header [TEXT] [TEXT] Hello [TEXT] [INCLUDE] dir/subdir/footer.tmplt $0 = subdir/footer.tmplt [INFO] dir/subdir/footer.tmplt -> base.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] Footer [TEXT] [INCLUDE] base.tmplt $0 = /base.tmplt [INFO] base.tmplt [C_INFO] 1 FALSE [TEXT] base! libtemplates-parser-11.6.orig/regtests/tests/0018_testme/test.py0000644000175000017500000000014411637170656024536 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme31.tmplt"]) run('print_tree', ["testme31.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0018_testme/testme31.tmplt0000755000175000017500000000003411637170656025735 0ustar lbrentalbrenta @@INCLUDE@@ dir/file.tmplt libtemplates-parser-11.6.orig/regtests/tests/0019_testme/0000755000175000017500000000000011637170657023210 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0019_testme/test.out0000644000175000017500000000374711637170656024732 0ustar lbrentalbrenta a value [ val] a value [value a] a text [text a] a text with < 6 words & good 92 chars like + > [1 (6 words & good )] a text with < 6 words & good 92 chars like + > [1 ( a text with < ) 2 ( words & good 9) 3 ( chars like + > )] a text with < 6 words & good 92 chars like + > [1 ( a text with ) 2 ( 6 words & good 9) 3 ( chars like + > )] vector_tag tag_vector a text with < 6 WORDs & good 92 chars like + > toto titi tata tata titi toto tata titi toto titi titi toto .... titi tata tata titi toto tata titi toto titi titi titi toto .... tata tata titi toto tata titi toto titi titi tata toto titi .... tata titi toto tata titi toto titi titi toto .... titi tata tata titi .... tata titi .... titi titi titi toto .... tata tata .... toto tata .... toto .... .... tata toto titi .... .... titi toto .... titi toto titi titi tata toto titi _\1_ _\1_ titi toto _\1_ titi toto titi titi [INFO] testme32.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_VAR1_@ [TEXT] [@_REPLACE(a(.*)ue/\1):VAR1_@] [TEXT] [TEXT] @_VAR1_@ [TEXT] [@_REPLACE(^([a-z]+) ([a-z]+).*/\2 \1):VAR1_@] [TEXT] [TEXT] @_SLICE(2 .. 8):CONTRACT:NO_DIGIT:CLEAN_TEXT:FILTER_@ [TEXT] [@_REPLACE(^([a-z]+) ([a-z]+).*/\2 \1):SLICE(2 .. 8):CONTRACT:NO_DIGIT:CLEAN_TEXT:FILTER_@] [TEXT] [TEXT] @_FILTER_@ [TEXT] [@_REPLACE(^[^6]+([^9]+).*$/1 (\1)):FILTER_@] [TEXT] [TEXT] @_FILTER_@ [TEXT] [@_REPLACE(^(.*)6(.*)2(.*)$/1 (\1) 2 (\2) 3 (\3)):FILTER_@] [TEXT] [TEXT] @_FILTER_@ [TEXT] [@_REPLACE(^(.*)<(.*)2(.*)$/1 (\1) 2 (\2) 3 (\3)):FILTER_@] [TEXT] [TEXT] @_REPLACE(([^_]+)/\1):VT_@ [TEXT] @_REPLACE(([a-z]+)_([a-z]+)/\2_\1):VT_@ [TEXT] [TEXT] @_REPLACE(word/WORD):FILTER_@ [TEXT] [TEXT] @_TEXT_@ [TEXT] toto @_REPLACE(toto/....):TEXT_@ [TEXT] titi @_REPLACE(titi/....):TEXT_@ [TEXT] tata @_REPLACE(tata/....):TEXT_@ [TEXT] toto @_REPLACE_ALL(toto/....):TEXT_@ [TEXT] titi @_REPLACE_ALL(titi/....):TEXT_@ [TEXT] tata @_REPLACE_ALL(tata/....):TEXT_@ [TEXT] tata @_REPLACE_ALL(tata/_\1_):TEXT_@ libtemplates-parser-11.6.orig/regtests/tests/0019_testme/test.py0000644000175000017500000000014411637170656024537 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme32.tmplt"]) run('print_tree', ["testme32.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0019_testme/testme32.tmplt0000755000175000017500000000143611637170656025746 0ustar lbrentalbrenta @_VAR1_@ [@_REPLACE(a(.*)ue):VAR1_@] @_VAR1_@ [@_REPLACE(^([a-z]+) ([a-z]+).*/\2 \1):VAR1_@] @_SLICE(2..8):CONTRACT:NO_DIGIT:CLEAN_TEXT:FILTER_@ [@_REPLACE(^([a-z]+) ([a-z]+).*/\2 \1):SLICE(2..8):CONTRACT:NO_DIGIT:CLEAN_TEXT:FILTER_@] @_FILTER_@ [@_REPLACE(^[^6]+([^9]+).*$/1 (\1)):FILTER_@] @_FILTER_@ [@_REPLACE(^(.*)6(.*)2(.*)$/1 (\1) 2 (\2) 3 (\3)):FILTER_@] @_FILTER_@ [@_REPLACE(^(.*)<(.*)2(.*)$/1 (\1) 2 (\2) 3 (\3)):FILTER_@] @_REPLACE(([^_]+)):VT_@ @_REPLACE(([a-z]+)_([a-z]+)/\2_\1):VT_@ @_REPLACE(word/WORD):FILTER_@ @_TEXT_@ toto @_REPLACE(toto/....):TEXT_@ titi @_REPLACE(titi/....):TEXT_@ tata @_REPLACE(tata/....):TEXT_@ toto @_REPLACE_ALL(toto/....):TEXT_@ titi @_REPLACE_ALL(titi/....):TEXT_@ tata @_REPLACE_ALL(tata/....):TEXT_@ tata @_REPLACE_ALL(tata/_\1_):TEXT_@ libtemplates-parser-11.6.orig/regtests/tests/0020_testme/0000755000175000017500000000000011637170657023200 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0020_testme/test.out0000644000175000017500000000036711637170656024715 0ustar lbrentalbrentaDoes it match? YES It definetely match ! [INFO] testme38.tmplt [C_INFO] 1 FALSE [TEXT] Does it match? @_YES_NO:MATCH(Test):TEST_VAR_@ [IF] @_MATCH(Test):TEST_VAR_@ [TEXT] It definetely match ! [ELSE] [TEXT] Hmm... Contradiction! [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0020_testme/test.py0000644000175000017500000000014411637170656024527 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme38.tmplt"]) run('print_tree', ["testme38.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0020_testme/testme38.tmplt0000755000175000017500000000022111637170656025733 0ustar lbrentalbrentaDoes it match? @_YES_NO:MATCH(Test):TEST_VAR_@ @@IF@@ @_MATCH(Test):TEST_VAR_@ It definetely match ! @@ELSE@@ Hmm... Contradiction! @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0021_testme/0000755000175000017500000000000011637170657023201 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0021_testme/test.out0000644000175000017500000000074511637170656024716 0ustar lbrentalbrenta tag:vector tag):vector TAG:VECTOR TAG(:VECTOR tag)_@vector tag)@_vector tag)@\_vector [INFO] testme53.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] @_REPLACE(([a-z]+)_([a-z]+)/\2:\1):VT_@ [TEXT] @_REPLACE(([a-z]+)_([a-z]+)/\2):\1):VT_@ [TEXT] @_UPPER:REPLACE(([a-z]+)_([a-z]+)/\2:\1):VT_@ [TEXT] @_UPPER:REPLACE(([a-z]+)_([a-z]+)/\2(:\1):VT_@ [TEXT] @_REPLACE(([a-z]+)_([a-z]+)/\2)_@\1):VT_@ [TEXT] @_REPLACE(([a-z]+)_([a-z]+)/\2)@_\1):VT_@ [TEXT] @_REPLACE(([a-z]+)_([a-z]+)/\2)@\_\1):VT_@ libtemplates-parser-11.6.orig/regtests/tests/0021_testme/test.py0000644000175000017500000000014411637170656024530 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme53.tmplt"]) run('print_tree', ["testme53.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0021_testme/testme53.tmplt0000755000175000017500000000046611637170656025744 0ustar lbrentalbrenta @_REPLACE(([a-z]+)_([a-z]+)/\2:\1):VT_@ @_REPLACE(([a-z]+)_([a-z]+)/\2\):\1):VT_@ @_UPPER:REPLACE(([a-z]+)_([a-z]+)/\2:\1):VT_@ @_UPPER:REPLACE(([a-z]+)_([a-z]+)/\2\(:\1):VT_@ @_REPLACE(([a-z]+)_([a-z]+)/\2\)_\@\1):VT_@ @_REPLACE(([a-z]+)_([a-z]+)/\2\)@\_\1):VT_@ @_REPLACE(([a-z]+)_([a-z]+)/\2\)@\\_\1):VT_@ libtemplates-parser-11.6.orig/regtests/tests/0022_testme/0000755000175000017500000000000011637170657023202 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0022_testme/test.out0000644000175000017500000000637511637170656024724 0ustar lbrentalbrenta -- Table 1 lab1:A1.1 lab1:A1.2 lab1:A1.3 lab2:A2.1 lab2:A2.2 lab2:A2.3 lab3:A3.1 lab3:A3.2 lab3:A3.3 lab4:A4.1 lab4:A4.2 lab4:A4.3 -- Table 2 lab1 lab1:A1.1 lab1:A1.2 lab1:A1.3 lab2 lab2:A2.1 lab2:A2.2 lab2:A2.3 lab3 lab3:A3.1 lab3:A3.2 lab3:A3.3 lab4 lab4:A4.1 lab4:A4.2 lab4:A4.3 -- Table 3 lab1 lab1 lab1:A1.1 lab1:A1.2 lab1:A1.3 lab2 lab2:A2.1 lab2:A2.2 lab2:A2.3 lab3 lab3:A3.1 lab3:A3.2 lab3:A3.3 lab4 lab4:A4.1 lab4:A4.2 lab4:A4.3 lab2 lab1 lab1:A1.1 lab1:A1.2 lab1:A1.3 lab2 lab2:A2.1 lab2:A2.2 lab2:A2.3 lab3 lab3:A3.1 lab3:A3.2 lab3:A3.3 lab4 lab4:A4.1 lab4:A4.2 lab4:A4.3 lab3 lab1 lab1:A1.1 lab1:A1.2 lab1:A1.3 lab2 lab2:A2.1 lab2:A2.2 lab2:A2.3 lab3 lab3:A3.1 lab3:A3.2 lab3:A3.3 lab4 lab4:A4.1 lab4:A4.2 lab4:A4.3 lab4 lab1 lab1:A1.1 lab1:A1.2 lab1:A1.3 lab2 lab2:A2.1 lab2:A2.2 lab2:A2.3 lab3 lab3:A3.1 lab3:A3.2 lab3:A3.3 lab4 lab4:A4.1 lab4:A4.2 lab4:A4.3 -- Table 4 lab1 lab1 lab1:A1.1 lab1:A1.2 lab1:A1.3 lab2 lab1:A2.1 lab1:A2.2 lab1:A2.3 lab3 lab1:A3.1 lab1:A3.2 lab1:A3.3 lab4 lab1:A4.1 lab1:A4.2 lab1:A4.3 lab2 lab1 lab2:A1.1 lab2:A1.2 lab2:A1.3 lab2 lab2:A2.1 lab2:A2.2 lab2:A2.3 lab3 lab2:A3.1 lab2:A3.2 lab2:A3.3 lab4 lab2:A4.1 lab2:A4.2 lab2:A4.3 lab3 lab1 lab3:A1.1 lab3:A1.2 lab3:A1.3 lab2 lab3:A2.1 lab3:A2.2 lab3:A2.3 lab3 lab3:A3.1 lab3:A3.2 lab3:A3.3 lab4 lab3:A4.1 lab3:A4.2 lab3:A4.3 lab4 lab1 lab4:A1.1 lab4:A1.2 lab4:A1.3 lab2 lab4:A2.1 lab4:A2.2 lab4:A2.3 lab3 lab4:A3.1 lab4:A3.2 lab4:A3.3 lab4 lab4:A4.1 lab4:A4.2 lab4:A4.3 -- Table 5 lab1, lab2, lab3, lab4 {lab1} lab1, lab2, lab3, lab4 {lab2} lab1, lab2, lab3, lab4 {lab3} lab1, lab2, lab3, lab4 {lab4} [INFO] testme54.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] -- Table 1 [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS'Up_Level_@:@_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] -- Table 2 [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS_@ [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS'Up_Level_@:@_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] -- Table 3 [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS_@ [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS_@ [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS'Up_Level_@:@_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] -- Table 4 [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS_@ [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS_@ [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS'Up_Level(2)_@:@_MAT_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] -- Table 5 [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_LABELS'Up_Level(2)_@ {@_LABELS_@} [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0022_testme/test.py0000644000175000017500000000014411637170656024531 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme54.tmplt"]) run('print_tree', ["testme54.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0022_testme/testme54.tmplt0000755000175000017500000000105211637170656025736 0ustar lbrentalbrenta -- Table 1 @@TABLE@@ @@TABLE@@ @_LABELS'Up_Level_@:@_MAT_@ @@END_TABLE@@ @@END_TABLE@@ -- Table 2 @@TABLE@@ @_LABELS_@ @@TABLE@@ @_LABELS'Up_Level(1)_@:@_MAT_@ @@END_TABLE@@ @@END_TABLE@@ -- Table 3 @@TABLE@@ @_LABELS_@ @@TABLE@@ @_LABELS_@ @@TABLE@@ @_LABELS'Up_Level(1)_@:@_MAT_@ @@END_TABLE@@ @@END_TABLE@@ @@END_TABLE@@ -- Table 4 @@TABLE@@ @_LABELS_@ @@TABLE@@ @_LABELS_@ @@TABLE@@ @_LABELS'Up_Level(2)_@:@_MAT_@ @@END_TABLE@@ @@END_TABLE@@ @@END_TABLE@@ -- Table 5 @@TABLE@@ @_LABELS'Up_Level(2)_@ {@_LABELS_@} @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0023_testme/0000755000175000017500000000000011637170657023203 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0023_testme/test.out0000644000175000017500000001111711637170656024713 0ustar lbrentalbrenta Test for include with parameters with default values ********************************************************** 1) one, toto, TOTO 2) two, two, two 3) , trois et trois 4) , quatre 5) , cinq 6) , six 7) , sept 8) , huit 9) , neuf, Neuf toujours ********************************************************** 1) one, toto, TOTO 2) two, two, two 3) , trois et trois 4) , quatre 5) , cinq 6) six, six 7) , sept 8) , huit 9) , neuf, Neuf toujours ********************************************************** 1) , toto, TOTO 2) two, two, two 3) , trois et trois 4) , quatre 5) , cinq 6) six, six 7) , sept 8) eight, eight 9) , neuf, Neuf toujours ********************************************************** 1) , this is P1, THIS IS P1 2) two, this is P2, two 3) , trois et trois 4) , quatre 5) , cinq 6) six, six 7) , sept 8) eight, eight 9) true, true, True toujours ********************************************************** [INFO] testme59.tmplt -> testme59.incl -> testme59.incl -> testme59.incl -> testme59.incl [C_INFO] 1 FALSE [TEXT] [TEXT] Test for include with parameters with default values [TEXT] [TEXT] ********************************************************** [INCLUDE] testme59.incl $0 = testme59.incl $1 = one $2 = two [INFO] testme59.incl [C_INFO] 1 FALSE [IF] (not @_$9_@) [SET] P1 = toto [SET] P2 = $2 | deux [ELSE] [SET] P1 = "this is P1" [SET] P2 = "this is P2" [END_IF] [TEXT] [SET] P3 = $3 | "trois et trois" [SET] P4 = $4 | quatre [SET] P5 = $5 | cinq [SET] P6 = $6 | six [SET] P7 = $7 | sept [SET] P8 = $8 | huit [SET] P9 = $9 | neuf [SET] ALIAS = $2 [SET] CST = toujours [TEXT] [TEXT] 1) @_$1_@, @_P1_@, @_UPPER:P1_@ [TEXT] 2) @_$2_@, @_P2_@, @_ALIAS_@ [TEXT] 3) @_$3_@, @_P3_@ [TEXT] 4) @_$4_@, @_P4_@ [TEXT] 5) @_$5_@, @_P5_@ [TEXT] 6) @_$6_@, @_P6_@ [TEXT] 7) @_$7_@, @_P7_@ [TEXT] 8) @_$8_@, @_P8_@ [TEXT] 9) @_$9_@, @_P9_@, @_CAPITALIZE:P9_@ [TEXT] @_CST_@ [TEXT] ********************************************************** [INCLUDE] testme59.incl $0 = testme59.incl $1 = one $2 = two $6 = six [INFO] testme59.incl [C_INFO] 1 FALSE [IF] (not @_$9_@) [SET] P1 = toto [SET] P2 = $2 | deux [ELSE] [SET] P1 = "this is P1" [SET] P2 = "this is P2" [END_IF] [TEXT] [SET] P3 = $3 | "trois et trois" [SET] P4 = $4 | quatre [SET] P5 = $5 | cinq [SET] P6 = $6 | six [SET] P7 = $7 | sept [SET] P8 = $8 | huit [SET] P9 = $9 | neuf [SET] ALIAS = $2 [SET] CST = toujours [TEXT] [TEXT] 1) @_$1_@, @_P1_@, @_UPPER:P1_@ [TEXT] 2) @_$2_@, @_P2_@, @_ALIAS_@ [TEXT] 3) @_$3_@, @_P3_@ [TEXT] 4) @_$4_@, @_P4_@ [TEXT] 5) @_$5_@, @_P5_@ [TEXT] 6) @_$6_@, @_P6_@ [TEXT] 7) @_$7_@, @_P7_@ [TEXT] 8) @_$8_@, @_P8_@ [TEXT] 9) @_$9_@, @_P9_@, @_CAPITALIZE:P9_@ [TEXT] @_CST_@ [TEXT] ********************************************************** [INCLUDE] testme59.incl $0 = testme59.incl $2 = two $6 = six $8 = eight [INFO] testme59.incl [C_INFO] 1 FALSE [IF] (not @_$9_@) [SET] P1 = toto [SET] P2 = $2 | deux [ELSE] [SET] P1 = "this is P1" [SET] P2 = "this is P2" [END_IF] [TEXT] [SET] P3 = $3 | "trois et trois" [SET] P4 = $4 | quatre [SET] P5 = $5 | cinq [SET] P6 = $6 | six [SET] P7 = $7 | sept [SET] P8 = $8 | huit [SET] P9 = $9 | neuf [SET] ALIAS = $2 [SET] CST = toujours [TEXT] [TEXT] 1) @_$1_@, @_P1_@, @_UPPER:P1_@ [TEXT] 2) @_$2_@, @_P2_@, @_ALIAS_@ [TEXT] 3) @_$3_@, @_P3_@ [TEXT] 4) @_$4_@, @_P4_@ [TEXT] 5) @_$5_@, @_P5_@ [TEXT] 6) @_$6_@, @_P6_@ [TEXT] 7) @_$7_@, @_P7_@ [TEXT] 8) @_$8_@, @_P8_@ [TEXT] 9) @_$9_@, @_P9_@, @_CAPITALIZE:P9_@ [TEXT] @_CST_@ [TEXT] ********************************************************** [INCLUDE] testme59.incl $0 = testme59.incl $2 = two $6 = six $8 = eight $9 = true [INFO] testme59.incl [C_INFO] 1 FALSE [IF] (not @_$9_@) [SET] P1 = toto [SET] P2 = $2 | deux [ELSE] [SET] P1 = "this is P1" [SET] P2 = "this is P2" [END_IF] [TEXT] [SET] P3 = $3 | "trois et trois" [SET] P4 = $4 | quatre [SET] P5 = $5 | cinq [SET] P6 = $6 | six [SET] P7 = $7 | sept [SET] P8 = $8 | huit [SET] P9 = $9 | neuf [SET] ALIAS = $2 [SET] CST = toujours [TEXT] [TEXT] 1) @_$1_@, @_P1_@, @_UPPER:P1_@ [TEXT] 2) @_$2_@, @_P2_@, @_ALIAS_@ [TEXT] 3) @_$3_@, @_P3_@ [TEXT] 4) @_$4_@, @_P4_@ [TEXT] 5) @_$5_@, @_P5_@ [TEXT] 6) @_$6_@, @_P6_@ [TEXT] 7) @_$7_@, @_P7_@ [TEXT] 8) @_$8_@, @_P8_@ [TEXT] 9) @_$9_@, @_P9_@, @_CAPITALIZE:P9_@ [TEXT] @_CST_@ [TEXT] ********************************************************** libtemplates-parser-11.6.orig/regtests/tests/0023_testme/test.py0000644000175000017500000000014411637170656024532 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme59.tmplt"]) run('print_tree', ["testme59.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0023_testme/testme59.incl0000755000175000017500000000107711637170656025540 0ustar lbrentalbrenta@@IF@@ not @_$9_@ @@SET@@ P1 = toto @@SET@@ P2 = $2 | deux @@ELSE@@ @@SET@@ P1 = "this is P1" @@SET@@ P2 = "this is P2" @@END_IF@@ @@SET@@ P3 = $3 | "trois et trois" @@SET@@ P4 = $4 | quatre @@SET@@ P5 = $5 | cinq @@SET@@ P6 = $6 | six @@SET@@ P7 = $7 | sept @@SET@@ P8 = $8 | huit @@SET@@ P9 = $9 | neuf @@SET@@ ALIAS = $2 @@SET@@ CST = toujours 1) @_$1_@, @_P1_@, @_UPPER:P1_@ 2) @_$2_@, @_P2_@, @_ALIAS_@ 3) @_$3_@, @_P3_@ 4) @_$4_@, @_P4_@ 5) @_$5_@, @_P5_@ 6) @_$6_@, @_P6_@ 7) @_$7_@, @_P7_@ 8) @_$8_@, @_P8_@ 9) @_$9_@, @_P9_@, @_CAPITALIZE:P9_@ @_CST_@ libtemplates-parser-11.6.orig/regtests/tests/0023_testme/testme59.tmplt0000755000175000017500000000104611637170656025747 0ustar lbrentalbrenta Test for include with parameters with default values ********************************************************** @@INCLUDE@@ testme59.incl one two ********************************************************** @@INCLUDE@@ testme59.incl (1=>one, 2=>two, 6=>six) ********************************************************** @@INCLUDE@@ testme59.incl (2=>two, 6=>six, 8=>eight) ********************************************************** @@INCLUDE@@ testme59.incl (2=>two, 6=>six, 8=>eight, 9=>true) ********************************************************** libtemplates-parser-11.6.orig/regtests/tests/0024_testme/0000755000175000017500000000000011637170657023204 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0024_testme/test.out0000644000175000017500000000260111637170656024712 0ustar lbrentalbrenta -- Inline and IF word1 word2.2 word3 word1 word2.2 word3 word1 word2.1 word3 word1 , word2.1 , word3 xyz -- Inline and TABLE one two three _one_:_two_:_three_ _one_(:)_two_(:)_three_(:)xx aa|_one_|_two_|_three_|xx|zz abc [INFO] testme64.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] -- Inline and IF [TEXT] [TEXT] word1 [IF] @_COND1_@ [TEXT] word2.1 [ELSE] [TEXT] word2.2 [END_IF] [TEXT] word3 [TEXT] [INLINE] ( ) [TEXT] word1 [IF] @_COND1_@ [TEXT] word2.1 [ELSE] [TEXT] word2.2 [END_IF] [TEXT] word3 [END_INLINE] [TEXT] [TEXT] word1 [IF] @_COND2_@ [TEXT] word2.1 [ELSE] [TEXT] word2.2 [END_IF] [TEXT] word3 [TEXT] [INLINE] ( , ) [TEXT] word1 , [IF] @_COND2_@ [TEXT] word2.1 , [ELSE] [TEXT] word2.2 , [END_IF] [TEXT] word3 [END_INLINE] [TEXT] [TEXT] xyz [TEXT] [TEXT] -- Inline and TABLE [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_VAR3_@ [END_BLOCK] [END_TABLE] [TEXT] [INLINE] (:) [TABLE] [BLOCK] [COMMON] [TEXT] _@_VAR3_@_ [END_BLOCK] [END_TABLE] [END_INLINE] [TEXT] [INLINE] ((:)) [TABLE] [BLOCK] [COMMON] [TEXT] _@_VAR3_@_ [END_BLOCK] [END_TABLE] [TEXT] xx [END_INLINE] [TEXT] [INLINE] (|) [TEXT] aa| [TABLE] [BLOCK] [COMMON] [TEXT] _@_VAR3_@_ [END_BLOCK] [END_TABLE] [TEXT] xx| [TEXT] zz [END_INLINE] [TEXT] [TEXT] abc libtemplates-parser-11.6.orig/regtests/tests/0024_testme/test.py0000644000175000017500000000014411637170656024533 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme64.tmplt"]) run('print_tree', ["testme64.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0024_testme/testme64.tmplt0000755000175000017500000000122011637170656025736 0ustar lbrentalbrenta -- Inline and IF word1 @@IF@@ @_COND1_@ word2.1 @@ELSE@@ word2.2 @@END_IF@@ word3 @@INLINE@@ word1 @@IF@@ @_COND1_@ word2.1 @@ELSE@@ word2.2 @@END_IF@@ word3 @@END_INLINE@@ word1 @@IF@@ @_COND2_@ word2.1 @@ELSE@@ word2.2 @@END_IF@@ word3 @@INLINE( , )@@ word1 @@IF@@ @_COND2_@ word2.1 @@ELSE@@ word2.2 @@END_IF@@ word3 @@END_INLINE@@ xyz -- Inline and TABLE @@TABLE@@ @_VAR3_@ @@END_TABLE@@ @@INLINE(:)@@ @@TABLE@@ _@_VAR3_@_ @@END_TABLE@@ @@END_INLINE@@ @@INLINE((:))@@ @@TABLE@@ _@_VAR3_@_ @@END_TABLE@@ xx @@END_INLINE@@ @@INLINE(|)@@ aa @@TABLE@@ _@_VAR3_@_ @@END_TABLE@@ xx zz @@END_INLINE@@ abc libtemplates-parser-11.6.orig/regtests/tests/0025_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0025_testme/test.out0000644000175000017500000000263711637170656024724 0ustar lbrentalbrenta ONE in INV : OK SONE in INV : OK ONE in V5 : OK STWO in V5 : OK STWO in V6 : OK VALUE in MAT : OK A3.3 in MAT : OK NOWHERE in MAT : OK ZZ not found A3.4 not found A4.2 found again! not found A2.2 found ! not found [INFO] testme78.tmplt [C_INFO] 1 FALSE [TEXT] [SET] VALUE = A4.2 [SET] NOWHERE = XxX [SET] SONE = 1 [SET] STWO = two [TEXT] [IF] (@_ONE_@ in @_INV_@) [TEXT] ONE in INV : OK [ELSE] [TEXT] ONE in INV : NOK [END_IF] [TEXT] [IF] (@_SONE_@ in @_INV_@) [TEXT] SONE in INV : OK [ELSE] [TEXT] SONE in INV : NOK [END_IF] [TEXT] [IF] (@_ONE_@ in @_V5_@) [TEXT] ONE in V5 : NOK [ELSE] [TEXT] ONE in V5 : OK [END_IF] [TEXT] [IF] (@_STWO_@ in @_V5_@) [TEXT] STWO in V5 : OK [ELSE] [TEXT] STWO in V5 : NOK [END_IF] [TEXT] [IF] (@_STWO_@ in @_V6_@) [TEXT] STWO in V6 : NOK [ELSE] [TEXT] STWO in V6 : OK [END_IF] [TEXT] [IF] (@_VALUE_@ in @_MAT_@) [TEXT] VALUE in MAT : OK [ELSE] [TEXT] VALUE in MAT : NOK [END_IF] [TEXT] [IF] (A3.3 in @_MAT_@) [TEXT] A3.3 in MAT : OK [ELSE] [TEXT] A3.3 in MAT : NOK [END_IF] [TEXT] [IF] (@_NOWHERE_@ in @_MAT_@) [TEXT] NOWHERE in MAT : NOK [ELSE] [TEXT] NOWHERE in MAT : OK [END_IF] [TEXT] [TABLE] [BLOCK] [COMMON] [IF] (@_VAR7_@ in @_MAT_@) [TEXT] @_VAR7_@ found [ELSE] [TEXT] @_VAR7_@ not found [END_IF] [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0025_testme/test.py0000644000175000017500000000014411637170656024534 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme78.tmplt"]) run('print_tree', ["testme78.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0025_testme/testme78.tmplt0000644000175000017500000000160311637170656025746 0ustar lbrentalbrenta @@SET@@ VALUE = "A4.2" @@SET@@ NOWHERE = "XxX" @@SET@@ SONE = "1" @@SET@@ STWO = "two" @@IF@@ @_ONE_@ in @_INV_@ ONE in INV : OK @@ELSE@@ ONE in INV : NOK @@END_IF@@ @@IF@@ @_SONE_@ in @_INV_@ SONE in INV : OK @@ELSE@@ SONE in INV : NOK @@END_IF@@ @@IF@@ @_ONE_@ in @_V5_@ ONE in V5 : NOK @@ELSE@@ ONE in V5 : OK @@END_IF@@ @@IF@@ @_STWO_@ in @_V5_@ STWO in V5 : OK @@ELSE@@ STWO in V5 : NOK @@END_IF@@ @@IF@@ @_STWO_@ in @_V6_@ STWO in V6 : NOK @@ELSE@@ STWO in V6 : OK @@END_IF@@ @@IF@@ @_VALUE_@ in @_MAT_@ VALUE in MAT : OK @@ELSE@@ VALUE in MAT : NOK @@END_IF@@ @@IF@@ "A3.3" in @_MAT_@ A3.3 in MAT : OK @@ELSE@@ A3.3 in MAT : NOK @@END_IF@@ @@IF@@ @_NOWHERE_@ in @_MAT_@ NOWHERE in MAT : NOK @@ELSE@@ NOWHERE in MAT : OK @@END_IF@@ @@TABLE@@ @@IF@@ @_VAR7_@ in @_MAT_@ @_VAR7_@ found @@ELSE@@ @_VAR7_@ not found @@END_IF@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0026_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0026_testme/test.out0000644000175000017500000000366511637170656024727 0ustar lbrentalbrenta 0 --------------------------- 1> one 2> two 3> three 1> (one) 2> (two) 3> 1 --------------------------- 1> one 2> two 3> three 1> (one) 2> (two) 2 --------------------------- 1> one 2> two 3> three 1> (one) 2> (two) 3 --------------------------- 3> three 2> two 1> one 2> (two) 1> (one) 4 --------------------------- 2> a value (two) 1> a value (one) 3> a value three 2> a value two 1> a value one [INFO] testme80.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] 0 --------------------------- [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [TEXT] @_TABLE_LINE_@> @_MATDSIZE_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] 1 --------------------------- [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] [BLOCK] [COMMON] [IF] (@_MATDSIZE_@ /= "") [TEXT] @_TABLE_LINE_@> @_MATDSIZE_@ [END_IF] [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] 2 --------------------------- [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] TERSE [BLOCK] [COMMON] [TEXT] @_TABLE_LINE_@> @_MATDSIZE_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] 3 --------------------------- [TEXT] [TABLE] [BLOCK] [COMMON] [TABLE] REVERSE TERSE [BLOCK] [COMMON] [TEXT] @_TABLE_LINE_@> @_MATDSIZE_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] [TEXT] [TEXT] 4 --------------------------- [TEXT] [TABLE] REVERSE [BLOCK] [COMMON] [TABLE] REVERSE TERSE [BLOCK] [COMMON] [TEXT] @_TABLE_LINE_@> @_VAR1_@ @_MATDSIZE_@ [END_BLOCK] [END_TABLE] [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0026_testme/test.py0000644000175000017500000000014411637170656024535 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme80.tmplt"]) run('print_tree', ["testme80.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0026_testme/testme80.tmplt0000644000175000017500000000126311637170656025742 0ustar lbrentalbrenta 0 --------------------------- @@TABLE@@ @@TABLE@@ @_TABLE_LINE_@> @_MATDSIZE_@ @@END_TABLE@@ @@END_TABLE@@ 1 --------------------------- @@TABLE@@ @@TABLE@@ @@IF@@ @_MATDSIZE_@ /= "" @_TABLE_LINE_@> @_MATDSIZE_@ @@END_IF@@ @@END_TABLE@@ @@END_TABLE@@ 2 --------------------------- @@TABLE@@ @@TABLE'TERSE@@ @_TABLE_LINE_@> @_MATDSIZE_@ @@END_TABLE@@ @@END_TABLE@@ 3 --------------------------- @@TABLE@@ @@TABLE'TERSE'REVERSE@@ @_TABLE_LINE_@> @_MATDSIZE_@ @@END_TABLE@@ @@END_TABLE@@ 4 --------------------------- @@TABLE'REVERSE@@ @@TABLE'TERSE'REVERSE@@ @_TABLE_LINE_@> @_VAR1_@ @_MATDSIZE_@ @@END_TABLE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0027_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0027_testme/test.out0000755000175000017500000000015711637170656024724 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : @@END_TABLE@@ found, @@END_IF@@ expected, in testme4.tmplt at line 4 libtemplates-parser-11.6.orig/regtests/tests/0027_testme/test.py0000644000175000017500000000007511637170656024541 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme4.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0027_testme/testme4.tmplt0000755000175000017500000000005311637170656025656 0ustar lbrentalbrenta@@IF@@ TRUE toto titi @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0028_testme/0000755000175000017500000000000011637170657023210 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0028_testme/test.out0000755000175000017500000000015111637170656024717 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : EOF found, @@END_TABLE@@ expected, in testme12.tmplt at line 3 libtemplates-parser-11.6.orig/regtests/tests/0028_testme/test.py0000644000175000017500000000007611637170656024543 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme12.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0028_testme/testme12.tmplt0000755000175000017500000000007111637170656025736 0ustar lbrentalbrenta@@TABLE@@ @@-- this is a table ddd @@END_TABLE_@ libtemplates-parser-11.6.orig/regtests/tests/0029_testme/0000755000175000017500000000000011637170657023211 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0029_testme/test.out0000755000175000017500000000014611637170656024724 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : EOF found, @@END_IF@@ expected, in testme13.tmplt at line 3 libtemplates-parser-11.6.orig/regtests/tests/0029_testme/test.py0000644000175000017500000000007611637170656024544 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme13.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0029_testme/testme13.tmplt0000755000175000017500000000003211637170656025735 0ustar lbrentalbrenta@@IF@@ kkk jjj @@END_IF_@ libtemplates-parser-11.6.orig/regtests/tests/0030_testme/0000755000175000017500000000000011637170657023201 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0030_testme/test.out0000755000175000017500000000013111637170656024706 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : missing parameter, in testme14.tmplt at line 2 libtemplates-parser-11.6.orig/regtests/tests/0030_testme/test.py0000644000175000017500000000007611637170656024534 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme14.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0030_testme/testme14.tmplt0000755000175000017500000000002711637170656025732 0ustar lbrentalbrenta @@IF@@ jjj @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0031_testme/0000755000175000017500000000000011637170657023202 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0031_testme/test.out0000755000175000017500000000020411637170656024710 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : This attribute is not valid for a matrix tag (@_MAT'Length_@) In testme19.tmplt at line 1 libtemplates-parser-11.6.orig/regtests/tests/0031_testme/test.py0000644000175000017500000000007611637170656024535 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme19.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0031_testme/testme19.tmplt0000755000175000017500000000001711637170656025737 0ustar lbrentalbrenta@_MAT'Length_@ libtemplates-parser-11.6.orig/regtests/tests/0032_testme/0000755000175000017500000000000011637170657023203 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0032_testme/test.out0000755000175000017500000000020111637170656024706 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : This attribute is not valid for a vector tag (@_V6'Line_@) In testme20.tmplt at line 2 libtemplates-parser-11.6.orig/regtests/tests/0032_testme/test.py0000644000175000017500000000007611637170656024536 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme20.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0032_testme/testme20.tmplt0000755000175000017500000000001511637170656025726 0ustar lbrentalbrenta @_V6'Line_@ libtemplates-parser-11.6.orig/regtests/tests/0033_testme/0000755000175000017500000000000011637170657023204 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0033_testme/test.out0000755000175000017500000000020711637170656024715 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : This attribute is not valid for a vector tag (@_V6'Min_Column_@) In testme21.tmplt at line 4 libtemplates-parser-11.6.orig/regtests/tests/0033_testme/test.py0000644000175000017500000000007611637170656024537 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme21.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0033_testme/testme21.tmplt0000755000175000017500000000002511637170656025731 0ustar lbrentalbrenta @_V6'Min_Column_@ libtemplates-parser-11.6.orig/regtests/tests/0034_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0034_testme/test.out0000755000175000017500000000020711637170656024716 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : This attribute is not valid for a vector tag (@_V6'Max_Column_@) In testme22.tmplt at line 2 libtemplates-parser-11.6.orig/regtests/tests/0034_testme/test.py0000644000175000017500000000007611637170656024540 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme22.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0034_testme/testme22.tmplt0000755000175000017500000000002311637170656025731 0ustar lbrentalbrenta @_V6'Max_Column_@ libtemplates-parser-11.6.orig/regtests/tests/0035_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0035_testme/test.out0000755000175000017500000000011011637170656024710 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : Unknown attribute name "toto" libtemplates-parser-11.6.orig/regtests/tests/0035_testme/test.py0000644000175000017500000000007611637170656024541 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme23.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0035_testme/testme23.tmplt0000755000175000017500000000001411637170656025733 0ustar lbrentalbrenta @_M'Toto_@ libtemplates-parser-11.6.orig/regtests/tests/0036_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0036_testme/test.out0000755000175000017500000006244511637170656024734 0ustar lbrentalbrenta 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 libtemplates-parser-11.6.orig/regtests/tests/0036_testme/test.py0000644000175000017500000000007611637170656024542 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme28.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0036_testme/testme28.tmplt0000644000175000017500000006244511637170656025756 0ustar lbrentalbrenta 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 libtemplates-parser-11.6.orig/regtests/tests/0037_testme/0000755000175000017500000000000011637170657023210 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0037_testme/test.out0000755000175000017500000000020511637170656024717 0ustar lbrentalbrenta Test MATCH() routine. TRUE = TRUE TRUE = TRUE TRUE = TRUE TRUE = TRUE TRUE = TRUE TRUE = TRUE FALSE = FALSE FALSE = FALSE libtemplates-parser-11.6.orig/regtests/tests/0037_testme/test.py0000644000175000017500000000007611637170656024543 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme29.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0037_testme/testme29.tmplt0000755000175000017500000000051311637170656025747 0ustar lbrentalbrenta Test MATCH() routine. TRUE = @_MATCH(.*words.*):FILTER_@ TRUE = @_MATCH(".*words.*"):FILTER_@ TRUE = @_MATCH(.* words.*):FILTER_@ TRUE = @_MATCH(".* words.*"):FILTER_@ TRUE = @_MATCH( a.*):FILTER_@ TRUE = @_MATCH(" a.*"):FILTER_@ FALSE = @_MATCH(.* words.*):FILTER_@ FALSE = @_MATCH(".* words.*"):FILTER_@ libtemplates-parser-11.6.orig/regtests/tests/0038_testme/0000755000175000017500000000000011637170657023211 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0038_testme/test.out0000644000175000017500000000007611637170656024723 0ustar lbrentalbrenta Test for the vector tag prepend 3, 2, 1 In a table: 3 2 1 libtemplates-parser-11.6.orig/regtests/tests/0038_testme/test.py0000644000175000017500000000007611637170656024544 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme33.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0038_testme/testme33.tmplt0000755000175000017500000000012711637170656025744 0ustar lbrentalbrenta Test for the vector tag prepend @_INV_@ In a table: @@TABLE@@ @_INV_@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0039_testme/0000755000175000017500000000000011637170657023212 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0039_testme/test.out0000644000175000017500000000023511637170656024721 0ustar lbrentalbrenta Try negative numbers: 1) -3 2) -3 Try filters with tag arguments: Plus : 6 Minus : -4 Multiply : 6 Divide : 1 Replace : [_ a text with < _] libtemplates-parser-11.6.orig/regtests/tests/0039_testme/test.py0000644000175000017500000000007611637170656024545 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme34.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0039_testme/testme34.tmplt0000755000175000017500000000045211637170656025747 0ustar lbrentalbrenta Try negative numbers: 1) @_"-"(4):ONE_@ 2) @_"+"(-4):ONE_@ Try filters with tag arguments: Plus : @_"+"(THREE):"+"(TWO):ONE_@ Minus : @_"-"(THREE):"-"(TWO):ONE_@ Multiply : @_"*"(THREE):"*"(TWO):ONE_@ Divide : @_"/"(TWO):"-"(ONE):THREE_@ Replace : @_REPLACE(([^6]*).*/REPL):FILTER_@ libtemplates-parser-11.6.orig/regtests/tests/0040_testme/0000755000175000017500000000000011637170657023202 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0040_testme/test.out0000755000175000017500000000012011637170656024705 0ustar lbrentalbrenta Some dates formatted: 1967-09-09 2003-12-12 Friday December 12 2003, 13:34:12 libtemplates-parser-11.6.orig/regtests/tests/0040_testme/test.py0000644000175000017500000000007611637170656024535 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme35.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0040_testme/testme35.tmplt0000755000175000017500000000017711637170656025744 0ustar lbrentalbrenta Some dates formatted: @_FORMAT_DATE(%Y-%m-%d):DATE1_@ @_FORMAT_DATE(%Y-%m-%d):DATE2_@ @_FORMAT_DATE(%A %B %d %Y, %T):DATE2_@ libtemplates-parser-11.6.orig/regtests/tests/0041_testme/0000755000175000017500000000000011637170657023203 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0041_testme/test.out0000755000175000017500000000663411637170656024726 0ustar lbrentalbrenta Add "toto=titi" http://host:port/ => http://host:port/?toto=titi http://host/ => http://host/?toto=titi http://host/? => http://host/?toto=titi http://host/?param1=un => http://host/?param1=un&toto=titi http://host:port/?param1=un¶m2=deux => http://host:port/?param1=un¶m2=deux&toto=titi http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux¶m3=trois&toto=titi Del "param1" http://host:port/ => http://host:port/ http://host/ => http://host/ http://host/? => http://host/? http://host/?param1=un => http://host/ http://host:port/?param1=un¶m2=deux => http://host:port/?param2=deux http://host?param1=un¶m2=deux¶m3=trois => http://host?param2=deux¶m3=trois Del "param2" http://host:port/ => http://host:port/ http://host/ => http://host/ http://host/? => http://host/? http://host/?param1=un => http://host/?param1=un http://host:port/?param1=un¶m2=deux => http://host:port/?param1=un http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m3=trois Del "param3" http://host:port/ => http://host:port/ http://host/ => http://host/ http://host/? => http://host/? http://host/?param1=un => http://host/?param1=un http://host:port/?param1=un¶m2=deux => http://host:port/?param1=un¶m2=deux http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux Replace "param1" http://host:port/ => http://host:port/?param1=one http://host/ => http://host/?param1=one http://host/? => http://host/?param1=one http://host/?param1=un => http://host/?param1=one http://host:port/?param1=un¶m2=deux => http://host:port/?param2=deux¶m1=one http://host?param1=un¶m2=deux¶m3=trois => http://host?param2=deux¶m3=trois¶m1=one Replace "param2" http://host:port/ => http://host:port/?param2=two http://host/ => http://host/?param2=two http://host/? => http://host/?param2=two http://host/?param1=un => http://host/?param1=un¶m2=two http://host:port/?param1=un¶m2=deux => http://host:port/?param1=un¶m2=two http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m3=trois¶m2=two Replace "param3" http://host:port/ => http://host:port/?param3=3 http://host/ => http://host/?param3=3 http://host/? => http://host/?param3=3 http://host/?param1=un => http://host/?param1=un¶m3=3 http://host:port/?param1=un¶m2=deux => http://host:port/?param1=un¶m2=deux¶m3=3 http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux¶m3=3 Replace "param3" http://host:port/ => http://host:port/?param3=3 http://host/ => http://host/?param3=3 http://host/? => http://host/?param3=3 http://host/?param1=un => http://host/?param1=un¶m3=3 http://host:port/?param1=un¶m2=deux => http://host:port/?param1=un¶m2=deux¶m3=3 http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux¶m3=3 Delete param not existing http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux¶m3=trois http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux¶m3=trois Add using a tag http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux¶m3=trois¶m3=123.9 Replace using a tag http://host?param1=un¶m2=deux¶m3=trois => http://host?param1=un¶m2=deux¶m3=123.9 libtemplates-parser-11.6.orig/regtests/tests/0041_testme/test.py0000644000175000017500000000007611637170656024536 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme36.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0041_testme/testme36.tmplt0000755000175000017500000000534411637170656025747 0ustar lbrentalbrenta Add "toto=titi" @_URL1_@ => @_ADD_PARAM(toto=titi):URL1_@ @_URL2_@ => @_ADD_PARAM(toto=titi):URL2_@ @_URL3_@ => @_ADD_PARAM(toto=titi):URL3_@ @_URL4_@ => @_ADD_PARAM(toto=titi):URL4_@ @_URL5_@ => @_ADD_PARAM(toto=titi):URL5_@ @_URL6_@ => @_ADD_PARAM(toto=titi):URL6_@ Del "param1" @_URL1_@ => @_DEL_PARAM(param1):URL1_@ @_URL2_@ => @_DEL_PARAM(param1):URL2_@ @_URL3_@ => @_DEL_PARAM(param1):URL3_@ @_URL4_@ => @_DEL_PARAM(param1):URL4_@ @_URL5_@ => @_DEL_PARAM(param1):URL5_@ @_URL6_@ => @_DEL_PARAM(param1):URL6_@ Del "param2" @_URL1_@ => @_DEL_PARAM(param2):URL1_@ @_URL2_@ => @_DEL_PARAM(param2):URL2_@ @_URL3_@ => @_DEL_PARAM(param2):URL3_@ @_URL4_@ => @_DEL_PARAM(param2):URL4_@ @_URL5_@ => @_DEL_PARAM(param2):URL5_@ @_URL6_@ => @_DEL_PARAM(param2):URL6_@ Del "param3" @_URL1_@ => @_DEL_PARAM(param3):URL1_@ @_URL2_@ => @_DEL_PARAM(param3):URL2_@ @_URL3_@ => @_DEL_PARAM(param3):URL3_@ @_URL4_@ => @_DEL_PARAM(param3):URL4_@ @_URL5_@ => @_DEL_PARAM(param3):URL5_@ @_URL6_@ => @_DEL_PARAM(param3):URL6_@ Replace "param1" @_URL1_@ => @_ADD_PARAM(param1=one):DEL_PARAM(param1):URL1_@ @_URL2_@ => @_ADD_PARAM(param1=one):DEL_PARAM(param1):URL2_@ @_URL3_@ => @_ADD_PARAM(param1=one):DEL_PARAM(param1):URL3_@ @_URL4_@ => @_ADD_PARAM(param1=one):DEL_PARAM(param1):URL4_@ @_URL5_@ => @_ADD_PARAM(param1=one):DEL_PARAM(param1):URL5_@ @_URL6_@ => @_ADD_PARAM(param1=one):DEL_PARAM(param1):URL6_@ Replace "param2" @_URL1_@ => @_ADD_PARAM(param2=two):DEL_PARAM(param2):URL1_@ @_URL2_@ => @_ADD_PARAM(param2=two):DEL_PARAM(param2):URL2_@ @_URL3_@ => @_ADD_PARAM(param2=two):DEL_PARAM(param2):URL3_@ @_URL4_@ => @_ADD_PARAM(param2=two):DEL_PARAM(param2):URL4_@ @_URL5_@ => @_ADD_PARAM(param2=two):DEL_PARAM(param2):URL5_@ @_URL6_@ => @_ADD_PARAM(param2=two):DEL_PARAM(param2):URL6_@ Replace "param3" @_URL1_@ => @_ADD_PARAM(param3=3):DEL_PARAM(param3):URL1_@ @_URL2_@ => @_ADD_PARAM(param3=3):DEL_PARAM(param3):URL2_@ @_URL3_@ => @_ADD_PARAM(param3=3):DEL_PARAM(param3):URL3_@ @_URL4_@ => @_ADD_PARAM(param3=3):DEL_PARAM(param3):URL4_@ @_URL5_@ => @_ADD_PARAM(param3=3):DEL_PARAM(param3):URL5_@ @_URL6_@ => @_ADD_PARAM(param3=3):DEL_PARAM(param3):URL6_@ Replace "param3" @_URL1_@ => @_REPLACE_PARAM(param3=3):URL1_@ @_URL2_@ => @_REPLACE_PARAM(param3=3):URL2_@ @_URL3_@ => @_REPLACE_PARAM(param3=3):URL3_@ @_URL4_@ => @_REPLACE_PARAM(param3=3):URL4_@ @_URL5_@ => @_REPLACE_PARAM(param3=3):URL5_@ @_URL6_@ => @_REPLACE_PARAM(param3=3):URL6_@ Delete param not existing @_URL6_@ => @_DEL_PARAM(param):URL6_@ @_URL6_@ => @_DEL_PARAM(toto):URL6_@ Add using a tag @_URL6_@ => @_ADD_PARAM(param3=NUM3):URL6_@ Replace using a tag @_URL6_@ => @_REPLACE_PARAM(param3=NUM3):URL6_@ libtemplates-parser-11.6.orig/regtests/tests/0042_testme/0000755000175000017500000000000011637170657023204 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0042_testme/test.out0000755000175000017500000000005311637170656024714 0ustar lbrentalbrenta >1 test ok test <1 >2 ok <2 >3 ok ok <3 libtemplates-parser-11.6.orig/regtests/tests/0042_testme/test.py0000644000175000017500000000007611637170656024537 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme37.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0042_testme/testme37.tmplt0000755000175000017500000000032211637170656025740 0ustar lbrentalbrenta >1 @@TABLE@@ @@IF@@ @_V5_@ = two ok @@ELSE@@ test @@END_IF@@ @@END_TABLE@@ <1 >2 @@TABLE@@ @@IF@@ @_V5_@ = two ok @@END_IF@@ @@END_TABLE@@ <2 >3 @@TABLE@@ @@IF@@ @_V5_@ /= two ok @@END_IF@@ @@END_TABLE@@ <3 libtemplates-parser-11.6.orig/regtests/tests/0043_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0043_testme/test.out0000755000175000017500000000241211637170656024716 0ustar lbrentalbrenta *** Nested 3 level outside TABLE A1.1, A1.2, A1.3 A2.1, A2.2, A2.3 A3.1, A3.2, A3.3 A4.1, A4.2, A4.3 B1.1, B1.2, B1.3 B2.1, B2.2, B2.3 B3.1, B3.2, B3.3 B4.1, B4.2, B4.3 *** Nested 3 level into TABLE level 1 0, 1 A1.1, A1.2, A1.3 A2.1, A2.2, A2.3 A3.1, A3.2, A3.3 A4.1, A4.2, A4.3 0, 2 B1.1, B1.2, B1.3 B2.1, B2.2, B2.3 B3.1, B3.2, B3.3 B4.1, B4.2, B4.3 *** Nested 3 level into TABLE level 2 [ 1 1, 1 A1.1, A1.2, A1.3 1, 2 A2.1, A2.2, A2.3 1, 3 A3.1, A3.2, A3.3 1, 4 A4.1, A4.2, A4.3 ] [ 2 2, 1 B1.1, B1.2, B1.3 2, 2 B2.1, B2.2, B2.3 2, 3 B3.1, B3.2, B3.3 2, 4 B4.1, B4.2, B4.3 ] *** Nested 3 level into TABLE level 3 < [ 1, 1 A1.1 1, 2 A1.2 1, 3 A1.3 ] [ 2, 1 A2.1 2, 2 A2.2 2, 3 A2.3 ] [ 3, 1 A3.1 3, 2 A3.2 3, 3 A3.3 ] [ 4, 1 A4.1 4, 2 A4.2 4, 3 A4.3 ] > < [ 1, 1 B1.1 1, 2 B1.2 1, 3 B1.3 ] [ 2, 1 B2.1 2, 2 B2.2 2, 3 B2.3 ] [ 3, 1 B3.1 3, 2 B3.2 3, 3 B3.3 ] [ 4, 1 B4.1 4, 2 B4.2 4, 3 B4.3 ] > libtemplates-parser-11.6.orig/regtests/tests/0043_testme/test.py0000644000175000017500000000007611637170656024540 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme39.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0043_testme/testme39.tmplt0000644000175000017500000000077011637170656025747 0ustar lbrentalbrenta *** Nested 3 level outside TABLE @_NESTED_3_@ *** Nested 3 level into TABLE level 1 @@TABLE@@ @_UP_TABLE_LINE_@, @_TABLE_LINE_@ @_NESTED_3_@ @@END_TABLE@@ *** Nested 3 level into TABLE level 2 @@TABLE@@ [ @_TABLE_LINE_@ @@TABLE@@ @_UP_TABLE_LINE_@, @_TABLE_LINE_@ @_NESTED_3_@ @@END_TABLE@@ ] @@END_TABLE@@ *** Nested 3 level into TABLE level 3 @@TABLE@@ < @@TABLE@@ [ @@TABLE@@ @_UP_TABLE_LINE_@, @_TABLE_LINE_@ @_NESTED_3_@ @@END_TABLE@@ ] @@END_TABLE@@ > @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0044_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0044_testme/include2.tmplt0000755000175000017500000000025011637170656025774 0ustar lbrentalbrenta @@-- Include file @_$0_@ 1> @_$1_@ 2> @_$2'Length_@ 3> @_$3'Line_@ 4> @_$3'Min_Column_@ 5> @_$3'Max_Column_@ @@IF@@ @_$2'Length_@ > 1 ok @@ELSE@@ nok @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0044_testme/test.out0000644000175000017500000000006211637170656024713 0ustar lbrentalbrenta include2.tmplt 1> 2> two 3> 4> 5> ok libtemplates-parser-11.6.orig/regtests/tests/0044_testme/test.py0000644000175000017500000000007611637170656024541 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme40.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0044_testme/testme40.tmplt0000755000175000017500000000004511637170656025736 0ustar lbrentalbrenta @@INCLUDE@@ include2.tmplt "" "two" libtemplates-parser-11.6.orig/regtests/tests/0045_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0045_testme/test.out0000755000175000017500000000012311637170656024715 0ustar lbrentalbrenta a value 0 0 0 0 0 0 This is a dynamic tag Dynamic vector: 12 89 90 2 libtemplates-parser-11.6.orig/regtests/tests/0045_testme/test.py0000644000175000017500000000007611637170656024542 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme41.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0045_testme/testme41.tmplt0000755000175000017500000000017211637170656025741 0ustar lbrentalbrenta @_VAR1_@ @_N_@ @_N_@ @_N_@ @_N_@ @_N_@ @_N_@ @_DYNAMIC_@ @_X_@ Dynamic vector: @@TABLE@@ @_DYN_VECT_@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0046_testme/0000755000175000017500000000000011637170657023210 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0046_testme/test.out0000644000175000017500000000002511637170656024714 0ustar lbrentalbrenta Should be "0" = "0" libtemplates-parser-11.6.orig/regtests/tests/0046_testme/test.py0000644000175000017500000000007611637170656024543 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme42.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0046_testme/testme42.tmplt0000755000175000017500000000004411637170656025741 0ustar lbrentalbrenta Should be "0" = "@_SIZE0'Length_@" libtemplates-parser-11.6.orig/regtests/tests/0047_testme/0000755000175000017500000000000011637170657023211 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0047_testme/test.out0000644000175000017500000000001111637170656024710 0ustar lbrentalbrenta OK OK libtemplates-parser-11.6.orig/regtests/tests/0047_testme/test.py0000644000175000017500000000007611637170656024544 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme43.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0047_testme/testme43.tmplt0000755000175000017500000000015711637170656025750 0ustar lbrentalbrenta @@IF@@ @_FILE_@ = /home/user OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_"/"(2):TWO_@ = 1 OK @@ELSE@@ NOK @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0048_testme/0000755000175000017500000000000011637170657023212 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0048_testme/include3.tmplt0000755000175000017500000000003511637170656026002 0ustar lbrentalbrenta @_$0_@ @_"+"(5):$1_@ @_$2_@ libtemplates-parser-11.6.orig/regtests/tests/0048_testme/test.out0000644000175000017500000000002611637170656024717 0ustar lbrentalbrenta include3.tmplt 10 libtemplates-parser-11.6.orig/regtests/tests/0048_testme/test.py0000644000175000017500000000007611637170656024545 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme44.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0048_testme/testme44.tmplt0000755000175000017500000000003611637170656025746 0ustar lbrentalbrenta @@INCLUDE@@ include3.tmplt 5 libtemplates-parser-11.6.orig/regtests/tests/0049_testme/0000755000175000017500000000000011637170657023213 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0049_testme/test.out0000644000175000017500000000056211637170656024725 0ustar lbrentalbrenta Test include parameters in filters: With 2 and 4 4 + 2 = 6 4 - 2 = 2 4 / 2 = 2 4 * 2 = 8 TestTestTestTest With 80 and 8 8 + 80 = 88 8 - 80 = -72 8 / 80 = 0 8 * 80 = 640 TestTestTestTestTestTestTestTest With @ _TWO_ @ and @ _THREE_ @ 3 + 2 = 5 3 - 2 = 1 3 / 2 = 1 3 * 2 = 6 TestTestTest 3 + 4 = 7 3 - 4 = -1 3 / 4 = 0 3 * 4 = 12 TestTestTest libtemplates-parser-11.6.orig/regtests/tests/0049_testme/test.py0000644000175000017500000000007611637170656024546 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme45.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0049_testme/testme45.incl0000755000175000017500000000024111637170656025533 0ustar lbrentalbrenta @_$2_@ + @_$1_@ = @_"+"($1):$2_@ @_$2_@ - @_$1_@ = @_"-"($1):$2_@ @_$2_@ / @_$1_@ = @_"/"($1):$2_@ @_$2_@ * @_$1_@ = @_"*"($1):$2_@ @_REPEAT($2):TEST_VAR_@ libtemplates-parser-11.6.orig/regtests/tests/0049_testme/testme45.tmplt0000755000175000017500000000037511637170656025756 0ustar lbrentalbrenta Test include parameters in filters: With 2 and 4 @@INCLUDE@@ testme45.incl 2 4 With 80 and 8 @@INCLUDE@@ testme45.incl 80 8 With @ _TWO_ @ and @ _THREE_ @ @@INCLUDE@@ testme45.incl @_TWO_@ @_THREE_@ @@INCLUDE@@ testme45.incl @_LABELS'Length_@ 3 libtemplates-parser-11.6.orig/regtests/tests/0050_testme/0000755000175000017500000000000011637170657023203 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0050_testme/test.out0000644000175000017500000000002411637170656024706 0ustar lbrentalbrenta 1: 1 -1 1 2: 1 1 1 libtemplates-parser-11.6.orig/regtests/tests/0050_testme/test.py0000644000175000017500000000007611637170656024536 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme46.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0050_testme/testme46.tmplt0000755000175000017500000000012711637170656025742 0ustar lbrentalbrenta 1: @_ONE_@ @_NEG:ONE_@ @_NEG:NEG:ONE_@ 2: @_ONE_@ @_ABS:NEG:ONE_@ @_ABS:NEG:NEG:ONE_@ libtemplates-parser-11.6.orig/regtests/tests/0051_testme/0000755000175000017500000000000011637170657023204 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0051_testme/include_simple.incl0000644000175000017500000000005011637170656027041 0ustar lbrentalbrenta1: @_$1_@ 2: @_$2_@ 3: @_$3_@ 4: @_$4_@ libtemplates-parser-11.6.orig/regtests/tests/0051_testme/test.out0000644000175000017500000000004011637170656024705 0ustar lbrentalbrenta1: one 2: two 3: three 4: four libtemplates-parser-11.6.orig/regtests/tests/0051_testme/test.py0000644000175000017500000000007611637170656024537 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme47.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0051_testme/testme47.tmplt0000755000175000017500000000006311637170656025743 0ustar lbrentalbrenta@@INCLUDE@@ include_simple.incl one two three four libtemplates-parser-11.6.orig/regtests/tests/0052_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0052_testme/include_simple.incl0000644000175000017500000000005011637170656027042 0ustar lbrentalbrenta1: @_$1_@ 2: @_$2_@ 3: @_$3_@ 4: @_$4_@ libtemplates-parser-11.6.orig/regtests/tests/0052_testme/test.out0000644000175000017500000000004011637170656024706 0ustar lbrentalbrenta1: one 2: two 3: three 4: four libtemplates-parser-11.6.orig/regtests/tests/0052_testme/test.py0000644000175000017500000000007611637170656024540 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme48.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0052_testme/testme48.tmplt0000755000175000017500000000010711637170656025744 0ustar lbrentalbrenta@@INCLUDE@@ include_simple.incl (one, 3 =>three, 4 => four, 2=>two) libtemplates-parser-11.6.orig/regtests/tests/0053_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0053_testme/include_simple.incl0000644000175000017500000000005011637170656027043 0ustar lbrentalbrenta1: @_$1_@ 2: @_$2_@ 3: @_$3_@ 4: @_$4_@ libtemplates-parser-11.6.orig/regtests/tests/0053_testme/test.out0000644000175000017500000000017311637170656024716 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : Can't have a positional parameter after a named one, in testme49.tmplt at line 1 libtemplates-parser-11.6.orig/regtests/tests/0053_testme/test.py0000644000175000017500000000007611637170656024541 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme49.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0053_testme/testme49.tmplt0000755000175000017500000000010411637170656025743 0ustar lbrentalbrenta@@INCLUDE@@ include_simple.incl (one, 3 =>three, two, 4 => four) libtemplates-parser-11.6.orig/regtests/tests/0054_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0054_testme/include_simple.incl0000644000175000017500000000005011637170656027044 0ustar lbrentalbrenta1: @_$1_@ 2: @_$2_@ 3: @_$3_@ 4: @_$4_@ libtemplates-parser-11.6.orig/regtests/tests/0054_testme/test.out0000644000175000017500000000015111637170656024713 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : Parameter 3 defined multiple time, in testme50.tmplt at line 1 libtemplates-parser-11.6.orig/regtests/tests/0054_testme/test.py0000644000175000017500000000007611637170656024542 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme50.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0054_testme/testme50.tmplt0000755000175000017500000000010711637170656025737 0ustar lbrentalbrenta@@INCLUDE@@ include_simple.incl (one, 3 =>three, 4 => four, 3=>two) libtemplates-parser-11.6.orig/regtests/tests/0055_testme/0000755000175000017500000000000011637170657023210 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0055_testme/include_simple.incl0000755000175000017500000000005011637170656027050 0ustar lbrentalbrenta1: @_$1_@ 2: @_$2_@ 3: @_$3_@ 4: @_$4_@ libtemplates-parser-11.6.orig/regtests/tests/0055_testme/test.out0000644000175000017500000000004411637170656024715 0ustar lbrentalbrenta1: one 2: two 3: three 33! 4: four libtemplates-parser-11.6.orig/regtests/tests/0055_testme/test.py0000644000175000017500000000007611637170656024543 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme51.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0055_testme/testme51.tmplt0000755000175000017500000000011511637170656025740 0ustar lbrentalbrenta@@INCLUDE@@ include_simple.incl (one, 3 =>"three 33!", 4 => four, 2=>two) libtemplates-parser-11.6.orig/regtests/tests/0056_testme/0000755000175000017500000000000011637170657023211 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0056_testme/test.out0000644000175000017500000000001211637170656024711 0ustar lbrentalbrenta 2 1 7 2 libtemplates-parser-11.6.orig/regtests/tests/0056_testme/test.py0000644000175000017500000000007611637170656024544 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme52.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0056_testme/testme52.tmplt0000755000175000017500000000007611637170656025750 0ustar lbrentalbrenta @_MIN(7):TWO_@ @_MIN(1):TWO_@ @_MAX(7):TWO_@ @_MAX(1):TWO_@ libtemplates-parser-11.6.orig/regtests/tests/0057_testme/0000755000175000017500000000000011637170657023212 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0057_testme/test.out0000644000175000017500000000020211637170656024713 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : TERMINATE_SECTIONS attribute given, but no section defined, in testme55.tmplt at line 4 libtemplates-parser-11.6.orig/regtests/tests/0057_testme/test.py0000644000175000017500000000007611637170656024545 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme55.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0057_testme/testme55.tmplt0000755000175000017500000000007111637170656025747 0ustar lbrentalbrenta @@TABLE@@ @@TERMINATE_SECTIONS@@ @_VAR2_@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0058_testme/0000755000175000017500000000000011637170657023213 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0058_testme/test.out0000644000175000017500000000002211637170656024714 0ustar lbrentalbrenta FALSE FALSE TRUE libtemplates-parser-11.6.orig/regtests/tests/0058_testme/test.py0000644000175000017500000000007611637170656024546 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme56.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0058_testme/testme56.tmplt0000755000175000017500000000010111637170656025743 0ustar lbrentalbrenta @_FILE_EXISTS:VAR1_@ @_FILE_EXISTS:FILE_@ @_FILE_EXISTS:FILE2_@ libtemplates-parser-11.6.orig/regtests/tests/0059_testme/0000755000175000017500000000000011637170657023214 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0059_testme/test.out0000644000175000017500000000067211637170656024730 0ustar lbrentalbrentaThe classes: Class1, Class2 The members: Member1.1, Member1.2 Member2.1, Member2.2, Member2.3 Class1 MISSING OUTPUT:Class1, Class2 ->Class1::Member1.1 ERROR IF PRESENT:Class1, Class2 ->Class1::Member1.2 ERROR IF PRESENT:Class1, Class2 Class2 MISSING OUTPUT:Class1, Class2 ->Class2::Member2.1 ERROR IF PRESENT:Class1, Class2 ->Class2::Member2.2 ERROR IF PRESENT:Class1, Class2 ->Class2::Member2.3 ERROR IF PRESENT:Class1, Class2 libtemplates-parser-11.6.orig/regtests/tests/0059_testme/test.py0000644000175000017500000000007611637170656024547 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme57.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0059_testme/testme57.tmplt0000644000175000017500000000040011637170656025744 0ustar lbrentalbrentaThe classes: @_CLASS_@ The members: @_MEMBER_@ @@TABLE@@ @_CLASS_@ MISSING OUTPUT:@_CLASS'UP_LEVEL(1)_@ @@TABLE@@ @@IF@@ @_EXIST:MEMBER_@ ->@_CLASS'UP_LEVEL(1)_@::@_MEMBER_@ ERROR IF PRESENT:@_CLASS'UP_LEVEL(2)_@ @@END_IF@@ @@END_TABLE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0060_testme/0000755000175000017500000000000011637170657023204 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0060_testme/test.out0000644000175000017500000000016011637170656024710 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : @@END_IF@@ found, @@END_TABLE@@ expected, in testme58.tmplt at line 5 libtemplates-parser-11.6.orig/regtests/tests/0060_testme/test.py0000644000175000017500000000007611637170656024537 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme58.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0060_testme/testme58.tmplt0000755000175000017500000000005011637170656025741 0ustar lbrentalbrenta@@-- foo @@-- bar @@TABLE@@ @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0061_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0061_testme/test.out0000644000175000017500000000032611637170656024715 0ustar lbrentalbrenta one two three three two one A4.1 A4.2 A4.3 A3.1 A3.2 A3.3 A2.1 A2.2 A2.3 A1.1 A1.2 A1.3 A4.3 A4.2 A4.1 A3.3 A3.2 A3.1 A2.3 A2.2 A2.1 A1.3 A1.2 A1.1 A1.3 A1.2 A1.1 A2.3 A2.2 A2.1 A3.3 A3.2 A3.1 A4.3 A4.2 A4.1 libtemplates-parser-11.6.orig/regtests/tests/0061_testme/test.py0000644000175000017500000000007611637170656024540 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme60.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0061_testme/testme60.tmplt0000755000175000017500000000042711637170656025743 0ustar lbrentalbrenta @@TABLE@@ @_VAR3_@ @@END_TABLE@@ @@TABLE'REVERSE@@ @_VAR3_@ @@END_TABLE@@ @@TABLE'REVERSE@@ @@TABLE@@ @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ @@TABLE'REVERSE@@ @@TABLE'REVERSE@@ @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ @@TABLE@@ @@TABLE'REVERSE@@ @_MAT_@ @@END_TABLE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0062_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0062_testme/test.out0000644000175000017500000000011411637170656024711 0ustar lbrentalbrenta testme61_1: foo foo testme61_2: foo testme61_2: foo testme61_2: foo libtemplates-parser-11.6.orig/regtests/tests/0062_testme/test.py0000644000175000017500000000007611637170656024541 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme61.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0062_testme/testme61.tmplt0000755000175000017500000000004611637170656025742 0ustar lbrentalbrenta @@INCLUDE@@ testme61_1.incl (5=>foo) libtemplates-parser-11.6.orig/regtests/tests/0062_testme/testme61_1.incl0000755000175000017500000000031011637170656025741 0ustar lbrentalbrenta @@SET@@ ALIAS = $5 testme61_1: @_$5_@ @_ALIAS_@ @@IF@@ @_EXIST:$5_@ @@INCLUDE@@ testme61_2.incl @_$5_@ @@INCLUDE@@ testme61_2.incl (1=>@_$5_@) @@INCLUDE@@ testme61_2.incl (1=>@_ALIAS_@) @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0062_testme/testme61_2.incl0000755000175000017500000000002411637170656025744 0ustar lbrentalbrenta testme61_2: @_$1_@ libtemplates-parser-11.6.orig/regtests/tests/0063_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0063_testme/test.out0000644000175000017500000000006111637170656024713 0ustar lbrentalbrenta $1=one, two, three $1=one $1=two $1=three libtemplates-parser-11.6.orig/regtests/tests/0063_testme/test.py0000644000175000017500000000007611637170656024542 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme62.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0063_testme/testme62.incl0000755000175000017500000000001311637170656025523 0ustar lbrentalbrenta $1=@_$1_@ libtemplates-parser-11.6.orig/regtests/tests/0063_testme/testme62.tmplt0000755000175000017500000000014011637170656025737 0ustar lbrentalbrenta @@INCLUDE@@ testme62.incl @_VAR3_@ @@TABLE@@ @@INCLUDE@@ testme62.incl @_VAR3_@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0064_testme/0000755000175000017500000000000011637170657023210 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0064_testme/test.out0000644000175000017500000000020311637170656024712 0ustar lbrentalbrenta <été ça être paramètre à paraître> & " <été ça être paramètre à paraître> & " libtemplates-parser-11.6.orig/regtests/tests/0064_testme/test.py0000644000175000017500000000007611637170656024543 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme63.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0064_testme/testme63.tmplt0000755000175000017500000000004511637170656025745 0ustar lbrentalbrenta @_ACCENTS_@ @_WEB_ENCODE:ACCENTS_@ libtemplates-parser-11.6.orig/regtests/tests/0065_testme/0000755000175000017500000000000011637170657023211 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0065_testme/test.out0000644000175000017500000000041611637170656024721 0ustar lbrentalbrenta --- 1. lab1 2. label 2 1. lab3 2. lab4 1. lab1|2. label 2|1. lab3|2. lab4 --- before lab1 after before sec: lab2 after before lab3 after before sec: lab4 after before, lab1, after, before, sec: lab2, after, before, lab3, after, before, sec: lab4, after libtemplates-parser-11.6.orig/regtests/tests/0065_testme/test.py0000644000175000017500000000007611637170656024544 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme65.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0065_testme/testme65.tmplt0000755000175000017500000000103111637170656025744 0ustar lbrentalbrenta --- @@TABLE@@ 1. @_LABELS_@ @@SECTION@@ @@IF@@ @_LABELS_@ = "lab2" 2. label 2 @@ELSE@@ 2. @_LABELS_@ @@END_IF@@ @@END_TABLE@@ @@INLINE(|)@@ @@TABLE@@ 1. @_LABELS_@ @@SECTION@@ @@IF@@ @_LABELS_@ = "lab2" 2. label 2 @@ELSE@@ 2. @_LABELS_@ @@END_IF@@ @@END_TABLE@@ @@END_INLINE@@ --- @@TABLE@@ before @@BEGIN@@ @_LABELS_@ @@SECTION@@ sec: @_LABELS_@ @@END@@ after @@END_TABLE@@ @@INLINE(, )@@ @@TABLE@@ before @@BEGIN@@ @_LABELS_@ @@SECTION@@ sec: @_LABELS_@ @@END@@ after @@END_TABLE@@ @@END_INLINE@@ libtemplates-parser-11.6.orig/regtests/tests/0066_testme/0000755000175000017500000000000011637170657023212 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0066_testme/test.out0000644000175000017500000000014011637170656024714 0ustar lbrentalbrenta. . .xxx. .333. .AAA. .AAA. . , , , . . , , , . 3 times nothing: .. nothing 3 times: .. libtemplates-parser-11.6.orig/regtests/tests/0066_testme/test.py0000644000175000017500000000007611637170656024545 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme66.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0066_testme/testme66.tmplt0000755000175000017500000000036011637170656025752 0ustar lbrentalbrenta.@_REPEAT( ):THREE_@. .@_REPEAT(x):THREE_@. .@_REPEAT(3):THREE_@. .@_REPEAT(3):VAR6_@. .@_REPEAT(THREE):VAR6_@. .@_REPEAT( , ):THREE_@. .@_REPEAT(" , "):THREE_@. 3 times nothing: .@_REPEAT():THREE_@. nothing 3 times: .@_REPEAT(3):VAR4_@. libtemplates-parser-11.6.orig/regtests/tests/0067_testme/0000755000175000017500000000000011637170657023213 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0067_testme/test.out0000644000175000017500000000024311637170656024721 0ustar lbrentalbrenta first ( 2. lab1 ) first ( 2. lab2 ) first ( 2. lab3 ) first ( 2. lab4 ) first (2. lab1) first (2. lab2) first (2. lab3) first (2. lab4) libtemplates-parser-11.6.orig/regtests/tests/0067_testme/test.py0000644000175000017500000000007611637170656024546 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme67.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0067_testme/testme67.tmplt0000755000175000017500000000056011637170656025756 0ustar lbrentalbrenta @@TABLE@@ first @@INLINE@@ ( @@IF@@ @_COND1_@ 1. @_LABELS_@ @@ELSE@@ 2. @_LABELS_@ @@END_IF@@ ) @@END_INLINE@@ @@END_TABLE@@ @@TABLE@@ first @@INLINE()@@ ( @@IF@@ @_COND1_@ 1. @_LABELS_@ @@ELSE@@ 2. @_LABELS_@ @@END_IF@@ ) @@END_INLINE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0068_testme/0000755000175000017500000000000011637170657023214 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0068_testme/test.out0000644000175000017500000000025511637170656024725 0ustar lbrentalbrenta start: lab1 lab2 lab3 lab4 .start:,lab1,lab2,lab3,lab4 ..start:,lab1,lab2,lab3,lab4 ...start:,lab1,lab2,lab3,lab4 class="lab1,lab2,lab3,lab4" ..class="lab1,lab2,lab3,lab4" libtemplates-parser-11.6.orig/regtests/tests/0068_testme/test.py0000644000175000017500000000007611637170656024547 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme68.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0068_testme/testme68.tmplt0000755000175000017500000000103111637170656025752 0ustar lbrentalbrenta @@INLINE@@ start: @@TABLE@@ @_LABELS_@ @@END_TABLE@@ @@END_INLINE@@ @@INLINE(.)(,)()@@ start: @@TABLE@@ @_LABELS_@ @@END_TABLE@@ @@END_INLINE@@ @@INLINE(..)(,)()@@ start: @@TABLE@@ @_LABELS_@ @@END_TABLE@@ @@END_INLINE@@ @@INLINE(...)(,)()@@ start: @@TABLE@@ @_LABELS_@ @@END_TABLE@@ @@END_INLINE@@ @@INLINE(class=")(,)(")@@ @@TABLE@@ @_LABELS_@ @@END_TABLE@@ @@END_INLINE@@ @@INLINE(..class=")(,)(")@@ @@TABLE@@ @_LABELS_@ @@END_TABLE@@ @@END_INLINE@@ libtemplates-parser-11.6.orig/regtests/tests/0069_testme/0000755000175000017500000000000011637170657023215 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0069_testme/test.out0000644000175000017500000000001511637170656024720 0ustar lbrentalbrenta"" libtemplates-parser-11.6.orig/regtests/tests/0069_testme/test.py0000644000175000017500000000007611637170656024550 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme69.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0069_testme/testme69.tmplt0000755000175000017500000000002511637170656025756 0ustar lbrentalbrenta@_WEB_ESCAPE:QUOTE_@ libtemplates-parser-11.6.orig/regtests/tests/0070_testme/0000755000175000017500000000000011637170657023205 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0070_testme/incl.tmplt0000644000175000017500000000003211637170656025206 0ustar lbrentalbrentaagain a new include file libtemplates-parser-11.6.orig/regtests/tests/0070_testme/test.out0000644000175000017500000000017511637170656024717 0ustar lbrentalbrenta -- 1 Error1: File ./toto/incl.tmplt does not exist! -- 2 again a new include file -- 3 again a new include file libtemplates-parser-11.6.orig/regtests/tests/0070_testme/test.py0000644000175000017500000000007611637170656024540 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme70.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0070_testme/testme70.tmplt0000755000175000017500000000100111637170656025731 0ustar lbrentalbrenta -- 1 @@SET@@ FILENAME = ./toto/incl.tmplt @@IF@@ @_FILE_EXISTS:FILENAME_@ @@INCLUDE@@ ./toto/incl.tmplt @@ELSE@@ Error1: File @_FILENAME_@ does not exist! @@END_IF@@ -- 2 @@SET@@ FILENAME = ./incl.tmplt @@IF@@ @_FILE_EXISTS:FILENAME_@ @@INCLUDE@@ @_FILENAME_@ @@ELSE@@ Error2: File @_FILENAME_@ does not exist! @@END_IF@@ -- 3 @@SET@@ FILENAME = ./incl.tmplt @@IF@@ @_FILE_EXISTS:FILENAME_@ @@INCLUDE@@ ./@_LOWER:FILENAME_@ @@ELSE@@ Error2: File @_FILENAME_@ does not exist! @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0071_testme/0000755000175000017500000000000011637170657023206 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0071_testme/test.out0000644000175000017500000000345311637170656024722 0ustar lbrentalbrenta ----------------------------------- 1a> CT 1 1 CT 2 1 CT 2 2 CT 3 1 CT 3 2 CT 3 3 1b> CMAT 1 1 1 CMAT 1 1 2 CMAT 1 1 3 CMAT 1 2 1 CMAT 1 2 2 CMAT 1 2 3 CMAT 1 2 4 CMAT 2 1 1 CMAT 2 1 2 CMAT 2 1 3 CMAT 2 2 1 CMAT 2 2 2 CMAT 2 2 3 CMAT 2 2 4 CMAT 3 1 1 CMAT 3 1 2 CMAT 3 1 3 CMAT 3 2 1 CMAT 3 2 2 CMAT 3 2 3 CMAT 3 2 4 1c> M 1 1 1, M 1 1 2, M 1 1 3 M 1 2 1, M 1 2 2, M 1 2 3, M 1 2 4 M 2 1 1, M 2 1 2, M 2 1 3 M 2 2 1, M 2 2 2, M 2 2 3, M 2 2 4 M 3 1 1, M 3 1 2, M 3 1 3 M 3 2 1, M 3 2 2, M 3 2 3, M 3 2 4 ----------------------------------- 2a> CT 1 1 2a> CT 2 1 CT 2 2 2a> CT 3 1 CT 3 2 CT 3 3 2b> CMAT 1 1 1 CMAT 1 1 2 CMAT 1 1 3 CMAT 1 2 1 CMAT 1 2 2 CMAT 1 2 3 CMAT 1 2 4 2b> CMAT 2 1 1 CMAT 2 1 2 CMAT 2 1 3 CMAT 2 2 1 CMAT 2 2 2 CMAT 2 2 3 CMAT 2 2 4 2b> CMAT 3 1 1 CMAT 3 1 2 CMAT 3 1 3 CMAT 3 2 1 CMAT 3 2 2 CMAT 3 2 3 CMAT 3 2 4 2c> M 1 1 1, M 1 1 2, M 1 1 3 M 1 2 1, M 1 2 2, M 1 2 3, M 1 2 4 2c> M 2 1 1, M 2 1 2, M 2 1 3 M 2 2 1, M 2 2 2, M 2 2 3, M 2 2 4 2c> M 3 1 1, M 3 1 2, M 3 1 3 M 3 2 1, M 3 2 2, M 3 2 3, M 3 2 4 -- Cursor . 3> CT 1 1 3> 3> . 3> CT 2 1 3> CT 2 2 3> . 3> CT 3 1 3> CT 3 2 3> CT 3 3 -- Cursor C_MAT3 . .. 4a> CMAT 1 1 1 4a> CMAT 1 1 2 4a> CMAT 1 1 3 4a> .. 4a> CMAT 1 2 1 4a> CMAT 1 2 2 4a> CMAT 1 2 3 4a> CMAT 1 2 4 . .. 4a> CMAT 2 1 1 4a> CMAT 2 1 2 4a> CMAT 2 1 3 4a> .. 4a> CMAT 2 2 1 4a> CMAT 2 2 2 4a> CMAT 2 2 3 4a> CMAT 2 2 4 . .. 4a> CMAT 3 1 1 4a> CMAT 3 1 2 4a> CMAT 3 1 3 4a> .. 4a> CMAT 3 2 1 4a> CMAT 3 2 2 4a> CMAT 3 2 3 4a> CMAT 3 2 4 ----------------------------------- . .. 4b> M 1 1 1 4b> M 1 1 2 4b> M 1 1 3 4b> .. 4b> M 1 2 1 4b> M 1 2 2 4b> M 1 2 3 4b> M 1 2 4 . .. 4b> M 2 1 1 4b> M 2 1 2 4b> M 2 1 3 4b> .. 4b> M 2 2 1 4b> M 2 2 2 4b> M 2 2 3 4b> M 2 2 4 . .. 4b> M 3 1 1 4b> M 3 1 2 4b> M 3 1 3 4b> .. 4b> M 3 2 1 4b> M 3 2 2 4b> M 3 2 3 4b> M 3 2 4 libtemplates-parser-11.6.orig/regtests/tests/0071_testme/test.py0000644000175000017500000000007611637170656024541 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme71.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0071_testme/testme71.tmplt0000644000175000017500000000105311637170656025737 0ustar lbrentalbrenta ----------------------------------- 1a> @_CURSOR_@ 1b> @_C_MAT3_@ 1c> @_MAT3_@ ----------------------------------- @@TABLE@@ 2a> @_CURSOR_@ @@END_TABLE@@ @@TABLE@@ 2b> @_C_MAT3_@ @@END_TABLE@@ @@TABLE@@ 2c> @_MAT3_@ @@END_TABLE@@ -- Cursor @@TABLE@@ . @@TABLE@@ 3> @_CURSOR_@ @@END_TABLE@@ @@END_TABLE@@ -- Cursor C_MAT3 @@TABLE@@ . @@TABLE@@ .. @@TABLE@@ 4a> @_C_MAT3_@ @@END_TABLE@@ @@END_TABLE@@ @@END_TABLE@@ ----------------------------------- @@TABLE@@ . @@TABLE@@ .. @@TABLE@@ 4b> @_MAT3_@ @@END_TABLE@@ @@END_TABLE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0072_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0072_testme/test.out0000644000175000017500000000040511637170656024715 0ustar lbrentalbrenta t o t o t i t i t a t a t a t a t i t i t o t o t a t a t i t i t o t o t i t i t i t i tot o tit i tat a tat a tit i tot o tat a tit i tot o tit i tit i toto titi tata tata titi toto tata titi toto titi titi First line Second line First line Second line libtemplates-parser-11.6.orig/regtests/tests/0072_testme/test.py0000644000175000017500000000007611637170656024542 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme72.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0072_testme/testme72.tmplt0000644000175000017500000000014111637170656025736 0ustar lbrentalbrenta @_WRAP(1):TEXT_@ @_WRAP(3):TEXT_@ @_WRAP(50):TEXT_@ @_WRAP(8):WITHLF_@ @_WRAP(15):WITHLF_@ libtemplates-parser-11.6.orig/regtests/tests/0073_testme/0000755000175000017500000000000011637170657023210 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0073_testme/test.out0000644000175000017500000000062011637170656024715 0ustar lbrentalbrenta one & two & three \\ xxxxxxxxxxxxxxxxxxxxxxxxxxx Member1.1 & Member1.2 & \\ Member2.1 & Member2.2 & Member2.3 \\ xxxxxxxxxxxxxxxxxxxxxxxxxxx Member1.1 & Member1.2 \\ Member2.1 & Member2.2 & Member2.3 \\ xxxxxxxxxxxxxxxxxxxxxxxxxxx Member1.1 & Member1.2 & \\ Member2.1 & Member2.2 & Member2.3 \\ xxxxxxxxxxxxxxxxxxxxxxxxxxx Member1.1 & Member1.2 & - \\ Member2.1 & Member2.2 & Member2.3 \\ libtemplates-parser-11.6.orig/regtests/tests/0073_testme/test.py0000644000175000017500000000007611637170656024543 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme73.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0073_testme/testme73.tmplt0000644000175000017500000000151411637170656025745 0ustar lbrentalbrenta @@INLINE()( & )( \\\\)@@ @@TABLE@@ @_V5_@ @@END_TABLE@@ @@END_INLINE@@ xxxxxxxxxxxxxxxxxxxxxxxxxxx @@TABLE@@ @@INLINE()( & )( \\\\)@@ @@TABLE@@ @_MEMBER_@ @@END_TABLE@@ @@END_INLINE@@ @@END_TABLE@@ xxxxxxxxxxxxxxxxxxxxxxxxxxx @@TABLE@@ @@INLINE()( & )( \\\\)@@ @@TABLE@@ @@IF@@ @_MEMBER_@ /= "" @_MEMBER_@ @@END_IF@@ @@END_TABLE@@ @@END_INLINE@@ @@END_TABLE@@ xxxxxxxxxxxxxxxxxxxxxxxxxxx @@TABLE@@ @@INLINE()( & )( \\\\)@@ @@TABLE@@ @@IF@@ @_MEMBER_@ /= "" @_MEMBER_@ @@ELSE@@ @@END_IF@@ @@END_TABLE@@ @@END_INLINE@@ @@END_TABLE@@ xxxxxxxxxxxxxxxxxxxxxxxxxxx @@TABLE@@ @@INLINE()( & )( \\\\)@@ @@TABLE@@ @@IF@@ @_MEMBER_@ /= "" @_MEMBER_@ @@ELSE@@ - @@END_IF@@ @@END_TABLE@@ @@END_INLINE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0074_testme/0000755000175000017500000000000011637170657023211 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0074_testme/test.out0000644000175000017500000000000011637170656024706 0ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0074_testme/test.py0000644000175000017500000000007611637170656024544 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme74.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0074_testme/testme74.tmplt0000755000175000017500000000004311637170656025746 0ustar lbrentalbrenta@@-- Next line has 5 spaces libtemplates-parser-11.6.orig/regtests/tests/0075_testme/0000755000175000017500000000000011637170657023212 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0075_testme/test.out0000644000175000017500000000054211637170656024722 0ustar lbrentalbrenta 1. return Fa1 (Self) = T_Rt1.Ra1 (T_Rt1.Table (Foreign)) and Fa2 (Self) = T_Rt2.Ra2 (T_Rt2.Table (Foreign)) and Fa3 (Self) = T_Rt3.Ra3 (T_Rt3.Table (Foreign)); 2. return Fa1 (Self) = T_Rt1.Ra1 (T_Rt1.Table (Foreign)) and Fa2 (Self) = T_Rt2.Ra2 (T_Rt2.Table (Foreign)) and Fa3 (Self) = T_Rt3.Ra3 (T_Rt3.Table (Foreign)); libtemplates-parser-11.6.orig/regtests/tests/0075_testme/test.py0000644000175000017500000000007611637170656024545 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme75.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0075_testme/testme75.tmplt0000644000175000017500000000077211637170656025756 0ustar lbrentalbrenta 1. @@INLINE( return )( and )(;)@@ @@TABLE@@ @_CAPITALIZE:FOREIGN_ATTRS_@ (Self) = T_@_CAPITALIZE:REFERENCED_TABLES_@.@_CAPITALIZE:REFERENCED_ATTRS_@ (T_@_CAPITALIZE:REFERENCED_TABLES_@.Table (Foreign)) @@END_TABLE@@ @@END_INLINE@@ 2. @@INLINE( return )(\n and )(;)@@ @@TABLE@@ @_CAPITALIZE:FOREIGN_ATTRS_@ (Self) = T_@_CAPITALIZE:REFERENCED_TABLES_@.@_CAPITALIZE:REFERENCED_ATTRS_@ (T_@_CAPITALIZE:REFERENCED_TABLES_@.Table (Foreign)) @@END_TABLE@@ @@END_INLINE@@ libtemplates-parser-11.6.orig/regtests/tests/0076_testme/0000755000175000017500000000000011637170657023213 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0076_testme/incl.tmplt0000644000175000017500000000003211637170656025214 0ustar lbrentalbrentaagain a new include file libtemplates-parser-11.6.orig/regtests/tests/0076_testme/test.out0000644000175000017500000000005311637170656024720 0ustar lbrentalbrenta again a new include file one, two, three libtemplates-parser-11.6.orig/regtests/tests/0076_testme/test.py0000644000175000017500000000007611637170656024546 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme76.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0076_testme/testme76.tmplt0000644000175000017500000000004611637170656025752 0ustar lbrentalbrenta @@INCLUDE@@ @_TMPLT_NAME_@ @_VAR3_@ libtemplates-parser-11.6.orig/regtests/tests/0077_testme/0000755000175000017500000000000011637170657023214 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0077_testme/single_line.incl0000644000175000017500000000002611637170656026350 0ustar lbrentalbrentaa single line include libtemplates-parser-11.6.orig/regtests/tests/0077_testme/test.out0000644000175000017500000000004411637170656024721 0ustar lbrentalbrentastart1 (a single line include) end1 libtemplates-parser-11.6.orig/regtests/tests/0077_testme/test.py0000644000175000017500000000007611637170656024547 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme77.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0077_testme/testme77.tmplt0000644000175000017500000000011611637170656025752 0ustar lbrentalbrentastart1 @@INLINE(\()()(\))@@ @@INCLUDE@@ single_line.incl @@END_INLINE@@ end1 libtemplates-parser-11.6.orig/regtests/tests/0078_testme/0000755000175000017500000000000011637170657023215 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0078_testme/test.out0000644000175000017500000000015611637170656024726 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : in operator right operand must be a tag In testme79.tmplt at line 2 libtemplates-parser-11.6.orig/regtests/tests/0078_testme/test.py0000644000175000017500000000007611637170656024550 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme79.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0078_testme/testme79.tmplt0000644000175000017500000000005411637170656025756 0ustar lbrentalbrenta @@IF@@ @_ONE_@ in "toto" error @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0079_testme/0000755000175000017500000000000011637170657023216 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0079_testme/test.out0000755000175000017500000000015711637170656024733 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : @@END_IF@@ found, @@END_TABLE@@ expected, in testme3.tmplt at line 5 libtemplates-parser-11.6.orig/regtests/tests/0079_testme/test.py0000644000175000017500000000007511637170656024550 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme3.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0079_testme/testme3.tmplt0000755000175000017500000000004611637170656025666 0ustar lbrentalbrenta @@TABLE@@ toto titi @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0080_blocks/0000755000175000017500000000000011637170657023162 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0080_blocks/blocks1.tmplt0000755000175000017500000000027611637170656025611 0ustar lbrentalbrentaligne1 @@TABLE@@ --- partie commune 1 partie commune 2 @@BEGIN@@ dans la table @_VAR3_@ @@SECTION@@ in the table @_VAR3_@ @@END@@ partie commune 3 @@END_TABLE@@ ligne2 libtemplates-parser-11.6.orig/regtests/tests/0080_blocks/test.out0000644000175000017500000000041611637170656024672 0ustar lbrentalbrentaligne1 --- partie commune 1 partie commune 2 dans la table one partie commune 3 --- partie commune 1 partie commune 2 in the table two partie commune 3 --- partie commune 1 partie commune 2 dans la table three partie commune 3 ligne2 libtemplates-parser-11.6.orig/regtests/tests/0080_blocks/test.py0000644000175000017500000000007511637170656024514 0ustar lbrentalbrentafrom test_support import * run('testme', ["blocks1.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0081_blocks/0000755000175000017500000000000011637170657023163 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0081_blocks/blocks2.tmplt0000755000175000017500000000043311637170656025606 0ustar lbrentalbrentaligne1 @@TABLE@@ --- partie commune 1 partie commune 2 @@BEGIN@@ dans la table @_VAR3_@ @@SECTION@@ in the table @_VAR3_@ @@END@@ partie commune 3 @@BEGIN@@ dans la table "@_VAR1_@" @@SECTION@@ in the table "@_VAR1_@" @@END@@ @@END_TABLE@@ ligne2 libtemplates-parser-11.6.orig/regtests/tests/0081_blocks/test.out0000644000175000017500000000054111637170656024672 0ustar lbrentalbrentaligne1 --- partie commune 1 partie commune 2 dans la table one partie commune 3 dans la table "a value" --- partie commune 1 partie commune 2 in the table two partie commune 3 in the table "a value" --- partie commune 1 partie commune 2 dans la table three partie commune 3 dans la table "a value" ligne2 libtemplates-parser-11.6.orig/regtests/tests/0081_blocks/test.py0000644000175000017500000000007511637170656024515 0ustar lbrentalbrentafrom test_support import * run('testme', ["blocks2.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0082_blocks/0000755000175000017500000000000011637170657023164 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0082_blocks/blocks3.tmplt0000755000175000017500000000045611637170656025615 0ustar lbrentalbrentaligne1 @@TABLE@@ --- partie commune 1 partie commune 2 @@BEGIN@@ dans la table @_VAR3_@ @@SECTION@@ in the table @_VAR3_@ @@END@@ partie commune 3 @@BEGIN@@ dans la table "@_VAR2_@" @@SECTION@@ in the table "@_VAR2_@" @@END@@ partie commune 4 @@END_TABLE@@ ligne2 libtemplates-parser-11.6.orig/regtests/tests/0082_blocks/test.out0000644000175000017500000000346011637170656024676 0ustar lbrentalbrentaligne1 --- partie commune 1 partie commune 2 dans la table one partie commune 3 dans la table "a table" partie commune 4 --- partie commune 1 partie commune 2 in the table two partie commune 3 in the table "with" partie commune 4 --- partie commune 1 partie commune 2 dans la table three partie commune 3 dans la table "many" partie commune 4 --- partie commune 1 partie commune 2 in the table partie commune 3 in the table "values" partie commune 4 --- partie commune 1 partie commune 2 dans la table partie commune 3 dans la table "to" partie commune 4 --- partie commune 1 partie commune 2 in the table partie commune 3 in the table "be" partie commune 4 --- partie commune 1 partie commune 2 dans la table partie commune 3 dans la table "displayed" partie commune 4 --- partie commune 1 partie commune 2 in the table partie commune 3 in the table "one" partie commune 4 --- partie commune 1 partie commune 2 dans la table partie commune 3 dans la table "by" partie commune 4 --- partie commune 1 partie commune 2 in the table partie commune 3 in the table "one" partie commune 4 ligne2 [INFO] blocks3.tmplt [C_INFO] 1 FALSE [TEXT] ligne1 [TABLE] [BLOCK] [COMMON] [TEXT] --- [TEXT] partie commune 1 [TEXT] partie commune 2 [SECTION] [TEXT] dans la table @_VAR3_@ [SECTION] [TEXT] in the table @_VAR3_@ [END_BLOCK] [BLOCK] [COMMON] [TEXT] partie commune 3 [SECTION] [TEXT] dans la table "@_VAR2_@" [SECTION] [TEXT] in the table "@_VAR2_@" [END_BLOCK] [BLOCK] [COMMON] [TEXT] partie commune 4 [END_BLOCK] [END_TABLE] [TEXT] ligne2 libtemplates-parser-11.6.orig/regtests/tests/0082_blocks/test.py0000644000175000017500000000014211637170656024511 0ustar lbrentalbrentafrom test_support import * run('testme', ["blocks3.tmplt"]) run('print_tree', ["blocks3.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0083_blocks/0000755000175000017500000000000011637170657023165 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0083_blocks/blocks4.tmplt0000755000175000017500000000005211637170656025607 0ustar lbrentalbrenta@@TABLE@@ @@BEGIN@@ @@END@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0083_blocks/test.out0000644000175000017500000000012311637170656024670 0ustar lbrentalbrenta[INFO] blocks4.tmplt [C_INFO] 1 FALSE [TABLE] [BLOCK] [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0083_blocks/test.py0000644000175000017500000000014211637170656024512 0ustar lbrentalbrentafrom test_support import * run('testme', ["blocks4.tmplt"]) run('print_tree', ["blocks4.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0084_blocks/0000755000175000017500000000000011637170657023166 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0084_blocks/blocks5.tmplt0000755000175000017500000000017711637170656025621 0ustar lbrentalbrentaligne1 @@TABLE@@ @@BEGIN@@ dans la table @_VAR3_@ @@SECTION@@ in the table @_VAR3_@ @@END@@ @@END_TABLE@@ ligne2 libtemplates-parser-11.6.orig/regtests/tests/0084_blocks/test.out0000644000175000017500000000012111637170656024667 0ustar lbrentalbrentaligne1 dans la table one in the table two dans la table three ligne2 libtemplates-parser-11.6.orig/regtests/tests/0084_blocks/test.py0000644000175000017500000000007511637170656024520 0ustar lbrentalbrentafrom test_support import * run('testme', ["blocks5.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0085_blocks/0000755000175000017500000000000011637170657023167 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0085_blocks/blocks6.tmplt0000755000175000017500000000025611637170656025621 0ustar lbrentalbrenta @@TABLE@@ @@TERMINATE_SECTIONS@@ --- code with @_VAR3_@ @@BEGIN@@ red @@SECTION@@ green @@END@@ end of the text. @@BEGIN@@ 1 @@SECTION@@ 2 @@END@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0085_blocks/test.out0000644000175000017500000000106611637170656024701 0ustar lbrentalbrenta --- code with one red end of the text. 1 --- code with two green end of the text. 2 --- code with three red end of the text. 1 --- code with green end of the text. 2 [INFO] blocks6.tmplt [C_INFO] 1 FALSE [TEXT] [TABLE] TERMINATE_SECTIONS [BLOCK] [COMMON] [TEXT] --- [TEXT] code with @_VAR3_@ [SECTION] [TEXT] red [SECTION] [TEXT] green [END_BLOCK] [BLOCK] [COMMON] [TEXT] end of the text. [SECTION] [TEXT] 1 [SECTION] [TEXT] 2 [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0085_blocks/test.py0000644000175000017500000000014211637170656024514 0ustar lbrentalbrentafrom test_support import * run('testme', ["blocks6.tmplt"]) run('print_tree', ["blocks6.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0086_blocks/0000755000175000017500000000000011637170657023170 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0086_blocks/blocks7.tmplt0000755000175000017500000000027411637170656025623 0ustar lbrentalbrenta @@TABLE@@ @@TERMINATE_SECTIONS@@ code with @_VAR3_@ @@BEGIN@@ red @@SECTION@@ green @@END@@ end of the text. @@BEGIN@@ 1 @@SECTION@@ 2 @@SECTION@@ 3 @@END@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0086_blocks/test.out0000644000175000017500000000022111637170656024672 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : All sections must have the same size when using TERMINATE_SECTIONS option, in blocks7.tmplt at line 17 libtemplates-parser-11.6.orig/regtests/tests/0086_blocks/test.py0000644000175000017500000000007511637170656024522 0ustar lbrentalbrentafrom test_support import * run('testme', ["blocks7.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0087_tcache/0000755000175000017500000000000011637170657023143 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0087_tcache/tcache.adb0000644000175000017500000000710511637170656025044 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser; procedure Tcache is use Ada.Text_IO; use Templates_Parser; procedure Set (Filename : String; C1, C2, C3 : String := "") is File : File_Type; begin Create (File, Out_File, Filename); Put_Line (File, C1); if C2 /= "" then Put_Line (File, C2); end if; if C3 /= "" then Put_Line (File, C3); end if; Close (File); end Set; procedure Run is begin Put_Line (Parse ("a.tmplt", Cached => True)); Put_Line (Parse ("b.tmplt", Cached => True)); Put_Line (Parse ("c.tmplt", Cached => True)); Put_Line (Parse ("main.tmplt", Cached => True)); Put_Line (Parse ("3level.tmplt", Cached => True)); end Run; begin for K in 1 .. 2 loop Release_Cache; Set ("a.tmplt", "@@INCLUDE@@ head.tmplt", "A", "@@INCLUDE@@ foot.tmplt"); Set ("b.tmplt", "@@INCLUDE@@ head.tmplt", "B", "@@INCLUDE@@ foot.tmplt"); Set ("c.tmplt", "@@INCLUDE@@ head.tmplt", "C", "@@INCLUDE@@ foot.tmplt"); Set ("head.tmplt", "heading"); Set ("foot.tmplt", "footing"); Set ("main.tmplt", "@@INCLUDE@@ incl.tmplt", "main"); Set ("incl.tmplt", "include file"); Set ("3level.tmplt", "@@INCLUDE@@ 3l1.tmplt", "3level"); Set ("3l1.tmplt", "@@INCLUDE@@ 3l2.tmplt", "3level-1"); Set ("3l2.tmplt", "This is 3 level 2"); Run; Put_Line ("--------------------------"); delay 2.0; Set ("foot.tmplt", "footing 2"); Set ("a.tmplt", "@@INCLUDE@@ head.tmplt", "New A", "@@INCLUDE@@ foot.tmplt"); Set ("main.tmplt", "@@INCLUDE@@ incl.tmplt", "new main file"); Set ("incl.tmplt", "new include file"); Set ("3l2.tmplt", "This is 3 level 2 - v2"); Run; Put_Line ("--------------------------"); delay 2.0; Set ("incl.tmplt", "again a new include file"); Set ("3l2.tmplt", "This is 3 level 2 - v3"); Run; Put_Line ("--------------------------"); end loop; end Tcache; libtemplates-parser-11.6.orig/regtests/tests/0087_tcache/tcache.gpr0000644000175000017500000000324511637170656025107 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project Tcache is for Source_Dirs use ("."); for Main use ("tcache.adb"); end Tcache; libtemplates-parser-11.6.orig/regtests/tests/0087_tcache/test.out0000755000175000017500000000166011637170656024660 0ustar lbrentalbrentaheading A footing heading B footing heading C footing include file main This is 3 level 2 3level-1 3level -------------------------- heading New A footing 2 heading B footing 2 heading C footing 2 new include file new main file This is 3 level 2 - v2 3level-1 3level -------------------------- heading New A footing 2 heading B footing 2 heading C footing 2 again a new include file new main file This is 3 level 2 - v3 3level-1 3level -------------------------- heading A footing heading B footing heading C footing include file main This is 3 level 2 3level-1 3level -------------------------- heading New A footing 2 heading B footing 2 heading C footing 2 new include file new main file This is 3 level 2 - v2 3level-1 3level -------------------------- heading New A footing 2 heading B footing 2 heading C footing 2 again a new include file new main file This is 3 level 2 - v3 3level-1 3level -------------------------- libtemplates-parser-11.6.orig/regtests/tests/0087_tcache/test.py0000644000175000017500000000007511637170656024475 0ustar lbrentalbrentafrom test_support import * gnatmake('tcache') run('tcache') libtemplates-parser-11.6.orig/regtests/tests/0088_testcat/0000755000175000017500000000000011637170657023364 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0088_testcat/test.out0000755000175000017500000000006311637170656025075 0ustar lbrentalbrentatestcat template testcat template testcat template libtemplates-parser-11.6.orig/regtests/tests/0088_testcat/test.py0000644000175000017500000000007711637170656024720 0ustar lbrentalbrentafrom test_support import * gnatmake('testcat') run('testcat') libtemplates-parser-11.6.orig/regtests/tests/0088_testcat/testcat.adb0000644000175000017500000000344311637170656025506 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser; procedure Testcat is use Ada.Text_IO; use Templates_Parser; begin Put_Line (Parse ("testcat.tmplt")); Put_Line (Parse ("testcat.tmplt")); Put_Line (Parse ("testcat.tmplt")); end Testcat; libtemplates-parser-11.6.orig/regtests/tests/0088_testcat/testcat.gpr0000644000175000017500000000325011637170657025545 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project Testcat is for Source_Dirs use ("."); for Main use ("testcat.adb"); end Testcat; libtemplates-parser-11.6.orig/regtests/tests/0088_testcat/testcat.tmplt0000755000175000017500000000002111637170657026111 0ustar lbrentalbrentatestcat template libtemplates-parser-11.6.orig/regtests/tests/0089_testme_kut/0000755000175000017500000000000011637170657024102 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0089_testme_kut/test.out0000644000175000017500000000135411637170657025615 0ustar lbrentalbrenta One 1 Unknown @_UPPER:unknown_@ 1 ok, not EXIST ok, not EMPTY ok, @_unknown_@ not equal to 1 one @_unknown_@ two @_unknown_@ three @_unknown_@ [INFO] testme10.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] One @_ONE_@ [TEXT] [TEXT] Unknown @_UPPER:unknown_@ [TEXT] [IF] (@_ONE_@ = 1) [TEXT] 1 [ELSE] [TEXT] error [END_IF] [TEXT] [IF] @_EXIST:unknown_@ [TEXT] error [ELSE] [TEXT] ok, not EXIST [END_IF] [TEXT] [IF] @_IS_EMPTY:unknown_@ [TEXT] error [ELSE] [TEXT] ok, not EMPTY [END_IF] [TEXT] [IF] (@_unknown_@ = 1) [TEXT] error, unknown = 1 [ELSE] [TEXT] ok, @_unknown_@ not equal to 1 [END_IF] [TEXT] [TEXT] [TABLE] [BLOCK] [COMMON] [TEXT] @_VAR3_@ @_unknown_@ [END_BLOCK] [END_TABLE] libtemplates-parser-11.6.orig/regtests/tests/0089_testme_kut/test.py0000644000175000017500000000015311637170657025432 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme10.tmplt", "kut"]) run('print_tree', ["testme10.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0089_testme_kut/testme10.tmplt0000755000175000017500000000057411637170657026637 0ustar lbrentalbrenta One @_ONE_@ Unknown @_UPPER:unknown_@ @@IF@@ @_ONE_@ = 1 1 @@ELSE@@ error @@END_IF@@ @@IF@@ @_EXIST:unknown_@ error @@ELSE@@ ok, not EXIST @@END_IF@@ @@IF@@ @_IS_EMPTY:unknown_@ error @@ELSE@@ ok, not EMPTY @@END_IF@@ @@IF@@ @_unknown_@ = 1 error, unknown = 1 @@ELSE@@ ok, @_unknown_@ not equal to 1 @@END_IF@@ @@TABLE@@ @_VAR3_@ @_unknown_@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0090_testme/0000755000175000017500000000000011637170657023207 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0090_testme/test.out0000644000175000017500000000331011637170657024714 0ustar lbrentalbrentaJust some special tags: a value A VALUE AValue Avalue EULAVA a text with < 6 words & good 92 chars like + > a text with < words & good chars like + > a text with < words & good chars like + > < 6 & 92 + > < 6 & 92 + > a text with < 6 words & good 92 chars like + >    a text with < 6   words & good   92  chars like + >  a text with < 6 words & good 92 chars like + > TRUE FALSE a valuea valuea value 7 4 123 456 1 234 567.98765 12.98765 123.9 1 234.98 .98 OK OK OK [INFO] testme9.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] Just some special tags: [TEXT] [TEXT] @_LOWER:VAR1_@ [TEXT] @_UPPER:VAR1_@ [TEXT] @_NO_SPACE:CAPITALIZE:VAR1_@ [TEXT] @_CAPITALIZE:NO_SPACE:VAR1_@ [TEXT] @_NO_SPACE:UPPER:REVERSE:VAR1_@ [TEXT] [TEXT] @_CONTRACT:FILTER_@ [TEXT] @_NO_DIGIT:FILTER_@ [TEXT] @_CONTRACT:NO_DIGIT:FILTER_@ [TEXT] @_CONTRACT:NO_LETTER:FILTER_@ [TEXT] @_TRIM:CONTRACT:NO_LETTER:FILTER_@ [TEXT] @_WEB_ESCAPE:FILTER_@ [TEXT] @_WEB_NBSP:FILTER_@ [TEXT] @_WEB_NBSP:TRIM:CONTRACT:FILTER_@ [TEXT] @_MATCH(.*text.*):FILTER_@ [TEXT] @_MATCH(.*abc):FILTER_@ [TEXT] @_REPEAT(3):VAR1_@ [TEXT] @_SIZE:VAR1_@ [TEXT] @_SIZE:COND2_@ [TEXT] @_FORMAT_NUMBER:NUM0_@ [TEXT] @_FORMAT_NUMBER:NUM1_@ [TEXT] @_FORMAT_NUMBER:NUM2_@ [TEXT] @_FORMAT_NUMBER:NUM3_@ [TEXT] @_FORMAT_NUMBER:NUM4_@ [TEXT] @_FORMAT_NUMBER:NUM5_@ [TEXT] [IF] @_VAR5_@ [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [IF] @_NO_SPACE:VAR5_@ [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] @_UPPER:NO_SPACE:VAR5_@ [TEXT] OK [ELSE] [TEXT] NOK [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0090_testme/test.py0000644000175000017500000000014211637170657024535 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme9.tmplt"]) run('print_tree', ["testme9.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0090_testme/testme9.tmplt0000644000175000017500000000137211637170657025666 0ustar lbrentalbrenta Just some special tags: @_LOWER:VAR1_@ @_UPPER:VAR1_@ @_NO_SPACE:CAPITALIZE:VAR1_@ @_CAPITALIZE:NO_SPACE:VAR1_@ @_NO_SPACE:UPPER:REVERSE:VAR1_@ @_CONTRACT:FILTER_@ @_NO_DIGIT:FILTER_@ @_CONTRACT:NO_DIGIT:FILTER_@ @_CONTRACT:NO_LETTER:FILTER_@ @_TRIM:CONTRACT:NO_LETTER:FILTER_@ @_WEB_ESCAPE:FILTER_@ @_WEB_NBSP:FILTER_@ @_WEB_NBSP:TRIM:CONTRACT:FILTER_@ @_MATCH(.*text.*):FILTER_@ @_MATCH(.*abc):FILTER_@ @_REPEAT(3):VAR1_@ @_SIZE:VAR1_@ @_SIZE:COND2_@ @_FORMAT_NUMBER:NUM0_@ @_FORMAT_NUMBER:NUM1_@ @_FORMAT_NUMBER:NUM2_@ @_FORMAT_NUMBER:NUM3_@ @_FORMAT_NUMBER:NUM4_@ @_FORMAT_NUMBER:NUM5_@ @@IF@@ @_VAR5_@ NOK @@ELSE@@ OK @@END_IF@@ @@IF@@ @_NO_SPACE:VAR5_@ OK @@ELSE@@ NOK @@END_IF@@ @@IF@@ @_UPPER:NO_SPACE:VAR5_@ OK @@ELSE@@ NOK @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0090_testme/testme9_pt.out0000644000175000017500000000203611637170657026036 0ustar lbrentalbrenta[INFO] testme9.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] Just some special tags: [TEXT] [TEXT] @_LOWER:VAR1_@ [TEXT] @_UPPER:VAR1_@ [TEXT] @_NO_SPACE:CAPITALIZE:VAR1_@ [TEXT] @_CAPITALIZE:NO_SPACE:VAR1_@ [TEXT] @_NO_SPACE:UPPER:REVERSE:VAR1_@ [TEXT] [TEXT] @_CONTRACT:FILTER_@ [TEXT] @_NO_DIGIT:FILTER_@ [TEXT] @_CONTRACT:NO_DIGIT:FILTER_@ [TEXT] @_CONTRACT:NO_LETTER:FILTER_@ [TEXT] @_TRIM:CONTRACT:NO_LETTER:FILTER_@ [TEXT] @_WEB_ESCAPE:FILTER_@ [TEXT] @_WEB_NBSP:FILTER_@ [TEXT] @_WEB_NBSP:TRIM:CONTRACT:FILTER_@ [TEXT] @_MATCH(.*text.*):FILTER_@ [TEXT] @_MATCH(.*abc):FILTER_@ [TEXT] @_REPEAT(3):VAR1_@ [TEXT] @_SIZE:VAR1_@ [TEXT] @_SIZE:COND2_@ [TEXT] @_FORMAT_NUMBER:NUM0_@ [TEXT] @_FORMAT_NUMBER:NUM1_@ [TEXT] @_FORMAT_NUMBER:NUM2_@ [TEXT] @_FORMAT_NUMBER:NUM3_@ [TEXT] @_FORMAT_NUMBER:NUM4_@ [TEXT] @_FORMAT_NUMBER:NUM5_@ [TEXT] [IF] @_VAR5_@ [TEXT] NOK [ELSE] [TEXT] OK [END_IF] [TEXT] [IF] @_NO_SPACE:VAR5_@ [TEXT] OK [ELSE] [TEXT] NOK [END_IF] [TEXT] [IF] @_UPPER:NO_SPACE:VAR5_@ [TEXT] OK [ELSE] [TEXT] NOK [END_IF] libtemplates-parser-11.6.orig/regtests/tests/0091_date_time/0000755000175000017500000000000011637170657023642 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0091_date_time/test.out0000644000175000017500000000027511637170657025356 0ustar lbrentalbrenta[INFO] testme.tmplt [C_INFO] 1 FALSE [TEXT] @_DAY_NAME_@ @_MONTH_NAME_@ [TEXT] @_YEAR_@/@_MONTH_@/@_DAY_@ [TEXT] @_HOUR_@ [TEXT] @_MINUTE_@ [TEXT] @_SECOND_@ OK L1 OK L2 OK L3 OK L4 OK L5 libtemplates-parser-11.6.orig/regtests/tests/0091_date_time/test.py0000644000175000017500000000255011637170657025175 0ustar lbrentalbrentafrom test_support import * import datetime import time def check(name, current, expected): if current == expected: print "OK " + name else: print "NOK " + name + ": '" + expected + "' != '" + current + "'" def check_n(name, current, expected): v = int (current) if v == expected or v == expected - 1 or v == expected + 1: print "OK " + name else: print "NOK " + name + ": '" + str(expected) + "' != '" + current + "'" WeekDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] Months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] now = datetime.datetime.now() # Make sure we are not going to change minute in the middle of the test while now.second > 56: time.sleep(5) now = datetime.datetime.now() l1 = WeekDays[now.weekday()] + " " + Months[now.month - 1] l2 = now.strftime ("%Y/%m/%d") l3 = now.hour l4 = now.minute l5 = now.second run('testme', ["testme.tmplt"], output_file="dt.out") run('print_tree', ["testme.tmplt"]) # Now check dt.out result file = open ('dt.out') lines = file.readlines() check ("L1", lines[0][:-1], l1) check ("L2", lines[1][:-1], l2) check_n ("L3", lines[2][:-1], l3) check_n ("L4", lines[3][:-1], l4) check_n ("L5", lines[4][:-1], l5) file.close() libtemplates-parser-11.6.orig/regtests/tests/0091_date_time/testme.tmplt0000644000175000017500000000012611637170657026224 0ustar lbrentalbrenta@_DAY_NAME_@ @_MONTH_NAME_@ @_YEAR_@/@_MONTH_@/@_DAY_@ @_HOUR_@ @_MINUTE_@ @_SECOND_@ libtemplates-parser-11.6.orig/regtests/tests/0092_ftp/0000755000175000017500000000000011637170657022501 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0092_ftp/ftp.tmplt0000644000175000017500000000154611637170657024362 0ustar lbrentalbrenta GNAT Pro Server

Upload/Download (Wavefront)

Files in your repository:

@@TABLE@@ @@IF@@ ( ( @_DEPTH_@ = "+1") )
begin table @@ELSIF@@ (@_DEPTH_@ = -1)
end table @@ELSE@@
@_ITEM_@ @_DEPTH_@
begin table @@ELSIF@@ (@_DEPTH_@ = "-1") and ((@_DEPTH_@ = -1) )
end table @@ELSE@@ @_ITEM_@ @_DEPTH_@ @@END_IF@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0092_ftp/test.out0000755000175000017500000000256211637170657024221 0ustar lbrentalbrenta[INFO] ftp.tmplt [C_INFO] 1 FALSE [TEXT] [TEXT] [TEXT] GNAT Pro Server [TEXT] [TEXT] [TEXT] [TEXT] [TEXT]

Upload/Download (Wavefront)

[TEXT] [TEXT]

Files in your repository:

[TEXT] [TEXT]
[TEXT] [TEXT] [TABLE] [BLOCK] [SECTION] [IF] (@_DEPTH_@ = +1) [TEXT]
begin table [ELSE] [IF] (@_DEPTH_@ = -1) [TEXT]
end table [ELSE] [TEXT] [TEXT] [TEXT] @_ITEM_@ @_DEPTH_@ [TEXT] [TEXT] [END_IF] [END_IF] [SECTION] [IF] (@_DEPTH_@ = +1) [TEXT] begin table [ELSE] [IF] ((@_DEPTH_@ = -1) and (@_DEPTH_@ = -1)) [TEXT]
end table [ELSE] [TEXT] [TEXT] [TEXT] @_ITEM_@ @_DEPTH_@ [TEXT] [TEXT] [END_IF] [END_IF] [END_BLOCK] [END_TABLE] [TEXT] [TEXT]
[TEXT] [TEXT] [TEXT] [TEXT] libtemplates-parser-11.6.orig/regtests/tests/0092_ftp/test.py0000644000175000017500000000007511637170657024034 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["ftp.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0093_test_templates_if/0000755000175000017500000000000011637170657025424 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0093_test_templates_if/ftp.tmplt0000755000175000017500000000154611637170657027310 0ustar lbrentalbrenta GNAT Pro Server

Upload/Download (Wavefront)

Files in your repository:

@@TABLE@@ @@IF@@ ( ( @_DEPTH_@ = "+1") )
begin table @@ELSIF@@ (@_DEPTH_@ = -1)
end table @@ELSE@@ @_ITEM_@ @_DEPTH_@ @@END_IF@@ @@SECTION@@ @@IF@@ ((@_DEPTH_@ = "+1")) begin table @@ELSIF@@ (@_DEPTH_@ = "-1") and ((@_DEPTH_@ = -1) )
end table @@ELSE@@ @_ITEM_@ @_DEPTH_@ @@END_IF@@ @@END_TABLE@@
libtemplates-parser-11.6.orig/regtests/tests/0093_test_templates_if/test.out0000755000175000017500000000145311637170657027142 0ustar lbrentalbrenta GNAT Pro Server

Upload/Download (Wavefront)

Files in your repository:

titi =
begin table
tata =
end table toto = toutou =
libtemplates-parser-11.6.orig/regtests/tests/0093_test_templates_if/test.py0000644000175000017500000000012311637170657026751 0ustar lbrentalbrentafrom test_support import * gnatmake('test_templates_if') run('test_templates_if') libtemplates-parser-11.6.orig/regtests/tests/0093_test_templates_if/test_templates_if.adb0000644000175000017500000000603211637170657031610 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- Program that tests the <> templates with Ada.Text_IO; use Ada.Text_IO; with Templates_Parser; use Templates_Parser; procedure Test_Templates_If is procedure Run is Names_To_Display, References_Names, Depths : Vector_Tag; Translations : Translate_Table (1 .. 3); First_Node : Natural := 0; begin Names_To_Display := Names_To_Display & "titi"; Names_To_Display := Names_To_Display & "."; Names_To_Display := Names_To_Display & "tata"; Names_To_Display := Names_To_Display & ".."; Names_To_Display := Names_To_Display & "toto"; Names_To_Display := Names_To_Display & "toutou"; References_Names := References_Names & "titi"; References_Names := References_Names & "."; References_Names := References_Names & "tata"; References_Names := References_Names & ".."; References_Names := References_Names & "toto"; References_Names := References_Names & "toutou"; Depths := Depths & "="; Depths := Depths & "+1"; Depths := Depths & "="; Depths := Depths & "-1"; Depths := Depths & "="; Depths := Depths & "="; Translations := (Assoc ("ITEM", Names_To_Display), Assoc ("FILE_NAME", References_Names), Assoc ("DEPTH", Depths) ); Put_Line (Parse ("ftp.tmplt", Translations)); end Run; begin Run; end Test_Templates_If; libtemplates-parser-11.6.orig/regtests/tests/0093_test_templates_if/test_templates_if.gpr0000644000175000017500000000330611637170657031653 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project Test_Templates_If is for Source_Dirs use ("."); for Main use ("test_templates_if.adb"); end Test_Templates_If; libtemplates-parser-11.6.orig/regtests/tests/0094_regtst1/0000755000175000017500000000000011637170657023303 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0094_regtst1/regtst1.adb0000644000175000017500000000405711637170657025352 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Templates_Parser; use Templates_Parser; with Ada.Text_IO; use Ada.Text_IO; procedure Regtst1 is Translate : Translate_Table := (1 => Assoc ("SESSIONS_V", +"session 1" & "session 2" & "session 3"), 2 => Assoc ("KEYS_M", +(+"s1k1" & "s1k2" & "s1k3") & (+"s2k1" & "s2k2")), 3 => Assoc ("VALUES_M", +(+"s1v1" & "s1v2" & "s1v3") & (+"s2v1"))); begin Put_Line (Parse ("regtst1.thtml", Translate)); end Regtst1; libtemplates-parser-11.6.orig/regtests/tests/0094_regtst1/regtst1.gpr0000644000175000017500000000325011637170657025406 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project Regtst1 is for Source_Dirs use ("."); for Main use ("regtst1.adb"); end Regtst1; libtemplates-parser-11.6.orig/regtests/tests/0094_regtst1/regtst1.thtml0000755000175000017500000000061711637170657025755 0ustar lbrentalbrenta
------------------------
@@TABLE@@
  @@IF@@ @_EXIST:KEYS_M_@
@_SESSIONS_V_@
     @@TABLE@@
        @@IF@@ @_EXIST:KEYS_M_@
	@_KEYS_M_@	@_VALUES_M_@
        @@END_IF@@
     @@END_TABLE@@
  @@END_IF@@
@@END_TABLE@@
------------------------
@_KEYS_M_@
@_VALUES_M_@
------------------------
@@TABLE@@
@_KEYS_M_@
@_VALUES_M_@
@@END_TABLE@@
------------------------
libtemplates-parser-11.6.orig/regtests/tests/0094_regtst1/test.out0000755000175000017500000000046611637170657025024 0ustar lbrentalbrenta
------------------------
session 1
	s1k1	s1v1
	s1k2	s1v2
	s1k3	s1v3
session 2
	s2k1	s2v1
	s2k2	
------------------------
s1k1, s1k2, s1k3
s2k1, s2k2
s1v1, s1v2, s1v3
s2v1
------------------------
s1k1, s1k2, s1k3
s1v1, s1v2, s1v3
s2k1, s2k2
s2v1
------------------------
libtemplates-parser-11.6.orig/regtests/tests/0094_regtst1/test.py0000644000175000017500000000007711637170657024640 0ustar lbrentalbrentafrom test_support import * gnatmake('regtst1') run('regtst1') libtemplates-parser-11.6.orig/regtests/tests/0095_include/0000755000175000017500000000000011637170657023336 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0095_include/include.adb0000644000175000017500000000375711637170657025445 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Exceptions; with Ada.Text_IO; with Templates_Parser; procedure Include is use Ada; use Ada.Exceptions; Translations : Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("NAME", "Ada")); begin Text_IO.Put_Line (Templates_Parser.Parse ("include_1.html", Translations)); exception when E : others => Text_IO.Put_Line ("raised " & Exception_Name (E) & " : " & Exception_Message (E)); end Include; libtemplates-parser-11.6.orig/regtests/tests/0095_include/include.gpr0000644000175000017500000000325011637170657025473 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project Include is for Source_Dirs use ("."); for Main use ("include.adb"); end Include; libtemplates-parser-11.6.orig/regtests/tests/0095_include/include_1.html0000755000175000017500000000004411637170657026070 0ustar lbrentalbrenta

test @@INCLUDE@@ include_2.html libtemplates-parser-11.6.orig/regtests/tests/0095_include/include_2.html0000644000175000017500000000002111637170657026061 0ustar lbrentalbrenta

test2 @@IF@@ libtemplates-parser-11.6.orig/regtests/tests/0095_include/test.out0000644000175000017500000000016611637170657025051 0ustar lbrentalbrenta raised TEMPLATES_PARSER.TEMPLATE_ERROR : missing parameter, in include_2.html at line 3, in include_1.html at line 2 libtemplates-parser-11.6.orig/regtests/tests/0095_include/test.py0000644000175000017500000000007711637170657024673 0ustar lbrentalbrentafrom test_support import * gnatmake('include') run('include') libtemplates-parser-11.6.orig/regtests/tests/0096_tess/0000755000175000017500000000000011637170657022672 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0096_tess/lp.tmplt0000755000175000017500000000027211637170657024373 0ustar lbrentalbrenta Line @_GROUP_ACR_M'Line_@ Min @_GROUP_ACR_M'Min_Column_@ Max @_GROUP_ACR_M'Max_Column_@ === @@TABLE@@ [ @@TABLE@@ @_GROUP_ACR_M_@, @@END_TABLE@@ ] @@END_TABLE@@ === libtemplates-parser-11.6.orig/regtests/tests/0096_tess/tess.adb0000644000175000017500000004042211637170657024322 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_Io; use Ada.Text_Io; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Templates_Parser; use Templates_Parser; procedure Tess is function "+" (Str : String) return Unbounded_String renames To_Unbounded_String; type PS is array (Positive range <>, Positive range <>) of Unbounded_String; People_Set : PS := ((+"LBOZJAQjltçhox", +"187", +"13", +"Yzfihjlojz"), (+"LGFOAFhzc", +"188", +"13", +"Yzfihjlojz"), (+"LSYHBKALao", +"127", +"10", +"O27"), (+"LTPLTXHTAEjkth", +"77", +"7", +"O24"), (+"LJBLKPAGzlt-Iroaoiiz", +"56", +"6", +"O23"), (+"LKDALOJAPhfotowkz", +"39", +"5", +"O22"), (+"ELPHALYHALtbzal", +"40", +"5", +"O22"), (+"ELTBOAADhjottz", +"128", +"10", +"O27"), (+"ELJEJLKAYAIlyjods", +"129", +"3", +"O20"), (+"ELJEJLKAYAIlyjods", +"129", +"10", +"O27"), (+"ELJJLKAYAFlvofz", +"174", +"13", +"Yzfihjlojz"), (+"EZPKAIroaoiiz", +"41", +"5", +"O22"), (+"EZAAALFUAGzlt-Dalkpz", +"24", +"4", +"O21A-AODX"), (+"EZTULROLADrljlq", +"190", +"13", +"Yzfihjlojz"), (+"EZJBZAAkphmod", +"163", +"12", +"O29"), (+"EZJYRHKAGzlt-Umzx", +"109", +"3", +"O20"), (+"EZJYRHKAGzlt-Umzx", +"109", +"9", +"O26"), (+"EZJYJLTPAGkaozt", +"228", +"13", +"Yzfihjlojz"), (+"EOPLTAGzlt-Umzx", +"57", +"6", +"O23"), (+"EOZAXSOATodhalx", +"94", +"8", +"O25A-AYLOD"), (+"EOHKVAIroaoiiz", +"130", +"10", +"O27"), (+"EHDDHT-BOEHPARztju", +"95", +"8", +"O25A-AYLOD"), (+"EHPZYAIlyjods", +"42", +"5", +"O22"), (+"EHOYZLKAHaomozj", +"58", +"6", +"O23"), (+"EHFILXAQjltçhoxz", +"59", +"6", +"O23"), (+"EHKDRZAYrozjju", +"191", +"13", +"Yzfihjlojz"), (+"EHKPZMOAAZAHaomozj", +"43", +"5", +"O22"), (+"EHKJRLTOARlaofl", +"192", +"13", +"Yzfihjlojz"), (+"EJLGZKAAIroaoiiz", +"25", +"4", +"O21A-AODX"), (+"EJZYLKAYALjfzaaz", +"148", +"11", +"O28"), (+"DLJZFHAOADrjoxyolt", +"110", +"9", +"O26"), (+"DZTXOZJADlyrzjotz", +"3", +"3", +"O20"), (+"DRLELKAYADrjoxyotz", +"193", +"13", +"Yzfihjlojz"), (+"DRZMLAAOZJADlyrzjotz", +"149", +"11", +"O28"), (+"DAZFZTYAEjkth", +"44", +"5", +"O22"), (+"DHAAZYYZAUltt", +"175", +"13", +"Yzfihjlojz"), (+"DHAAOBTHTADalojz", +"131", +"10", +"O27"), (+"DHJEOZJZAEétépodyz", +"194", +"13", +"Yzfihjlojz"), (+"DHJPZAEjoboyyz", +"45", +"5", +"O22"), (+"DHJZAVlmozj", +"132", +"10", +"O27"), (+"DHXYLTCHAAlkjzty", +"133", +"10", +"O27"), (+"DHKJLKAYltbku", +"150", +"11", +"O28"), (+"DHKUJLXAPlmop", +"164", +"12", +"O29"), (+"DJOTZAAohtza", +"195", +"13", +"Yzfihjlojz"), (+"PLQQHXAMotdzty", +"165", +"12", +"O29"), (+"PLQQHXAMotdzty", +"165", +"3", +"O20"), (+"PLBKXZAYrozjju", +"60", +"6", +"O23"), (+"PZFKUTDSAFodrza", +"4", +"3", +"O20"), (+"PZJEUXROJZALttl", +"16", +"3", +"O20"), (+"PZJOZTTOD-HKJAUARéaètz", +"61", +"6", +"O23"), (+"PZXDLFIXAQjépéjod", +"166", +"12", +"O29"), (+"PZMZAZUAFljd", +"78", +"7", +"O24"), (+"PZMODADlyrzjotz", +"26", +"4", +"O21A-AODX"), (+"POLAXZUPOTLAHflj", +"176", +"13", +"Yzfihjlojz"), (+"PGZFLPOAJlaop", +"196", +"13", +"Yzfihjlojz"), (+"PHTTLPOZKVAZmzautz", +"17", +"3", +"O20"), (+"PHJFHUAGzlt-Akd", +"79", +"7", +"O24"), (+"PJHKOTALttoz", +"80", +"7", +"O24"), (+"PKEHOXAHaomozj", +"62", +"3", +"O20"), (+"PKEHOXAHaomozj", +"62", +"6", +"O23"), (+"PKYSL-FLAZTAOmlt", +"111", +"9", +"O26"), (+"PKNOBAMéjhtowkz", +"63", +"6", +"O23"), (+"ZQQLTYOTAFljd", +"151", +"11", +"O28"), (+"ZILOAALJPADrljazx", +"197", +"13", +"Yzfihjlojz"), (+"ZJRLJPAIlyjods", +"64", +"6", +"O23"), (+"QLTZJATlyrlaoz", +"134", +"10", +"O27"), (+"QLKAHYALkpjzu", +"198", +"13", +"Yzfihjlojz"), (+"QLMZJZLKAPztox", +"96", +"8", +"O25A-AYLOD"), (+"QLUHAAZAZjod", +"112", +"9", +"O26"), (+"QZEKJOZAGzlt", +"135", +"10", +"O27"), (+"QZAYZJADrjoxyolt", +"97", +"8", +"O25A-AYLOD"), (+"QHJYOZJAPZAEKTDZUAF.", +"199", +"13", +"Yzfihjlojz"), (+"QHKWKZYAYrozjju", +"65", +"6", +"O23"), (+"QJLTWKZCLAGklt", +"200", +"13", +"Yzfihjlojz"), (+"BLDHTABkoaalkfz", +"167", +"12", +"O29"), (+"BLALTALtbéaowkz", +"229", +"13", +"Yzfihjlojz"), (+"BLJDOLAZjod", +"136", +"10", +"O27"), (+"BLJDOLAPltozal", +"98", +"8", +"O25A-AYLOD"), (+"BLJCZTTZADalkpz", +"152", +"11", +"O28"), (+"BLKXXHYAGzlt-Iroaoiiz", +"113", +"9", +"O26"), (+"BLMZAAZAGzlt-Akd", +"153", +"11", +"O28"), (+"BLUJLJPAMotdzty", +"27", +"4", +"O21A-AODX"), (+"BZJLJPAAlkjzty", +"201", +"13", +"Yzfihjlojz"), (+"BOTHKVAEjkth", +"46", +"5", +"O22"), (+"BOTHKVAEjkth", +"46", +"3", +"O20"), (+"BOJLJPHYAPhfotowkz", +"137", +"10", +"O27"), (+"BHPZQJHUAMotdzty", +"99", +"8", +"O25A-AYLOD"), (+"BHUAAlkjzty", +"154", +"11", +"O28"), (+"BJLTPBKOAAHY-THUJZYAIlxdlaz", +"114", +"9", +"O26"), (+"BJZBHOJZAGzlt-Iozjjz", +"115", +"9", +"O26"), (+"BKOAAZJFOTAIlxdla", +"28", +"4", +"O21A-AODX"), (+"BKUHTAFljd", +"116", +"9", +"O26"), (+"RLLBASjoxyotl", +"203", +"13", +"Yzfihjlojz"), (+"RZJUAGzlt-Qjltçhox", +"82", +"7", +"O24"), (+"RHLJZLKAQlejodz", +"231", +"13", +"Yzfihjlojz"), (+"RHZAAOTBZJAQjltdox", +"204", +"13", +"Yzfihjlojz"), (+"RHKYYZFLTZAFojzoaaz", +"232", +"8", +"O25A-AYLOD"), (+"OJXLIHKAAZAGzlt-Plmop", +"205", +"13", +"Yzfihjlojz"), (+"GLSKEOZDAFljoz-Qjltdz", +"18", +"3", +"O20"), (+"GZLTTOTAEaltpotz", +"206", +"13", +"Yzfihjlojz"), (+"SRKDAPztox", +"207", +"13", +"Yzfihjlojz"), (+"ALDHXYZAPlmop", +"29", +"4", +"O21A-AODX"), (+"ALQLJBZAIroaoiiz", +"138", +"10", +"O27"), (+"ALQQHTYALaodz", +"83", +"7", +"O24"), (+"ALAZKQAGzlt-Dalkpz", +"84", +"7", +"O24"), (+"ALF-ROFZAFodrza", +"139", +"10", +"O27"), (+"ALFUAGzlt-Xuamzxyjz", +"155", +"11", +"O28"), (+"ALJWKZYHKVALttoz", +"19", +"3", +"O20"), (+"ALKBOZJAFlyrozk", +"208", +"13", +"Yzfihjlojz"), (+"ALKBOZJAQjépéjod", +"168", +"12", +"O29"), (+"ALKJZOAALJPAIlxdla", +"85", +"7", +"O24"), (+"AZAPZAAOHKAJlufhtpz", +"47", +"5", +"O22"), (+"AZDLJIZTYOZJAPlmop", +"156", +"11", +"O28"), (+"AZQZEMJZAMotdzty", +"117", +"9", +"O26"), (+"AZQHJYAFkjoza", +"209", +"13", +"Yzfihjlojz"), (+"AZBZJALalot", +"66", +"6", +"O23"), (+"AZBHAAAQjépéjod", +"177", +"13", +"Yzfihjlojz"), (+"AZAOZMJZALalot", +"48", +"5", +"O22"), (+"AZFZXAZAVlmozj", +"30", +"4", +"O21A-AODX"), (+"AZFHJAGzlt-Iroaoiiz", +"183", +"13", +"Yzfihjlojz"), (+"AZJHTPZAAPopozj", +"140", +"10", +"O27"), (+"AZJHKVABkoaalkfz", +"157", +"11", +"O28"), (+"AHJOZYYZAIroaoiiz", +"158", +"11", +"O28"), (+"AKDLXAGzlt-Umzx", +"67", +"6", +"O23"), (+"AKDLXAFljoz-Aotz", +"230", +"13", +"Yzfihjlojz"), (+"FLOXXZAIlxdlaz", +"20", +"3", +"O20"), (+"FLAMLBOALttz-Fljoz", +"141", +"10", +"O27"), (+"FLTQJZPOAOxlezaaz", +"21", +"3", +"O20"), (+"FLJDAJlirlëa", +"86", +"7", +"O24"), (+"FLJDZAAQlejodz", +"159", +"11", +"O28"), (+"FLJBKZYAXzjbz", +"160", +"11", +"O28"), (+"FLJOAEzjtljp", +"49", +"5", +"O22"), (+"FLXWKZAOZJAAhux", +"87", +"7", +"O24"), (+"FLXXLJYAXéelxyozt", +"178", +"13", +"Yzfihjlojz"), (+"FZJUASljof", +"210", +"13", +"Yzfihjlojz"), (+"FZKTOZJAXéelxyozt", +"211", +"13", +"Yzfihjlojz"), (+"FODRLKALjfzaaz", +"212", +"13", +"Yzfihjlojz"), (+"FOALTPJZABztzmoèmzA(DZD)", +"226", +"13", +"Yzfihjlojz"), (+"FHTPHYAIroaoiiz", +"179", +"13", +"Yzfihjlojz"), (+"FHTQHJYAFljyola", +"31", +"3", +"O20"), (+"FHTQHJYAFljyola", +"31", +"4", +"O21A-AODX"), (+"FHTOHYABéjljp", +"88", +"7", +"O24"), (+"FHJMLTYAHaomozj", +"142", +"10", +"O27"), (+"FHKFZTZASrlazp", +"213", +"13", +"Yzfihjlojz"), (+"FHKTZUAVlmozj", +"169", +"12", +"O29"), (+"FHKJHBHMALazvltpjz", +"143", +"10", +"O27"), (+"FHKYHTADrjoxyhirz", +"89", +"7", +"O24"), (+"FHKYYLILAIlyjods", +"68", +"6", +"O23"), (+"TBKUZTAIRHTBADRLKAIozjjz", +"32", +"4", +"O21A-AODX"), (+"TODHALXABéjlap", +"69", +"6", +"O23"), (+"TGHRAXlfkza", +"180", +"13", +"Yzfihjlojz"), (+"THKLOARLXAEzjtljp", +"90", +"7", +"O24"), (+"HEJUAIlxdla", +"102", +"8", +"O25A-AYLOD"), (+"HAOMOZJADujoaaz", +"214", +"13", +"Yzfihjlojz"), (+"HAOMJUAAlkjzty", +"103", +"8", +"O25A-AYLOD"), (+"HKPGLTZATlpol", +"70", +"6", +"O23"), (+"ILGHYALaotz", +"33", +"4", +"O21A-AODX"), (+"ILHAOAAHAFljyotz", +"118", +"9", +"O26"), (+"ILXYHJOTOAXzjbz", +"170", +"12", +"O29"), (+"IZBHTALttz-Dalojz", +"215", +"13", +"Yzfihjlojz"), (+"IZJJOTAGzlt", +"50", +"5", +"O22"), (+"IZYOYAFljd", +"51", +"5", +"O22"), (+"IZYOYABkoaalkfz", +"144", +"10", +"O27"), (+"IODLJPAGzlt-Qjltçhox", +"71", +"6", +"O23"), (+"IODLKAYALttz", +"52", +"5", +"O22"), (+"IOZYJZ-DLFELDZPZXAAkphmod", +"34", +"4", +"O21A-AODX"), (+"IOAAHTAEzthîy", +"72", +"6", +"O23"), (+"IALBTZAAlkjzty", +"119", +"9", +"O26"), (+"IHTDHYALtbéaowkz", +"73", +"6", +"O23"), (+"IHKAFLJ'DRAZffltkza", +"145", +"10", +"O27"), (+"IJHMZTXLAABkoaalkfz", +"216", +"13", +"Yzfihjlojz"), (+"WKLYJLOTAJodrljp", +"233", +"8", +"O25A-AYLOD"), (+"WKOTTZCAEjkth", +"146", +"10", +"O27"), (+"JLTTHKAGkaozt", +"217", +"13", +"Yzfihjlojz"), (+"JLXDAZAIlka", +"120", +"9", +"O26"), (+"JZTHKQAFojolf", +"218", +"13", +"Yzfihjlojz"), (+"JHEZJYAZjod", +"91", +"7", +"O24"), (+"JHEOTAFhtowkz", +"1", +"3", +"O20"), (+"JHPOZJZALazvltpjz", +"219", +"13", +"Yzfihjlojz"), (+"JHXZADrjoxyolt", +"121", +"9", +"O26"), (+"JHXXZYAQjltçhox-Plmop", +"171", +"12", +"O29"), (+"JHKDLUJHAAQlejodz", +"122", +"9", +"O26"), (+"JHKBOZJAGzlt-Zffltkza", +"181", +"13", +"Yzfihjlojz"), (+"JHUTZYYZALtyhotz", +"227", +"13", +"Yzfihjlojz"), (+"XLTXHTAGzlt-Akd", +"104", +"3", +"O20"), (+"XLTXHTAGzlt-Akd", +"104", +"8", +"O25A-AYLOD"), (+"XDLMLJPLADrjoxyotz", +"105", +"8", +"O25A-AYLOD"), (+"XDROQQFLTTAAupol", +"35", +"4", +"O21A-AODX"), (+"XDRFOPALalot", +"92", +"7", +"O24"), (+"XDRHZTEZJBZJAIroaoiiz", +"123", +"9", +"O26"), (+"XDRKFFALtpjélx", +"74", +"6", +"O23"), (+"XDRNLJYCADrjoxyza", +"220", +"13", +"Yzfihjlojz"), (+"XDRNLJYCATlpotz", +"147", +"10", +"O27"), (+"XDJOFLADrjoxyoltz", +"22", +"3", +"O20"), (+"XZBLKPAFljoz", +"221", +"13", +"Yzfihjlojz"), (+"XOAMOAQjépéjod", +"36", +"4", +"O21A-AODX"), (+"XHOTLJPAVlmozj", +"106", +"8", +"O25A-AYLOD"), (+"XHKQQZCAUmzx", +"124", +"9", +"O26"), (+"XYLAGzlt-Plmop", +"107", +"8", +"O25A-AYLOD"), (+"YLJJLBHALjtlkp", +"37", +"4", +"O21A-AODX"), (+"YZJMZJAFodrza", +"234", +"3", +"O20"), (+"YZJMZJAFodrza", +"234", +"7", +"O24"), (+"YZYLJYAIroaoiiz", +"161", +"11", +"O28"), (+"YRLOAMLTAPhfotowkz", +"125", +"9", +"O26"), (+"YROELKAYABkoaalkfz", +"93", +"7", +"O24"), (+"YHTTHOJAXltpjotz", +"53", +"5", +"O22"), (+"YJLMZJXHTAEjkth", +"54", +"5", +"O22"), (+"YJOSOAZjod", +"222", +"13", +"Yzfihjlojz"), (+"YKGKELAZjfolx", +"223", +"13", +"Yzfihjlojz"), (+"YKJEHKAYAQjltçhox", +"75", +"6", +"O23"), (+"MLAAZZABzhqqjhu", +"182", +"13", +"Yzfihjlojz"), (+"MLAAOZCADujoa", +"224", +"13", +"Yzfihjlojz"), (+"MLKPZXDLAAGzlt-Ahkox", +"2", +"3", +"O20"), (+"MZJBTZXAGzlt", +"5", +"3", +"O20"), (+"MOALOTAPhfotowkz", +"38", +"4", +"O21A-AODX"), (+"MOAALJPAGldwkzaotz", +"55", +"5", +"O22"), (+"MKAPUAGzlt-Ahkox", +"108", +"8", +"O25A-AYLOD"), (+"NLZDSZAAQjltçhoxz", +"162", +"3", +"O20"), (+"NLZDSZAAQjltçhoxz", +"162", +"11", +"O28"), (+"NLAAZYAXhiroz", +"23", +"3", +"O20"), (+"NLJOTAVlmozj", +"76", +"6", +"O23"), (+"ULROLHKOAXhkfzulTzxjotz", +"225", +"13", +"Yzfihjlojz"), (+"UZXXLULTALtyhotz", +"126", +"9", +"O26"), (+"UKLTALalot", +"173", +"12", +"O29")); Counter_Id : Integer; List_Lbl : Vector_Tag; List_Id : Vector_Tag; List_First_Gpp : Vector_Tag; List_Group_Id : Vector_Tag; List_Group_Acr : Vector_Tag; People_Group_Id : Matrix_Tag; People_Group_Acr : Matrix_Tag; Result : Translate_Table (1 .. 1); begin Counter_Id := 1; for I in People_Set'Range (1) loop if Counter_Id > 1 then -- Check the id if To_String (People_Set (I, 2)) = Item (List_Id, Counter_Id - 1) then -- Merge the group id in the same vector for a same -- peope id. List_Group_Acr := List_Group_Acr & To_String (People_Set (I, 4)); List_Group_Id := List_Group_Id & To_String (People_Set (I, 3)); else -- Insert groups vectors into the matrix People_Group_Id := People_Group_Id & List_Group_Id; People_Group_Acr := People_Group_Acr & List_Group_Acr; Clear (List_Group_Acr); Clear (List_Group_Id); List_Group_Acr := List_Group_Acr & To_String (People_Set (I, 4)); List_Group_Id := List_Group_Id & To_String (People_Set (I, 3)); List_Lbl := List_Lbl & To_String (People_Set (I, 1)); List_Id := List_Id & To_String (People_Set (I, 2)); List_First_Gpp := List_First_Gpp & To_String (People_Set (I, 3)); Counter_Id := Counter_Id + 1; end if; else -- First item List_Group_Acr := List_Group_Acr & To_String (People_Set (I, 4)); List_Group_Id := List_Group_Id & To_String (People_Set (I, 3)); List_Lbl := List_Lbl & To_String (People_Set (I, 1)); List_Id := List_Id & To_String (People_Set (I, 2)); List_First_Gpp := List_First_Gpp & To_String (People_Set (I, 3)); Counter_Id := Counter_Id + 1; end if; end loop; -- Last item People_Group_Id := People_Group_Id & List_Group_Id; People_Group_Acr := People_Group_Acr & List_Group_Acr; Result (1) := Assoc ("GROUP_ACR_M", People_Group_Acr); Put_Line (Parse ("lp.tmplt", Result)); end Tess; libtemplates-parser-11.6.orig/regtests/tests/0096_tess/tess.gpr0000644000175000017500000000323711637170657024367 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project tess is for Source_Dirs use ("."); for Main use ("tess.adb"); end tess; libtemplates-parser-11.6.orig/regtests/tests/0096_tess/test.out0000755000175000017500000000622611637170657024413 0ustar lbrentalbrenta Line 215 Min 1 Max 2 === [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O27, , ] [ O24, , ] [ O23, , ] [ O22, , ] [ O22, , ] [ O27, , ] [ O20, O27, ] [ Yzfihjlojz, , ] [ O22, , ] [ O21A-AODX, , ] [ Yzfihjlojz, , ] [ O29, , ] [ O20, O26, ] [ Yzfihjlojz, , ] [ O23, , ] [ O25A-AYLOD, , ] [ O27, , ] [ O25A-AYLOD, , ] [ O22, , ] [ O23, , ] [ O23, , ] [ Yzfihjlojz, , ] [ O22, , ] [ Yzfihjlojz, , ] [ O21A-AODX, , ] [ O28, , ] [ O26, , ] [ O20, , ] [ Yzfihjlojz, , ] [ O28, , ] [ O22, , ] [ Yzfihjlojz, , ] [ O27, , ] [ Yzfihjlojz, , ] [ O22, , ] [ O27, , ] [ O27, , ] [ O28, , ] [ O29, , ] [ Yzfihjlojz, , ] [ O29, O20, ] [ O23, , ] [ O20, , ] [ O20, , ] [ O23, , ] [ O29, , ] [ O24, , ] [ O21A-AODX, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O20, , ] [ O24, , ] [ O24, , ] [ O20, O23, ] [ O26, , ] [ O23, , ] [ O28, , ] [ Yzfihjlojz, , ] [ O23, , ] [ O27, , ] [ Yzfihjlojz, , ] [ O25A-AYLOD, , ] [ O26, , ] [ O27, , ] [ O25A-AYLOD, , ] [ Yzfihjlojz, , ] [ O23, , ] [ Yzfihjlojz, , ] [ O29, , ] [ Yzfihjlojz, , ] [ O27, , ] [ O25A-AYLOD, , ] [ O28, , ] [ O26, , ] [ O28, , ] [ O21A-AODX, , ] [ Yzfihjlojz, , ] [ O22, O20, ] [ O27, , ] [ O25A-AYLOD, , ] [ O28, , ] [ O26, , ] [ O26, , ] [ O21A-AODX, , ] [ O26, , ] [ Yzfihjlojz, , ] [ O24, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O25A-AYLOD, , ] [ Yzfihjlojz, , ] [ O20, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O21A-AODX, , ] [ O27, , ] [ O24, , ] [ O24, , ] [ O27, , ] [ O28, , ] [ O20, , ] [ Yzfihjlojz, , ] [ O29, , ] [ O24, , ] [ O22, , ] [ O28, , ] [ O26, , ] [ Yzfihjlojz, , ] [ O23, , ] [ Yzfihjlojz, , ] [ O22, , ] [ O21A-AODX, , ] [ Yzfihjlojz, , ] [ O27, , ] [ O28, , ] [ O28, , ] [ O23, , ] [ Yzfihjlojz, , ] [ O20, , ] [ O27, , ] [ O20, , ] [ O24, , ] [ O28, , ] [ O28, , ] [ O22, , ] [ O24, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O20, O21A-AODX, ] [ O24, , ] [ O27, , ] [ Yzfihjlojz, , ] [ O29, , ] [ O27, , ] [ O24, , ] [ O23, , ] [ O21A-AODX, , ] [ O23, , ] [ Yzfihjlojz, , ] [ O24, , ] [ O25A-AYLOD, , ] [ Yzfihjlojz, , ] [ O25A-AYLOD, , ] [ O23, , ] [ O21A-AODX, , ] [ O26, , ] [ O29, , ] [ Yzfihjlojz, , ] [ O22, , ] [ O22, , ] [ O27, , ] [ O23, , ] [ O22, , ] [ O21A-AODX, , ] [ O23, , ] [ O26, , ] [ O23, , ] [ O27, , ] [ Yzfihjlojz, , ] [ O25A-AYLOD, , ] [ O27, , ] [ Yzfihjlojz, , ] [ O26, , ] [ Yzfihjlojz, , ] [ O24, , ] [ O20, , ] [ Yzfihjlojz, , ] [ O26, , ] [ O29, , ] [ O26, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O20, O25A-AYLOD, ] [ O25A-AYLOD, , ] [ O21A-AODX, , ] [ O24, , ] [ O26, , ] [ O23, , ] [ Yzfihjlojz, , ] [ O27, , ] [ O20, , ] [ Yzfihjlojz, , ] [ O21A-AODX, , ] [ O25A-AYLOD, , ] [ O26, , ] [ O25A-AYLOD, , ] [ O21A-AODX, , ] [ O20, O24, ] [ O28, , ] [ O26, , ] [ O24, , ] [ O22, , ] [ O22, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O23, , ] [ Yzfihjlojz, , ] [ Yzfihjlojz, , ] [ O20, , ] [ O20, , ] [ O21A-AODX, , ] [ O22, , ] [ O25A-AYLOD, , ] [ O20, O28, ] [ O20, , ] [ O23, , ] [ Yzfihjlojz, , ] [ O26, , ] [ O29, , ] === libtemplates-parser-11.6.orig/regtests/tests/0096_tess/test.py0000644000175000017500000000007111637170657024221 0ustar lbrentalbrentafrom test_support import * gnatmake('tess') run('tess') libtemplates-parser-11.6.orig/regtests/tests/0097_ts_assoc/0000755000175000017500000000000011637170657023533 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0097_ts_assoc/test.out0000755000175000017500000000041411637170657025245 0ustar lbrentalbrenta----------------------------------- @_NAME1_@ @_NAME2_@ >NAME1 >NAME2 ----------------------------------- one two ----------------------------------- one @_NAME2_@ ----------------------------------- new one two ----------------------------------- @_NAME1_@ @_NAME2_@ libtemplates-parser-11.6.orig/regtests/tests/0097_ts_assoc/test.py0000644000175000017500000000010111637170657025054 0ustar lbrentalbrentafrom test_support import * gnatmake('ts_assoc') run('ts_assoc') libtemplates-parser-11.6.orig/regtests/tests/0097_ts_assoc/ts_assoc.adb0000644000175000017500000000476611637170657026036 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser.Query; procedure TS_Assoc is use Ada.Text_IO; use Templates_Parser; TS : Translate_Set; procedure Display is procedure Output (A : Association; Quit : in out Boolean) is begin Put_Line (">" & Query.Variable (A)); end Output; procedure Display_All_Assoc is new For_Every_Association (Output); begin Display_All_Assoc (TS); end Display; procedure Parse is begin Put_Line ("-----------------------------------"); Put_Line (Parse ("ts_assoc.tmplt", TS, Keep_Unknown_Tags => True)); end Parse; A : Association; begin Parse; Insert (TS, Assoc ("NAME1", "one")); Insert (TS, Assoc ("NAME2", "two")); Display; Parse; A := Get (TS, "NAME2"); Remove (TS, "NAME2"); Parse; Insert (TS, A); Insert (TS, Assoc ("NAME1", "new one")); Parse; Remove (TS, "NAME1"); Remove (TS, "NAME2"); Parse; end TS_Assoc; libtemplates-parser-11.6.orig/regtests/tests/0097_ts_assoc/ts_assoc.gpr0000644000175000017500000000325311637170657026066 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project ts_assoc is for Source_Dirs use ("."); for Main use ("ts_assoc.adb"); end ts_assoc; libtemplates-parser-11.6.orig/regtests/tests/0097_ts_assoc/ts_assoc.tmplt0000755000175000017500000000002411637170657026432 0ustar lbrentalbrenta@_NAME1_@ @_NAME2_@ libtemplates-parser-11.6.orig/regtests/tests/0098_user_filter/0000755000175000017500000000000011637170657024241 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0098_user_filter/test.out0000644000175000017500000000025111637170657025747 0ustar lbrentalbrenta tag_value [F1=tag_value] > [F1=v1] > [F1=v2] > [F1=v3] > [F2=v1/azerty+tag_value] > [F2=v2/azerty+tag_value] > [F2=v3/azerty+tag_value] tag_value .@SET. = //@SET\\ libtemplates-parser-11.6.orig/regtests/tests/0098_user_filter/test.py0000644000175000017500000000010711637170657025570 0ustar lbrentalbrentafrom test_support import * gnatmake('user_filter') run('user_filter') libtemplates-parser-11.6.orig/regtests/tests/0098_user_filter/user_filter.adb0000755000175000017500000000716011637170657027243 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2006-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser; procedure User_Filter is use Ada.Text_IO; use Templates_Parser; package LT is type Local_Tag is new Dynamic.Lazy_Tag with null record; procedure Value (Lazy_Tag : not null access Local_Tag; Var_Name : String; Translations : in out Translate_Set); end LT; Lazy : aliased LT.Local_Tag; function F1 (S : String; C : Filter_Context) return String; function F2 (S : String; P : String; C : Filter_Context) return String; function Selected (S : String; P : String; C : Filter_Context) return String; -------- -- LT -- -------- package body LT is procedure Value (Lazy_Tag : not null access Local_Tag; Var_Name : String; Translations : in out Translate_Set) is begin Insert (Translations, Assoc (Var_Name, "//" & Var_Name & "\\")); end Value; end LT; -------- -- F1 -- -------- function F1 (S : String; C : Filter_Context) return String is begin return "[F1=" & S & "]"; end F1; -------- -- F2 -- -------- function F2 (S : String; P : String; C : Filter_Context) return String is begin return "[F2=" & S & "/" & P & "+" & Get (Get (C.Translations, "STAG")) & "]"; end F2; -------------- -- Selected -- -------------- function Selected (S : String; P : String; C : Filter_Context) return String is T : Translate_Set; begin C.Lazy_Tag.Value (P, T); return S & " ." & P & ". = " & Get (Get (T, P)); end Selected; T : Tag := +"v1" & "v2" & "v3"; begin Register_Filter ("F1", F1'Unrestricted_Access); Register_Filter ("F2", F2'Unrestricted_Access); Register_Filter ("SELECTED", Selected'Unrestricted_Access); Put_Line (Parse ("user_filter.tmplt", Translate_Table' (Assoc ("STAG", "tag_value"), Assoc ("VTAG", T)), Lazy_Tag => Lazy'Unchecked_Access)); end User_Filter; libtemplates-parser-11.6.orig/regtests/tests/0098_user_filter/user_filter.gpr0000644000175000017500000000326411637170657027303 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project user_filter is for Source_Dirs use ("."); for Main use ("user_filter.adb"); end user_filter; libtemplates-parser-11.6.orig/regtests/tests/0098_user_filter/user_filter.tmplt0000755000175000017500000000020611637170657027647 0ustar lbrentalbrenta @_STAG_@ @_F1:STAG_@ @@TABLE@@ > @_F1:VTAG_@ @@END_TABLE@@ @@TABLE@@ > @_F2(azerty):VTAG_@ @@END_TABLE@@ @_SELECTED(@SET):STAG_@ libtemplates-parser-11.6.orig/regtests/tests/0099_nullset/0000755000175000017500000000000011637170657023405 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0099_nullset/nullset.adb0000644000175000017500000000343311637170657025546 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2006-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser; procedure Nullset is use Ada; use Templates_Parser; S : Translate_Set := Null_Set; begin Text_IO.Put_Line (Parse ("nullset.tmplt", S)); Insert (S, Assoc ("VAR", 1)); end Nullset; libtemplates-parser-11.6.orig/regtests/tests/0099_nullset/nullset.gpr0000644000175000017500000000325011637170657025605 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project nullset is for Source_Dirs use ("."); for Main use ("nullset.adb"); end nullset; libtemplates-parser-11.6.orig/regtests/tests/0099_nullset/nullset.tmplt0000644000175000017500000000001511637170657026151 0ustar lbrentalbrentaNull Set OK libtemplates-parser-11.6.orig/regtests/tests/0099_nullset/test.out0000644000175000017500000000001511637170657025111 0ustar lbrentalbrentaNull Set OK libtemplates-parser-11.6.orig/regtests/tests/0099_nullset/test.py0000644000175000017500000000007711637170657024742 0ustar lbrentalbrentafrom test_support import * gnatmake('nullset') run('nullset') libtemplates-parser-11.6.orig/regtests/tests/0100_include2/0000755000175000017500000000000011637170657023403 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0100_include2/include2.adb0000755000175000017500000000402111637170657025560 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser; procedure Include2 is use Ada.Text_IO; use Templates_Parser; TS : Translate_Set; begin Insert (TS, Assoc ("ONE", "un")); Insert (TS, Assoc ("TWO", "deux")); Insert (TS, Assoc ("THREE", "trois")); Put_Line (Parse ("include2_main.tmplt", TS, Cached => True)); Put_Line (Parse ("include2_main2.tmplt", TS, Cached => True)); end Include2; libtemplates-parser-11.6.orig/regtests/tests/0100_include2/include2.gpr0000644000175000017500000000325311637170657025625 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project include2 is for Source_Dirs use ("."); for Main use ("include2.adb"); end include2; libtemplates-parser-11.6.orig/regtests/tests/0100_include2/include2.tincl0000644000175000017500000000012611637170657026142 0ustar lbrentalbrenta 1 : @_$1_@ 2 : @_$2_@ 3 : @_$3_@ 1 : @_UPPER:$1_@ 2 : @_UPPER:$2_@ 3 : @_UPPER:$3_@ libtemplates-parser-11.6.orig/regtests/tests/0100_include2/include2_main.tmplt0000755000175000017500000000116711637170657027206 0ustar lbrentalbrenta ================================================================== @@INCLUDE@@ include2.tincl un deux trois ================================================================== @@INCLUDE@@ include2.tincl "un deux" trois quatre ================================================================== @@INCLUDE@@ include2.tincl @_ONE_@ @_TWO_@ trois ================================================================== @@INCLUDE@@ include2.tincl @_REVERSE:ONE_@ @_CAPITALIZE:TWO_@ trois ================================================================== @@INCLUDE@@ include2.tincl "One = @_ONE_@" "@_TWO_@ = Two" "3 = @_THREE_@ = Three" libtemplates-parser-11.6.orig/regtests/tests/0100_include2/include2_main2.tmplt0000755000175000017500000000015611637170657027265 0ustar lbrentalbrenta ------------------------------------------------------------------ @@INCLUDE@@ include2.tincl toto titi tata libtemplates-parser-11.6.orig/regtests/tests/0100_include2/test.out0000644000175000017500000000143611637170657025117 0ustar lbrentalbrenta ================================================================== 1 : un 2 : deux 3 : trois 1 : UN 2 : DEUX 3 : TROIS ================================================================== 1 : un deux 2 : trois 3 : quatre 1 : UN DEUX 2 : TROIS 3 : QUATRE ================================================================== 1 : un 2 : deux 3 : trois 1 : UN 2 : DEUX 3 : TROIS ================================================================== 1 : nu 2 : Deux 3 : trois 1 : NU 2 : DEUX 3 : TROIS ================================================================== 1 : One = un 2 : deux = Two 3 : 3 = trois = Three 1 : ONE = UN 2 : DEUX = TWO 3 : 3 = TROIS = THREE ------------------------------------------------------------------ 1 : toto 2 : titi 3 : tata 1 : TOTO 2 : TITI 3 : TATA libtemplates-parser-11.6.orig/regtests/tests/0100_include2/test.py0000644000175000017500000000010111637170657024724 0ustar lbrentalbrentafrom test_support import * gnatmake('include2') run('include2') libtemplates-parser-11.6.orig/regtests/tests/0101_not_initialized/0000755000175000017500000000000011637170657025064 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0101_not_initialized/not_initialized.adb0000644000175000017500000000504711637170657030727 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Exceptions; with Ada.Strings.Unbounded; with Ada.Text_IO; with Templates_Parser; procedure Not_Initialized is use Ada.Exceptions; use Ada.Strings.Unbounded; use Ada.Text_IO; use Templates_Parser; procedure Run1 is T1, T2 : Tag; R : Unbounded_String; TS : Translate_Set; begin T1 := T1 & T2; Insert (TS, Assoc ("VAR", T1)); R := Parse ("not_initialized.tmplt", TS); exception when E : others => Put_Line (Exception_Message (E)); end Run1; procedure Run2 is T1, T2 : Tag; R : Unbounded_String; TS : Translate_Set; begin T1 := T1 & "toto" & "titi" & "toto"; T1 := T1 & T2; Insert (TS, Assoc ("VAR", T1)); R := Parse ("not_initialized.tmplt", TS); exception when E : others => Put_Line (Exception_Message (E)); end Run2; begin Run1; Run2; end Not_Initialized; libtemplates-parser-11.6.orig/regtests/tests/0101_not_initialized/not_initialized.gpr0000644000175000017500000000330011637170657030757 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project not_initialized is for Source_Dirs use ("."); for Main use ("not_initialized.adb"); end not_initialized; libtemplates-parser-11.6.orig/regtests/tests/0101_not_initialized/not_initialized.tmplt0000755000175000017500000000002011637170657031326 0ustar lbrentalbrenta @_VAR'Length_@ libtemplates-parser-11.6.orig/regtests/tests/0101_not_initialized/test.out0000755000175000017500000000030211637170657026572 0ustar lbrentalbrentaThis attribute is not valid for a matrix tag (@_VAR'Length_@) In not_initialized.tmplt at line 2 This attribute is not valid for a matrix tag (@_VAR'Length_@) In not_initialized.tmplt at line 2 libtemplates-parser-11.6.orig/regtests/tests/0101_not_initialized/test.py0000644000175000017500000000011711637170657026414 0ustar lbrentalbrentafrom test_support import * gnatmake('not_initialized') run('not_initialized') libtemplates-parser-11.6.orig/regtests/tests/0102_regtst4/0000755000175000017500000000000011637170657023274 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0102_regtst4/regtst4.adb0000644000175000017500000000424011637170657025340 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Templates_Parser; with Ada.Text_IO; with Ada.Strings.Unbounded; procedure Regtst4 is use Ada.Strings.Unbounded; use Ada.Text_IO; use Templates_Parser; V1 : Tag := +"v11" & "v12" & "v13"; V2 : Tag := +"v21" & "v22"; V3 : Tag := +"v31" & "v32" & "v33"; Result : Unbounded_String; begin Result := Parse ("regtst4.tmplt", (1 => Assoc ("V1", V1, " - "), 2 => Assoc ("V2", V2, " $ "), 3 => Assoc ("V3", V3)), Cached => true); Put_Line (To_String (Result)); end Regtst4; libtemplates-parser-11.6.orig/regtests/tests/0102_regtst4/regtst4.gpr0000644000175000017500000000325011637170657025402 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project regtst4 is for Source_Dirs use ("."); for Main use ("regtst4.adb"); end regtst4; libtemplates-parser-11.6.orig/regtests/tests/0102_regtst4/regtst4.tmplt0000755000175000017500000000004411637170657025753 0ustar lbrentalbrenta V1: @_V1_@ V2: @_V2_@ V3: @_V3_@ libtemplates-parser-11.6.orig/regtests/tests/0102_regtst4/test.out0000644000175000017500000000006711637170657025007 0ustar lbrentalbrenta V1: v11 - v12 - v13 V2: v21 $ v22 V3: v31, v32, v33 libtemplates-parser-11.6.orig/regtests/tests/0102_regtst4/test.py0000644000175000017500000000007711637170657024631 0ustar lbrentalbrentafrom test_support import * gnatmake('regtst4') run('regtst4') libtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/0000755000175000017500000000000011637170657023325 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/dynamic.adb0000755000175000017500000000401611637170657025425 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser; with Test_Callback; procedure Dynamic is use Ada; Dynamic : aliased Test_Callback.Log_Context; Translations : Templates_Parser.Translate_Table := (1 => Templates_Parser.Assoc ("NAME", "Ada")); begin Text_IO.Put_Line (Templates_Parser.Parse ("dynamic.tmplt", Translations, Lazy_Tag => Dynamic'Unchecked_Access)); end Dynamic; libtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/dynamic.gpr0000644000175000017500000000325011637170657025463 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project dynamic is for Source_Dirs use ("."); for Main use ("dynamic.adb"); end dynamic; libtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/dynamic.tmplt0000755000175000017500000000021311637170657026032 0ustar lbrentalbrenta Table level: @_TABLE_LEVEL_@ @_NAME_@ @@IF@@ @_EXIST:VAR_@ @_VAR_@ @@END_IF@@ @@IF@@ @_EXIST:NO_DYNAMIC:VAR_@ @_VAR_@ @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/test.out0000644000175000017500000000005111637170657025031 0ustar lbrentalbrentaTag VAR missing. Table level: 0 Ada libtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/test.py0000644000175000017500000000007711637170657024662 0ustar lbrentalbrentafrom test_support import * gnatmake('dynamic') run('dynamic') libtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/test_callback.adb0000644000175000017500000001063111637170657026571 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; package body Test_Callback is --------------- -- Dimension -- --------------- overriding function Dimension (C : not null access Cursor_Tag; Var : String) return Natural is begin if Var = "CURSOR" then return 2; elsif Var = "C_MAT3" then return 3; else return 0; end if; end Dimension; ------------ -- Length -- ------------ overriding function Length (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return Natural is begin if Var = "CURSOR" then if Path'Length = 1 then return 3; elsif Path'Length /= 2 then raise Constraint_Error; else return Path (Path'Last); end if; elsif Var = "C_MAT3" then if Path'Length = 1 then return 3; elsif Path'Length = 2 then return 2; elsif Path'Length /= 3 then raise Constraint_Error; else return Path (Path'Last) + 2; end if; else return 0; end if; end Length; -------------- -- Callback -- -------------- overriding procedure Value (L : not null access Lazy_Tag; Var : String; S : in out Templates_Parser.Translate_Set) is use Templates_Parser; begin if Var = "VAR1" then Insert (S, Assoc ("VAR1", "Callback value")); elsif Var = "DYNAMIC" then Insert (S, Assoc ("DYNAMIC", "This is a dynamic tag")); elsif Var = "N" then Insert (S, Assoc ("N", Integer'Image (L.N))); L.N := L.N + 1; elsif Var = "DYN_VECT" then Insert (S, Assoc ("DYN_VECT", +"12" & "89" & "90" & "2")); elsif Var = "TMPLT_NAME" then Insert (S, Assoc (Var, +"incl.tmplt")); end if; end Value; overriding procedure Value (L : not null access Log_Context; Var : String; S : in out Templates_Parser.Translate_Set) is pragma Unreferenced (L, S); begin Ada.Text_IO.Put_Line ("Tag " & Var & " missing."); end Value; overriding function Value (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return String is begin if Var = "CURSOR" then if Path'Length = 2 then return "CT" & Path (Path'First)'Img & Path (Path'First + 1)'Img; else raise Constraint_Error; end if; elsif Var = "C_MAT3" then if Path'Length = 3 then return "CMAT" & Path (Path'First)'Img & Path (Path'First + 1)'Img & Path (Path'First + 2)'Img; else raise Constraint_Error; end if; else raise Constraint_Error; end if; end Value; end Test_Callback; libtemplates-parser-11.6.orig/regtests/tests/0103_dynamic/test_callback.ads0000644000175000017500000000521611637170657026615 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Templates_Parser; package Test_Callback is type Lazy_Tag is new Templates_Parser.Dynamic.Lazy_Tag with private; overriding procedure Value (L : not null access Lazy_Tag; Var : String; S : in out Templates_Parser.Translate_Set); type Log_Context is new Templates_Parser.Dynamic.Lazy_Tag with null record; overriding procedure Value (L : not null access Log_Context; Var : String; S : in out Templates_Parser.Translate_Set); type Cursor_Tag is new Templates_Parser.Dynamic.Cursor_Tag with null record; overriding function Dimension (C : not null access Cursor_Tag; Var : String) return Natural; overriding function Length (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return Natural; overriding function Value (C : not null access Cursor_Tag; Var : String; Path : Templates_Parser.Dynamic.Path) return String; private type Lazy_Tag is new Templates_Parser.Dynamic.Lazy_Tag with record N : Natural := 0; end record; end Test_Callback; libtemplates-parser-11.6.orig/regtests/tests/0104_regtst2/0000755000175000017500000000000011637170657023274 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0104_regtst2/error.tmplt0000755000175000017500000000016211637170657025511 0ustar lbrentalbrenta libtemplates-parser-11.6.orig/regtests/tests/0104_regtst2/regtst2.adb0000644000175000017500000000626011637170657025342 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2007 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Templates_Parser; with Ada.Text_IO; with Ada.Strings.Unbounded; with Ada.Strings.Fixed; with Ada.Task_Identification; with Ada.Exceptions; procedure Regtst2 is use Ada.Strings.Unbounded; use Ada.Text_IO; use Templates_Parser; task type Parser is pragma Storage_Size (100_000); end Parser; protected Start_Line is procedure Start; entry Wait; private State : Boolean := False; end Start_Line; protected body Start_Line is procedure Start is begin State := True; end; entry Wait when State is begin null; end; end Start_Line; task body Parser is use Ada.Strings.Fixed; use Ada.Task_Identification; B : constant Boolean := False; Result : Unbounded_String; Last_Error_Code : constant Integer := 12345; Task_Image : constant String := Image (Current_Task); Short_Error_Message : String renames Task_Image; Error_Message : constant String := 140 * (Short_Error_Message & ASCII.LF); begin Start_Line.Wait; Result := Parse ("error.tmplt", (1 => Assoc ("CODE", Last_Error_Code), 2 => Assoc ("MESSAGE", Short_Error_Message), 3 => Assoc ("DETAIL", Error_Message)), Cached => True); exception when E : others => Put_Line (Ada.Exceptions.Exception_Information (E)); end; Parsers : array (1 .. 20) of Parser; begin delay 1.0; Start_Line.Start; Put_Line ("OK"); end Regtst2; libtemplates-parser-11.6.orig/regtests/tests/0104_regtst2/regtst2.gpr0000644000175000017500000000325011637170657025400 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project regtst2 is for Source_Dirs use ("."); for Main use ("regtst2.adb"); end regtst2; libtemplates-parser-11.6.orig/regtests/tests/0104_regtst2/test.out0000644000175000017500000000000311637170657024775 0ustar lbrentalbrentaOK libtemplates-parser-11.6.orig/regtests/tests/0104_regtst2/test.py0000644000175000017500000000007711637170657024631 0ustar lbrentalbrentafrom test_support import * gnatmake('regtst2') run('regtst2') libtemplates-parser-11.6.orig/regtests/tests/0105_regtst3/0000755000175000017500000000000011637170657023276 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0105_regtst3/aws_status.thtml0000755000175000017500000000042511637170657026551 0ustar lbrentalbrenta

------------------------
@@TABLE@@
  @@IF@@ @_EXIST:KEYS_M_@
@_SESSIONS_V_@
     @@TABLE@@
        @@IF@@ @_EXIST:KEYS_M_@
	@_KEYS_M_@	@_VALUES_M_@
        @@END_IF@@
     @@END_TABLE@@
  @@END_IF@@
@@END_TABLE@@
------------------------
libtemplates-parser-11.6.orig/regtests/tests/0105_regtst3/regtst3.adb0000644000175000017500000000446411637170657025351 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Templates_Parser; with Ada.Text_IO; with Ada.Strings.Unbounded; procedure Regtst3 is use Ada.Strings.Unbounded; use Ada.Text_IO; use Templates_Parser; V1 : Vector_Tag := +"v11" & "v12" & "v13"; V2 : Vector_Tag := +"v21" & "v22"; V3 : Vector_Tag := +"v31"; V4 : Vector_Tag := +"v41"; V5 : Vector_Tag; K : Matrix_Tag := +V5; V : Matrix_Tag := +V2; Result : Unbounded_String; begin Result := Parse ("aws_status.thtml", (1 => Assoc ("KEYS_M", K), 2 => Assoc ("VALUES_M", V), 3 => Assoc ("SESSIONS_V", V1)), Cached => true); Put_Line ("Result : " & To_String (Result)); end Regtst3; libtemplates-parser-11.6.orig/regtests/tests/0105_regtst3/regtst3.gpr0000644000175000017500000000325011637170657025403 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project regtst3 is for Source_Dirs use ("."); for Main use ("regtst3.adb"); end regtst3; libtemplates-parser-11.6.orig/regtests/tests/0105_regtst3/test.out0000755000175000017500000000014211637170657025006 0ustar lbrentalbrentaResult :
------------------------
------------------------
libtemplates-parser-11.6.orig/regtests/tests/0105_regtst3/test.py0000644000175000017500000000007711637170657024633 0ustar lbrentalbrentafrom test_support import * gnatmake('regtst3') run('regtst3') libtemplates-parser-11.6.orig/regtests/tests/0106_test_cache/0000755000175000017500000000000011637170657024006 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0106_test_cache/incl.tmplt0000644000175000017500000000003211637170657026010 0ustar lbrentalbrentaagain a new include file libtemplates-parser-11.6.orig/regtests/tests/0106_test_cache/test.out0000644000175000017500000000005311637170657025514 0ustar lbrentalbrenta again a new include file one, two, three libtemplates-parser-11.6.orig/regtests/tests/0106_test_cache/test.py0000644000175000017500000000010711637170657025335 0ustar lbrentalbrentafrom test_support import * run('testme', ["testme76.tmplt", "cache"]) libtemplates-parser-11.6.orig/regtests/tests/0106_test_cache/testme76.tmplt0000644000175000017500000000004611637170657026546 0ustar lbrentalbrenta @@INCLUDE@@ @_TMPLT_NAME_@ @_VAR3_@ libtemplates-parser-11.6.orig/regtests/tests/0107_translations_demo/0000755000175000017500000000000011637170657025432 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0107_translations_demo/test.out0000644000175000017500000000263611637170657027151 0ustar lbrentalbrenta ONE 1 TABLE les a et les b A/B Année 11a1 12a2 13a3 21b1 22b2 23b3 VAR le label un essai TWO 2 10 10 11 11 OK libtemplates-parser-11.6.orig/regtests/tests/0107_translations_demo/test.py0000644000175000017500000000226011637170657026763 0ustar lbrentalbrentafrom test_support import * Current = "EndTag" def set_start(str): global Current if str.find("SimpleTag") != -1: Current = "SimpleTag" elif str.find("CompositeTag") != -1: Current = "CompositeTag" else: Current = "EndTag" def is_end(str): global Current if Current == "SimpleTag": return str.find("") != -1 elif Current == "CompositeTag": return str.find("") != -1 else: return True def filter(infile): file = open(infile) lines = file.readlines() file.close() txt = [] # Copy headers txt.append(lines[0][:-1]) txt.append(lines[1][:-1]) l=2 data="" while l < len(lines): v=lines[l][:-1] data = data + v.translate(None, ' ') set_start(v) l=l+1 while not is_end(v) and l < len(lines): v=lines[l][:-1] l=l+1 data = data + v.translate(None, ' ') txt.append(data) data="" return txt.sort() gnatmake('translations_demo') run('translations_demo') res1 = filter("ts.xml") res2 = filter("tsr.xml") if res1 == res2: print "OK" else: print "NOK" libtemplates-parser-11.6.orig/regtests/tests/0107_translations_demo/translations_demo.adb0000644000175000017500000000550311637170657031632 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2008, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; with Ada.Text_IO; with Templates_Parser.XML; procedure Translations_Demo is use Ada.Strings.Unbounded; use Templates_Parser; TS, TSR : Translate_Set; TA : Tag; TB : Tag; T : Tag; L1, L2 : Tag; begin TA := +"a1" & "a2" & "a3"; TB := +"b1" & "b2" & "b3"; T := +TA & TB; L1 := +"les A" & "les B"; L2 := +"2001" & "2002" & "2003"; Insert (TS, Assoc ("ONE", 1)); Insert (TS, Assoc ("TWO", 2)); Insert (TS, Assoc ("VAR", "un essai")); Insert (TS, Assoc ("VAR_DESCRIPTION", "le label")); Insert (TS, Assoc ("TABLE", T)); Insert (TS, Assoc ("TABLE_DESCRIPTION", "les a et les b")); Insert (TS, Assoc ("TABLE_DIM1_DESCRIPTION", "A/B")); Insert (TS, Assoc ("TABLE_DIM2_DESCRIPTION", "Année")); Insert (TS, Assoc ("TABLE_DIM1_LABELS", L1)); Insert (TS, Assoc ("TABLE_DIM2_LABELS", L2)); Ada.Text_IO.Put_Line (To_String (XML.Image (TS))); XML.Save ("ts.xml", TS); TSR := XML.Load ("ts.xml"); XML.Save ("tsr.xml", TSR); Ada.Text_IO.Put_Line (Integer'Image (Size (TS)) & Integer'Image (Size (TSR))); TS := TSR & Assoc ("ONE", 1) & Assoc ("TWO", 2) & Assoc ("THREE", 3); Ada.Text_IO.Put_Line (Integer'Image (Size (TS)) & Integer'Image (Size (TSR))); end Translations_Demo; libtemplates-parser-11.6.orig/regtests/tests/0107_translations_demo/translations_demo.gpr0000644000175000017500000000332511637170657031674 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; with "xmlada"; project translations_demo is for Source_Dirs use ("."); for Main use ("translations_demo.adb"); end translations_demo; libtemplates-parser-11.6.orig/regtests/tests/0108_t2a/0000755000175000017500000000000011637170657022374 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0108_t2a/localtempl.tads0000644000175000017500000002606311637170657025414 0ustar lbrentalbrenta@@-- This template is intended as a model of how to generate an Ada package @@-- describing all the variables used in a set of AWS templates. @@-- These Ada packages can then be used in your application to avoid @@-- hard-coded strings, and help maintain the templates and the code to @@-- parse them in sync. @@-- @@-- This template contains two possible behaviors, chosen through the @@-- following variable: @@SET@@ SINGLE_FILE = False @@-- If you set it to True, then a single Ada package with its nested @@-- packages is generated. If you set it to False, then the file generated @@-- should be further processed through gnatchop, to generate several @@-- Ada files organized into several files. This latter organization @@-- avoids recompiling all your source files every time at least one @@-- template changes. @@-- @@-- The following variable should be changed to set the name of the @@-- generated packages. @@SET@@ PACKAGE = Templates @@-- @@-- @@-- When designing your own template for Ada packages, you should take @@-- into account that the variables in your templates might not necessarily @@-- be valid Ada identifier names, and you should therefore update the calls @@-- to @_REPLACE:..._@ below. @@-- @@-- This template example also assumes a convention for Lazy_Tags. If you @@-- are using such types, they are generally shared among templates, and @@-- the Ada package should reflect that fact. Assuming all such tags start @@-- with the prefix LAZY_, we generate one special package for them, and @@-- omit them in all the other packages. @@-- @@-- Likewise, the templates2ada tool will not generate tag entries for tags @@-- that are set through a @@SET@@ statement, since these are purely internal @@-- to your template file and have no impact on your source code. @@-- @@-- For the best use of this tool, it is recommended that your template not @@-- use @@INCLUDE@@ statements, but instead use a tag, set in the Ada code @@-- to the preprocessed result of the same template file. This allows you to @@-- better control unset tags. For instance, instead of using: @@-- @@INCLUDE@@ foo.thtml @@-- use something like: @@-- @_BLOCK_FOO_@ @@-- and in your Ada code set BLOCK_FOO to the result of Parse ("foo.thtml"). @@-- @@-- The templates2ada tool is able to generate constants for the HTTP @@-- parameters set in your page, so that you can process them in your Ada @@-- code. A few conventions must be followed, however: @@-- - The name should be on a single line, preceded by "name=", as in @@-- name="FOO" @@-- - The name should use only letters, underscores and digits, unless you @@-- enhance the regular expressions below to also remove other special @@-- characters. @@-- - In some cases, you must use a AWS tag in the name of an HTTP param, @@-- for instance for checkboxes for which names should be unique (or you @@-- won't know when the parameter is set to false). In this case, the @@-- tag must be at the beginning or end of the name, not in the middle. @@-- If there are multiple tags, they should be separated by non-letters, @@-- as in: @@-- name="PN_@_TAG1_@:@_TAG2_" @@-- In this case, the following constant is generated: @@-- PN_Prefix : constant String := "PN"; @@-- - The name mustn't be only an AWS tag. The following is invalid: @@-- name="@_TAG_@" @@-- To avoid generating constants for , you must put the name @@-- attribute right after the "

@_SET_VAR_@

@_LAZY_BLOCK_@ libtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/0000755000175000017500000000000011637170657023622 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/check_mem.adb0000644000175000017500000000561211637170657026211 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2008, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Command_Line; with Ada.Strings.Unbounded; with Ada.Text_Io; with Templates_Parser.XML; procedure Check_Mem is use Ada; use Ada.Strings.Unbounded; use Ada.Text_IO; use Templates_Parser; procedure Run is T1, T2, T, M : Tag; Translations : Translate_Table (1 .. 4); Result : Unbounded_String; TS : Translate_Set; TC : Tag; begin TC := +"1" & "2" & "3" & "4" & "5" & "6" & "7" & "8" & "9"; T1 := T1 & "first value"; T1 := T1 & "second value"; T2 := T2 & 1; T2 := T2 & 2; T := +T1; T := T & T2; M := +T & T & T & T & T & T; TC := M; TC := T1; Translations := (1 => Assoc ("VAR", "Value"), 2 => Assoc ("T1", T1), 3 => Assoc ("T2", T2), 4 => Assoc ("T", T)); Result := Parse ("check_mem.tmplt", Translations); Put_Line ("============================="); Put_Line (To_String (Result)); New_Line; XML.Save ("m.xml", To_Set (Translations)); TS := XML.Load ("m.xml"); end Run; begin if Command_Line.Argument_Count = 1 then for K in 1 .. Positive'Value (Command_Line.Argument (1)) loop Put_Line ("Run" & Positive'Image (K)); Run; end loop; else Put_Line ("Usage: check_mem "); end if; end Check_Mem; libtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/check_mem.gpr0000644000175000017500000000356111637170657026254 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; with "xmlada"; project check_mem is for Source_Dirs use ("."); for Main use ("check_mem.adb"); package Builder is for Default_Switches ("Ada") use ("-g"); end Builder; package Linker is for Default_Switches ("Ada") use ("-g", "-lgmem"); end Linker; end check_mem; libtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/check_mem.tmplt0000644000175000017500000000075311637170657026624 0ustar lbrentalbrenta@@MACRO(M1)@@ _ (@_$1_@) _ @@END_MACRO@@ @@-- @@INCLUDE@@ include2.tincl "toto titi" deux three V : @_VAR_@ M1: @_M1(12)_@ M2: @_M1(toto)_@ ---------------------- @@TABLE@@ 1: @UPPER:_T1_@ 2: @_T2_@ T: @_T_@ @@END_TABLE@@ ---------------------- @@TABLE@@ @@TABLE@@ 1: @_T1_@ 2: @_T2_@ T: @LOWER:_T_@ @@END_TABLE@@ @@END_TABLE@@ ---------------------- @@TABLE@@ --- @@BEGIN@@ dans la table @_VAR3_@ @@SECTION@@ in the table @_VAR3_@ @@END@@ partie commune @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/include2.tincl0000755000175000017500000000012611637170657026364 0ustar lbrentalbrenta 1 : @_$1_@ 2 : @_$2_@ 3 : @_$3_@ 1 : @_UPPER:$1_@ 2 : @_UPPER:$2_@ 3 : @_UPPER:$3_@ libtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/test.opt0000644000175000017500000000004411637170657025323 0ustar lbrentalbrentadarwin DEAD "gnatmem not supported" libtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/test.out0000644000175000017500000000000311637170657025323 0ustar lbrentalbrentaOK libtemplates-parser-11.6.orig/regtests/tests/0109_check_mem/test.py0000644000175000017500000000174211637170657025157 0ustar lbrentalbrentafrom test_support import * def print_file(content): for line in content: print line # Build driver gnatmake('check_mem') # Run driver (2 loops) run('check_mem', ['2'], output_file='check_mem.res1') run('gnatmem', ['3', '-i', 'gmem.out', './check_mem', "2"], output_file='check_mem.run1') # Run driver (30 loops) run('check_mem', ['30'], output_file='check_mem.res2') run('gnatmem', ['3', '-i', 'gmem.out', './check_mem', "30"], output_file='check_mem.run2') # Now check that final water-mark for run1 and run2 is equal r1 = open ('check_mem.run1').readlines() r2 = open ('check_mem.run2').readlines() fr1 = "1" fr2 = "2" for item in r1: if item[0:8] == " Final": fr1 = item; for item in r2: if item[0:8] == " Final": fr2 = item; if fr1 != fr2: print "NOK" print "run 1 ---------------" print_file (r1) print "run 2 ---------------" print_file (r2) sys.exit(1) else: print "OK" sys.exit(0) libtemplates-parser-11.6.orig/regtests/tests/0110_test_tag/0000755000175000017500000000000011637170657023511 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0110_test_tag/test.out0000644000175000017500000000023011637170657025214 0ustar lbrentalbrentaT1'Length = 3 T2'Length = 3 T1 = (N= 3, Min= 1, Max= 1, Nested_Level= 1 1 2 3 ) T2 = (N= 3, Min= 1, Max= 1, Nested_Level= 1 1 2 3 ) libtemplates-parser-11.6.orig/regtests/tests/0110_test_tag/test.py0000644000175000017500000000011311637170657025035 0ustar lbrentalbrentafrom test_support import * import os gnatmake('test_tag') run('test_tag') libtemplates-parser-11.6.orig/regtests/tests/0110_test_tag/test_tag.adb0000755000175000017500000000412011637170657025773 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Templates_Parser.Debug; procedure Test_Tag is use Ada; use Templates_Parser; T1, T2 : Tag; begin T1 := +"1" & "2"; T2 := T1; T1 := T1 & "3"; Text_IO.Put_Line ("T1'Length = " & Natural'Image (Size (T1))); Text_IO.Put_Line ("T2'Length = " & Natural'Image (Size (T2))); Text_IO.Put ("T1 = "); Debug.Print (T1); Text_IO.New_Line; Text_IO.Put ("T2 = "); Debug.Print (T2); Text_IO.New_Line; end Test_Tag; libtemplates-parser-11.6.orig/regtests/tests/0110_test_tag/test_tag.gpr0000644000175000017500000000325311637170657026040 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project test_tag is for Source_Dirs use ("."); for Main use ("test_tag.adb"); end test_tag; libtemplates-parser-11.6.orig/regtests/tests/0111_speed/0000755000175000017500000000000011637170657023000 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0111_speed/speed.adb0000755000175000017500000000540011637170657024552 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Calendar; with Ada.Strings.Unbounded; with Ada.Text_IO; with Templates_Parser; procedure Speed is use Ada; use Ada.Strings.Unbounded; use Templates_Parser; use type Calendar.Time; Str : constant String := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" & "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" & "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"; Start, Stop : Calendar.Time; Elaps1, Elaps2 : Duration; --------- -- Job -- --------- procedure Job (N : Positive) is V : Vector_Tag; T : Translate_Table (1 .. 1); R : Unbounded_String; begin for K in 1 .. N loop V := V & Str; end loop; T (1) := Assoc ("V", V); R := Parse ("speed.tmplt", T); end Job; begin Start := Calendar.Clock; Job (4_000); Stop := Calendar.Clock; Elaps1 := Stop - Start; Start := Calendar.Clock; Job (40_000); Stop := Calendar.Clock; Elaps2 := Stop - Start; if Elaps2 < (Elaps1 * 30) then Text_Io.Put_Line ("OK"); else Text_IO.Put_Line ("NOK: " & Duration'Image (Elaps1 * 30) & " < " & Elaps2'Img); end if; end Speed; libtemplates-parser-11.6.orig/regtests/tests/0111_speed/speed.gpr0000644000175000017500000000324211637170657024613 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project speed is for Source_Dirs use ("."); for Main use ("speed.adb"); end speed; libtemplates-parser-11.6.orig/regtests/tests/0111_speed/speed.tmplt0000755000175000017500000000005311637170657025163 0ustar lbrentalbrenta Speed test @@TABLE@@ @_V_@ @@END_TABLE@@ libtemplates-parser-11.6.orig/regtests/tests/0111_speed/test.out0000755000175000017500000000000311637170657024504 0ustar lbrentalbrentaOK libtemplates-parser-11.6.orig/regtests/tests/0111_speed/test.py0000644000175000017500000000007311637170657024331 0ustar lbrentalbrentafrom test_support import * gnatmake('speed') run('speed') libtemplates-parser-11.6.orig/regtests/tests/0112_macro/0000755000175000017500000000000011637170657023002 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0112_macro/macro.tmplt0000644000175000017500000000032411637170657025164 0ustar lbrentalbrenta@@MACRO(MNAME)@@ this text : @_$1_@ @@END_MACRO@@ > macro for 8 : @_MNAME(8)_@ < > macro for none : @_MNAME()_@ < > macro for xyz : @_MNAME(xyz)_@ < > macro for var ONE : @_MNAME(@_ONE_@)_@ < libtemplates-parser-11.6.orig/regtests/tests/0112_macro/test.out0000644000175000017500000000060611637170657024514 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] > macro for 8 : this text : 8 < [TEXT] > macro for none : this text : < [TEXT] > macro for xyz : this text : xyz < [TEXT] > macro for var ONE : @_MNAME(@_ONE_@)_@ < > macro for 8 : this text : 8 < > macro for none : this text : < > macro for xyz : this text : xyz < > macro for var ONE : this text : 1 < libtemplates-parser-11.6.orig/regtests/tests/0112_macro/test.py0000644000175000017500000000013611637170657024333 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0113_macro2/0000755000175000017500000000000011637170657023065 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0113_macro2/macro.tmplt0000644000175000017500000000036611637170657025255 0ustar lbrentalbrenta@@MACRO(MACRO)@@ @@SET@@ FIRST=$1 @@SET@@ SECOND=$2 @@SET@@ THIRD=$3|defval @@IF@@ @_FIRST_@ = 1 only second @_SECOND_@ @@ELSE@@ both @_FIRST_@ and @_SECOND_@ @@END_IF@@ finally : @_THIRD_@ @@END_MACRO@@ -- @_MACRO(2,3)_@ -- @_MACRO(1,5,99)_@ -- libtemplates-parser-11.6.orig/regtests/tests/0113_macro2/test.out0000644000175000017500000000026411637170657024577 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] -- [TEXT] @_MACRO(2,3)_@ [TEXT] -- [TEXT] @_MACRO(1,5,99)_@ [TEXT] -- -- both 2 and 3 finally : defval -- only second 5 finally : 99 -- libtemplates-parser-11.6.orig/regtests/tests/0113_macro2/test.py0000644000175000017500000000013611637170657024416 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0114_macro3/0000755000175000017500000000000011637170657023067 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0114_macro3/macro.tmplt0000644000175000017500000000022611637170657025252 0ustar lbrentalbrenta@@MACRO(MACRO)@@ @@IF@@ @_$1_@ = 1 only second @_$2_@ @@ELSE@@ both @_$1_@ and @_$2_@ @@END_IF@@ @@END_MACRO@@ -- @_MACRO(2,3)_@ -- @_MACRO(1,5)_@ -- libtemplates-parser-11.6.orig/regtests/tests/0114_macro3/test.out0000644000175000017500000000022011637170657024571 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] -- [TEXT] both 2 and 3 [TEXT] -- [TEXT] only second 5 [TEXT] -- -- both 2 and 3 -- only second 5 -- libtemplates-parser-11.6.orig/regtests/tests/0114_macro3/test.py0000644000175000017500000000013611637170657024420 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0115_macro4/0000755000175000017500000000000011637170657023071 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0115_macro4/macro.tmplt0000644000175000017500000000040411637170657025252 0ustar lbrentalbrenta@@MACRO(MACRO1)@@ @@IF@@ @_$1_@ = 1 only second @_$2_@ @@ELSE@@ both @_$1_@ and @_$2_@ @@END_IF@@ @@END_MACRO@@ @@-- @@MACRO(MACRO2)@@ Some text @_$1_@ @_MACRO1(@_$2_@,@_$1_@)_@ End of macro2 @_$2_@ @@END_MACRO@@ -- @_MACRO2(2,3)_@ -- @_UPPER:MACRO2(5,1)_@ -- libtemplates-parser-11.6.orig/regtests/tests/0115_macro4/test.out0000644000175000017500000000032311637170657024577 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] -- [TEXT] @_MACRO2(2,3)_@ [TEXT] -- [TEXT] @_UPPER:MACRO2(5,1)_@ [TEXT] -- -- Some text 2 both 3 and 2 End of macro2 3 -- SOME TEXT 5 ONLY SECOND 5 END OF MACRO2 1 -- libtemplates-parser-11.6.orig/regtests/tests/0115_macro4/test.py0000644000175000017500000000013611637170657024422 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0116_user_macro/0000755000175000017500000000000011637170657024044 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0116_user_macro/test.out0000644000175000017500000000016511637170657025556 0ustar lbrentalbrenta-- this is macro1 23, tag_value -- [MACRO2](5,1) -- [macro2](maison,ada) -- [MACRO2](TAG_VALUE,ADA) -- [MACRO3]() -- libtemplates-parser-11.6.orig/regtests/tests/0116_user_macro/test.py0000644000175000017500000000010511637170657025371 0ustar lbrentalbrentafrom test_support import * gnatmake('user_macro') run('user_macro') libtemplates-parser-11.6.orig/regtests/tests/0116_user_macro/user_macro.adb0000644000175000017500000000441311637170657026655 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; with Ada.Text_IO; with Templates_Parser; procedure User_Macro is use Ada.Strings.Unbounded; use Ada.Text_IO; use Templates_Parser; function UM (Name : String; Parameters : Parameter_Set) return String is P : Unbounded_String; begin for K in Parameters'Range loop Append (P, Parameters (K)); if K /= Parameters'Last then Append (P, ","); end if; end loop; return '[' & Name & ']' & '(' & To_String (P) & ')'; end UM; begin Register_Macro_Handler (UM'Unrestricted_Access); Put_Line (Parse ("user_macro.tmplt", Translate_Table' (1 => Assoc ("STAG", "tag_value")))); end User_Macro; libtemplates-parser-11.6.orig/regtests/tests/0116_user_macro/user_macro.gpr0000644000175000017500000000326111637170657026717 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "templates_parser"; project user_macro is for Source_Dirs use ("."); for Main use ("user_macro.adb"); end user_macro; libtemplates-parser-11.6.orig/regtests/tests/0116_user_macro/user_macro.tmplt0000644000175000017500000000027211637170657027266 0ustar lbrentalbrenta@@MACRO(MACRO1)@@ this is macro1 @_$1_@, @_STAG_@ @@END_MACRO@@ -- @_MACRO1(23)_@ -- @_MACRO2(5,1)_@ -- @_LOWER:MACRO2(MAISON,Ada)_@ -- @_UPPER:MACRO2(@_STAG_@,Ada)_@ -- @_MACRO3()_@ -- libtemplates-parser-11.6.orig/regtests/tests/0117_macro5/0000755000175000017500000000000011637170657023074 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0117_macro5/macro.tmplt0000644000175000017500000000034711637170657025263 0ustar lbrentalbrenta@@MACRO(MACRO)@@ @@IF@@ @_$1_@ = 1 only second @_$2_@ @@ELSE@@ both @_$1_@ and @_$2_@ @@END_IF@@ Named and Optional: 3:(@_$3_@) 5:(@_$5_@) 8:(@_$8_@) @@END_MACRO@@ -- @_MACRO(2,3,3=>trois)_@ -- @_MACRO(1,5,5=>cinq, 8 => huit)_@ -- libtemplates-parser-11.6.orig/regtests/tests/0117_macro5/test.out0000644000175000017500000000040211637170657024600 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] -- [TEXT] @_MACRO(2,3,trois)_@ [TEXT] -- [TEXT] @_MACRO(1,5, 5 => cinq, 8 => huit)_@ [TEXT] -- -- both 2 and 3 Named and Optional: 3:(trois) 5:() 8:() -- only second 5 Named and Optional: 3:() 5:(cinq) 8:(huit) -- libtemplates-parser-11.6.orig/regtests/tests/0117_macro5/test.py0000644000175000017500000000013611637170657024425 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0118_macro6/0000755000175000017500000000000011637170657023076 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0118_macro6/ajax_api.tjs0000644000175000017500000000627311637170657025404 0ustar lbrentalbrenta @@--------------------------------------------------------------------------- @@-- @@MACRO(BIND_JS)@@ @@-- @@-- $1 action to register @@-- $2 the tag node ID to handle in the DOM tree @@-- $3 the name of the javascript routine to execute @@-- $18 ID index to be added to $2 (index in table for unique id for ex) @@-- @@SET@@ BJS_ACTION = $1 @@SET@@ BJS_ID = $2 @@SET@@ BJS_ROUTINE = $3 @@SET@@ BJS_ID_INDEX = $18 @@-- @@END_MACRO@@ @@--------------------------------------------------------------------------- @@-- @@MACRO(JS_ACTION)@@ @@-- @@-- $1 action name (onclick, onchange...) @@-- $2 the tag node ID to handle in the DOM tree @@-- $3 a set of parameters to pass to the URL @@-- $4-$8 are linked fields id to this request, all fields are passed as @@-- parameters to the request. @@-- $18 ID index to be added to $2 (index in table for unique id for ex) @@-- $19 URL to call instead of the generated one @@-- $20 the name of a function to call when this routine terminate @@-- @@-- The final request is : /$1$$$2$18?$3&$4=value($4)&$5=value($5) @@-- or : $19?$3&$4=value($4)&$5=value($5) @@-- with value(name) being the value for the field named "name". @@-- @@SET@@ JSA_ACTION = $1 @@SET@@ JSA_ID = $2 @@SET@@ JSA_PARAMETERS = $3 @@SET@@ JSA_F1 = $4 @@SET@@ JSA_F2 = $5 @@SET@@ JSA_F3 = $6 @@SET@@ JSA_F4 = $7 @@SET@@ JSA_F5 = $8 @@SET@@ JSA_ID_INDEX = $18 @@SET@@ JSA_CONSTANT_URL = $19 @@SET@@ JSA_ONCOMPLETE = $20 @_BIND_JS(@_JSA_ACTION_@, @_JSA_ID_@, 18=>@_JSA_ID_INDEX_@)_@ @@END_MACRO@@ libtemplates-parser-11.6.orig/regtests/tests/0118_macro6/test.out0000644000175000017500000000253511637170657024613 0ustar lbrentalbrenta[INFO] widget_counter.thtml -> ajax_api.tjs [C_INFO] 1 FALSE [INCLUDE] ajax_api.tjs $0 = ajax_api.tjs [INFO] ajax_api.tjs [C_INFO] 1 FALSE [TEXT] [TEXT] [TEXT] [TEXT]

@_COUNTER_@

[TEXT]
[TEXT] [TEXT] @_JS_ACTION(onclick,next)_@ [TEXT] @_JS_ACTION(onclick,previous)_@

libtemplates-parser-11.6.orig/regtests/tests/0118_macro6/test.py0000644000175000017500000000016011637170657024424 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["widget_counter.thtml"]) run('testme', ["widget_counter.thtml"]) libtemplates-parser-11.6.orig/regtests/tests/0118_macro6/widget_counter.thtml0000644000175000017500000000032011637170657027165 0ustar lbrentalbrenta@@-- @@INCLUDE@@ ajax_api.tjs @@--

@_COUNTER_@

@_JS_ACTION(onclick,next)_@ @_JS_ACTION(onclick,previous)_@ libtemplates-parser-11.6.orig/regtests/tests/0119_macro_include/0000755000175000017500000000000011637170657024514 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0119_macro_include/main.tmplt0000644000175000017500000000020011637170657026512 0ustar lbrentalbrenta@@MACRO(WINCL)@@ before @@INCLUDE@@ mincl.incl @_$2_@ @_$1_@ after @@END_MACRO@@ Some text: @_WINCL(A,B)_@ -- @_WINCL(98,123)_@ libtemplates-parser-11.6.orig/regtests/tests/0119_macro_include/mincl.incl0000644000175000017500000000010011637170657026454 0ustar lbrentalbrentainclude @_$1_@ and @_$2_@ @@INCLUDE@@ mincl2.incl @_$2_@ @_$1_@ libtemplates-parser-11.6.orig/regtests/tests/0119_macro_include/mincl2.incl0000644000175000017500000000002611637170657026545 0ustar lbrentalbrentaAnother @_$1_@ @_$2_@ libtemplates-parser-11.6.orig/regtests/tests/0119_macro_include/test.out0000644000175000017500000000036511637170657026230 0ustar lbrentalbrenta[INFO] main.tmplt -> mincl.incl [C_INFO] 1 FALSE [TEXT] Some text: [TEXT] @_WINCL(A,B)_@ [TEXT] -- [TEXT] @_WINCL(98,123)_@ Some text: before include B and A Another A B after -- before include 123 and 98 Another 98 123 after libtemplates-parser-11.6.orig/regtests/tests/0119_macro_include/test.py0000644000175000017500000000013411637170657026043 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["main.tmplt"]) run('testme', ["main.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0120_include/0000755000175000017500000000000011637170657023323 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0120_include/navbutton.tmpl0000644000175000017500000000004211637170657026235 0ustar lbrentalbrentanavbut "@_$1_@" "@_$2_@" "@_$3_@" libtemplates-parser-11.6.orig/regtests/tests/0120_include/navigation.tmpl0000644000175000017500000000013411637170657026356 0ustar lbrentalbrenta@@SET@@ WHEREAMI = $1 @@INCLUDE@@ navbutton.tmpl "@_WHEREAMI_@" "@_TITI_@" "@_TATA_@" libtemplates-parser-11.6.orig/regtests/tests/0120_include/src.tmpl0000644000175000017500000000004011637170657025002 0ustar lbrentalbrenta @@INCLUDE@@ navigation.tmpl P libtemplates-parser-11.6.orig/regtests/tests/0120_include/test.out0000644000175000017500000000065711637170657025043 0ustar lbrentalbrenta[INFO] src.tmpl -> navigation.tmpl [C_INFO] 1 FALSE [INCLUDE] navigation.tmpl $0 = navigation.tmpl $1 = P [INFO] navigation.tmpl -> navbutton.tmpl [C_INFO] 1 FALSE [SET] WHEREAMI = $1 [INCLUDE] navbutton.tmpl $0 = navbutton.tmpl $1 = @_WHEREAMI_@ $2 = @_TITI_@ $3 = @_TATA_@ [INFO] navbutton.tmpl [C_INFO] 1 FALSE [TEXT] navbut "@_$1_@" "@_$2_@" "@_$3_@" navbut "P" "" "" libtemplates-parser-11.6.orig/regtests/tests/0120_include/test.py0000644000175000017500000000013011637170657024646 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["src.tmpl"]) run('testme', ["src.tmpl"]) libtemplates-parser-11.6.orig/regtests/tests/0121_optimize_tree/0000755000175000017500000000000011637170657024560 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0121_optimize_tree/macro.tmplt0000644000175000017500000000051611637170657026745 0ustar lbrentalbrenta@@MACRO(M1)@@ @@IF@@ @_$1_@ = 8 eigth @_$1_@ value @@ELSE@@ @_$1_@ : something else @@END_IF@@ @@END_MACRO@@ -- @_M1(8)_@ -- M1-8 : @_M1(8)_@ -- @_M1(8)_@ : M1-8 -- M1-8 : @_M1(8)_@ : M1-8 -- @_M1(128)_@ -- @@IF@@ "A" = "A" this is A @@ELSE@@ NOT A @@END_IF@@ -- @@IF@@ "A" = "B" this is A @@ELSE@@ NOT A @@END_IF@@ libtemplates-parser-11.6.orig/regtests/tests/0121_optimize_tree/test.out0000644000175000017500000000075711637170657026301 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] -- [TEXT] eigth 8 value [TEXT] -- [TEXT] M1-8 : eigth 8 value [TEXT] -- [TEXT] eigth 8 value : M1-8 [TEXT] -- [TEXT] M1-8 : eigth 8 value : M1-8 [TEXT] -- [TEXT] 128 : something else [TEXT] -- [TEXT] this is A [TEXT] -- [TEXT] NOT A -- eigth 8 value -- M1-8 : eigth 8 value -- eigth 8 value : M1-8 -- M1-8 : eigth 8 value : M1-8 -- 128 : something else -- this is A -- NOT A libtemplates-parser-11.6.orig/regtests/tests/0121_optimize_tree/test.py0000644000175000017500000000014411637170657026110 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["-M", "macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0122_optimize_tree2/0000755000175000017500000000000011637170657024643 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0122_optimize_tree2/macro.tmplt0000644000175000017500000000007511637170657027030 0ustar lbrentalbrenta@@MACRO(CALL)@@ /@_$1_@/ @@END_MACRO@@ -- @_UPPER:CALL(me)_@ libtemplates-parser-11.6.orig/regtests/tests/0122_optimize_tree2/test.out0000644000175000017500000000010311637170657026345 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] -- [TEXT] /ME/ -- /ME/ libtemplates-parser-11.6.orig/regtests/tests/0122_optimize_tree2/test.py0000644000175000017500000000014411637170657026173 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["-M", "macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0123_optimize_tree3/0000755000175000017500000000000011637170657024645 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0123_optimize_tree3/ajax_api.tjs0000644000175000017500000000627311637170657027153 0ustar lbrentalbrenta @@--------------------------------------------------------------------------- @@-- @@MACRO(BIND_JS)@@ @@-- @@-- $1 action to register @@-- $2 the tag node ID to handle in the DOM tree @@-- $3 the name of the javascript routine to execute @@-- $18 ID index to be added to $2 (index in table for unique id for ex) @@-- @@SET@@ BJS_ACTION = $1 @@SET@@ BJS_ID = $2 @@SET@@ BJS_ROUTINE = $3 @@SET@@ BJS_ID_INDEX = $18 @@-- @@END_MACRO@@ @@--------------------------------------------------------------------------- @@-- @@MACRO(JS_ACTION)@@ @@-- @@-- $1 action name (onclick, onchange...) @@-- $2 the tag node ID to handle in the DOM tree @@-- $3 a set of parameters to pass to the URL @@-- $4-$8 are linked fields id to this request, all fields are passed as @@-- parameters to the request. @@-- $18 ID index to be added to $2 (index in table for unique id for ex) @@-- $19 URL to call instead of the generated one @@-- $20 the name of a function to call when this routine terminate @@-- @@-- The final request is : /$1$$$2$18?$3&$4=value($4)&$5=value($5) @@-- or : $19?$3&$4=value($4)&$5=value($5) @@-- with value(name) being the value for the field named "name". @@-- @@SET@@ JSA_ACTION = $1 @@SET@@ JSA_ID = $2 @@SET@@ JSA_PARAMETERS = $3 @@SET@@ JSA_F1 = $4 @@SET@@ JSA_F2 = $5 @@SET@@ JSA_F3 = $6 @@SET@@ JSA_F4 = $7 @@SET@@ JSA_F5 = $8 @@SET@@ JSA_ID_INDEX = $18 @@SET@@ JSA_CONSTANT_URL = $19 @@SET@@ JSA_ONCOMPLETE = $20 @_BIND_JS(@_JSA_ACTION_@, @_JSA_ID_@, 18=>@_JSA_ID_INDEX_@)_@ @@END_MACRO@@ libtemplates-parser-11.6.orig/regtests/tests/0123_optimize_tree3/macro.tmplt0000644000175000017500000000116011637170657027026 0ustar lbrentalbrenta@@INCLUDE@@ ajax_api.tjs @@-- @@MACRO(CPLX)@@ start @_$1_@ @@IF@@ @_$1_@ = "" and @_$2_@ = "" $1 and $2 = "" @@END_IF@@ @@IF@@ @_$2_@ = "" $2 = "" @@END_IF@@ @@IF@@ @_$1_@ = "" or @_$2_@ = "" $1 or $2 = "" @@END_IF@@ @@IF@@ (@_$1_@ = "" and @_$2_@ = "") or @_$3_@ = "" ($1 and $2 = "") or $3 = "" @@END_IF@@ @@IF@@ @_$3_@ /= "" or @_$2_@ = "bb" $3 /= "" or $2 = "bb" @@ELSE@@ not ($3 /= "" or $2 = "bb") @@END_IF@@ @@IF@@ @_$2_@ = "" AGAIN $2 = "" @@END_IF@@ end @@END_MACRO@@ -- @_CPLX(a)_@ -- @_CPLX(a,b)_@ -- @_CPLX(a,b,c)_@ -- @_JS_ACTION(onclick,myid, 4=>fourth)_@ -- @_JS_ACTION(onclick,myid, 4=>whatever, 18=>8)_@ -- libtemplates-parser-11.6.orig/regtests/tests/0123_optimize_tree3/test.out0000644000175000017500000000671211637170657026363 0ustar lbrentalbrenta[INFO] macro.tmplt -> ajax_api.tjs [C_INFO] 1 FALSE [INCLUDE] ajax_api.tjs $0 = ajax_api.tjs [INFO] ajax_api.tjs [C_INFO] 1 FALSE [TEXT] [TEXT] [TEXT] [TEXT] -- [TEXT] [TEXT] start a [TEXT] $2 = "" [TEXT] $1 or $2 = "" [TEXT] ($1 and $2 = "") or $3 = "" [TEXT] not ($3 /= "" or $2 = "bb") [TEXT] AGAIN $2 = "" [TEXT] end [TEXT] -- [TEXT] [TEXT] start a [TEXT] ($1 and $2 = "") or $3 = "" [TEXT] not ($3 /= "" or $2 = "bb") [TEXT] end [TEXT] -- [TEXT] [TEXT] start a [TEXT] $3 /= "" or $2 = "bb" [TEXT] end [TEXT] -- [TEXT] [TEXT] [TEXT] [TEXT] [TEXT] [TEXT] [TEXT] -- [TEXT] [TEXT] [TEXT] [TEXT] [TEXT] [TEXT] [TEXT] -- -- start a $2 = "" $1 or $2 = "" ($1 and $2 = "") or $3 = "" not ($3 /= "" or $2 = "bb") AGAIN $2 = "" end -- start a ($1 and $2 = "") or $3 = "" not ($3 /= "" or $2 = "bb") end -- start a $3 /= "" or $2 = "bb" end -- -- -- libtemplates-parser-11.6.orig/regtests/tests/0123_optimize_tree3/test.py0000644000175000017500000000014411637170657026175 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["-M", "macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/0124_embedded_macro/0000755000175000017500000000000011637170657024616 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/0124_embedded_macro/macro.tmplt0000644000175000017500000000035011637170657026777 0ustar lbrentalbrenta@@MACRO(MACRO1)@@ $1:@_$1_@ $2:@_$2_@ $5:@_$5_@ @@IF@@ @_$9_@ /= "" $9:@_$9_@ @@END_IF@@ @@END_MACRO@@ @@-- @@MACRO(MACRO2)@@ @_MACRO1(@_$2_@,@_$1_@,5=>five,9=>nine)_@ @@END_MACRO@@ -- @_MACRO1(2,3, 5=>FiVe)_@ -- @_MACRO2(2,3)_@ -- libtemplates-parser-11.6.orig/regtests/tests/0124_embedded_macro/test.out0000644000175000017500000000033511637170657026327 0ustar lbrentalbrenta[INFO] macro.tmplt [C_INFO] 1 FALSE [TEXT] -- [TEXT] $1:2 $2:3 $5:FiVe [TEXT] -- [TEXT] [TEXT] [TEXT] $1:3 $2:2 $5:five [TEXT] $9:nine [TEXT] -- -- $1:2 $2:3 $5:FiVe -- $1:3 $2:2 $5:five $9:nine -- libtemplates-parser-11.6.orig/regtests/tests/0124_embedded_macro/test.py0000644000175000017500000000014411637170657026146 0ustar lbrentalbrentafrom test_support import * run('print_tree', ["-M", "macro.tmplt"]) run('testme', ["macro.tmplt"]) libtemplates-parser-11.6.orig/regtests/tests/Z999_xfail/0000755000175000017500000000000011637170657023105 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/Z999_xfail/test.opt0000644000175000017500000000003511637170657024606 0ustar lbrentalbrentaALL xfail should always fail libtemplates-parser-11.6.orig/regtests/tests/Z999_xfail/test.out0000644000175000017500000000000011637170657024603 0ustar lbrentalbrentalibtemplates-parser-11.6.orig/regtests/tests/Z999_xfail/test.py0000644000175000017500000000015511637170657024437 0ustar lbrentalbrentaimport sys import time from test_support import * print(time.strftime("%y-%m-%d %H:%M", time.localtime())) libtemplates-parser-11.6.orig/regtests/testsuite.py0000755000175000017500000000757411637170657022517 0ustar lbrentalbrenta#!/usr/bin/env gnatpython """./testsuite.py [options] [test name] Run the templates_parser testsuite """ from gnatpython.env import Env from gnatpython.ex import Run from gnatpython.fileutils import mkdir, rm from gnatpython.main import Main from gnatpython.mainloop import (MainLoop, add_mainloop_options, generate_collect_result) from gnatpython.testdriver import add_run_test_options from gnatpython.reports import ReportDiff from glob import glob import os import sys # Compute PATH to global test drivers (testme, print_tree) PLATFORM = os.environ.get("PLATFORM") PRJ_BUILD = os.environ.get("PRJ_BUILD") if PLATFORM == None: PLATFORM = "native" else: PLATFORM = PLATFORM.lower() if PRJ_BUILD == None: PRJ_BUILD = "debug" else: PRJ_BUILD = PRJ_BUILD.lower() ep = os.getcwd() + "/../.build/" + PLATFORM + "/" + PRJ_BUILD + "/static/" os.environ["PATH"] = os.environ.get("PATH") + os.pathsep + ep \ + "bin" + os.pathsep + ep + "rbin" from gnatpython.ex import Run def gnatmake(prj): """Compile a project with gnatmake""" cmd = ["gnatmake", "-p", "-gnat05", "-P" + prj, "-bargs", "-E"] process = Run(cmd) if process.status: print process.out def main(): """Run the testsuite""" options = __parse_options() assert os.path.exists(ep), "cannot find %s directory" % ep env = Env() env.add_search_path("PYTHONPATH", os.getcwd()) test_list = [t for t in filter_list('tests/*', options.run_test) if os.path.isdir(t)] # Various files needed or created by the testsuite result_dir = options.output_dir results_file = result_dir + '/results' if os.path.exists(result_dir): rm(result_dir, True) mkdir(result_dir) discs = env.discriminants if options.discs: discs += options.discs def test_build_cmd(test, _): """Run the given test""" cmd = [sys.executable, 'run-test', '-d', ",".join(discs), '-o', result_dir, '-t', options.tmp, test] if options.verbose: cmd.append('-v') if options.host: cmd.append('--host=' + options.host) if options.target: cmd.append('--target=' + options.target) if not options.enable_cleanup: cmd.append('--disable-cleanup') return Run(cmd, bg=True) collect_result = generate_collect_result( result_dir, results_file, options.view_diffs) MainLoop(test_list, test_build_cmd, collect_result, options.mainloop_jobs) # Write report with open(result_dir + '/discs', 'w') as discs_f: discs_f.write(" ".join(discs)) ReportDiff(result_dir, options.old_result_dir).txt_image( result_dir + '/report') def filter_list(pattern, run_test=""): """Compute the list of test matching pattern If run_test is not null, run only tests containing run_test """ test_list = glob(pattern) if not run_test: return test_list else: return [test for test in test_list if run_test in test] def __parse_options(): """Parse command lines options""" m = Main(add_targets_options=True) add_mainloop_options(m) add_run_test_options(m) m.add_option("--diffs", dest="view_diffs", action="store_true", default=False, help="Print .diff content") m.add_option("--old-result-dir", type="string", default=None, help="Old result dir") m.parse_args() if m.args: m.options.run_test = m.args[0] # User want to run only one test print "Running only test '%s'" % m.options.run_test else: m.options.run_test = "" if m.options.discs: m.options.discs = m.options.discs.split(',') return m.options if __name__ == "__main__": try: main() except AssertionError, e: print 'ERROR: %s' % e libtemplates-parser-11.6.orig/src/0000755000175000017500000000000011637170657017023 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/src/ChangeLog0000755000175000017500000022377311637170657020616 0ustar lbrentalbrenta2005-12-05 Florian Villoing * templates_parser-filter.adb: (Wrap): If possible, do not split a line in the middle of a word. For E614-006. 2005-11-20 Pascal Obry * templates_parser-filter.adb: (Wap): Add missing unreferenced pragma for T and I. Continued work for E614-006. 2005-11-18 Florian Villoing * templates_parser-filter.adb: (Wrap_Token): New constant. (Table): Add an entry for Wrap. Minor reformating. (Wrap): First implementation of the filter. For E614-006. * templates_parser.adb: (Filter.Mode): Add Wrap. (Wrap): New filter subprogram. For E614-006. 2005-10-04 Pascal Obry * templates_parser.adb: Add a with/use clause for Ada.Strings.Unbounded to be able to build using GNAT GPL and GNAT 5.03a1. This is to work around a visibility problem on these version of GNAT. 2005-09-21 Pascal Obry * templates_parser.adb: Fix obvious error in previous check-in. * templates_parser-expr.adb: (Next_Token): Removes redundant with clauses found by -gnatwr. * templates_parser.adb, templates_parser-definitions.adb: Removes redundant with clauses found by -gnatwr. 2005-09-15 Pascal Obry * templates_parser.adb: (Analyze): Clean-up code by using Ada.Containers Include instead of Find/Has_Element/Replace_Element/Insert. 2005-09-14 Pascal Obry * templates_parser.adb: (Insert) [Association]: Use Containers.Include as this is supposed to insert or replace the item. Fix regression test. 2005-09-14 Pascal Obry * templates_parser.adb, templates_parser-filter.adb: Use Ada.Containers instead of internal AI302. Update copyright notice. 2005-06-27 Pascal Obry * templates_parser-input__standalone.adb: (Close): Fix implementation to properly propagate Status_Error. * templates_parser.adb: (Release): Fix previous check-in to avoid memory leak. Continued work for E527-017. 2005-06-27 Pascal Obry * templates_parser.adb: (Release): Do not recurse for the Text nodes. We can have lot of them contiguous so it is more efficient to just iterate through them. This is already done for the Analyze routine. Fixes regression found on FreeBSD. Part of work for E527-017. 2005-06-22 name * templates_parser-filter.adb: (BR_2_EOL_Token): New constant. (Table): Add entry for BR_2_EOL. (BR_2_EOL): New subprograms. (BR_2_LF): Rewrite using the above subprogram. (Mode_Value): Update subprogram box. * templates_parser.adb: (Filter.Mode): Add BR_2_EOL. (Filter.BR_2_EOL): New subprogram. 2005-06-17 Florian Villoing * templates_parser.ads, templates_parser.adb: (Dimension): Renames dimention. Fix other typos. 2005-05-26 Florian Villoing * templates_parser.adb: (Get_Tag_Parser): Properly handle the case where the end of the tag is not found. Fixes E526-012. 2005-05-14 Pascal Obry * templates_parser.ads: (Lazy_Tag): Is now an abstract type. (Cursor_Tag): Idem. Continued work for E423-002. * templates_parser.adb: (Dynamic): Remove separate body declaration. Not needed now. Continued work for E423-002. * templates_parser-dynamic.adb: Removed, this is not needed now as the Lazy_Tag and Cursor_Tag are now abstract types. Continued work for E423-002. 2005-05-13 Pascal Obry * templates_parser-dynamic.adb: (Dimention): New routine. (Length): Idem. (Value) [Cursor_Tag]: Idem. These routines are used to implement the new Cursor_Tag object. Continued work for E423-002. * templates_parser.adb: (Tag_Var): Minor comment update. (Parse) [*]: Add parameter Cursor_Tag. Continued work for E423-002. * templates_parser.ads: (Value) [Lazy_Tag]: Lazy_Tag has now an access mode (was in out). (Dynamic.Cursor_Tag): New tag object that support a tag that can be iterated by the parser. This make it possible to iterate through complex data that live on the Ada side only. (Parse) [*]: Add parameter Cursor_Tag. (Parse): Add support for the new Cursor_Tag object. The main changes are in the nested Translate and Check routines. (Get_Max_Lines.Check) [Expr.Tree]: Cleaner implementation. (Get_Association): Fix call to Value as now Lazy_Tag parameter has an access mode. Continued work for E423-002. 2005-05-09 Pascal Obry * templates_parser.adb: (Unescape): Handle some special characters like \n \t and \r. Part of this patch has been contributed by Henrik Sundberg. Minor reformatting. 2005-05-08 Pascal Obry * templates_parser-dynamic.adb: Initial revision. Implementation which supports Lazy_Tags default callback. Part of work for E423-002. * templates_parser-filter.adb: (No_Context_Token): Removed. (No_Dynamic_Token): Added. (No_Context): Removed filter routine. (No_Dynamic): Added filter routine. Part of work for E423-002. * templates_parser.adb: (No_Context): Filter removed and replaced by No_Dynamic. (No_Dynamic): Renamig on No_Context. (Internal_Tag): New enumeration that contains all the internal tag name. This is used at load time to detect internal tags. It should speed up parsing of cached files using internal tags. (Get_Var_Name): Returns a String now (avoid on convertion between Unbounded_String and String. (Build) [Tag_Var]: Properly set new Internal field. (Callback): Routine removed. (Parse) [*]: Replace Context parameter by Lazy_Tag. (Get_Association): New routine used to get an association either from the translate set or the Lazy_Tag set. Better code sharing. This new routine is also in charge of calling the Lazy_Tag callback if necessary. (Translate): Use Get_Association. Use new Internal field that speed up the internal tag handling. Remove handling of the Context type. (Check): Use Get_Association so the Lazy_Tag are properly loaded at the time of the analyze of the table ranges. (Filter.Is_No_Context): Removed routine. (Filter.Is_No_Dynamic): Added routine. Part of work for E423-002. (Analyze): Add some comments for previous check-in. Minor reformatting. * templates_parser.ads: (Context): Removed. This is now longer supported and as been replaced by Lazy_Tag (a more general solution). (Callback): Routine removed. (Dynamic): New package. Implements Lazy_Tag support for now. (Parse) [*]: Replace Context parameter by Lazy_Tag. Part of work for E423-002. 2005-05-03 Pascal Obry * templates_parser-data.adb: (Release): Properly set the tree to null on return. Found while working on DA25-015. * templates_parser.adb: (Load): Properly release the include filename data tree if not needed (in the case of static filename). (Parse): Improve test for non static include file to properly handle the cache. Continued work for DA25-015. 2005-05-03 Pascal Obry * templates_parser-print_tree.adb: Adjust the Include_Stmt case to cover the case of deferred include filename. * templates_parser.adb: (Build_Include_Pathname): Move to library level as it is shared by Load and Parse routines. (Load): Load include file if the name is static (set definitions or string) otherwise the load is deferred at parse time. This make it possible to pass the filename into a tag variable. So we raise an exception for missing include file only for static filename here. We have also a special case for include tag command in if tag statement where we defer the exception propagation at parsing time. It could be the case that this path is not taken at parse time. (Parse): Load the include file here if not done at load time. This is called a deferred load and happen when the include filename is not static (tag variable). 2005-04-17 Pascal Obry * templates_parser-cached_files.adb: (Add): Properly update the used counter of the obsolete tree. This fix a rare problem of deallocated memory usage. * templates_parser.adb: Fix typo in comment. 2005-04-11 Pascal Obry * templates_parser.adb: (Count_Tag_Attributes): Fix code to avoid reading uninitialized data. Checked-in for Dmitriy Anisimkov. 2005-04-07 Pascal Obry * templates_parser-data.adb: Minor reformatting. * templates_parser-filter.adb: (Web_Escape): Fix Max_Escape_Sequence constant. Fix for E406-003, checked-in for Florian Villoing. 2005-04-06 Pascal Obry * templates_parser-cached_files.adb: (Update_Used_Counter): Add some comments. 2005-04-02 Pascal Obry * templates_parser-cached_files.adb: (Release): Remove exception occurence in exception handler checked-in by error. 2005-04-01 Pascal Obry * templates_parser.ads: (For_Every_Association): Fix typo in comment. (Release_Cache): New routine. * templates_parser.adb: (Cached_Files.Release): New routine. (Release_Cache): New routine. (Release) [Tree, Include]: Fix recursive call for the Info node. * templates_parser-cached_files.adb: (Release): New routine. Minor reformatting. 2005-03-30 Pascal Obry * templates_parser-print_tree.adb: Removes the "_STMT" statement node names suffix for a lighter tree output. 2005-03-30 Pascal Obry * templates_parser.adb: (Node) [Inline_Stmt]: Add Before and After field. (Get_Tag_Parameter): Improve to support any number of tag parameter. (Get_Tag_Parameter_Count): New routine. (Parse): Handle the new INLINE tag parameters before/after text. (Analyse): Idem. This new INLINE tag command permit a finer control on the layout. 2005-03-28 Pascal Obry * templates_parser.adb: (Get_Tag_Parameters): Add parameter Default. It is now possible to pass an empty string to the INLINE tag command. 2005-03-28 Pascal Obry * templates_parser.adb: (No_Quote): Improve check to avoid Constraint_Error. * templates_parser-filter.adb: (Repeat): Change implementation to accept inverted parameters. It is now possible to do @_REPEAT(3):VAR_@ (repeat 3 times var content) and also @_REPEAT(x):VAR_@ (repeat 'x' a number of time corresponding to VAR value). (Value): Fix check to avoid Contraint_Error. 2005-03-27 Pascal Obry * templates_parser.adb: (Inline_Token): New constant. (End_Inline_Token): Idem. (Nkind): Add Inline_Stmt. (Node): Add support for Inline_Stmt. (Get_Tag_Parameter): New function that returns the command tag parameter. This is currently used only for the new @@INLINE@@ command tag. (Is_Stmt): Rename With_Attributes parameter to Extended as used not only in the context of command tag attributes now. Improve check, should catch some more wrong syntax. (Parse_Mode): Add Parse_Inline. (Get_Tag_Attributes): Minor code cleanup. (Rewrite_Inlined_Block): New routine used after parsing an inlined block. This routine rewrite some part of the tree. This gives better performance as it avoids too much checks at rendering time. (Parse): Add support for inlined block. (Parse_State): Add field Inline_Sep. (Empty_State): Adjust accordingly. (Last_Was_Sep): New parse global status status. (Add) [String, Boolean]: Move one level upper as shared now. (Get_Max_Lines): Add support for new Inline_Stmt node. (Analyze): Add support for new Inline_Stmt node. Output the inline separators when needed. (Release): Add support for new Inline_Stmt node. Minor reformatting. * templates_parser-print_tree.adb: (Print_Tree): Handle new Inline_Stmt node. * templates_parser-data.adb: (Print_Tree): Adjust to handle inlined block. The inlined text node have no LF terminator now. 2005-02-28 Pascal Obry * templates_parser-filter.adb: (Web_Encode_Token): New constant. (Table): Add Web_Encode. (Web_Encode): New routine. * templates_parser.adb: (Mode): Add Web_Encode. (Web_Encode): New routine used to implement the new WEB_ENCODE filter. 2005-02-17 Pascal Obry * templates_parser-input.adb: Removed. Was checked-in by error. * templates_parser-input__standalone.adb: (Open): Add exception message to help tracing missing files. 2005-02-16 Pascal Obry * templates_parser-tasking__standard_tasking.adb: Split CVS tag to avoid long lines. * templates_parser-tasking__no_tasking.adb: Split CVS tag to avoid long lines. * templates_parser-input__standalone.adb: Split CVS tag to avoid long lines. * templates_parser-definitions.adb: Split CVS tag to avoid long lines. * templates_parser-configuration__standalone.ads: Split CVS tag to avoid long lines. * templates_parser.adb: (Get_Next_Line): Fix check for comment. In some cases an empty line after a comment was skipped. 2005-02-16 Pascal Obry * templates_parser-cached_files.adb: (Cached_Files): Remove the protected object. This is now configurable to have a templates_parser version that does not drag the tasking runtime. (Add): Add a call to the Tasking.Lock and Tasking.Unlock. (Get): Idem. (Release): Idem. * templates_parser.adb: (Cached_Files): Remove the protected object. This is now configurable to have a templates_parser version that does not drag the tasking runtime. Use new configuration unit to be able to use the templates engine alone or in the context of AWS. * templates_parser-filter.adb: Use new configuration unit to be able to use the templates engine alone or in the context of AWS. * templates_parser-tasking__standard_tasking.adb: Initial revision. * templates_parser-tasking__no_tasking.adb: Initial revision. * templates_parser-tasking.ads: Initial revision. * templates_parser-input__standalone.adb: Initial revision. * templates_parser-configuration__standalone.ads: Initial revision. 2005-02-12 Pascal Obry * templates_parser.ads, templates_parser.adb: Moved from top src directory. Update copyright notice. * templates_parser-utils.ads, templates_parser-utils.adb: Moved from top src directory. Update copyright notice. * templates_parser-query.ads, templates_parser-query.adb: Moved from top src directory. Update copyright notice. * templates_parser-print_tree.adb: Moved from top src directory. Update copyright notice. * templates_parser-input.ads, templates_parser-input.adb: Moved from top src directory. Update copyright notice. * templates_parser-filter.adb: Moved from top src directory. Update copyright notice. * templates_parser-expr.adb: Moved from top src directory. Update copyright notice. * templates_parser-definitions.adb: Moved from top src directory. Update copyright notice. * templates_parser-debug.ads, templates_parser-debug.adb: Moved from top src directory. Update copyright notice. * templates_parser-data.adb: Moved from top src directory. Update copyright notice. * templates_parser-cached_files.adb: Moved from top src directory. Update copyright notice. 2005-01-09 Pascal Obry * templates_parser.adb (Module): (Name_Parameter): Fully prefix the return value to avoid ambiguity detected by recent GNAT versions. (Check) [Include_Parameters]: New function. (Get_Max_Lines): Properly check the include parameters. This fix handling of include tag statement inside a table tag statement. 2004-12-17 Pascal Obry * templates_parser.adb: (Parse_State_Access): New type. (Parse_State): New field Parent which reference the parent state. This is used for include parameter referencing an alias or a parent include parameter. (Empty_State): Update accordingly. (Translate) [Tag_Var]: Add parameter State. (I_Translate): Idem and properly handle reference to parent include parameters. (Analyse): Update all calls to Translate and I_Translate to pass the state. Also update recursive call to Analyse. 2004-12-17 Pascal Obry * templates_parser.adb: (Field): Minor optimization. 2004-12-15 Pascal Obry * templates_parser-print_tree.adb: Output the table attributes only if set. * templates_parser.adb: (A_Terminate_Sections_Token): New constant. (A_Reverse_Token): New constant. (Node) [Table_Stmt]: Add field Reverse_Index. (Clear): Remove code for Position. (Initialize): Idem. (Finalize): Idem and initialize the new Tag_Nodes field. ("+") [String]: Remove code for Position and add support for new Tag_Nodes field. ("&") [*]: Idem. (Field): Create the fast access array to nodes if needed. Use it to return the proper element. (Count_Tag_Attributes): New routine to support attributes on tag commands. (Get_Tag_Attribute): Idem. (Is_Stmt): Update to handle tag attributes. (Parse): Add support for table TERMINATE_SECTIONS and REVERSE attributes. (Parse_State): Add Reverse_Index field. (Empty_State): Update accordingly. * templates_parser.ads: (Cursor): Removed. (Tag_Node_Arr): New type. (Tag_Node_Arr_Access): New type. (Tag_Data): Remove Position, add Tag_Nodes. 2004-12-14 Pascal Obry * templates_parser.adb: (Quote): Fix style error. 2004-12-14 Pascal Obry * templates_parser-definitions.adb: Initial revision. * templates_parser-expr.adb: (Print_Tree): Use new Quote procedure. * templates_parser-print_tree.adb: Handle Set_Stmt. Fix handling of the include parameters now that we can have default values. * templates_parser.adb: (Quote): New routine. (Set_Token): New constant. (Definitions): New package. (NKind): Add Set_Stmt. (Node): Handle Set_Stmt case. (Load.Parse): Idem. (Translate) [Tag_Var]: Check the definition table before checking the translate table. (Analyse): Handle Set_Stmt case. (Release): Idem. 2004-11-24 Pascal Obry * templates_parser-xml.adb: (Add_Descriptions): Do not output empty value. (B_Tag): Fix code to properly handle vectors with different size. 2004-11-18 Pascal Obry * templates_parser.adb: (Get_Next_Line): Properly increment the line number when skiping comments. 2004-11-16 Pascal Obry * templates_parser.adb: (Field): Fix test to detect Up_Level attribute going on or above the top level. 2004-11-15 Pascal Obry * templates_parser-filter.adb: (File_Exists_Token): New constant. (Table): Add File_Exists filter. (File_Exists): New filter. * templates_parser.adb: (Mode): Add File_Exists filter. (File_Exists): New filter. 2004-11-15 Pascal Obry * templates_parser.adb: (Field): If Up_Level reference the top level (or above) we inline the variable. (Parse): Properly detect the case where TERMINATE_SECTIONS attribute is used but no section is defined. 2004-11-14 Pascal Obry * templates_parser.adb: Minor comment fix. 2004-11-12 Pascal Obry * templates_parser-xml.ads, templates_parser-xml.adb: (Value) [String]: New routine. (Value) [Unbounded_String]: Idem. 2004-11-12 Pascal Obry * templates_parser.adb: (Translate): Remove not needed check. 2004-11-12 Pascal Obry * templates_parser.adb: (Attribute): Add Up_Level value. (Attribute_Data): New record composed of an attribute defintiion and its associated value. (Tag_Var): Use Attribute_Data instead of Attribute only. (Image): Add support for new Up_Level attribute. (Get_Attribute): Returns now an Attribute_Data instead of a simple Attribute. Handles new Up_Level attribute. (Field): Add parameter Up_Value used to compute value position. (Translate): Update to handle new Up_Level attribute. 2004-11-11 Pascal Obry * templates_parser.adb: (Find): New routine used to find filter separator. (Unescape): New routine, removes \ for escaped characters in regpat replacement pattern. (Name_Parameter): Use it. (Get_Filter_Set): Returns the proper filter set slice. 2004-11-06 Pascal Obry * templates_parser-filter.adb: (Max_Token): New constant. (Min_Token): Idem. (Table): Add Min and Max filters. (Is_Number): Moved to parent package. (Max): New filter. (Min): Idem. Minor reformatting. * templates_parser.adb: (Is_Number): Moved here from Filter separate. (Filter): Add support for Min and Max filters. (Max): New filter. (Min): Idem. (Load_Include_Parameters): Handle now named include parameters. 2004-11-03 Pascal Obry * templates_parser.ads: (For_Every_Association): New routine. * templates_parser.adb: (Absolute): New filter. (Neg): New filter. (For_Every_Association): New routine. (Assoc): Handle properly the separator if specified. * templates_parser-filter.adb: (Abs_Token): New constant. (Table): Add Absolute abd Neg filters. (Is_Number): Add '-' as possible character. (Absolute): New filter. (Neg): New filter. 2004-10-26 Pascal Obry * templates_parser.adb: (I_Kind): Removed. (Parameters_Data): Removed. (Include_Parameters): Change definition, this is cleaner. (Flatten_Parameters): Translate variable here, this is cleaner and it is possible to handle attributes. (I_Translate): Inherit attribute only if the tag has no attribute already definied. Handles include parameters with attribute. * templates_parser-filter.adb: (Value): Simplify code, the new include parameters set is now already translated. 2004-10-26 Pascal Obry * templates_parser.adb: (Max_Include_Parameters): Moved to main body as it is shared by two different sub-packages. (I_Kind): New type. (Parameters_Data): New record. (Include_Parameters): New array. (No_Include_Parameters): New constant. (Callback): Add I parameter (flat include parameters). Idem for all filters prototypes. (Is_Number): New routine, moved here from filter body. (Translate): Add new parameter I_Params. (Analyse.Flatten_Parameters): New routine. (Parse_State): Add new field F_Params. (Empty_State): Update accordingly. (Analyse): In Translate and Analyse calls properly pass the F_Params state. Minor reformatting. This changes are made to support $ in filter parameters. * templates_parser-filter.adb: (Replace_One_Or_All): Add I parameters (include parameters). (Value): Idem. Properly detect $ filter name and check in this case the include parameter table. Add I parameters to all filter routines. In filter having a filter call Value with the include parameters. 2004-10-16 Pascal Obry * templates_parser.adb: (Load_Include_Parameters): Fix test to properly handle the last include parameter if it has a single character. 2004-10-15 Pascal Obry * templates_parser-expr.adb: (Next_Token): Properly handle the "/" filter in if condition. Patch contibuted by Jean-Pierre Rosen. 2004-09-20 Pascal Obry * templates_parser.adb: (Count_Sections): Fix algorithm. (Parse): In the Parse_Block case properly detect empty section. Rewrite a block with a single section with no common section as a simple common section. Properly check the table parameter, raise an exception if the parameter is not known. Check that, if a TERMINATE_SECTIONS is specified in a table, all blocks have the same number of sections otherwise raise an exception. * templates_parser-print_tree.adb: Fix output when there is only a common section in a block. 2004-09-19 Pascal Obry * templates_parser.adb: (Begin_Token): New constant. (End_Token): Idem. (Nkind): Add Section_Block. (Node): Add Section_Block entry. Add variable Sections_Count to avoid recomputing this value for each rendering. (Parse_Mode): Add Parse_Block needed to support the new table's block feature. (Parse.Count_Sections): New routine. (Parse.Count_Blocks): New routine. (Load.Parse): Handle new Parse_Block mode. (Parse.Block_State): New type to keep track of the block status. Needed to have fast block/section handling. (Parse_State): Add field Block of type Block_State. (Get_Max_Lines.Count_Section): Removed from here, this is now computed at load time. (Get_Max_Lines): Handles new Section_Block node. (Analyse): Idem. (Release): Idem. * templates_parser-print_tree.adb: Add output for the new Section_Block node. 2004-09-18 Pascal Obry * templates_parser-filter.adb: (No_Context_Token): New constant. (Table): Add No_Context entry. (Mode_Value): Fix tests to exit from this routine. (Is_No_Context): New routine. (No_Context): New routine. * templates_parser.adb: (Filter.Mode): Add No_Context. (Filter.No_Context): New routine. (Filter.Is_No_Context): New routine. (Get_Filter_Set): Check that if no context filter is given it is in the first position. (Translate): Call the context callback after handling the default tags and only if there is no NO_CONTEXT filter specified. 2004-09-02 Pascal Obry * templates_parser.adb: Fix code to use new AI302 container Is_In prototype. * templates_parser-xml.adb: Fix code to use new AI302 container Is_In prototype. 2004-08-05 Pascal Obry * templates_parser.adb: (Clear): Properly initialize Min and Max as done in Initialize. 2004-07-07 Pascal Obry * templates_parser-query.adb, templates_parser-debug.adb: Some changes due to new Tag record structure to fix reference semantic implementation. * templates_parser-xml.adb, templates_parser-utils.adb: Some changes due to new Tag record structure to fix reference semantic implementation. * templates_parser.adb: (Get): New procedure. Lot of changes due to new Tag record structure to fix reference semantic implementation. * templates_parser.ads: (Tag): Add comments about reference semantic. Fix referenc semantic implementation. (Get): New procedure. 2004-06-25 Pascal Obry * templates_parser.adb, templates_parser-xml.adb: Some fixes due to AI302 changes. 2004-06-14 Pascal Obry * templates_parser.adb: (Tag_Var): Add N field (include parameter index). (Is_Include_Variable): New function. (Build) [Tag_Var]: Detect include variable and set index N. (Max_Include_Parameters): New constant. (Include_Parameters): New type. (No_Parameter): New constant. (Node): Add I_Params field. (Replace_Include_Variables): Removed. We do not want to expand the include parameters at load time as, in the case of cached files, the include tree can be shared by multiple templates. This will be handled at parsing time. (Load_Include_Parameters): New procedure that create a Data.Tree for each include parameter in I_Params field. (Parse): Use it instead of Replace_Include_Variables. (Table_State): Renamed Parse_State. (Parse) [Unbounded_String]: Add I_Params field in Parse_State. (I_Translate): New procedure. (Flush); New procedure. (Add): Use Flush. (Analyse) [Data.Tree]: Handle include variables. (Analyse) [Expr.Tree]: Idem. (Analyse) []: Adjust state aggregates with new field. (Release) [Tree]: Free memory associated with include parameters. * templates_parser-print_tree.adb: (Print_Tree): Output the include file parameters. * templates_parser-data.adb: (Parse): Minor reformatting. Add some comments. 2004-06-04 Pascal Obry * templates_parser.adb: (Clear): Initialize Nested_Level to 1. (Initialize): Idem. (Translate) [Tag_Var]: Improve error messages. Patch contributed by Emmanuel Briot. * templates_parser.adb: ("&") [Tag]: Properly set the nested level if the left value already contains values. 2004-05-26 Pascal Obry * templates_parser.adb: (Remove): New routine. (Get): New routine. (Parse) [all versions]: Context is now of Context_Access type. Fix accessibility check problem. * templates_parser.ads: (Null_Association): New constant. (Remove): New routine. (Get): New routine. (TP_Context): Removed. (Parse) [all versions]: Context is now of Context_Access type. 2004-05-24 Pascal Obry * templates_parser.adb: (Translate): Do not call Callback for Null_Context. Minor reformatting. 2004-05-19 Pascal Obry * templates_parser-xml.adb: (To_Utf8): New routine. (Process): Properly generate Utf8. (Load): New routine. First implementation of the XML loader. * templates_parser-xml.ads: (Load): New routine. First implementation of the XML loader. * templates_parser.ads, templates_parser.adb: (Insert) [Translate_Set]: New routine. 2004-05-19 Pascal Obry * templates_parser-xml.ads: Minor comment fixes. Remove tabulations introduced with the copy&paste of the DTD. 2004-05-18 Pascal Obry * templates_parser-utils.ads, templates_parser-utils.adb: Initial revision. * templates_parser-xml.ads: Add DTD. * templates_parser-xml.adb: New version based on the new DTD (should be stable now). * templates_parser.adb: (Parse) [All versions]: Add a Context parameter. This implements the context/callback mechanism in the templates engine. This callback routine is used to get the value for a variable if not found in the translation set. (Callback): New procedure. (Is_True): Add pragma inline. (Translate): Use context if variable was not in the translation set. * templates_parser.ads: (Context): New type. (COntext_Access): New type. (TP_Context): New subtype alias for Context above. (Callback): New procedure. (Null_Context): New constant. (Parse) [All versions]: Add a Context parameter. This implements the context/callback mechanism in the templates engine. This callback routine is used to get the value for a variable if not found in the translation set. 2004-05-17 Pascal Obry * templates_parser-filter.adb, templates_parser-xml.adb: Changes to use new AI302 interface. * templates_parser.ads, templates_parser.adb: Changes to use new AI302 interface. 2004-05-15 Pascal Obry * templates_parser-xml.adb: (Process_Std): Put in alphabetical order. 2004-05-14 Pascal Obry * templates_parser.ads, templates_parser.adb: (Item) [Tag]: Renamed to Composite. (Composite): Renaming of Item. Sounds better and avoid some non upward compatibilities. 2004-05-13 Pascal Obry * templates_parser-query.ads, templates_parser-query.adb: (Vector): Renamed Composite. (Nested_Level): New routine. Update copyright notice. * templates_parser-xml.adb: Minor reformatting. 2004-05-12 Pascal Obry * makefile: (.SILENT): Remove build. (build): Removed. (clean): Do not call clean on directory obj. * templates_parser.adb: (Replace): Properly handle the case where the value is an empty string. In that case the Data.Tree object is null. 2004-05-11 Pascal Obry * templates_parser.ads, templates_parser.adb: (Translate) [Translate_Set]: New version based on a Translate_Set. Continued work for Templates_Engine speed-up. Minor reformatting. 2004-05-11 Pascal Obry * templates_parser.ads: (Assoc) [Tag]: Add some comments. * templates_parser-xml.adb: (Is_Label): New routine. Detect properly all case where a tag is a label for a tag. (Process): Use Is_Label. 2004-05-11 Pascal Obry * makefile: (DEBUG): Removed. (build): Call build on obj directory. (clean): Call clean on obj directory. * templates_parser-filter.adb: Change the spec of all filter routines to use a Translate_Set. (Value): This version is far more efficient, the top level loop has been removed as it now uses a Translate_Set. * templates_parser.adb: (Image): Move to spec. (Filter.Callback): Adjust parameter to use a Translate_Set. This change is also done for all filter routines. (Translate): Change spec to use a Translate_Set for efficiency. This version is far more efficient, the top level loop has been removed. (Check): This version is far more efficient, the top level loop has been removed as it now uses a Translate_Set. (Initialize): New routine. (Finalize): Idem. (Adjust): Idem. (Insert): New routtine. (Exists): Idem. (To_Set): Idem. (Parse) [String]: New routine with a Translate_Set. (Parse) [Unbounded_String]: New routine with a Translate_Set. Minor reformatting. * templates_parser.ads: (Translate_Set): New type. (Insert): New routtine. (Exists): Idem. (To_Set): Idem. Add supports for translate set based on maps. This is far more efficient that having to read the translate table when looking for a specific tag name. (Parse) [String]: New routine with a Translate_Set. (Parse) [Unbounded_String]: New routine with a Translate_Set. (Initialize): New routine. (Finalize): Idem. (Adjust): Idem. (Image): Routine moved here from body. * templates_parser-xml.ads, templates_parser-xml.adb: Initial revision. 2004-05-10 Pascal Obry * templates_parser.adb: (F_Sup): Add ??? about exception. (Get_Max_Line): Remove condition for Table_Stmt to support properly tag with any nested level at any table level. (Check): Complete rewrite to handle properly tag with any nested level at any table level. 2004-05-09 Pascal Obry * templates_parser.adb: (Field): Better implementation to share code. 2004-05-09 Pascal Obry * templates_parser-debug.ads, templates_parser-debug.adb: Initial revision. * templates_parser-query.adb: (Vector): Change code to detect what a vector structure is. Now it is checking if Nested_Level = 1. * templates_parser.ads: Lot of changes to support tags nested at any level. Vector_Tag and Matrix_Tag are now implemented using this new generic tag implementation. (Print_Tree): Moved to private part. This can now be accessed from Templates_Parser.Debug child package. * templates_parser.adb: Lot of changes to support tags nested at any level. Vector_Tag and Matrix_Tag are now implemented using this new generic tag implementation. 2004-04-14 Pascal Obry * templates_parser-filter.adb: (BR_2_LF): Fix Constraint_Error if S is empty. 2004-03-12 Pascal Obry * templates_parser-expr.adb: (Next_Token): Properly handle filter parameters. Minor reformatting. 2004-03-09 Pascal Obry * templates_parser-cached_files.adb: (Mark_Mode): New type. (Update_Used_Counter): New routine. (Add): Properly handle include files on reload. (Get): Use Null_Static_Tree. Remove Load parameter. Call Update_Used_Counter to mark main template file and all files included. (Release): Call Update_Used_Counter to release main template file and all files included. (Up_To_Date): Properly check for all include files not only the first level. * templates_parser-print_tree.adb: (Print_Tree): Remove output of Ref field. Update copyright notice. * templates_parser.adb: (Null_Static_Tree): New constant. (Node) [Info]: Remove Ref field. (Cached_Files.Get): Remove Load parameter. (Load): Use Null_Static_Tree. Minor reformatting. 2004-03-08 Pascal Obry * templates_parser.adb: Minor reformatting. * templates_parser-expr.adb: Complete rewrite to be LL(0) parser. Patch contributed by Jean-Pierre Rosen. 2004-03-07 Pascal Obry * templates_parser-filter.adb: (Replace_One_Or_All): New routine used to implement the REPLACE and REPLACE_ALL filters. (Replace): Filter implemented using Replace_One_Or_All. (Replace_All): Idem. 2004-03-06 Pascal Obry * templates_parser-cached_files.adb: (Add): Do not release include file. Fix cache handling. This introduces a memory leak but it is better than a crash. See ???. * templates_parser.adb: (Release): Add Include parameter to control include file release. Code clean up. (Parse): Code clean up. 2004-03-04 Pascal Obry * templates_parser.adb: (Load): Improve previous check-in, do not put the Open into the exception handler. Patch contributed by Jean-Pierre Rosen. 2004-03-03 Pascal Obry * templates_parser.adb: (Load): Ensure that the file is always closed even if the parsing failed. Patch contributed by Jean-Pierre Rosen. 2004-02-07 Pascal Obry * templates_parser.adb: (Check) [Tag]: New procedure. (Check) [Data.Tree]: Use Check above (code moved from here). (Check) [Expr.Tree]: New procedure. (Get_Max_Line): Call Check for the condition on an If_Stmt. 2004-02-06 Pascal Obry * templates_parser.adb: (Parse): Remove return statement, never reached. (Parse): Buffer, Last new variable to implement a cache. This improves the performance by avoiding to many reallocation on the Unbounded_String. (Analyse.Add): New routine. Handle the cache. Patch contributed by Jean-Pierre Rosen. 2004-01-27 Pascal Obry * templates_parser.adb: (Ada.IO_Exceptions): Removed as it is not used. Minor style and case fixes to be compliant with AWS style. * templates_parser-expr.adb: (Parse): Add loop name in exit statement to be compliant with AWS style. * templates_parser-filter.adb: Fix casing error. Minor reformatting. Add some pragma Unreferenced to be compliant with AWS style. * templates_parser-query.adb: Remove duplicate routine header box. 2004-01-14 Pascal Obry * templates_parser-filter.adb: (Add_Param): Replace value by its tag's value. * templates_parser.adb: Update copyright notice. 2004-01-14 Pascal Obry * templates_parser.adb: (Mode): Add Replace_Param. (Replace_Param): New routine. (Build): Fix handling of quote in filter parameter. * templates_parser-filter.adb: (Replace_Param_Token): New constant. (Table): Add Replace_Param. (Del_Param): Fix implementation, properly check the name of the parameter. (Replace_Param): New routine. 2004-01-05 Pascal Obry * templates_parser-filter.adb: (Replace_All): Use Regpat.Match call compatible with GNAT 3.15p. Update copyright notice. 2003-12-20 Pascal Obry * templates_parser-filter.adb: (Add_Param_Token): New constant. (Del_Param_Token): Idem. (Table): Add Add_Param and Del_Param. (Add_Param): New routine. (Del_Param): Idem. * templates_parser.adb: (Mode): Add Add_Param and Del_Param. (Add_Param): New routine. (Del_Param): Idem. 2003-12-19 Pascal Obry * templates_parser-input-aws.adb: (Open): Remove call to Support_Compressed, not needed with the new AWS design. 2003-12-17 Pascal Obry * templates_parser.adb: (Translate): Add new variable NOW that represent the current date and time. 2003-12-15 Pascal Obry * templates_parser.adb: (Parameter_Data): Use a a Regpat instead of a Regexp. (Name_Parameter): Properly build a Regpat. * templates_parser-filter.adb: (Match): Use GNAT.Regpat instead of GNAT.Regexp. This is upward compatible and now the template engine use only the GNAT.Regpat unit. (Release): Properly release memory for the regpat used by match. 2003-12-12 Pascal Obry * templates_parser-filter.adb: (Format_Date_Token): New constant. (Table): Add Format_Date. (Format_Date): New routine. * templates_parser.adb: (Mode): Add Format_Date. (Format_Date): New routine. 2003-12-09 Pascal Obry * templates_parser-filter.adb: (Replace_All_Token): New constant. (Table): Add Replace_All entry. (Parameter): Handle Replace_All. (Replace): Handle case where replacement string is not a pattern. If no match return the original string. (Replace_All): New routine. * templates_parser.adb: (Mode): Add Replace_All. (Replace_All): New routine. 2003-12-08 Pascal Obry * templates_parser-filter.adb: (Is_Number): New routine. Add Translate_Table parameter to all filters routine. (Repeat): Use translate table if argument is not a number. (Plus): Idem and handles negative numbers. (Minus): Idem. (Multiply): Idem. (Divide): Idem. (Value): New routine. * templates_parser.adb: (Callback): Add a Translate_Table parameter. Add Translate_Table parameter to all filters routine. (Translate): Add a Translate_Table parameter. (Analyze): Pass Translations to all Translate calls. 2003-12-06 Pascal Obry * templates_parser.ads, templates_parser.adb: ("&"): Add versions to prepend data into the vector. 2003-12-03 Pascal Obry * templates_parser-input-aws.adb: (Open): Set the support compressed feature to false. The template must be parse in uncompressed mode. 2003-11-30 Pascal Obry * templates_parser.adb: (Analyse): Do not use recursivity for consecutives Text nodes. This use lot less stack space and should be faster. 2003-11-29 Pascal Obry * templates_parser-filter.adb: (Replace_Token): New variable. (Table): Add entry for Replace. (Parameter): Handles Replace filter. (Image): Idem. (Mode_Value): Fix algorithm, was sometimes looping forever looking for an unknown filter in some cases. (Is_Number): Add function header. (Replace): New implementation. (Release) [Parameter_Data]: New impementation. (Release) [Set]: New impementation. * templates_parser.adb: (Mode): Add Replace. (Parameter_Mode): Add Regpat. (Parameter_Data): Add variant part for Regpat. (Release) [Parameter_Data]: New routine. (Release) [Set]: New routine. (Find_Slash): New routine, look for not escaped slash. (Name_Parameter): Handles Regpat case. (Release) [Tag]: Call Release for the filter set. (Build_Include_Pathname): Fix detection of rooted filename, this time it should be ok. 2003-11-08 Pascal Obry * makefile: (build): Add templates_parser-input and templates_parser-query. (clean): Add *~ * templates_parser-query.ads, templates_parser-query.adb: Initial revision. * templates_parser.ads: (Association_Kind): Type moved from private part and renamed (was Var_Kind). 2003-11-05 Pascal Obry * templates_parser-cached_files.adb: (Get): Remove use type for GNAT.OS_Lib.OS_Time as it is not needed anymore. 2003-10-28 Pascal Obry * templates_parser.adb: (Error_Include_Filename): Removed. (Error_Include_Message): New variable. (Fatal_Error): Handle properly nested messages. (Parse): Retrieve include filename message and set Error_Include_Message. (Load): Fix way messages from include template are reported. 2003-10-09 Pascal Obry * templates_parser.adb: (Build_Include_Pathname): Properly handle rooted pathname and subdirectories. 2003-09-27 Pascal Obry * templates_parser-filter.adb: (Mode_Value): Use a dichotomy algorithm. (Slice): New filter. * templates_parser.adb: Put all Filter tokens into Filter separate package. (Mode): Sort in alphabetical order. (Slice): New routine. (Get_Slice): New routine. (Name_Parameter): Handle slice. (Parameter_Data): Idem. (Get_Next_Line): Handle comments at end of template properly. 2003-09-26 Pascal Obry * templates_parser.adb: Move all filter related codes to Templates_Parser.Filter separate package. (Name_Parameter): Remove quote around filter parameter. * templates_parser-filter.adb: Initial revision. 2003-09-24 Pascal Obry * templates_parser.adb: (Field): Now procedure, return a boolean to True if value Found. Complete rewrite to use the cached position. This is a large speed-up for iterators. (Clear): Properly initialize new fields. (Initialize): Idem. (Finalize): Properly free memory used by the new fields. (Item): Implementation based on Field. Code was duplicated. (Vector): Implementation based on Field. Code was duplicated. (Translate): Use new Field routines. * templates_parser.ads: (Access_Vector_Tag_Node_Access): New type. (Access_Matrix_Tag_Node_Access): Idem. (Vector_Tag): Add Current, Pos fields. (Matrux_Tag): Idem. These new fields are used to cache the current position to speed up a lot iterators. 2003-08-29 Pascal Obry * templates_parser.adb: (Load.Parse): Do not use recursivity to read standards text line. This lower a lot the use of the stack and make it possible to parse large files. Minor reformatting. 2003-07-31 Pascal Obry * templates_parser.adb: (Load): Properly detect missing include files and release the memory associated with the incomplete tree before raising a fatal error. 2003-03-27 Pascal Obry * templates_parser.adb: (Clear): Always call Finalize as this structure use a ref counter. Fix memory leak bug. 2003-03-25 Pascal Obry * templates_parser.adb: (Release): Properly free include files memory. 2003-03-15 Pascal Obry * templates_parser.adb: (Replace_Include_Variables): Also inherit the attributes. Complete previous fix. 2003-03-15 Pascal Obry * templates_parser.adb: Minor comment fix. 2003-03-15 Pascal Obry * templates_parser.adb: (Replace_Include_Variables): Handle all cases. Expression are correctly replaced. Filters are inherited by the new variable or applied to the new static value. 2003-03-11 Pascal Obry * templates_parser.adb: (Get_Next_Line): Skip all CR at the end of line. 2003-03-05 Pascal Obry * templates_parser-input-aws.adb: Use IO_Exceptions instead of Text_IO. (Open): Free allocated memory if Name_Error is raised. * templates_parser-input.adb: (Open): Free allocated memory if Name_Error is raised. 2003-02-27 Pascal Obry * templates_parser.adb: (Get_First_Parameter): Do not return the space after the filename if present. 2003-02-25 Pascal Obry * templates_parser.adb: Update copyright notice. 2003-02-25 Pascal Obry * templates_parser.adb: (Replace_Include_Variables): New procedure. (Get_All_Parameters): Change error message. (Get_Next_Line): Skip comment lines. (Parse): Call Replace_Include_Variables for include files. Minor reformatting. 2003-01-23 Pascal Obry * templates_parser.adb: (Filter_LF_2_BR_Token): New constant. (Filter_BR_2_LF_Token): New constant. (Filters_Mode): Add FS_2_BR and BR_2_LF. (BR_2_LF_Filter): New routine. (LF_2_BR_Filter): New routine. (Filter_Table): Add FS_2_BR and BR_2_LF. 2003-01-16 Pascal Obry * templates_parser-expr.adb: (Get_Token): Uses Index instead of Index_Non_Blank which handle only spaces. * templates_parser.adb: (Get_First_Parameter): Uses Index instead of Index_Non_Blank which handle only spaces. (Get_Next_Line): Idem. 2002-12-19 Pascal Obry * templates_parser.adb: (Clear): Finalize vector if it was the last reference. ("&"): Fix Min and Max handling (cut&paste error). (Initialize): Correctly initialize Min to Natural'Last. * templates_parser.ads: (Vector_Tag): Add comments about reference semantic. (Matrix): Add comments. (Clear): Add comments. 2002-11-29 Pascal Obry * templates_parser.adb: (Filter_Add_Token): Set to upper-case. (Filter_Sub_Token): Idem. (Filter_Mult_Token): Idem. (Filter_Div_Token): Idem. (Filter_Modula_Token): Idem. 2002-11-29 Pascal Obry * templates_parser.adb: (Image): New routine. (Filter_Plus_Token): New constant. (Filter_Add_Token): New constant. (Filter_Minus_Token): New constant. (Filter_Sub_Token): New constant. (Filter_Multiply_Token): New constant. (Filter_Mult_Token): New constant. (Filter_Divide_Token): New constant. (Filter_Div_Token): New constant. (Filter_Modulo_Token): New constant. (Filters_Mode): Add Plus, Add, Minus, Sub, Multiply, Mult, Divide, Div and Modulo. (Plus_Filter): New routine. (Minus_Filter): New routine. (Divide_Filter): New routine. (Multiply_Filter): New routine. (Modulo_Filter): New routine. (Filter_Table): Add entry for Plus, Add, Minus, Sub, Multiply, Mult, Divide, Div and Modulo. In many places use Image. 2002-11-28 Pascal Obry * templates_parser-data.adb: Minor reformatting. * templates_parser.adb: (Attribute): New type. (Tag): Add Attr attribute field. (Image): Handle attribute. (Get_Attribute): New function. (Get_Var_Name): Change to handle attribute. ("+"): Initialize Min/Max matrix field. ("&"): Update Min/Max matrix field. (Initialize): Set Min and Max to 0. (Vect_Size): New rotuine. (Mat_Line): New routine. (Mat_Min_Column): New routine. (Mat_Max_Column): New routine. (Translate): [for a tag], Handle attribute. (Get_Max_Lines.Check): Handle only tag with no atribute. Use matrix's Max field instead of recomputing it here. Minor reformatting. * templates_parser.ads: (Matrix_Tag): Add Min and Max fields. Minor reformatting. 2002-10-12 Pascal Obry * templates_parser-input-aws.adb: (LF_Terminated): New routine. * templates_parser-input.adb: (File_Record): Add field to support stream buffered input. Implementation was based on Text_IO but it is now using Stream_IO. (LF_Terminated): New routine. (Get_Line): Implement stream buffered input. More efficient and can now recognized lines terminated with LF. Change implementation of other routines to use Stream_IO instead of Text_IO. * templates_parser-input.ads: (LF_Terminated): New routine. * templates_parser-print_tree.adb: (Print_Tree): Text case, do not call New_Line. The new line is now part of the text data. Update copyright notice. * templates_parser.adb: (Load): Add Include_File parameter. Call load with Include_File set to True in include case. Add the LF at then end of text line only if needed. (Analyze): Text case, do not add LF at the end of line. 2002-10-10 Pascal Obry * templates_parser-expr.adb: (Parse): Handle string. (Print_Tree): Quote value containing spaces. Correctly quote unary operators. Update copyright notice. * templates_parser.adb: Reformat code. Update copyright notice. 2002-10-09 Pascal Obry * templates_parser-expr.adb: (Is_Op): New function. (Is_U_Op): New function. (Image): New routine (for U_Ops). (Value): New routine (for U_Ops). (Parse): Handle U_Op case. (Print_Tree): Handle U_Op case. (Release): Handle U_Op case. * templates_parser.adb: (U_Ops): New type. (Image): New routine (for U_Ops). (Value): New routine (for U_Ops). (NKind): Add U_Op (unary operator). (Node): Handle U_Op. (F_Diff): Add prototype. (U_Ops_Fct): New type. (F_Not): New routine. (U_Op_Table): New variable. (Analyse): Handle U_Op. * templates_parser-expr.adb: (Image): Add case for O_Diff. (Value): Handle "/=" operator. Support for /= operator. * templates_parser.adb: (Ops): Add O_Diff. (F_Diff): New function. (Analyse.Op_Table): Add entry for O_Diff. Support for /= operator. 2002-08-05 Pascal Obry * templates_parser-expr.adb: (No_Quote): New function. (Parse): Removes quote around variables and values. * templates_parser-expr.adb: (Get_Token): If a expression with parenthesis parsed, return parenthesis. (Parse): L_Tok can be an expression (not only a value or variable). 2002-06-29 Pascal Obry * templates_parser-input-aws.adb: (Check_Open): New routine. Use it in all routines to check the file status before using it. (File_Record): Is a derived type insted of a record. 2002-06-22 Pascal Obry * makefile: (GARGS): Add rules for RELEASE / DEBUG modes. * templates_parser.adb: Remove with Ada.Text_IO. Add unit Templates_Parser.Input. (Load): Use input routines from Templates_Parser.Input instead of Text_IO. * templates_parser-print_tree.adb: Add with Ada.Text_IO. * templates_parser-expr.adb: Add with Ada.Text_IO. * templates_parser-data.adb: Add with Ada.Text_IO. * templates_parser-input-aws.adb: Initial revision. * templates_parser-input.ads, templates_parser-input.adb: Initial revision. 2002-05-17 Pascal Obry * templates_parser.adb: Remove unused subtype. Patch from Wiljan Derks. 2002-03-15 Pascal Obry * templates_parser.adb: (Add_Vector): Check that vector is not empty. Fix a bug reported by Dmitriy Anisimkov. 2002-02-19 Pascal Obry * templates_parser.ads: Fix minor comment's typo. 2002-02-18 Pascal Obry * templates_parser-cached_files.adb: (Add): If file is not in use, we still want to initialize Old to C_Info node. If tree in use, mark the new tree as not used. (Prot.Get): Now a procedure instead of a function. (Prot.Release): Add assertion. Remove test as this case should never happen. Fix another memory leak in the cache handling. * templates_parser.adb: (Prot.Get): Now a procedure instead of a function. (Load): Update to use Prot.Get. Add Assertion. Always set Old to the C_Info node. (Parse): Call analyse on the C_Info tree. Change to fix another memory leak in the cache handling. 2002-02-17 Pascal Obry * templates_parser-cached_files.adb: (Add): Always initialize Old with current tree C_Info node. (Get): Returns a static tree. (Release): Parameter is now a Static_Tree. Fix another bug with multitasking programs. * templates_parser.adb: (Prot.Release): Parameter is now a Static_Tree. (Prot.Get): Returns a static tree. (Load): Update to use cache interface. (Parse): Idem. Add many comments about cache handling has it is quite tricky piece of code. * templates_parser-cached_files.adb: (Prot.Release): Removes debug code. * makefile: Adjust for Cygwin make. * templates_parser-cached_files.adb: (Prot.Add): Add Old parameter. Add many comments, this part is tricky. Do not free a tree that is currently used by another task. (Release): New procedure. (Up_To_Date): Minor reformatting. These changes provides a complete thread safe cache implementation. This is the right fix for the previous check-in. * templates_parser-print_tree.adb: Handle C_Info node in many places. * templates_parser.adb: (Nkind): Add C_Info. (cache info node). (Static_Tree): New type. (Node): Handle C_Info, Add comments. File (Include_Stmt case) is now a Static_Tree. (Prot.Add): Add Old parameter. (Load): Returns now a Static_Tree. Reorder the code to close the file as soon as possible. Build C_Info node. (Print_Tree): Change to support Static_Tree. (Get_Max_Line): Handle C_Info node. (Analyze): Idem. (Parse): Change to handle Static_Tree. (Release): Handle C_Info node. Include_Stmt case handle Static_Tree. These changes provides a complete thread safe cache implementation. 2002-02-15 Pascal Obry * makefile: (VERSION): Set to 3.4 Add regtst2 regression test. * templates_parser-cached_files.adb: (Prot.Add): Check if file is already added. Fix a bug in multithreaded appliations. 2002-01-30 Pascal Obry * makefile: (VERSION): Set to 3.3 (ada.sed): Fix quote usage. * templates_parser.adb: (Mat_List): Do not try to add a vector that does not exist. In the case of a matrix outside a table statement do not add the last LF. 2002-01-25 Pascal Obry * makefile: (VERSION): Set to 3.2 * templates_parser.adb: (Get_Filter_Set): Remove wrong pragma assert. 2001-11-24 Pascal Obry * makefile: (distrib) create a tarball using VERSION. * makefile: (VERSION): new variable, used to build the tarball. * templates_parser.adb: Minor casing fix. * templates_parser.texi: Fix spelling. * templates_parser.adb: (Get_Next_Line): correctly compute end of line removing all trailing spaces. * templates_parser.ads: Fix spelling. 2001-11-22 Pascal Obry * templates_parser.adb: (Analyze): put the whole exception information into the exception message. 2001-11-08 Pascal Obry * makefile: (test): add 3 tests (error recovery). * templates_parser.adb: (Load.Parse): handle better some common errors. (Is_Stmt): is now inlined. Minor reformating. 2001-09-11 Pascal Obry * templates_parser.adb: (Item): Fix bug, advance the index counter. 2001-09-03 Pascal Obry * templates_parser.ads, templates_parser.adb: (Item): new function. * templates_parser-expr.adb: (Release): fix bug in freeing the memory. 2001-07-24 Pascal Obry * templates_parser.adb: (Get_All_Parameters): removes trailing ASCII.CR. This fix condition handling when the template has a DOS format and is used under UNIX. (Format_Number_Filter): Trim number. all spaces on the left or right is removed before processing it. 2001-07-21 Pascal Obry * templates_parser.texi: Document FORMAT_NUMBER filter. * templates_parser.adb: Add FORMAT_NUMBER filter implementation. (Filter_Format_Number_Token): new constant. (Filter_Mode): add Format_Number. (Filter_Table): add Format_Number. (Format_Number_Filter): new function. 2001-07-16 Pascal Obry * templates_parser.texi: Document SIZE filter. * templates_parser.adb: Add SIZE filter implementation. (Filter_Size_Token): new constant. (Filter_Mode): add Size. (Filter_Table): add Size. (Size_Filter): new function. 2001-07-11 Pascal Obry * templates_parser.texi: Update documentation for Web_Escape_Filter. * templates_parser.adb: (Web_Escape_Filter): Handle Web " 2001-06-30 Pascal Obry * templates_parser.texi: Add documentation for ELSIF implementation. * templates_parser.adb: (End_If_Token): new constant. (Parse_Mode): add Parse_Elsif. (Parse): Implementation of ELSIF token. Add some checks about misplaced @@END_IF@@ and @@END_TABLE@@ statement. 2001-06-30 Pascal Obry * templates_parser.adb: (Parameter_Data): new type. (Image): new function to return Parameter_Data string representation. (Filter_Function): use Parameter_Data for parameters. (Filter_Routine): Parameters field is now a Parameter_Data type. (*_Filter): Filters function takes a Parameter_Data object instead of the Unbounded_String one. (Check_Null_Parameter): idem. (Filter_Handle): new function. (Filter_Mode): new function. (Image): for a Tag, use Image for Parameter_Data. (Name_Parameter): change returned value to use new spec based on Parameter_Data. (Expect_Regexp): new function. (Match_Filter): use now the precompiled regexp in Parameter_Data. This is a important speed-up. 2001-06-24 Pascal Obry * templates_parser.adb: Put all packages body separate and Print_Tree procedure. * templates_parser-cached_files.adb, templates_parser-data.adb, templates_parser-expr.adb, templates_parser-print_tree.adb: Initial revision (code separated from main unit). * templates_parser.texi: Reorganize the documentation. Add some info about filters. Described all specifics tags that are recognized. * templates_parser.adb: (Print_Tree): fix typo in section. 2001-06-11 Pascal Obry * templates_parser.adb: (Name_Parameter): better detect misformed filter parameter. * templates_parser.adb: (Name_Parameter): correctly handle regexp with parenthesis. (Node): add line information into the node to be able to display line where error occurs during analysis (after parsing). (Match_Filter): check that there is a parameter. (Load): correctly set Line field for each node. * templates_parser.adb: (Filter_Repeat_Token): new constant. (Filter_Match_Token): new constant. (Filters_Mode): add Match and Repeat. (Filter_Function): add a second parameter. (Filter_Routine): new record. (Filter_Set): is now an array of Filter_Routine. (Check_Null_Parameter): new procedure. (*_Filter): add a second parameter to pass filter's parameters. Check if no parameter are passed. (Image): for tag, display filter parameter. (Get_Filter_Set.Name_Parameter): new function. (Get_Filter_Set): handle filter's parameter. (Repeat_Filter): new function. (Match_Filter): new function. (Filter_Table): add Match and Repeat. Minor reformatting. 2001-05-30 Pascal Obry * templates_parser.adb: (Contract_Filter): removes unused variable K. (Translate): if Var is not found we still want to process the registedred filters. 2001-05-28 Pascal Obry * templates_parser.ads: Add some comments. * templates_parser.texi: Add Coma_2_Point and Point_2_Coma. * templates_parser.ads: (Parse): Add boolean parameter Keep_Unknown_Tags. * templates_parser.adb: (Parse): Add boolean parameter Keep_Unknown_Tags. Add 2 new filters: Coma_2_Point and Point_2_Coma. (Filter_Coma_2_Point_Token): new constant. (Filter_Point_2_Coma_Token): idem. (Filters_Mode): add Coma_2_Point and Point_2_Coma (Coma_2_Point_Filter): new function. (Point_2_Coma_Filter): idem. (Filter_Table): add Coma_2_Point and Point_2_Coma. 2001-05-25 Pascal Obry * templates_parser.adb: Minor comment editing. * templates_parser.adb: (Filter_Contract_Token): new constant. (Filter_No_Digit_Token): idem. (Filter_No_Letter_Token): idem. (Filter_Trim_Token): idem. (Filter_Web_Escape_Token): idem. (Filter_Web_NBSP_Token): idem. (Filters_Mode): add No_Digit, No_Letter, Contract, Trim, Web_Escape, Web_NBSP. (Contract_Filter): new function. (No_Digit_Filter): idem. (No_Letter_Filter): idem. (Trim_Filter): idem. (Web_Escape_Filter): idem. (Web_NBSP_Filter): idem. (Filter_Table): add Contract, No_Digit, No_Letter, Trim, Web_Escape, Web_NBSP. 2001-05-23 Pascal Obry * templates_parser.adb: (Nkind): add Info into the enumeration. (Node): add case for new Info node. removes File and Filename field from the Include_Stmt case (handled by info node). (Cahced_Files): put Add and Get into a protected record. This package is now thread safe. (Prot): new protected record. (File_Data): removed. (Get): new function. (Add): lot of change to handle case of file already present but reloaded because it has changed on disk. (Get): idem. (Up_To_Date): new function. Check if file has changed on disk or not and if it is needed to reload it. This means a check for the main file and all include files for this file. (Load): Add I_File variable and set it with the list of included files for current loaded file. (Print_Tree): add code to display INFO node. (Get_Max_Lines): handle Info node. (Release): handle Info node. 2001-05-22 Pascal Obry * templates_parser.adb: (Fatal_Error): add pragma No_Return. Avoid compiler warning. (Get_First_Parameter): handle case where there is only spaces after a tag. (Get_Next_Line): handle case where there is only spaces on a line. 2001-05-21 Pascal Obry * templates_parser.adb: (Open_Par): removed. (Close_Par): removed. (Filter_Table): set to constant. (Build_Include_Pathname): new function. (Load): use Build_Include_Pathname when including a template file. This fix a bug when a template in a subdirectory where including another template without specifying a pathname. Minor reformating. 2001-05-16 Pascal Obry * templates_parser.adb: (Vect_List): moved inside function using it. (Mat_List): idem. Minor reformating. * templates_parser.adb: A lot of changes. This new implementation is 2 or 3 times faster than the previous one. (Internal_Error): new exception. (Node): removed filed Has_Tag. (With_Tag): new function. (Filter_*_Token): remove @_ prefix. (Check_Filter): removed. (Through_Filter): removed. (Filter_Length): removed. (Identity_Filter): removed. (Translate): removed. (Filter_Handle): new function. (Filter_Name): new function. New type and method to handle a tag variable. This new abstraction is used to have better performance. (Tag): new type. (Build): new procedure to build Tag. (Image): new procedure. (Translate): new procedure. (Release): new procedure. New abstraction to build a standard line (where there is no Tag statement). (Data): new package. (Parse): use Data.Parse for parsing the text line. (Load): open file with sharing=no. (Print_Tree): update to display new format. (Translate): add special tag variables YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MONTH_NAME and DAY_NAME. * templates_parser.ads: (Translate): fix comment. 2001-05-13 Pascal Obry * templates_parser.texi: Add doc for No_Space filter. * templates_parser.adb: (Filter_No_Space_Token): new constant. (Filter_Mode): add No_Space. (No_Space_Filter): new function. Put all filter function in alphabetical order. (Filter_Table): set No_Space entry. (Check_Filter): minor reformating. * templates_parser.adb: (Parse): Use Append function to build the results instead of operator &. This avoid a lot of copy to/from the stack and we have a general speed up of a factor 4. * templates_parser.adb: (Image): Add support for xor condition operator. (Value): Add support for xor condition operator. (Op_Table): add xor in the table. (Ops): add O_Xor. (F_Xor): new function. * templates_parser.texi: Update documentation with new Templates_Parser features. 2001-05-12 Pascal Obry * templates_parser.adb: (Begin_Tag): new variable. (End_Tag): new variable. (Filter_*_Token): change start to "@_" (Blank): move to global to share it. (Expr): new package. (Node): add Has_Tag boolean. It is set to True if the line does contains some tag and False otherwise. (Assoc): remove Begin_Tag and End_Tag parameters. (Get_All_Parameters): new function. (Get_First_Parameter): Blank definition removed. (Parse): set Has_Tag field. (Print_Tree): output properly the condition tree for @@IF@@ tag statement. (Analyze): new procedure (to Analyze expression tree). (Translate): set internal variable to new format. (Is_True): new function. (Analyze): use Has_Tag variable to trigger call to Translate. Handle new condition expression. (With_Tag): new function. * templates_parser.ads: (Set_Tag_Separators): new procedure. (Assoc): remove Begin_Tag and End_Tag parameters. (Default_Begin_Tag): set to "@_" (Default_End_Tag): set to "_@" * templates_parser.adb: (Filter_Exist_Token): new constant. (Filter_Is_Empty_Token): new constant. (Filter_Mode): add Exist and Is_Empty. (Exist_Filter): new function. (Is_Empty_Filter): new function. (Check): compute now the manimum number of items. (Get_Max): idem. removes check for Natural'Last since now by default if no tag found the result is 0. 2001-05-09 Pascal Obry * templates_parser.ads, templates_parser.adb: (Clear): new procedure. (Initialize): new procedure for Matrix_Tag_Int. (Finalize): idem. (Adjust): idem. 2001-05-09 Pascal Obry * templates_parser.ads: (Matrix_Tag): new type. (Size): new function. (on Matrix_Tag). (Vector): new function. (Assoc): new function (on Matrix_Tag). (Matrix_Tag_Int): new type. (Var_Kind): add Matrix. (Association): add handling for Matrix. * templates_parser.adb: ("+"): new function (Matrix_Tag constructor). ("&"): new function (Matrix_Tag constructor). (Size): new function. (on Matrix_Tag). (Vector): new function. (Assoc): new function (on Matrix_Tag). (Table_State): new type. (Analyse): use Table_State instead of multiple variables. Hanlde properly matrix tag through the table state. (Vect_List): new function. (Mat_List): new function. (Translate): fastest implementation. build properly vector or matrix image outside of TABLE tag statement. Build UP_TABLE_LINE tag value. (Get_Max): complete rewrite to handle properly matrix tag value. 2001-05-06 Pascal Obry * templates_parser.ads: (Max_Template_Lines): removed. There is no more limitation. (Size): new function. (Parse): Add Cached parameter. Rename Template_Filename to Filename. (Template_File): removed. (Parse): version with Template_File removed. (Open): removed. Minor comment fixes. * templates_parser.adb: This a complete rewrite of the Templates_Parser engine. Now the file is read into memory and put into a tree. The tree is then analysed to create the resulting file from the templates. This is more dynamic and now an @@IF@@ tag statement inside a @@TABLE@@ tag statement is analysed for each table expansion instead of beeing statically analysed during the first pass. (Max_Section): removed, not more limitation. (Node): new type. (Tree): new type. (Cached_Files): new package. (Size): new function. (Field): return empty string is index too high. (Load): new function. (Print_Tree): new procedure. (Parse): complete rewrite. (Open): removed. (Initialize): for Telmplate_File removed. (Finalize): for Telmplate_File removed. (Adjust): for Telmplate_File removed. Minor comment fixes. 2001-04-28 Pascal Obry * templates_parser.ads, templates_parser.adb: Add operators "+" for Character, Unbounded_String, Integer and boolean. 2001-04-27 Pascal Obry * templates_parser.ads: ("&"): new version for Character, Boolean, Unbounded_String and Integer. (Assoc): new version for Unbounded_String and Integer. * templates_parser.adb: ("&"): new version for Character, Boolean, Unbounded_String and Integer. (Assoc): new version for Unbounded_String and Integer. (List): fix, return the empty string when there is no element. 2001-04-27 Pascal Obry * templates_parser.ads: Minor reformating. Vector_Tas is now a Controlled type to avoid memory leak. * templates_parser.adb: ("&"): change, now Vector_Tag is a controlled type. ("+"): idem. (Finalize): new procedure (on Vector_Tag type). (Initialize): idem. (Adjust): idem. Minor reformating. Vector_Tas is now a Controlled type to avoid memory leak. Note: this version has no memory leak at all. 2001-04-26 Pascal Obry * templates_parser.ads, templates_parser.adb: Update copyright notice. 2001-04-26 Pascal Obry * templates_parser.ads: (Vector_Tag): new type. ("+"): Initial revision. ("&"): Initial revision. (Assoc): new verison for Vector_Tag. Separator is now a string and is used to build list from a vector tag. A vector tag is not anymore a string with separator. Reformat. * templates_parser.adb: Remove with String_Cutter (not used anymore). (Count_Lines): change implementation, was using String_Cutter, use vector tag fields. (Vector_Tag): new type. ("+"): Initial revision. ("&"): Initial revision. (Assoc): new verison for Vector_Tag. Separator is now a string and is used to build list from a vector tag. A vector tag is not anymore a string with separator. (Translate): change implementation, do not use String_Cutter anymore. Reformat. 2000-09-03 Pascal Obry * templates_parser.adb: (Filter_Yes_No_Token): new constant. (Filter_Oui_Non_Token): new constant. (Filter_Mode): add entry for Yes_No and Oui_Non filters. (Yes_No_Filter): new function. (Oui_Non_Filter): new function. (Filter_Table): add entry for above filters. (Check_Filter): minor indentation fix. 2000-02-07 Pascal Obry * templates_parser.adb: Major changes to implement tag variable filters. 1999-12-08 Pascal Obry * templates_parser.adb: minor reformating. 1999-12-03 Pascal Obry * templates_parser.adb: (Translate): fix bug when a empty discrete variable was used in table. 1999-12-02 Pascal Obry * templates_parser.ads, templates_parser.adb: (Translate): new function 1999-12-01 Pascal Obry * templates_parser.ads: Minor reformating. Add some comments 1999-11-30 Pascal Obry * templates_parser.ads, templates_parser.adb: (Initialize): new procedure (Finalize): new procedure (Adjust): new procedure (Close): removed. Not needed anymore because the Template_File is controlled. 1999-11-30 Pascal Obry * templates_parser.ads, templates_parser.adb: (Parse, Open, Close): new unit This new version implement the in-memory template file. This way it is possible to cache the template file in a server for better performance. 1999-11-30 Pascal Obry * templates_parser.ads: Minor comment added. 1999-11-25 Pascal Obry * templates_parser.ads: (Assoc): add Is_Vector boolean parameter. This must be set to true if we want to build a vector tag. * templates_parser.adb: (Assoc): add Is_Vector boolean parameter. This must be set to true if we want to build a vector tag. (Translate): add support for tag with a single value in a table. 1999-11-23 Pascal Obry * templates_parser.adb: (Terminate_Sections_Token): new token for table (Parse): handle case where the translation variable number does not exist. In this case we translate to an empty string. (Parse_Table): new parameter for terminate sections mode Fix exception handler. 1999-11-20 Pascal Obry * templates_parser.ads: removes documentation from the spec as it is in the documentation. * templates_parser.adb: Minor reformating. 1999-11-20 Pascal Obry * templates_parser.adb: Add code to handle section in a table. (Parse): add TABLE_LINE, NUMBER_LINE, TABLE_LEVEL tags handling (Count_Lines): new function used to update Max_Lines variable. (Parse): fix infinit loop bug when a table had no tag variable inside. Check when the template file was not found. 1999-11-01 Pascal Obry * templates_parser.ads, templates_parser.adb: First complete version 1999-11-01 Pascal Obry * templates_parser.ads, templates_parser.adb: Implement IF, TABLE, INCLUDE 1999-11-01 Pascal Obry * templates_parser.adb: Initial revision libtemplates-parser-11.6.orig/src/templates_parser-cached_files.adb0000644000175000017500000002237611637170657025446 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 1999-2011, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ separate (Templates_Parser) package body Cached_Files is Initial_Size : constant := 20; -- cache initial size Growing_Size : constant := 50; -- cache growing size type File_Array is array (Positive range <>) of Tree; type File_Array_Access is access File_Array; Files : File_Array_Access; Index : Natural := 0; procedure Growth; -- Growth the size (by Growing_Size places) of Files array function Get (Filename : String) return Natural; -- Look for Filename into the set and return its index. Returns 0 if -- filename was not found. function Up_To_Date (T : Tree) return Boolean; -- Returns True if the file tree is up to date (the templates files -- have not been modified on disk) or False otherwise. type Mark_Mode is (Used, Released); procedure Update_Used_Counter (T : in out Static_Tree; Mode : Mark_Mode); -- Update C_Info used counter according to Mode --------- -- Add -- --------- procedure Add (Filename : String; T : Tree; Old : out Tree) is L_Filename : constant Unbounded_String := To_Unbounded_String (Filename); S : Natural := 1; E : Natural; N : Natural; I : Tree; begin E := Index; -- Does the table initialized and do we have enough place on it ? if Files = null or else Index = Files'Last then Growth; end if; loop exit when S > E; N := (S + E) / 2; if Files (N).Filename = L_Filename then -- This is a file that was already loaded. If loaded again -- it is because the file timestamp has changed. We want to -- just update the tree and not the info node (first node). Old := Files (N).Next; -- This is a pointer to the C_Info tree node, skipping the -- info node (first node). I := Files (N).I_File; -- Old include files dependencies Files (N).Next := T.Next; Files (N).Timestamp := T.Timestamp; Files (N).I_File := T.I_File; -- Now free old I_File declare O : Tree; begin while I /= null loop O := I; I := I.Next; Unchecked_Free (O); end loop; end; -- This part is tricky, the tree could be currently used -- (parsed). So we need to be careful to not release the tree -- too early. if Old.Used = 0 then -- File is not currently used, we can release it safely Release (Old, Include => False); Old := T.Next; else -- Tree is used, mark it as obsoleted, it will be removed -- when no more used by the Release call. Old.Obsolete := True; Old.Used := Old.Used + 1; -- But current tree is not used, it has been posted here -- for futur use. But if replaced right away it should be -- freed. Files (N).Next.Used := 0; end if; -- Nothing more to do in this case return; elsif Files (N).Filename < L_Filename then S := N + 1; else E := N - 1; end if; end loop; -- Filename was not found, insert it in the array at position S Files (S + 1 .. Index + 1) := Files (S .. Index); Index := Index + 1; Files (S) := T; Old := T.Next; -- Old point to the current C_Info tree end Add; --------- -- Get -- --------- procedure Get (Filename : String; Result : out Static_Tree) is N : constant Natural := Get (Filename); begin if N = 0 then Result := Null_Static_Tree; else Result := (Files (N), Files (N).Next); Update_Used_Counter (Result, Mode => Used); end if; end Get; function Get (Filename : String) return Natural is L_Filename : constant Unbounded_String := To_Unbounded_String (Filename); S : Natural := 1; E : Natural := Index; N : Natural; begin loop exit when S > E; N := (S + E) / 2; if Files (N).Filename = L_Filename then if Up_To_Date (Files (N)) then return N; else -- File has changed on disk, we need to read it again. Just -- pretend that the file was not found. return 0; end if; elsif Files (N).Filename < L_Filename then S := N + 1; else E := N - 1; end if; end loop; return 0; end Get; ------------ -- Growth -- ------------ procedure Growth is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (File_Array, File_Array_Access); begin if Files = null then Files := new File_Array (1 .. Initial_Size); else declare New_Array : File_Array_Access; begin New_Array := new File_Array (1 .. Files'Length + Growing_Size); New_Array (1 .. Files'Length) := Files.all; Unchecked_Free (Files); Files := New_Array; end; end if; end Growth; ------------- -- Release -- ------------- procedure Release (T : in out Static_Tree) is begin Templates_Parser_Tasking.Lock; pragma Assert (T.C_Info /= null); Update_Used_Counter (T, Mode => Released); if T.C_Info.Obsolete and then T.C_Info.Used = 0 then pragma Assert (T.Info.Next /= T.C_Info); Release (T.C_Info, Include => False); end if; Templates_Parser_Tasking.Unlock; exception when others => Templates_Parser_Tasking.Unlock; raise; end Release; ------------- -- Release -- ------------- procedure Release is begin Templates_Parser_Tasking.Lock; for K in 1 .. Index loop -- We do not want to release the include files, each include file as -- its own entry into the cache and is released as part of this loop. Release (Files (K), Include => False); end loop; Index := 0; Templates_Parser_Tasking.Unlock; exception when others => Templates_Parser_Tasking.Unlock; raise; end Release; ---------------- -- Up_To_Date -- ---------------- function Up_To_Date (T : Tree) return Boolean is use Configuration; P : Tree; Result : Boolean; begin -- Check main file if Configuration.File_Time_Stamp (To_String (T.Filename)) /= T.Timestamp then return False; end if; -- Check all include files P := T.I_File; while P /= null loop Result := Up_To_Date (P.File.Info); if not Result then return False; end if; P := P.Next; end loop; return True; end Up_To_Date; ------------------------- -- Update_Used_Counter -- ------------------------- procedure Update_Used_Counter (T : in out Static_Tree; Mode : Mark_Mode) is P : Tree; begin -- Mark current tree if T.Info = null then return; end if; case Mode is when Used => T.Info.Next.Used := T.Info.Next.Used + 1; when Released => T.Info.Next.Used := T.Info.Next.Used - 1; end case; -- And mark all include files P := T.Info.I_File; while P /= null loop Update_Used_Counter (P.File, Mode); P := P.Next; end loop; end Update_Used_Counter; end Cached_Files; libtemplates-parser-11.6.orig/src/templates_parser-configuration__standalone.ads0000755000175000017500000000425311637170657030311 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with GNAT.OS_Lib; package Templates_Parser.Configuration is subtype Time_Stamp is GNAT.OS_Lib.OS_Time; pragma Style_Checks (Off); -- Kill bogus style check on missing overriding keyword with old GNAT -- versions. function "=" (T1, T2 : Time_Stamp) return Boolean renames GNAT.OS_Lib."="; pragma Style_Checks (All_Checks); function Is_Regular_File (Filename : String) return Boolean renames GNAT.OS_Lib.Is_Regular_File; function File_Time_Stamp (Filename : String) return Time_Stamp renames GNAT.OS_Lib.File_Time_Stamp; end Templates_Parser.Configuration; libtemplates-parser-11.6.orig/src/templates_parser-data.adb0000644000175000017500000007227611637170657023772 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 1999-2011, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; separate (Templates_Parser) package body Data is ----------- -- Build -- ----------- function Build (Str : String) return Tag_Var is function Get_Var_Name (Tag : String) return String; -- Given a Tag name, it returns the variable name only. It removes -- the tag separator and the filters. function Get_Filter_Set (Tag : String) return Filter.Set_Access; -- Given a tag name, it retruns a set of filter to apply to this -- variable when translated. function Get_Attribute (Tag : String) return Attribute_Data; -- Returns attribute for the given tag function Is_Internal (Name : String) return Internal_Tag; -- Returns True if Name is an internal tag function Is_Macro return Boolean; pragma Inline (Is_Macro); -- Returns True if we are parsing a macro F_Sep : constant Natural := Strings.Fixed.Index (Str, ":", Strings.Backward); -- Last filter separator A_Sep : Natural := Strings.Fixed.Index (Str, "'", Strings.Backward); -- Attribute separator MP_Start, MP_End : Natural := 0; -- Start/End of the macro parameters, 0 if not a macro ------------------- -- Get_Attribute -- ------------------- function Get_Attribute (Tag : String) return Attribute_Data is Start, Stop : Natural; begin if A_Sep = 0 then return No_Attribute; else Start := A_Sep + 1; Stop := Tag'Last - Length (End_Tag); end if; declare A_Name : constant String := Characters.Handling.To_Lower (Tag (Start .. Stop)); begin if A_Name = "length" then return (Length, 0); elsif A_Name = "line" then return (Line, 0); elsif A_Name = "min_column" then return (Min_Column, 0); elsif A_Name = "max_column" then return (Max_Column, 0); elsif A_Name'Length >= 8 and then A_Name (A_Name'First .. A_Name'First + 7) = "up_level" then if A_Name'Length > 8 then -- We have a parameter declare V : constant String := Strings.Fixed.Trim (A_Name (A_Name'First + 8 .. A_Name'Last), Strings.Both); N : Integer; begin if V (V'First) = '(' and then V (V'Last) = ')' and then Is_Number (V (V'First + 1 .. V'Last - 1)) then N := Integer'Value (V (V'First + 1 .. V'Last - 1)); else raise Template_Error with "Wrong value for attribute Up_Level"; end if; return (Up_Level, N); end; else return (Up_Level, 1); end if; else raise Template_Error with "Unknown attribute name """ & A_Name & '"'; end if; end; end Get_Attribute; -------------------- -- Get_Filter_Set -- -------------------- function Get_Filter_Set (Tag : String) return Filter.Set_Access is use type Filter.Callback; Start : Natural; Stop : Natural := Tag'Last; FS : Filter.Set (1 .. Strings.Fixed.Count (Tag, ":")); -- Note that FS can be larger than needed as ':' can be used inside -- filter parameters for example. K : Positive := FS'First; function Name_Parameter (Filter : String) return Templates_Parser.Filter.Routine; -- Given a Filter description, returns the filter handle and -- parameter. procedure Get_Slice (Slice : String; First, Last : out Integer); -- Returns the First and Last slice index as parsed into the Slice -- string. Returns First and Last set to 0 if there is not valid -- slice definition in Slice. function Find_Slash (Str : String) return Natural; -- Returns the first slash index in Str, skip espaced slashes function Find (Str : String; Start : Positive; C : Character) return Natural; -- Look backward for character C in Str starting at position Start. -- This procedure skips quoted strings and parenthesis. Returns 0 if -- the character if not found otherwize it returns the positon of C -- in Str. ---------- -- Find -- ---------- function Find (Str : String; Start : Positive; C : Character) return Natural is Pos : Natural := Start; Count : Integer := 0; begin while Pos > Str'First and then (Str (Pos) /= C or else Count /= 0) loop if Pos > Str'First and then Str (Pos - 1) /= '\' then -- This is not a quoted character if Str (Pos) = ')' then Count := Count - 1; elsif Str (Pos) = '(' then Count := Count + 1; end if; end if; Pos := Pos - 1; end loop; if Pos = Str'First then return 0; else return Pos; end if; end Find; ---------------- -- Find_Slash -- ---------------- function Find_Slash (Str : String) return Natural is Escaped : Boolean := False; begin for K in Str'Range loop if Str (K) = '\' then Escaped := not Escaped; elsif Str (K) = '/' and then not Escaped then return K; else Escaped := False; end if; end loop; return 0; end Find_Slash; --------------- -- Get_Slice -- --------------- procedure Get_Slice (Slice : String; First, Last : out Integer) is P1 : constant Natural := Fixed.Index (Slice, ".."); begin First := 0; Last := 0; if P1 = 0 then raise Template_Error with "slice expected """ & Slice & '"'; else First := Integer'Value (Slice (Slice'First .. P1 - 1)); Last := Integer'Value (Slice (P1 + 2 .. Slice'Last)); end if; end Get_Slice; -------------------- -- Name_Parameter -- -------------------- function Name_Parameter (Filter : String) return Templates_Parser.Filter.Routine is package F renames Templates_Parser.Filter; use type F.Mode; function Unescape (Str : String) return String; -- Unespace characters Str, to be used with regpat replacement -- pattern. -------------- -- Unescape -- -------------- function Unescape (Str : String) return String is S : String (Str'Range); I : Natural := S'First - 1; K : Positive := Str'First; begin loop exit when K > Str'Last; I := I + 1; if Str (K) = '\' and then K < Str'Last and then not (Str (K + 1) in '0' .. '9') then -- An escaped character, skip the backslash K := K + 1; -- Handle some special escaped characters \n \r \t case Str (K) is when 'n' => S (I) := ASCII.LF; when 'r' => S (I) := ASCII.CR; when 't' => S (I) := ASCII.HT; when others => S (I) := Str (K); end case; else S (I) := Str (K); end if; K := K + 1; end loop; return S (S'First .. I); end Unescape; P1 : constant Natural := Fixed.Index (Filter, "("); P2 : constant Natural := Fixed.Index (Filter, ")", Backward); begin if (P1 = 0 and then P2 /= 0) or else (P1 /= 0 and then P2 = 0) then raise Template_Error with "unbalanced parenthesis """ & Filter & '"'; elsif P2 /= 0 and then P2 < Filter'Last and then Filter (P2 + 1) /= ':' then raise Template_Error with "unexpected character after parenthesis """ & Filter & '"'; end if; if P1 = 0 then -- No parenthesis, so there is no parameter to parse if F.Mode_Value (Filter) = F.User_Defined then return (F.Handle (Filter), F.Parameter_Data'(Mode => F.User_Callback, Handler => F.User_Handle (Filter), P => Null_Unbounded_String)); else return (F.Handle (Filter), Templates_Parser.Filter.No_Parameter); end if; else declare use GNAT.Regpat; Name : constant String := Filter (Filter'First .. P1 - 1); Mode : constant F.Mode := F.Mode_Value (Name); Parameter : constant String := No_Quote (Filter (P1 + 1 .. P2 - 1)); begin case F.Parameter (Mode) is when F.Regexp => return (F.Handle (Mode), F.Parameter_Data' (F.Regexp, R_Str => To_Unbounded_String (Parameter), Regexp => new Pattern_Matcher' (Compile (Parameter)))); when F.Regpat => declare K : constant Natural := Find_Slash (Parameter); begin if K = 0 then -- No replacement, this is equivalent to -- REPLACE(/\1) return (F.Handle (Mode), F.Parameter_Data' (F.Regpat, P_Str => To_Unbounded_String (Parameter), Regpat => new Pattern_Matcher' (Compile (Parameter)), Param => To_Unbounded_String ("\1"))); else return (F.Handle (Mode), F.Parameter_Data' (F.Regpat, P_Str => To_Unbounded_String (Parameter (Parameter'First .. K - 1)), Regpat => new Pattern_Matcher' (Compile (Parameter (Parameter'First .. K - 1))), Param => To_Unbounded_String (Unescape (Parameter (K + 1 .. Parameter'Last))))); end if; end; when F.Slice => declare First, Last : Integer; begin Get_Slice (Parameter, First, Last); return (F.Handle (Mode), F.Parameter_Data'(F.Slice, First, Last)); end; when F.Str => return (F.Handle (Mode), F.Parameter_Data' (F.Str, S => To_Unbounded_String (Parameter))); when F.User_Callback => return (F.Handle (Mode), F.Parameter_Data' (F.User_Callback, F.User_Handle (Name), P => To_Unbounded_String (Parameter))); end case; end; end if; end Name_Parameter; begin if FS'Length = 0 then return null; end if; loop Start := Tag'First; Stop := Find (Str, Stop, ':'); exit when Stop = 0; Start := Find (Str, Stop - 1, ':'); if Start = 0 then -- Last filter found FS (K) := Name_Parameter (Tag (Tag'First + Length (Begin_Tag) .. Stop - 1)); else FS (K) := Name_Parameter (Tag (Start + 1 .. Stop - 1)); end if; -- Specific check for the NO_DYNAMIC filter which must appear -- first. if FS (K).Handle = Filter.No_Dynamic'Access and then K /= FS'First then raise Template_Error with "NO_DYNAMIC must be the first filter"; end if; K := K + 1; Stop := Stop - 1; end loop; return new Filter.Set'(FS (FS'First .. K - 1)); end Get_Filter_Set; ------------------ -- Get_Var_Name -- ------------------ function Get_Var_Name (Tag : String) return String is Start, Stop : Natural; begin if A_Sep = 0 then -- No attribute Stop := Tag'Last - Length (End_Tag); -- Check for macro parameters if Tag (Stop) = ')' then MP_End := Stop; -- Go back to matching open parenthesis loop Stop := Stop - 1; -- ??? check for string literal exit when Tag (Stop + 1) = '(' or else Stop = Tag'First; end loop; MP_Start := Stop + 1; end if; else Stop := A_Sep - 1; end if; if F_Sep = 0 then -- No filter Start := Tag'First + Length (Begin_Tag); else Start := F_Sep + 1; end if; return Tag (Start .. Stop); end Get_Var_Name; ----------------- -- Is_Internal -- ----------------- function Is_Internal (Name : String) return Internal_Tag is begin case Name (Name'First) is when 'D' => if Name = "DAY" then return Day; elsif Name = "DAY_NAME" then return Day_Name; else return No; end if; when 'H' => if Name = "HOUR" then return Hour; else return No; end if; when 'M' => if Name = "MONTH" then return Month; elsif Name = "MONTH_NAME" then return Month_Name; elsif Name = "MINUTE" then return Minute; else return No; end if; when 'N' => if Name = "NOW" then return Now; elsif Name = "NUMBER_LINE" then return Number_Line; else return No; end if; when 'S' => if Name = "SECOND" then return Second; else return No; end if; when 'T' => if Name = "TABLE_LINE" then return Table_Line; elsif Name = "TABLE_LEVEL" then return Table_Level; else return No; end if; when 'U' => if Name = "UP_TABLE_LINE" then return Up_Table_Line; else return No; end if; when 'Y' => if Name = "YEAR" then return Year; else return No; end if; when others => return No; end case; end Is_Internal; -------------- -- Is_Macro -- -------------- function Is_Macro return Boolean is begin return MP_Start /= 0 and MP_End /= 0; end Is_Macro; Result : Tag_Var; begin if A_Sep <= F_Sep then -- This is not an attribute in fact, but something like: -- Filter(that's it):VAR A_Sep := 0; end if; Result.Filters := Get_Filter_Set (Str); Result.Attribute := Get_Attribute (Str); declare Name : constant String := Get_Var_Name (Str); begin Result.Name := To_Unbounded_String (Name); Result.Internal := Is_Internal (Name); -- If there is no attribute, check for a macro if Result.Attribute = No_Attribute and then Is_Macro then Result.Is_Macro := True; declare P : constant Templates_Parser.Parameter_Set := Get_Parameters (Str (MP_Start .. MP_End)); begin Result.Parameters := To_Data_Parameters (P); end; -- Check if this is a known macro Result.Def := Clone (Macro.Get (Name)); if Result.Def /= null then Macro.Rewrite (Result.Def, Result.Parameters); end if; end if; if Name (Name'First) = '$' and then Strings.Fixed.Count (Name, Strings.Maps.Constants.Decimal_Digit_Set) = Name'Length - 1 then Result.N := Natural'Value (Name (Name'First + 1 .. Name'Last)); else Result.N := -1; end if; end; return Result; end Build; ----------- -- Clone -- ----------- function Clone (V : Tag_Var) return Tag_Var is use type Filter.Set_Access; R : Tag_Var := V; begin if R.Filters /= null then R.Filters := new Filter.Set'(R.Filters.all); end if; if R.Is_Macro then R.Parameters := new Data.Parameter_Set'(R.Parameters.all); for K in R.Parameters'Range loop if R.Parameters (K) /= null then R.Parameters (K) := Data.Clone (R.Parameters (K)); end if; end loop; R.Def := Clone (R.Def); end if; return R; end Clone; function Clone (D : Tree) return Tree is Root, N : Tree; begin if D /= null then Root := new Node'(D.all); N := Root; loop if N.Kind = Data.Var then N.Var := Data.Clone (N.Var); end if; exit when N.Next = null; N.Next := new Node'(N.Next.all); N := N.Next; end loop; end if; return Root; end Clone; ----------- -- Image -- ----------- function Image (T : Tag_Var) return String is use type Filter.Set_Access; R : Unbounded_String; Named : Boolean := False; begin R := Begin_Tag; -- Filters if T.Filters /= null then for K in reverse T.Filters'Range loop Append (R, Filter.Name (T.Filters (K).Handle)); Append (R, Filter.Image (T.Filters (K).Parameters)); Append (R, ":"); end loop; end if; -- Tag name Append (R, T.Name); -- Macro parameters if any if T.Is_Macro then Append (R, "("); for K in T.Parameters'Range loop if T.Parameters (K) = null then Named := True; else if Named then Append (R, Natural'Image (K) & " => "); end if; case T.Parameters (K).Kind is when Text => Append (R, T.Parameters (K).Value); when Var => Append (R, Image (T.Parameters (K).Var)); end case; if K /= T.Parameters'Last then Append (R, ","); end if; end if; end loop; Append (R, ")"); end if; -- Attributes case T.Attribute.Attr is when Nil => null; when Length => Append (R, "'Length"); when Line => Append (R, "'Line"); when Min_Column => Append (R, "'Min_Column"); when Max_Column => Append (R, "'Max_Column"); when Up_Level => Append (R, "'Up_Level"); if T.Attribute.Value /= 1 then Append (R, '(' & Utils.Image (T.Attribute.Value) & ')'); end if; end case; Append (R, End_Tag); return To_String (R); end Image; ------------------------- -- Is_Include_Variable -- ------------------------- function Is_Include_Variable (T : Tag_Var) return Boolean is begin return T.N /= -1; end Is_Include_Variable; ----------- -- Parse -- ----------- function Parse (Line : String) return Tree is Begin_Tag : constant String := To_String (Templates_Parser.Begin_Tag); End_Tag : constant String := To_String (Templates_Parser.End_Tag); function Build (Line : String) return Tree; -- Recursive function to build the tree ----------- -- Build -- ----------- function Build (Line : String) return Tree is Start, Stop, S : Natural; begin if Line = "" then return null; else Start := Strings.Fixed.Index (Line, Begin_Tag); if Start = 0 then -- No more tag return new Node'(Text, Next => null, Value => To_Unbounded_String (Line)); else -- Get matching ending separator, a macro can have variables -- as parameter: -- @_MACRO(2,@_VAR_@)_@ S := Start + Begin_Tag'Length; Search_Matching_Tag : loop Stop := Strings.Fixed.Index (Line, End_Tag, From => S); S := Strings.Fixed.Index (Line, Begin_Tag, From => S); exit Search_Matching_Tag when S = 0 or else S > Stop; S := Stop + End_Tag'Length; end loop Search_Matching_Tag; if Stop = 0 then raise Internal_Error with "Tag variable not terminated (missing " & End_Tag & ")"; else Stop := Stop + End_Tag'Length - 1; if Start = Line'First then -- The first token in Line is a variable return new Node' (Var, Next => Build (Line (Stop + 1 .. Line'Last)), Var => Build (Line (Start .. Stop))); else -- We have some text before the tag return new Node' (Text, Next => Build (Line (Start .. Line'Last)), Value => To_Unbounded_String (Line (Line'First .. Start - 1))); end if; end if; end if; end if; end Build; begin return Build (Line); end Parse; ---------------- -- Print_Tree -- ---------------- procedure Print_Tree (D : Tree) is N : Tree := D; NL : Boolean := False; begin while N /= null loop case N.Kind is when Text => declare Value : constant String := To_String (N.Value); begin Text_IO.Put (Value); if Value'Length > 0 then NL := Value (Value'Last) = ASCII.LF; else NL := False; end if; end; when Var => if N.Var.Is_Macro and then Expand_Macro then Print_Tree (N.Var.Def); else Text_IO.Put (Image (N.Var)); NL := False; end if; end case; N := N.Next; end loop; if not NL then Text_IO.New_Line; end if; end Print_Tree; ------------- -- Release -- ------------- procedure Release (T : in out Tag_Var) is use type Filter.Set_Access; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Filter.Set, Filter.Set_Access); begin if T.Filters /= null then Filter.Release (T.Filters.all); Unchecked_Free (T.Filters); end if; if T.Parameters /= null then for K in T.Parameters'Range loop Data.Release (T.Parameters (K)); end loop; Data.Unchecked_Free (T.Parameters); end if; Release (T.Def, Include => False); end Release; procedure Release (D : in out Tree; Single : Boolean := False) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Node, Tree); P : Tree; T : Tree := D; begin while T /= null loop P := T; T := T.Next; case P.Kind is when Var => Release (P.Var); when Text => null; end case; Unchecked_Free (P); exit when Single; end loop; D := null; end Release; ------------------------ -- To_Data_Parameters -- ------------------------ function To_Data_Parameters (Parameters : Templates_Parser.Parameter_Set) return Data.Parameters is P : constant Data.Parameters := new Parameter_Set (Parameters'Range); begin for K in P'Range loop P (K) := Data.Parse (To_String (Parameters (K))); end loop; return P; end To_Data_Parameters; --------------- -- Translate -- --------------- function Translate (T : Tag_Var; Value : String; Context : not null access Filter.Filter_Context) return String is use type Filter.Set_Access; begin if T.Filters /= null then declare R : Unbounded_String := To_Unbounded_String (Value); begin for K in T.Filters'Range loop R := To_Unbounded_String (T.Filters (K).Handle (To_String (R), Context, T.Filters (K).Parameters)); end loop; return To_String (R); end; end if; return Value; end Translate; end Data; libtemplates-parser-11.6.orig/src/templates_parser-debug.adb0000644000175000017500000000621511637170657024135 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Ada.Strings.Fixed; package body Templates_Parser.Debug is use Ada.Text_IO; use Ada.Strings.Fixed; ----------- -- Print -- ----------- procedure Print (T : Tag) is procedure Print (T : Tag; K : Natural); -- Print tag T, K is the indent level ----------- -- Print -- ----------- procedure Print (T : Tag; K : Natural) is Indent : constant String := K * ' '; N : Tag_Node_Access := T.Data.Head; begin Put (Indent); Put_Line ("(N=" & Natural'Image (T.Data.Count) & ", Min=" & Natural'Image (T.Data.Min) & ", Max=" & Natural'Image (T.Data.Max) & ", Nested_Level=" & Natural'Image (T.Data.Nested_Level)); while N /= null loop if N.Kind = Value then Put_Line (Indent & Indent & To_String (N.V)); else Print (N.VS.all, K + 1); end if; N := N.Next; end loop; Put_Line (Indent & ")"); end Print; begin Print (T, 1); end Print; -------------------------- -- Print_Defined_Macros -- -------------------------- procedure Print_Defined_Macros is begin Templates_Parser.Print_Defined_Macros; end Print_Defined_Macros; ---------------- -- Print_Tree -- ---------------- procedure Print_Tree (Filename : String; Expand_Macro : Boolean := False) is begin Templates_Parser.Expand_Macro := Expand_Macro; Templates_Parser.Print_Tree (Filename); end Print_Tree; end Templates_Parser.Debug; libtemplates-parser-11.6.orig/src/templates_parser-debug.ads0000644000175000017500000000354611637170657024162 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ package Templates_Parser.Debug is procedure Print (T : Tag); -- Print tag representation procedure Print_Tree (Filename : String; Expand_Macro : Boolean := False); -- Print tree for template Filename procedure Print_Defined_Macros; -- Print all defined macros end Templates_Parser.Debug; libtemplates-parser-11.6.orig/src/templates_parser-definitions.adb0000644000175000017500000001054711637170657025365 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2011, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; separate (Templates_Parser) package body Definitions is ----------- -- Clone -- ----------- function Clone (D : Tree) return Tree is begin return new Def'(D.all); end Clone; ----------- -- Parse -- ----------- function Parse (Line : String) return Tree is -- Format to parse: = ['|'] K, L : Natural; Name : Unbounded_String; Value : Unbounded_String; Ref : Natural; begin K := Strings.Fixed.Index (Line, "="); if K = 0 then raise Internal_Error with "SET wrong definition, missing name or value"; end if; Name := To_Unbounded_String (Fixed.Trim (Line (Line'First .. K - 1), Both)); -- Check if we have a single value declare Data : constant String := Fixed.Trim (Line (K + 1 .. Line'Last), Both); begin L := Fixed.Index (Data, "|"); if L = 0 then -- Single data, this can be a ref or a value if Data (Data'First) = '$' then Ref := Positive'Value (Data (Data'First + 1 .. Data'Last)); return new Def' (Name, (Definitions.Ref, Null_Unbounded_String, Ref)); else Value := To_Unbounded_String (No_Quote (Fixed.Trim (Data (L + 1 .. Data'Last), Left))); return new Def'(Name, (Definitions.Const, Value, 1)); end if; else -- Multiple data, the first one must be a ref, the second a value if Data (Data'First) /= '$' then raise Internal_Error with "SET, reference expected found a value"; end if; Ref := Positive'Value (Data (Data'First + 1 .. L - 1)); Value := To_Unbounded_String (No_Quote (Fixed.Trim (Data (L + 1 .. Data'Last), Left))); return new Def' (Name, (Definitions.Ref_Default, Value, Ref)); end if; end; end Parse; ---------------- -- Print_Tree -- ---------------- procedure Print_Tree (D : Tree) is N : constant Node := D.N; begin Text_IO.Put (To_String (D.Name) & " = "); case D.N.Kind is when Const => Text_IO.Put (Quote (To_String (N.Value))); when Ref => Text_IO.Put ('$' & Utils.Image (N.Ref)); when Ref_Default => Text_IO.Put ('$' & Utils.Image (N.Ref) & " | " & Quote (To_String (N.Value))); end case; end Print_Tree; ------------- -- Release -- ------------- procedure Release (D : in out Tree) is procedure Unchecked_Free is new Unchecked_Deallocation (Def, Tree); begin Unchecked_Free (D); end Release; end Definitions; libtemplates-parser-11.6.orig/src/templates_parser-dynamic.adb0000755000175000017500000000556011637170657024500 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- $Id: templates_parser-dynamic.adb 435 2005-05-13 19:50:23Z obry $ separate (Templates_Parser) package body Dynamic is --------------- -- Dimention -- --------------- function Dimention (Cursor_Tag : access Dynamic.Cursor_Tag; Var_Name : in String) return Natural is pragma Unreferenced (Cursor_Tag, Var_Name); begin return 0; end Dimention; ------------ -- Length -- ------------ function Length (Cursor_Tag : access Dynamic.Cursor_Tag; Var_Name : in String; Path : in Dynamic.Path) return Natural is pragma Unreferenced (Cursor_Tag, Var_Name, Path); begin return 0; end Length; ----------- -- Value -- ----------- procedure Value (Lazy_Tag : access Dynamic.Lazy_Tag; Var_Name : in String; Translations : in out Translate_Set) is pragma Unreferenced (Lazy_Tag, Var_Name, Translations); begin null; end Value; function Value (Cursor_Tag : access Dynamic.Cursor_Tag; Var_Name : in String; Path : in Dynamic.Path) return String is pragma Unreferenced (Cursor_Tag, Var_Name, Path); begin return ""; end Value; end Dynamic; libtemplates-parser-11.6.orig/src/templates_parser-expr.adb0000644000175000017500000005427511637170657024036 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 1999-2011, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; separate (Templates_Parser) package body Expr is use Ada.Strings.Maps; -- BNF definition of the expression language: -- -- ::= { } -- ::= { } -- ::= ["not"] -- ::= | | "(" ")" -- ::= "and" | "or" | "xor" -- ::= "<" | "<=" | "=" | ">=" | ">" | "/=" subtype Comp_Op is Ops range O_Sup .. O_In; subtype Logic_Op is Ops range O_And .. O_Xor; Separator : constant Character_Set := Blank or To_Set ("<>=/()"); ------------- -- Analyze -- ------------- function Analyze (E : Expr.Tree) return String is type Ops_Fct is access function (L, R : Expr.Tree) return String; function F_And (L, R : Expr.Tree) return String; function F_Or (L, R : Expr.Tree) return String; function F_Xor (L, R : Expr.Tree) return String; function F_Sup (L, R : Expr.Tree) return String; function F_Esup (L, R : Expr.Tree) return String; function F_Einf (L, R : Expr.Tree) return String; function F_Inf (L, R : Expr.Tree) return String; function F_Equ (L, R : Expr.Tree) return String; function F_Diff (L, R : Expr.Tree) return String; function F_In (L, R : Expr.Tree) return String; type U_Ops_Fct is access function (N : Expr.Tree) return String; function F_Not (N : Expr.Tree) return String; ----------- -- F_And -- ----------- function F_And (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Is_True (LV) and then Is_True (RV) then return "TRUE"; else return "FALSE"; end if; end F_And; ------------ -- F_Diff -- ------------ function F_Diff (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Analyze (L) /= Analyze (R) then return "TRUE"; else return "FALSE"; end if; end F_Diff; ------------ -- F_Einf -- ------------ function F_Einf (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Utils.Is_Number (LV) and then Utils.Is_Number (RV) then if Integer'Value (LV) <= Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV <= RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Einf; ----------- -- F_Equ -- ----------- function F_Equ (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif LV = RV then return "TRUE"; else return "FALSE"; end if; end F_Equ; ------------ -- F_Esup -- ------------ function F_Esup (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Utils.Is_Number (LV) and then Utils.Is_Number (RV) then if Integer'Value (LV) >= Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV >= RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Esup; ---------- -- F_In -- ---------- function F_In (L, R : Expr.Tree) return String is pragma Unreferenced (L, R); begin -- Always unknown as an in expression contains a variable return Unknown; end F_In; ----------- -- F_Inf -- ----------- function F_Inf (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Utils.Is_Number (LV) and then Utils.Is_Number (RV) then if Integer'Value (LV) < Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV < RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Inf; ----------- -- F_Not -- ----------- function F_Not (N : Expr.Tree) return String is NV : constant String := Analyze (N); begin if NV = Unknown then return Unknown; elsif Is_True (NV) then return "FALSE"; else return "TRUE"; end if; end F_Not; ---------- -- F_Or -- ---------- function F_Or (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Is_True (LV) or else Is_True (RV) then return "TRUE"; else return "FALSE"; end if; end F_Or; ----------- -- F_Sup -- ----------- function F_Sup (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Utils.Is_Number (LV) and then Utils.Is_Number (RV) then if Integer'Value (LV) > Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV > RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Sup; ----------- -- F_Xor -- ----------- function F_Xor (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if LV = Unknown or else RV = Unknown then return Unknown; elsif Is_True (LV) xor Is_True (RV) then return "TRUE"; else return "FALSE"; end if; end F_Xor; Op_Table : constant array (Expr.Ops) of Ops_Fct := (Expr.O_And => F_And'Access, Expr.O_Or => F_Or'Access, Expr.O_Xor => F_Xor'Access, Expr.O_Sup => F_Sup'Access, Expr.O_Inf => F_Inf'Access, Expr.O_Esup => F_Esup'Access, Expr.O_Einf => F_Einf'Access, Expr.O_Equal => F_Equ'Access, Expr.O_Diff => F_Diff'Access, Expr.O_In => F_In'Access); U_Op_Table : constant array (Expr.U_Ops) of U_Ops_Fct := (Expr.O_Not => F_Not'Access); begin case E.Kind is when Expr.Value => return To_String (E.V); when Expr.Var => return Unknown; when Expr.Op => return Op_Table (E.O) (E.Left, E.Right); when Expr.U_Op => return U_Op_Table (E.U_O) (E.Next); end case; end Analyze; ----------- -- Clone -- ----------- function Clone (E : Tree) return Tree is N : Tree; begin if E = null then return null; else N := new Node'(E.all); end if; case E.Kind is when Value | Var => null; when Op => N.Left := Clone (N.Left); N.Right := Clone (N.Right); when U_Op => N.Next := Clone (N.Next); end case; return N; end Clone; ----------- -- Image -- ----------- function Image (O : Ops) return String is begin case O is when O_And => return "and"; when O_Or => return "or"; when O_Xor => return "xor"; when O_Sup => return ">"; when O_Inf => return "<"; when O_Esup => return ">="; when O_Einf => return "<="; when O_Equal => return "="; when O_Diff => return "/="; when O_In => return "in"; end case; end Image; function Image (O : U_Ops) return String is begin case O is when O_Not => return "not"; end case; end Image; ------------- -- Is_True -- ------------- function Is_True (Str : String) return Boolean is L_Str : constant String := Characters.Handling.To_Upper (Str); begin return L_Str = "TRUE" or else L_Str = "T" or else L_Str = "1"; end Is_True; ----------- -- Parse -- ----------- function Parse (Expression : String) return Tree is Start_Index : Natural := Expression'First; Index : Natural := Expression'First; type Token_Kind is (Open_Par, Close_Par, Binary_Op, Unary_Op, Value, Var, End_Expr); type Token (Kind : Token_Kind := Var) is record case Kind is when Open_Par | Close_Par | End_Expr => null; when Binary_Op => Bin_Op : Ops; when Unary_Op => Un_Op : U_Ops; when Value | Var => Start : Positive; -- range of the token Stop : Positive; -- in Expression string end case; end record; Current_Token : Token; procedure Error (Mess : String); pragma No_Return (Error); -- Raises Internal_Error with the column of the condition function Expr return Tree; -- Parse a logical operator function Term return Tree; -- Parse a term (unary operator) function Relation return Tree; -- Parse a relational operator function Primary return Tree; -- ??? ----------- -- Error -- ----------- procedure Error (Mess : String) is begin raise Internal_Error with "col" & Integer'Image (Start_Index) & " condition, " & Mess; end Error; procedure Next_Token; -- Moves Current_Token to next token. Set Index after the last analysed -- consumed from expression. ---------- -- Expr -- ---------- function Expr return Tree is N : Tree; O : Ops; begin N := Relation; while Current_Token.Kind = Binary_Op and then Current_Token.Bin_Op in Logic_Op loop O := Current_Token.Bin_Op; Next_Token; N := new Node'(Op, O, N, Relation); end loop; return N; end Expr; ---------------- -- Next_Token -- ---------------- procedure Next_Token is use Ada.Characters.Handling; I : Natural; begin -- Skip blanks while Index <= Expression'Last and then Is_In (Expression (Index), Blank) loop Index := Index + 1; end loop; Start_Index := Index; if Index > Expression'Last then -- No more data to read Current_Token := (Kind => End_Expr); -- Check symbolic operators elsif Expression (Index) = '(' then Current_Token := (Kind => Open_Par); Index := Index + 1; elsif Expression (Index) = ')' then Current_Token := (Kind => Close_Par); Index := Index + 1; elsif Expression (Index) = '=' then Current_Token := (Kind => Binary_Op, Bin_Op => O_Equal); Index := Index + 1; elsif Expression (Index) = '/' and then Index < Expression'Last and then Expression (Index + 1) = '=' then Current_Token := (Kind => Binary_Op, Bin_Op => O_Diff); Index := Index + 2; elsif Expression (Index) = '<' then Index := Index + 1; if Expression (Index) = '=' then Current_Token := (Kind => Binary_Op, Bin_Op => O_Einf); Index := Index + 1; else Current_Token := (Kind => Binary_Op, Bin_Op => O_Inf); end if; elsif Expression (Index) = '>' then Index := Index + 1; if Expression (Index) = '=' then Current_Token := (Kind => Binary_Op, Bin_Op => O_Esup); Index := Index + 1; else Current_Token := (Kind => Binary_Op, Bin_Op => O_Sup); end if; elsif Expression (Index) = '"' then -- This is a string, return it Current_Token := (Kind => Value, Start => Index + 1, Stop => Index); loop if Current_Token.Stop = Expression'Last then Error ("condition, no matching closing quote string"); elsif Expression (Current_Token.Stop + 1) = '"' then exit; else Current_Token.Stop := Current_Token.Stop + 1; end if; end loop; Index := Current_Token.Stop + 2; else -- We have found the start of a string token, look for end of it I := Index; loop Index := Fixed.Index (Expression (Index .. Expression'Last), Separator); if Index = 0 then -- Token end is the end of Expression Index := Expression'Last + 1; exit; end if; -- Special case for '/': it is a separator only if appearing -- in '/='. Without this test, the "/" filter is not recognized -- Moreover, this allows comparisons of file paths (with '/') exit when Expression (Index) /= '/' or else Expression (Index + 1) = '='; Index := Index + 1; end loop; declare Token_Image : constant String := To_Lower (Expression (I .. Index - 1)); begin if Token_Image = "not" then Current_Token := (Kind => Unary_Op, Un_Op => O_Not); elsif Token_Image = "and" then Current_Token := (Kind => Binary_Op, Bin_Op => O_And); elsif Token_Image = "or" then Current_Token := (Kind => Binary_Op, Bin_Op => O_Or); elsif Token_Image = "xor" then Current_Token := (Kind => Binary_Op, Bin_Op => O_Xor); elsif Token_Image = "in" then Current_Token := (Kind => Binary_Op, Bin_Op => O_In); elsif Token_Image'Length > Length (Begin_Tag) and then Token_Image (Token_Image'First .. Token_Image'First + Length (Begin_Tag) - 1) = Begin_Tag then -- This is a variable, we have the start of it, now look -- for the end of the variable. if Index <= Expression'Last and then Expression (Index) = '(' then -- This is not the end of the tag variable but the -- start of the tag parameters. Look for tag variable -- end. Index := Fixed.Index (Expression (Index .. Expression'Last), To_String (End_Tag)); Index := Index + Length (End_Tag); end if; if Index = 0 then Error ("variable end not found"); else Current_Token := (Kind => Var, Start => I, Stop => Index - 1); end if; else Current_Token := (Kind => Value, Start => I, Stop => Index - 1); end if; end; end if; end Next_Token; ------------- -- Primary -- ------------- function Primary return Tree is Result : Tree; Start, Stop : Natural; begin case Current_Token.Kind is -- Normal cases when Open_Par => Next_Token; Result := Expr; if Current_Token.Kind = Close_Par then Next_Token; return Result; else Error ("missing closing parenthesis"); end if; when Value => Start := Current_Token.Start; Stop := Current_Token.Stop; Next_Token; return new Node' (Value, V => To_Unbounded_String (Expression (Start .. Stop))); when Var => Start := Current_Token.Start; Stop := Current_Token.Stop; Next_Token; return new Node' (Var, Var => Data.Build (Expression (Start .. Stop))); -- Errors when Unary_Op => Error ("misplaced operator """ & Image (Current_Token.Un_Op) & '"'); when Binary_Op => Error ("misplaced operator """ & Image (Current_Token.Bin_Op) & '"'); when Close_Par => Error ("unexpected right parenthesis"); when End_Expr => Error ("missing operand"); end case; end Primary; -------------- -- Relation -- -------------- function Relation return Tree is N : Tree; O : Ops; begin N := Term; while Current_Token.Kind = Binary_Op and then Current_Token.Bin_Op in Comp_Op loop O := Current_Token.Bin_Op; Next_Token; N := new Node'(Op, O, N, Term); end loop; return N; end Relation; ---------- -- Term -- ---------- function Term return Tree is O : U_Ops; begin if Current_Token.Kind = Unary_Op then O := Current_Token.Un_Op; Next_Token; return new Node'(U_Op, U_O => O, Next => Primary); else return Primary; end if; end Term; Result : Tree; begin Next_Token; Result := Expr; case Current_Token.Kind is when End_Expr => null; when Open_Par | Close_Par | Value | Var => Error ("Missing operator"); when Binary_Op | Unary_Op => Error ("Missing operand"); end case; return Result; end Parse; ---------------- -- Print_Tree -- ---------------- procedure Print_Tree (E : Tree) is begin case E.Kind is when Value => Text_IO.Put (Quote (To_String (E.V))); when Var => Text_IO.Put (Data.Image (E.Var)); when Op => Text_IO.Put ('('); Print_Tree (E.Left); Text_IO.Put (' ' & Image (E.O) & ' '); Print_Tree (E.Right); Text_IO.Put (')'); when U_Op => Text_IO.Put ('('); Text_IO.Put (Image (E.U_O) & ' '); Print_Tree (E.Next); Text_IO.Put (')'); end case; end Print_Tree; ------------- -- Release -- ------------- procedure Release (E : in out Tree; Single : Boolean := False) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Node, Tree); begin case E.Kind is when Value => null; when Var => Data.Release (E.Var); when Op => if not Single then Release (E.Left); Release (E.Right); end if; when U_Op => if not Single then Release (E.Next); end if; end case; Unchecked_Free (E); end Release; end Expr; libtemplates-parser-11.6.orig/src/templates_parser-filter.adb0000644000175000017500000015134711637170657024343 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2003-2011, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Strings.Fixed; with Ada.Strings.Hash; with Templates_Parser.Configuration; with Templates_Parser.Utils; separate (Templates_Parser) package body Filter is -- User's defined filter package Filter_Map is new Containers.Indefinite_Hashed_Maps (String, User_CB, Strings.Hash, "=", "="); User_Filters : Filter_Map.Map; -- Filter tokens Multiply_Token : aliased constant String := """*"""; Plus_Token : aliased constant String := """+"""; Minus_Token : aliased constant String := """-"""; Divide_Token : aliased constant String := """/"""; Abs_Token : aliased constant String := "ABS"; Add_Token : aliased constant String := "ADD"; Add_Param_Token : aliased constant String := "ADD_PARAM"; BR_2_EOL_Token : aliased constant String := "BR_2_EOL"; BR_2_LF_Token : aliased constant String := "BR_2_LF"; Capitalize_Token : aliased constant String := "CAPITALIZE"; Clean_Text_Token : aliased constant String := "CLEAN_TEXT"; Coma_2_Point_Token : aliased constant String := "COMA_2_POINT"; Contract_Token : aliased constant String := "CONTRACT"; Del_Param_Token : aliased constant String := "DEL_PARAM"; Div_Token : aliased constant String := "DIV"; Exist_Token : aliased constant String := "EXIST"; File_Exists_Token : aliased constant String := "FILE_EXISTS"; Format_Date_Token : aliased constant String := "FORMAT_DATE"; Format_Number_Token : aliased constant String := "FORMAT_NUMBER"; Is_Empty_Token : aliased constant String := "IS_EMPTY"; LF_2_BR_Token : aliased constant String := "LF_2_BR"; Lower_Token : aliased constant String := "LOWER"; Match_Token : aliased constant String := "MATCH"; Max_Token : aliased constant String := "MAX"; Min_Token : aliased constant String := "MIN"; Modulo_Token : aliased constant String := "MOD"; Mult_Token : aliased constant String := "MULT"; Neg_Token : aliased constant String := "NEG"; No_Digit_Token : aliased constant String := "NO_DIGIT"; No_Dynamic_Token : aliased constant String := "NO_DYNAMIC"; No_Letter_Token : aliased constant String := "NO_LETTER"; No_Space_Token : aliased constant String := "NO_SPACE"; Oui_Non_Token : aliased constant String := "OUI_NON"; Point_2_Coma_Token : aliased constant String := "POINT_2_COMA"; Repeat_Token : aliased constant String := "REPEAT"; Replace_Token : aliased constant String := "REPLACE"; Replace_All_Token : aliased constant String := "REPLACE_ALL"; Replace_Param_Token : aliased constant String := "REPLACE_PARAM"; Reverse_Token : aliased constant String := "REVERSE"; Size_Token : aliased constant String := "SIZE"; Slice_Token : aliased constant String := "SLICE"; Sub_Token : aliased constant String := "SUB"; Trim_Token : aliased constant String := "TRIM"; Upper_Token : aliased constant String := "UPPER"; User_Defined_Token : aliased constant String := "USER_DEFINED"; Web_Encode_Token : aliased constant String := "WEB_ENCODE"; Web_Escape_Token : aliased constant String := "WEB_ESCAPE"; Web_NBSP_Token : aliased constant String := "WEB_NBSP"; Wrap_Token : aliased constant String := "WRAP"; Yes_No_Token : aliased constant String := "YES_NO"; -- Filters Table Table : constant array (Mode) of Filter_Record := (Multiply => (Multiply_Token'Access, Multiply'Access), Plus => (Plus_Token'Access, Plus'Access), Minus => (Minus_Token'Access, Minus'Access), Divide => (Divide_Token'Access, Divide'Access), Absolute => (Abs_Token'Access, Absolute'Access), Add => (Add_Token'Access, Plus'Access), Add_Param => (Add_Param_Token'Access, Add_Param'Access), BR_2_EOL => (BR_2_EOL_Token'Access, BR_2_EOL'Access), BR_2_LF => (BR_2_LF_Token'Access, BR_2_LF'Access), Capitalize => (Capitalize_Token'Access, Capitalize'Access), Clean_Text => (Clean_Text_Token'Access, Clean_Text'Access), Coma_2_Point => (Coma_2_Point_Token'Access, Coma_2_Point'Access), Contract => (Contract_Token'Access, Contract'Access), Del_Param => (Del_Param_Token'Access, Del_Param'Access), Div => (Div_Token'Access, Divide'Access), Exist => (Exist_Token'Access, Exist'Access), File_Exists => (File_Exists_Token'Access, File_Exists'Access), Format_Date => (Format_Date_Token'Access, Format_Date'Access), Format_Number => (Format_Number_Token'Access, Format_Number'Access), Is_Empty => (Is_Empty_Token'Access, Is_Empty'Access), LF_2_BR => (LF_2_BR_Token'Access, LF_2_BR'Access), Lower => (Lower_Token'Access, Lower'Access), Match => (Match_Token'Access, Match'Access), Max => (Max_Token'Access, Max'Access), Min => (Min_Token'Access, Min'Access), Modulo => (Modulo_Token'Access, Modulo'Access), Mult => (Mult_Token'Access, Multiply'Access), Neg => (Neg_Token'Access, Neg'Access), No_Digit => (No_Digit_Token'Access, No_Digit'Access), No_Dynamic => (No_Dynamic_Token'Access, No_Dynamic'Access), No_Letter => (No_Letter_Token'Access, No_Letter'Access), No_Space => (No_Space_Token'Access, No_Space'Access), Oui_Non => (Oui_Non_Token'Access, Oui_Non'Access), Point_2_Coma => (Point_2_Coma_Token'Access, Point_2_Coma'Access), Repeat => (Repeat_Token'Access, Repeat'Access), Replace => (Replace_Token'Access, Replace'Access), Replace_All => (Replace_All_Token'Access, Replace_All'Access), Replace_Param => (Replace_Param_Token'Access, Replace_Param'Access), Invert => (Reverse_Token'Access, Reverse_Data'Access), Size => (Size_Token'Access, Size'Access), Slice => (Slice_Token'Access, Slice'Access), Sub => (Sub_Token'Access, Minus'Access), Trim => (Trim_Token'Access, Trim'Access), Upper => (Upper_Token'Access, Upper'Access), User_Defined => (User_Defined_Token'Access, User_Defined'Access), Web_Encode => (Web_Encode_Token'Access, Web_Encode'Access), Web_Escape => (Web_Escape_Token'Access, Web_Escape'Access), Web_NBSP => (Web_NBSP_Token'Access, Web_NBSP'Access), Wrap => (Wrap_Token'Access, Wrap'Access), Yes_No => (Yes_No_Token'Access, Yes_No'Access) ); function Replace_One_Or_All (S : String; P : Parameter_Data; T : Translate_Set; I : Parameter_Set; One : Boolean) return String; -- Routine used to implement the REPLACE (One set to True) and REPLACE_ALL -- filters. function Value (Str : String; Translations : Translate_Set; I_Params : Parameter_Set) return String; -- Returns the value for Str, or if Str is a tag, returns it's value function BR_2_EOL (S : String; EOL : String) return String; -- Returns a string where all occurences of
HTML tag have been -- replaced by EOL, assuming EOL is "LF", "CR", "LFCR" or "CRLF". -------------- -- Absolute -- -------------- function Absolute (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); if S = "" or else not Is_Number (S) then return ""; else return Utils.Image (abs Integer'Value (S)); end if; end Absolute; --------------- -- Add_Param -- --------------- function Add_Param (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is function Get (Str : String) return String; pragma Inline (Get); -- Returns the parameter key=value to be added --------- -- Get -- --------- function Get (Str : String) return String is P : constant Natural := Strings.Fixed.Index (Str, "="); begin if P = 0 then return Str; else return Str (Str'First .. P) & Value (Str (P + 1 .. Str'Last), C.Translations, C.I_Parameters); end if; end Get; Param : constant String := Get (To_String (P.S)); begin if Strings.Fixed.Index (S, "?") = 0 then -- No parameter yet return S & '?' & Param; elsif S (S'Last) = '?' or else S (S'Last) = '&' then return S & Param; else return S & '&' & Param; end if; end Add_Param; -------------- -- BR_2_EOL -- -------------- function BR_2_EOL (S : String; EOL : String) return String is Result : String (S'Range); K : Positive := Result'First; J : Positive := S'First; begin if S = "" then return ""; end if; loop if S (J) = '<' and then J + 3 <= S'Last and then Characters.Handling.To_Lower (S (J .. J + 2)) = " S'Last; end loop; return Result (Result'First .. K - 1); end BR_2_EOL; function BR_2_EOL (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); V_Str : constant String := To_String (P.S); EOL : String (1 .. V_Str'Length / 2); begin if V_Str = "LF" then EOL (EOL'First) := ASCII.LF; elsif V_Str = "CRLF" then EOL := ASCII.CR & ASCII.LF; elsif V_Str = "CR" then EOL (EOL'First) := ASCII.CR; elsif V_Str = "LFCR" then EOL := ASCII.LF & ASCII.CR; else raise Template_Error with "unknown parameter for BR_2_EOL filter"; end if; return BR_2_EOL (S, EOL); end BR_2_EOL; ------------- -- BR_2_LF -- ------------- function BR_2_LF (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); return BR_2_EOL (S, String'(1 => ASCII.LF)); end BR_2_LF; ---------------- -- Capitalize -- ---------------- function Capitalize (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Result : String (S'Range); Upper : Boolean := True; begin Check_Null_Parameter (P); for K in Result'Range loop if Upper then Result (K) := Characters.Handling.To_Upper (S (K)); Upper := False; else Result (K) := Characters.Handling.To_Lower (S (K)); if Result (K) = ' ' or else Result (K) = '_' then Upper := True; end if; end if; end loop; return Result; end Capitalize; -------------------------- -- Check_Null_Parameter -- -------------------------- procedure Check_Null_Parameter (P : Parameter_Data) is begin if P /= No_Parameter then raise Template_Error with "no parameter allowed in this filter"; end if; end Check_Null_Parameter; ---------------- -- Clean_Text -- ---------------- function Clean_Text (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); use type Strings.Maps.Character_Set; Result : String (S'Range); Clean_Set : constant Strings.Maps.Character_Set := Strings.Maps.Constants.Letter_Set or Strings.Maps.Constants.Decimal_Digit_Set or Strings.Maps.To_Set (" éèêîïàôç"); begin Check_Null_Parameter (P); for K in S'Range loop if Strings.Maps.Is_In (S (K), Clean_Set) then Result (K) := S (K); else Result (K) := ' '; end if; end loop; return Result; end Clean_Text; ------------------ -- Coma_2_Point -- ------------------ function Coma_2_Point (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Result : String := S; begin Check_Null_Parameter (P); for K in Result'Range loop if Result (K) = ',' then Result (K) := '.'; end if; end loop; return Result; end Coma_2_Point; -------------- -- Contract -- -------------- function Contract (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); use type Strings.Maps.Character_Set; Result : String (S'Range); R : Natural := 0; Space : Boolean := False; begin Check_Null_Parameter (P); for K in S'Range loop if S (K) = ' ' then if Space = False then Space := True; R := R + 1; Result (R) := ' '; end if; else Space := False; R := R + 1; Result (R) := S (K); end if; end loop; if R = 0 then return ""; else return Result (Result'First .. R); end if; end Contract; --------------- -- Del_Param -- --------------- function Del_Param (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Param : constant String := To_String (P.S); E : constant Natural := Strings.Fixed.Index (S, "?"); Len : constant Natural := Param'Length; begin if E = 0 then -- No parameter, return original string return S; else declare Pos : constant Natural := Strings.Fixed.Index (S, Param); First, Last : Natural; begin if Pos < E or else (Pos + Len <= S'Last and then S (Pos + Len) /= '=' and then S (Pos + Len) /= '&') then -- The parameter is not present, return original string return S; else First := Pos; Last := Pos; while Last < S'Last and then S (Last) /= '&' loop Last := Last + 1; end loop; if Last = S'Last then -- This is the last parameter, remove the parameter with -- leading parameter separator (? or &) First := Pos - 1; end if; return S (S'First .. First - 1) & S (Last + 1 .. S'Last); end if; end; end if; end Del_Param; ------------ -- Divide -- ------------ function Divide (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is N, V : Integer; begin declare V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) then N := Integer'Value (V_Str); else N := Integer'Value (Value (V_Str, C.Translations, C.I_Parameters)); end if; exception when Constraint_Error => raise Template_Error with """/"" filter parameter error"; end; begin V := Integer'Value (S); return Utils.Image (V / N); exception when others => return ""; end; end Divide; ----------- -- Exist -- ----------- function Exist (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); if S /= "" then return "TRUE"; else return "FALSE"; end if; end Exist; ----------------- -- File_Exists -- ----------------- function File_Exists (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); if Configuration.Is_Regular_File (S) then return "TRUE"; else return "FALSE"; end if; end File_Exists; ----------------- -- Format_Date -- ----------------- function Format_Date (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is Date_Only : constant := 10; Date_Time : constant := 19; Param : constant GNAT.Calendar.Time_IO.Picture_String := GNAT.Calendar.Time_IO.Picture_String (Value (To_String (P.S), C.Translations, C.I_Parameters)); F : constant Positive := S'First; Year : Calendar.Year_Number; Month : Calendar.Month_Number; Day : Calendar.Day_Number; Hour : GNAT.Calendar.Hour_Number := 0; Minute : GNAT.Calendar.Minute_Number := 0; Second : GNAT.Calendar.Second_Number := 0; Time : Calendar.Time; begin if S'Length >= Date_Only then Year := Calendar.Year_Number'Value (S (F .. F + 3)); Month := Calendar.Month_Number'Value (S (F + 5 .. F + 6)); Day := Calendar.Day_Number'Value (S (F + 8 .. F + 9)); if S (F + 4) /= '-' or else S (F + 7) /= '-' then return S; end if; else return S; end if; if S'Length = Date_Time then Hour := GNAT.Calendar.Hour_Number'Value (S (F + 11 .. F + 12)); Minute := GNAT.Calendar.Minute_Number'Value (S (F + 14 .. F + 15)); Second := GNAT.Calendar.Second_Number'Value (S (F + 17 .. F + 18)); if S (F + 13) /= ':' or else S (F + 16) /= ':' then return S; end if; end if; Time := GNAT.Calendar.Time_Of (Year, Month, Day, Hour, Minute, Second); return GNAT.Calendar.Time_IO.Image (Time, Param); end Format_Date; ------------------- -- Format_Number -- ------------------- function Format_Number (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is TS : constant String := Strings.Fixed.Trim (S, Both); Separator : Character := ' '; function Is_Number return Boolean; -- Returns true if S is a number Point : Natural := 0; --------------- -- Is_Number -- --------------- function Is_Number return Boolean is begin for K in TS'Range loop if TS (K) = '.' then Point := K; elsif not Characters.Handling.Is_Digit (TS (K)) then return False; end if; end loop; return True; end Is_Number; Result : String (1 .. TS'Length * 2); K : Natural := Result'Last; N : Natural; Count : Natural := 0; begin if P.Mode = Str then declare Param : constant String := Value (To_String (P.S), C.Translations, C.I_Parameters); begin Separator := Param (Param'First); end; end if; if Is_Number then if Point = 0 then N := TS'Last; else N := Point - 1; end if; for P in reverse TS'First .. N loop Result (K) := TS (P); K := K - 1; Count := Count + 1; if Count mod 3 = 0 and then P /= TS'First then Result (K) := Separator; K := K - 1; end if; end loop; if Point = 0 then return Result (K + 1 .. Result'Last); else return Result (K + 1 .. Result'Last) & TS (Point .. TS'Last); end if; else return S; end if; end Format_Number; ------------------ -- Free_Filters -- ------------------ procedure Free_Filters is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (User_Filter'Class, User_Filter_Access); C : Filter_Map.Cursor := Filter_Map.First (User_Filters); U : User_CB; begin while Filter_Map.Has_Element (C) loop if Filter_Map.Element (C).Typ = As_Tagged then U := Filter_Map.Element (C); Unchecked_Free (U.CBT); end if; Filter_Map.Next (C); end loop; Filter_Map.Clear (User_Filters); end Free_Filters; ------------ -- Handle -- ------------ function Handle (Name : String) return Callback is Mode : constant Filter.Mode := Mode_Value (Name); begin return Table (Mode).Handle; end Handle; function Handle (Mode : Filter.Mode) return Callback is begin return Table (Mode).Handle; end Handle; ----------- -- Image -- ----------- function Image (P : Parameter_Data) return String is begin if P = No_Parameter then return ""; else case P.Mode is when Str => return '(' & To_String (P.S) & ')'; when Regexp => return '(' & To_String (P.R_Str) & ')'; when Regpat => return '(' & To_String (P.P_Str) & '/' & To_String (P.Param) & ')'; when Slice => return '(' & Utils.Image (P.First) & " .. " & Utils.Image (P.Last) & ')'; when User_Callback => return '(' & To_String (P.P) & ')'; end case; end if; end Image; -------------- -- Is_Empty -- -------------- function Is_Empty (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); if S = "" then return "TRUE"; else return "FALSE"; end if; end Is_Empty; ------------------- -- Is_No_Dynamic -- ------------------- function Is_No_Dynamic (Filters : Set_Access) return Boolean is begin return Filters /= null and then Filters (Filters'First).Handle = No_Dynamic'Access; end Is_No_Dynamic; ------------- -- LF_2_BR -- ------------- function LF_2_BR (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); N : constant Natural := Fixed.Count (S, Strings.Maps.To_Set (ASCII.LF)); begin Check_Null_Parameter (P); if N = 0 then -- No LF, return the original string return S; end if; declare Result : String (1 .. S'Length + N * 4); K : Positive := S'First; begin for J in S'Range loop if S (J) = ASCII.LF then Result (K .. K + 4) := "
"; K := K + 5; else Result (K) := S (J); K := K + 1; end if; end loop; return Result (1 .. K - 1); end; end LF_2_BR; ----------- -- Lower -- ----------- function Lower (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); return Characters.Handling.To_Lower (S); end Lower; ----------- -- Match -- ------------ function Match (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); use type GNAT.Regpat.Match_Location; Matches : GNAT.Regpat.Match_Array (0 .. 0); begin if P = No_Parameter then raise Template_Error with "missing parameter for MATCH filter"; end if; GNAT.Regpat.Match (P.Regexp.all, S, Matches); if Matches (0) = GNAT.Regpat.No_Match then return "FALSE"; else return "TRUE"; end if; end Match; --------- -- Max -- --------- function Max (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) and then Is_Number (S) then return Utils.Image (Integer'Max (Integer'Value (V_Str), Integer'Value (S))); else return ""; end if; end Max; --------- -- Min -- --------- function Min (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) and then Is_Number (S) then return Utils.Image (Integer'Min (Integer'Value (V_Str), Integer'Value (S))); else return ""; end if; end Min; ----------- -- Minus -- ----------- function Minus (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is N, V : Integer; begin declare V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) then N := Integer'Value (V_Str); else N := Integer'Value (Value (V_Str, C.Translations, C.I_Parameters)); end if; exception when Constraint_Error => raise Template_Error with """-"" filter parameter error"; end; begin V := Integer'Value (S); return Utils.Image (V - N); exception when others => return ""; end; end Minus; ---------------- -- Mode_Value -- ---------------- function Mode_Value (Name : String) return Mode is F, L, K : Mode; begin F := Mode'First; L := Mode'Last; loop K := Mode'Val ((Mode'Pos (F) + Mode'Pos (L)) / 2); if Table (K).Name.all = Name then return K; else exit when F = K and then L = K; if Table (K).Name.all < Name then F := K; if F /= Mode'Last then F := Mode'Succ (F); end if; exit when Table (F).Name.all > Name; else L := K; if L /= Mode'First then L := Mode'Pred (L); end if; exit when Table (L).Name.all < Name; end if; end if; end loop; -- Not found in the table of built-in filters, look for a user's one if User_Filters.Contains (Name) then return User_Defined; end if; raise Internal_Error with "Unknown filter " & Name; end Mode_Value; ------------ -- Modulo -- ------------ function Modulo (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is N, V : Integer; begin declare V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) then N := Integer'Value (V_Str); else N := Integer'Value (Value (V_Str, C.Translations, C.I_Parameters)); end if; exception when Constraint_Error => raise Template_Error with "modulo filter parameter error"; end; begin V := Integer'Value (S); return Utils.Image (V mod N); exception when others => return ""; end; end Modulo; -------------- -- Multiply -- -------------- function Multiply (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is N, V : Integer; begin declare V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) then N := Integer'Value (V_Str); else N := Integer'Value (Value (V_Str, C.Translations, C.I_Parameters)); end if; exception when Constraint_Error => raise Template_Error with """*"" filter parameter error"; end; begin V := Integer'Value (S); return Utils.Image (V * N); exception when others => return ""; end; end Multiply; ---------- -- Name -- ---------- function Name (Handle : Callback) return String is begin for K in Table'Range loop if Table (K).Handle = Handle then return Table (K).Name.all; end if; end loop; raise Internal_Error with "Unknown filter handle"; end Name; --------- -- Neg -- --------- function Neg (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); if S = "" or else not Is_Number (S) then return ""; else return Utils.Image (Integer'Value (S) * (-1)); end if; end Neg; -------------- -- No_Digit -- -------------- function No_Digit (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Result : String := S; begin Check_Null_Parameter (P); for K in S'Range loop if Strings.Maps.Is_In (S (K), Strings.Maps.Constants.Decimal_Digit_Set) then Result (K) := ' '; end if; end loop; return Result; end No_Digit; ---------------- -- No_Dynamic -- ---------------- function No_Dynamic (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); return S; end No_Dynamic; --------------- -- No_Letter -- --------------- function No_Letter (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Result : String := S; begin Check_Null_Parameter (P); for K in S'Range loop if Strings.Maps.Is_In (S (K), Strings.Maps.Constants.Letter_Set) then Result (K) := ' '; end if; end loop; return Result; end No_Letter; -------------- -- No_Space -- -------------- function No_Space (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Result : String (S'Range); L : Natural := Result'First - 1; begin Check_Null_Parameter (P); for K in S'Range loop if not (S (K) = ' ') then L := L + 1; Result (L) := S (K); end if; end loop; return Result (Result'First .. L); end No_Space; ------------- -- Oui_Non -- ------------- function Oui_Non (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); if S = "TRUE" then return "OUI"; elsif S = "true" then return "oui"; elsif S = "True" then return "Oui"; elsif S = "FALSE" then return "NON"; elsif S = "false" then return "non"; elsif S = "False" then return "Non"; else return S; end if; end Oui_Non; --------------- -- Parameter -- --------------- function Parameter (Mode : Filter.Mode) return Parameter_Mode is begin case Mode is when Match => return Regexp; when Replace | Replace_All => return Regpat; when Slice => return Slice; when User_Defined => return User_Callback; when others => return Str; end case; end Parameter; ---------- -- Plus -- ---------- function Plus (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is N, V : Integer; begin declare V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) then N := Integer'Value (V_Str); else N := Integer'Value (Value (V_Str, C.Translations, C.I_Parameters)); end if; exception when Constraint_Error => raise Template_Error with """+"" filter parameter error"; end; begin V := Integer'Value (S); return Utils.Image (V + N); exception when others => return ""; end; end Plus; ------------------ -- Point_2_Coma -- ------------------ function Point_2_Coma (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Result : String := S; begin Check_Null_Parameter (P); for K in Result'Range loop if Result (K) = '.' then Result (K) := ','; end if; end loop; return Result; end Point_2_Coma; -------------- -- Register -- -------------- procedure Register (Name : String; Handler : Templates_Parser.Callback) is Position : Filter_Map.Cursor; Success : Boolean; begin User_Filters.Insert (Name, (With_Param, Handler), Position, Success); end Register; procedure Register (Name : String; Handler : Callback_No_Param) is Position : Filter_Map.Cursor; Success : Boolean; begin User_Filters.Insert (Name, (No_Param, Handler), Position, Success); end Register; procedure Register (Name : String; Handler : not null access User_Filter'Class) is Position : Filter_Map.Cursor; Success : Boolean; begin User_Filters.Insert (Name, (As_Tagged, User_Filter_Access (Handler)), Position, Success); end Register; ------------- -- Release -- ------------- procedure Release (P : in out Parameter_Data) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (GNAT.Regpat.Pattern_Matcher, Pattern_Matcher_Access); begin if P.Mode = Regpat then Unchecked_Free (P.Regpat); elsif P.Mode = Regexp then Unchecked_Free (P.Regexp); end if; end Release; procedure Release (S : in out Set) is begin for K in S'Range loop Release (S (K).Parameters); end loop; end Release; ------------ -- Repeat -- ------------ function Repeat (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is N : Natural; Pattern : Unbounded_String; begin declare V_Str : constant String := To_String (P.S); begin if Is_Number (V_Str) then -- REPEAT(N):STR N := Natural'Value (V_Str); Pattern := To_Unbounded_String (S); else declare N_Str : constant String := Value (V_Str, C.Translations, C.I_Parameters); begin if Is_Number (N_Str) then -- REPEAT(N_VAR):STR N := Natural'Value (N_Str); Pattern := To_Unbounded_String (S); else -- REPEAT(STR):N N := Natural'Value (S); Pattern := P.S; end if; end; end if; declare S : constant String := To_String (Pattern); R : String (1 .. N * S'Length); begin for K in 1 .. N loop R (1 + (K - 1) * S'Length .. S'Length * K) := S; end loop; return R; end; end; exception when Constraint_Error => raise Template_Error with "repeat filter parameter error"; end Repeat; ------------- -- Replace -- ------------- function Replace (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is begin return Replace_One_Or_All (S, P, C.Translations, C.I_Parameters, One => True); end Replace; ----------------- -- Replace_All -- ----------------- function Replace_All (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is begin return Replace_One_Or_All (S, P, C.Translations, C.I_Parameters, One => False); end Replace_All; ------------------------ -- Replace_One_Or_All -- ------------------------ function Replace_One_Or_All (S : String; P : Parameter_Data; T : Translate_Set; I : Parameter_Set; One : Boolean) return String is use type GNAT.Regpat.Match_Location; use Ada.Strings.Fixed; Param : constant String := Value (To_String (P.Param), T, I); Matches : GNAT.Regpat.Match_Array (0 .. GNAT.Regpat.Paren_Count (P.Regpat.all)); Result : Unbounded_String; Temp : Unbounded_String; N : Natural; Current : Natural := S'First; Matched : Boolean := False; begin loop GNAT.Regpat.Match (P.Regpat.all, S (Current .. S'Last), Matches); exit when Matches (0) = GNAT.Regpat.No_Match; Matched := True; Temp := To_Unbounded_String (Param); -- Replace each occurrence of \n in Temp by the corresponding match for K in 1 .. Matches'Last loop -- We only accept \1 ... \9 because we want to be able to write -- such a replacement string "\10123456789\2" exit when K = 10 or else Matches (K) = GNAT.Regpat.No_Match; N := 1; loop N := Index (Slice (Temp, N, Length (Temp)), '\' & Utils.Image (K)); exit when N = 0; Replace_Slice (Temp, N, N + 1, By => S (Matches (K).First .. Matches (K).Last)); -- Position N just after the inserted replacement text N := N + Matches (K).Last - Matches (K).First + 1; end loop; end loop; -- Prepend the beginning of string before the match Result := Result & To_Unbounded_String (S (Current .. Matches (0).First - 1)) & Temp; -- Position the cursor just after the current match Current := Matches (0).Last + 1; exit when One; end loop; if Matched then return To_String (Result) & S (Current .. S'Last); else -- No match, returns the initial string return S; end if; exception when Constraint_Error => raise Template_Error with "replace filter parameter error"; end Replace_One_Or_All; ------------------- -- Replace_Param -- ------------------- function Replace_Param (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is Param : constant String := To_String (P.S); Pos : constant Natural := Strings.Fixed.Index (Param, "="); begin if Pos = 0 then raise Template_Error with "Replace_Param error"; else declare Key : constant String := Param (Param'First .. Pos - 1); begin return Add_Param (Del_Param (S, C, (Str, To_Unbounded_String (Key))), C, P); end; end if; end Replace_Param; ------------------ -- Reverse_Data -- ------------------ function Reverse_Data (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Result : String (S'Range); begin Check_Null_Parameter (P); for K in S'Range loop Result (Result'Last - K + Result'First) := S (K); end loop; return Result; end Reverse_Data; ---------- -- Size -- ---------- function Size (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); return Utils.Image (S'Length); end Size; ----------- -- Slice -- ----------- function Slice (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); First, Last : Integer; begin if S'Length = 0 then return ""; else if P.First <= 0 then First := Integer'Max (S'First, S'Last + P.First); else First := S'First + P.First - 1; end if; if P.Last <= 0 then Last := S'Last + P.Last; else Last := Integer'Min (S'Last, S'First + P.Last - 1); end if; if First > S'Last then return ""; end if; return S (First .. Last); end if; end Slice; ---------- -- Trim -- ---------- function Trim (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); return Ada.Strings.Fixed.Trim (S, Ada.Strings.Both); end Trim; ----------- -- Upper -- ----------- function Upper (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); return Characters.Handling.To_Upper (S); end Upper; ------------------ -- User_Defined -- ------------------ function User_Defined (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is begin case P.Handler.Typ is when With_Param => return P.Handler.CBP (S, To_String (P.P), (C.Translations, C.Lazy_Tag)); when No_Param => if P.P /= Null_Unbounded_String then raise Template_Error with "no parameter allowed in this filter"; else return P.Handler.CB (S, (C.Translations, C.Lazy_Tag)); end if; when As_Tagged => if P.Handler.CBT /= null then return Execute (P.Handler.CBT, Value => S, Parameters => To_String (P.P), Context => (C.Translations, C.Lazy_Tag)); else return ""; end if; end case; end User_Defined; ----------------- -- User_Handle -- ----------------- function User_Handle (Name : String) return User_CB is begin return User_Filters.Element (Name); end User_Handle; ----------- -- Value -- ----------- function Value (Str : String; Translations : Translate_Set; I_Params : Parameter_Set) return String is Pos : Association_Map.Cursor; begin if Str'Length > 0 and then Str (Str'First) = '$' and then Is_Number (Str (Str'First + 1 .. Str'Last)) then -- This is an include parameter declare N : constant Natural := Natural'Value (Str (Str'First + 1 .. Str'Last)); begin return To_String (I_Params (N + 1)); end; elsif Translations = Null_Set then return Str; else Pos := Translations.Set.Find (Str); if Association_Map.Has_Element (Pos) then declare Tk : constant Association := Association_Map.Element (Pos); begin if Tk.Kind = Std then return To_String (Tk.Value); end if; end; end if; return Str; end if; end Value; ---------------- -- Web_Encode -- ---------------- function Web_Encode (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); C_Inf : constant Natural := Character'Pos ('<'); C_Sup : constant Natural := Character'Pos ('>'); C_And : constant Natural := Character'Pos ('&'); C_Quo : constant Natural := Character'Pos ('"'); Result : Unbounded_String; Last : Integer := S'First; Code : Natural; procedure Append_To_Result (Str : String; From : Integer; To : Integer); -- Append S (From .. To) to Result if not empty concatenated with Str -- and update Last. ---------------------- -- Append_To_Result -- ---------------------- procedure Append_To_Result (Str : String; From : Integer; To : Integer) is begin if From <= To then Append (Result, S (From .. To) & Str); else Append (Result, Str); end if; Last := To + 2; end Append_To_Result; begin Check_Null_Parameter (P); for K in S'Range loop Code := Character'Pos (S (K)); if Code not in 32 .. 127 or else Code = C_Inf or else Code = C_Sup or else Code = C_And or else Code = C_Quo then declare I_Code : constant String := Utils.Image (Code); begin Append_To_Result ("&#" & I_Code & ";", Last, K - 1); end; end if; end loop; if Last <= S'Last then Append (Result, S (Last .. S'Last)); end if; return To_String (Result); end Web_Encode; ---------------- -- Web_Escape -- ---------------- function Web_Escape (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); return Utils.Web_Escape (S); end Web_Escape; -------------- -- Web_NBSP -- -------------- function Web_NBSP (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Nbsp_Token : constant String := " "; Max_Escape_Sequence : constant Positive := Nbsp_Token'Length; Result : String (1 .. S'Length * Max_Escape_Sequence); Last : Natural := 0; begin Check_Null_Parameter (P); for I in S'Range loop Last := Last + 1; if S (I) = ' ' then Result (Last .. Last + Nbsp_Token'Length - 1) := Nbsp_Token; Last := Last + Nbsp_Token'Length - 1; else Result (Last) := S (I); end if; end loop; return Result (1 .. Last); end Web_NBSP; ---------- -- Wrap -- ---------- function Wrap (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); Max_Line_Length : constant Positive := Positive'Value (To_String (P.S)); Last : Natural := S'First; First : Natural := S'First; Last_Space_Init : constant Integer := S'First - 1; Last_Space : Integer := Last_Space_Init; Result : Unbounded_String; begin while Last <= S'Last loop if S (Last) = ' ' then Last_Space := Last; end if; if S (Last) = ASCII.LF then -- End of the line Append (Result, S (First .. Last)); First := Last + 1; Last := First; Last_Space := Last_Space_Init; elsif Last - First >= Max_Line_Length then -- The line must be wrapped if Last_Space in First .. Last then -- Split the line before the last word Append (Result, S (First .. Last_Space - 1) & ASCII.LF); First := Last_Space + 1; Last := First; else -- There is only one word on the line: cut it Append (Result, S (First .. Last - 1) & ASCII.LF); First := Last; end if; Last_Space := Last_Space_Init; else -- Go to the next character Last := Last + 1; end if; end loop; Append (Result, S (First .. S'Last)); return To_String (Result); exception when Constraint_Error => raise Template_Error with "wrap filter parameter error"; end Wrap; ------------ -- Yes_No -- ------------ function Yes_No (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String is pragma Unreferenced (C); begin Check_Null_Parameter (P); if S = "TRUE" then return "YES"; elsif S = "true" then return "yes"; elsif S = "True" then return "Yes"; elsif S = "FALSE" then return "NO"; elsif S = "false" then return "no"; elsif S = "False" then return "No"; else return S; end if; end Yes_No; end Filter; libtemplates-parser-11.6.orig/src/templates_parser-input.adb0000644000175000017500000001304211637170657024202 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2002 - 2005 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- $Id: templates_parser-input.adb 303 2005-02-12 11:51:02Z obry $ -- This is the standard version to be used with the standalone version of -- Templates_Parser. with Ada.Streams.Stream_IO; with Ada.Unchecked_Deallocation; package body Templates_Parser.Input is use Ada; use Ada.Streams; Buffer_Size : constant := 8_192; type File_Record is record File : Stream_IO.File_Type; LFT : Boolean; -- LF terminated state Buffer : Streams.Stream_Element_Array (1 .. Buffer_Size); Current : Streams.Stream_Element_Offset; Last : Streams.Stream_Element_Count; end record; procedure Free is new Ada.Unchecked_Deallocation (File_Record, File_Type); ----------- -- Close -- ----------- procedure Close (File : in out File_Type) is begin if File = null then raise Stream_IO.Status_Error; else Stream_IO.Close (File.File); end if; Free (File); exception when others => Free (File); end Close; ----------------- -- End_Of_File -- ----------------- function End_Of_File (File : in File_Type) return Boolean is begin if File = null then raise Stream_IO.Status_Error; else return Stream_IO.End_Of_File (File.File) and then File.Current > File.Last; end if; end End_Of_File; ------------------- -- LF_Terminated -- ------------------- function LF_Terminated (File : in File_Type) return Boolean is begin if File = null then raise Stream_IO.Status_Error; else return File.LFT; end if; end LF_Terminated; -------------- -- Get_Line -- -------------- procedure Get_Line (File : in File_Type; Buffer : out String; Last : out Natural) is C : Character; -- Current character. procedure Next_Char; -- Set C with next character in the file, update Resource.Last. --------------- -- Next_Char -- --------------- procedure Next_Char is begin if File.Current > File.Last then Stream_IO.Read (File.File, File.Buffer, File.Last); File.Current := File.Buffer'First; end if; C := Character'Val (File.Buffer (File.Current)); File.Current := File.Current + 1; end Next_Char; begin if File = null then raise Stream_IO.Status_Error; else Last := 0; File.LFT := False; loop Next_Char; if File.Last < File.Buffer'First then exit; else if C = ASCII.LF then -- UNIX style line terminator File.LFT := True; exit; elsif C = ASCII.CR then -- DOS style line terminator Next_Char; if File.Last < File.Buffer'First then -- no more char exit; elsif C = ASCII.LF then -- Ok, found CR+LF File.LFT := True; exit; else -- CR, but no LF, continue reading Last := Last + 1; Buffer (Last) := C; end if; else Last := Last + 1; Buffer (Last) := C; end if; end if; end loop; end if; end Get_Line; ---------- -- Open -- ---------- procedure Open (File : in out File_Type; Name : in String; Form : in String := "") is begin if File /= null then Close (File); end if; File := new File_Record; File.Current := 1; File.Last := 0; Stream_IO.Open (File.File, Stream_IO.In_File, Name, Form); exception when Stream_IO.Name_Error => Free (File); raise; end Open; end Templates_Parser.Input; libtemplates-parser-11.6.orig/src/templates_parser-input.ads0000644000175000017500000000540111637170657024223 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2002-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.IO_Exceptions; package Templates_Parser.Input is type File_Type is limited private; Status_Error : exception renames Ada.IO_Exceptions.Status_Error; Name_Error : exception renames Ada.IO_Exceptions.Name_Error; procedure Open (File : in out File_Type; Name : String; Form : String := ""); pragma Inline (Open); -- Like Text_IO.Open and Mode = In_File procedure Close (File : in out File_Type); pragma Inline (Close); -- Like Text_IO.Close. Raises text_IO.Status_Error is file is not open function End_Of_File (File : File_Type) return Boolean; pragma Inline (End_Of_File); -- Like Text_IO.End_Of_File. Raises Text_IO.Status_Error is file is not -- open. function LF_Terminated (File : File_Type) return Boolean; pragma Inline (LF_Terminated); -- Returns True if last line returned by Get_Line was terminated with a LF -- or CR+LF on DOS based systems. procedure Get_Line (File : File_Type; Buffer : out String; Last : out Natural); -- Like Text_IO.Get_Line. Raises Text_IO.Status_Error is file is not open private type File_Record; type File_Type is access File_Record; end Templates_Parser.Input; libtemplates-parser-11.6.orig/src/templates_parser-input__standalone.adb0000755000175000017500000001310711637170657026556 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2002-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- This is the standard version to be used with the standalone version of -- Templates_Parser. with Ada.Exceptions; with Ada.Streams.Stream_IO; with Ada.Unchecked_Deallocation; package body Templates_Parser.Input is use Ada.Exceptions; use Ada.Streams; Buffer_Size : constant := 8_192; type File_Record is record File : Stream_IO.File_Type; LFT : Boolean; -- LF terminated state Buffer : Streams.Stream_Element_Array (1 .. Buffer_Size); Current : Streams.Stream_Element_Offset; Last : Streams.Stream_Element_Count; end record; procedure Free is new Ada.Unchecked_Deallocation (File_Record, File_Type); ----------- -- Close -- ----------- procedure Close (File : in out File_Type) is begin if File = null then raise Stream_IO.Status_Error; else begin Stream_IO.Close (File.File); Free (File); exception when others => Free (File); raise; end; end if; end Close; ----------------- -- End_Of_File -- ----------------- function End_Of_File (File : File_Type) return Boolean is begin if File = null then raise Stream_IO.Status_Error; else return Stream_IO.End_Of_File (File.File) and then File.Current > File.Last; end if; end End_Of_File; -------------- -- Get_Line -- -------------- procedure Get_Line (File : File_Type; Buffer : out String; Last : out Natural) is C : Character; -- Current character procedure Next_Char; -- Set C with next character in the file, update Resource.Last --------------- -- Next_Char -- --------------- procedure Next_Char is begin if File.Current > File.Last then Stream_IO.Read (File.File, File.Buffer, File.Last); File.Current := File.Buffer'First; end if; C := Character'Val (File.Buffer (File.Current)); File.Current := File.Current + 1; end Next_Char; begin if File = null then raise Stream_IO.Status_Error; else Last := 0; File.LFT := False; loop Next_Char; if File.Last < File.Buffer'First then exit; else if C = ASCII.LF then -- UNIX style line terminator File.LFT := True; exit; elsif C = ASCII.CR then -- DOS style line terminator Next_Char; if File.Last < File.Buffer'First then -- No more char exit; elsif C = ASCII.LF then -- Ok, found CR+LF File.LFT := True; exit; else -- CR, but no LF, continue reading Last := Last + 1; Buffer (Last) := C; end if; else Last := Last + 1; Buffer (Last) := C; end if; end if; end loop; end if; end Get_Line; ------------------- -- LF_Terminated -- ------------------- function LF_Terminated (File : File_Type) return Boolean is begin if File = null then raise Stream_IO.Status_Error; else return File.LFT; end if; end LF_Terminated; ---------- -- Open -- ---------- procedure Open (File : in out File_Type; Name : String; Form : String := "") is begin if File /= null then Close (File); end if; File := new File_Record; File.Current := 1; File.Last := 0; Stream_IO.Open (File.File, Stream_IO.In_File, Name, Form); exception when Stream_IO.Name_Error => Free (File); Raise_Exception (IO_Exceptions.Name_Error'Identity, "File '" & Name & "' not found."); end Open; end Templates_Parser.Input; libtemplates-parser-11.6.orig/src/templates_parser-macro.adb0000644000175000017500000004317511637170657024156 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Strings.Hash_Case_Insensitive; with Ada.Text_IO; separate (Templates_Parser) package body Macro is function Default_Callback (Name : String; Params : Parameter_Set) return String; -- Default macro callback package Registry is new Containers.Indefinite_Hashed_Maps (String, Tree, Strings.Hash_Case_Insensitive, "="); Set : Registry.Map; -------------------------- -- Print_Defined_Macros -- -------------------------- procedure Print_Defined_Macros is procedure Print (Position : Registry.Cursor); -- Print the given macro ----------- -- Print -- ----------- procedure Print (Position : Registry.Cursor) is Name : constant String := Registry.Key (Position); Macro : constant Tree := Registry.Element (Position); begin Text_IO.Put_Line ("[MACRO] " & Name); Print_Tree (Macro); Text_IO.Put_Line ("[END_MACRO]"); Text_IO.New_Line; end Print; begin Text_IO.Put_Line ("------------------------------------- MACROS"); Set.Iterate (Print'Access); end Print_Defined_Macros; -------------- -- Register -- -------------- procedure Register (Name : String; T : Tree) is Old : Tree := Get (Name); begin if Old /= null then Set.Delete (Name); Release (Old); end if; Set.Insert (Name, T); end Register; --------- -- Get -- --------- function Get (Name : String) return Tree is Position : constant Registry.Cursor := Set.Find (Name); begin if Registry.Has_Element (Position) then return Registry.Element (Position); else return null; end if; end Get; ------------- -- Rewrite -- ------------- procedure Rewrite (T : in out Tree; Parameters : not null access Data.Parameter_Set) is use type Definitions.Tree; procedure Rewrite_Tree (T : in out Tree; Parameters : not null access Data.Parameter_Set); -- Recursivelly rewrite the whole tree package Set_Var is new Containers.Indefinite_Hashed_Maps (String, Definitions.Tree, Strings.Hash_Case_Insensitive, "="); procedure Release_Definition (Position : Set_Var.Cursor); -- Release definition tree pointed to by Position Vars : Set_Var.Map; ------------------ -- Rewrite_Tree -- ------------------ procedure Rewrite_Tree (T : in out Tree; Parameters : not null access Data.Parameter_Set) is procedure Rewrite (T : in out Data.Tree); -- Rewrite every variable references @_$N_@ (where N is a -- number) by the corresponding variable or value found in -- Parameters(N) or by the corresponding variable mapping in Vars. procedure Rewrite (T : in out Expr.Tree); -- Rewrite condition. -- In @@IF@@ @_$N_@ = val -- Replace $N by Parameters(N) or by the corresponding value in the -- variable mapping or does nothing if Parameters(N) does not exists -- or no variable mapping found. ------------- -- Rewrite -- ------------- procedure Rewrite (T : in out Data.Tree) is procedure Replace (T, C, Prev : in out Data.Tree; Ref : Positive); -- Replace node C with the parameters pointed to by Ref procedure Replace (T, C, Prev : in out Data.Tree; Value : String); -- As above, but replace by Value procedure Delete_Node (T : in out Data.Tree; C, Prev : Data.Tree); -- Delete node C ----------------- -- Delete_Note -- ----------------- procedure Delete_Node (T : in out Data.Tree; C, Prev : Data.Tree) is use type Data.Tree; Old : Data.Tree; begin if Prev = null then Old := T; T := C.Next; else Old := C; Prev.Next := C.Next; end if; Data.Release (Old, Single => True); end Delete_Node; ------------- -- Replace -- ------------- procedure Replace (T, C, Prev : in out Data.Tree; Ref : Positive) is use type Data.NKind; use type Data.Tree; New_Node : constant Data.Tree := Data.Clone (Parameters (Ref)); begin New_Node.Next := C.Next; if Prev = null then Data.Release (T, Single => True); T := New_Node; else Data.Release (Prev.Next, Single => True); Prev.Next := New_Node; end if; Prev := New_Node; C := New_Node.Next; end Replace; procedure Replace (T, C, Prev : in out Data.Tree; Value : String) is use type Data.Tree; New_Node : constant Data.Tree := new Data.Node' (Data.Text, Next => C.Next, Value => To_Unbounded_String (Value)); begin if Prev = null then Data.Release (T, Single => True); T := New_Node; else Data.Release (Prev.Next, Single => True); Prev.Next := New_Node; end if; Prev := New_Node; C := New_Node.Next; end Replace; use type Data.Tree; D, Prev : Data.Tree; Moved : Boolean := False; begin D := T; Prev := null; while D /= null loop case D.Kind is when Data.Text => null; when Data.Var => -- Rewrite also the macro call if any if D.Var.Is_Macro then Rewrite_Tree (D.Var.Def, Parameters); else if D.Var.N > 0 then -- This is a reference to a parameter if D.Var.N <= Parameters'Length and then Parameters (D.Var.N) /= null then -- This is a reference to replace Replace (T, D, Prev, D.Var.N); else -- This variable does not have reference, remove -- it. Delete_Node (T, D, Prev); D := D.Next; end if; Moved := True; elsif Vars.Contains (To_String (D.Var.Name)) then -- This is a variable that exists into the map. -- It means that this variable is actually the -- name of a SET which actually has been passed -- a reference to another variable. declare E : constant Definitions.Tree := Vars.Element (To_String (D.Var.Name)); begin case E.N.Kind is when Definitions.Const => Replace (T, D, Prev, To_String (E.N.Value)); when Definitions.Ref => if E.N.Ref <= Parameters'Length and then Parameters (E.N.Ref) /= null then Replace (T, D, Prev, E.N.Ref); else Replace (T, D, Prev, ""); end if; when Definitions.Ref_Default => if E.N.Ref <= Parameters'Length and then Parameters (E.N.Ref) /= null then Replace (T, D, Prev, E.N.Ref); else Replace (T, D, Prev, To_String (E.N.Value)); end if; end case; end; Moved := True; end if; end if; end case; if Moved then Moved := False; else Prev := D; D := D.Next; end if; end loop; end Rewrite; ------------- -- Rewrite -- ------------- procedure Rewrite (T : in out Expr.Tree) is use type Expr.Tree; use type Data.Tree; procedure Replace (T : in out Expr.Tree; Ref : Positive); pragma Inline (Replace); -- Replace T with the parameters pointed to by Ref procedure Replace (T : in out Expr.Tree; Value : String); pragma Inline (Replace); -- Replace the node by the given value ------------- -- Replace -- ------------- procedure Replace (T : in out Expr.Tree; Value : String) is begin Expr.Release (T, Single => True); T := new Expr.Node' (Expr.Value, V => To_Unbounded_String (Value)); end Replace; procedure Replace (T : in out Expr.Tree; Ref : Positive) is Tag_Var : Data.Tag_Var; begin case Parameters (Ref).Kind is when Data.Text => Replace (T, To_String (Parameters (Ref).Value)); when Data.Var => Tag_Var := Data.Clone (Parameters (Ref).Var); Data.Release (T.Var); T.Var := Tag_Var; end case; end Replace; begin case T.Kind is when Expr.Value => null; when Expr.Var => if T.Var.N > 0 and then T.Var.N <= Parameters'Length and then Parameters (T.Var.N) /= null then -- This is a reference to replace Replace (T, T.Var.N); elsif Vars.Contains (To_String (T.Var.Name)) then -- This is a variable that exists into the map. -- It means that this variable is actually the -- name of a SET which actually has been passed -- a reference to another variable. declare E : constant Definitions.Tree := Vars.Element (To_String (T.Var.Name)); begin case E.N.Kind is when Definitions.Const => Replace (T, To_String (E.N.Value)); when Definitions.Ref => if E.N.Ref <= Parameters'Length and then Parameters (E.N.Ref) /= null then Replace (T, E.N.Ref); else Replace (T, ""); end if; when Definitions.Ref_Default => null; end case; end; else -- This is undefined, replace by an empty string Replace (T, ""); end if; when Expr.Op => Rewrite (T.Left); Rewrite (T.Right); when Expr.U_Op => Rewrite (T.Next); end case; end Rewrite; N : Tree := T; Prev : Tree; Moved : Boolean := False; begin T := N; while N /= null loop case N.Kind is when Text => Rewrite (N.Text); when If_Stmt => Rewrite (N.Cond); Rewrite_Tree (N.N_True, Parameters); Rewrite_Tree (N.N_False, Parameters); when Set_Stmt => -- Record definition and delete node, note that the -- defintion tree will be freed later as we need the tree -- for the rewriting. Vars.Include (To_String (N.Def.Name), N.Def); declare Old : Tree := N; begin if Prev = null then T := N.Next; N := T; else Prev.Next := N.Next; N := Prev.Next; end if; Unchecked_Free (Old); Moved := True; end; when Table_Stmt => Rewrite_Tree (N.Blocks, Parameters); when Section_Block => Rewrite_Tree (N.Common, Parameters); Rewrite_Tree (N.Sections, Parameters); when Section_Stmt => Rewrite_Tree (N.N_Section, Parameters); when Include_Stmt => for K in N.I_Params'Range loop declare use type Data.Tree; use type Data.NKind; P : Data.Tree renames N.I_Params (K); Old : Data.Tree; begin if P /= null and then P.Kind = Data.Var and then P.Var.N > 0 then Old := N.I_Params (K); N.I_Params (K) := Data.Clone (Parameters (P.Var.N)); Data.Release (Old); end if; end; end loop; when others => null; end case; if Moved then Moved := False; else Prev := N; N := N.Next; end if; end loop; end Rewrite_Tree; ------------------------ -- Release_Definition -- ------------------------ procedure Release_Definition (Position : Set_Var.Cursor) is E : Definitions.Tree := Set_Var.Element (Position); begin Definitions.Release (E); end Release_Definition; begin Rewrite_Tree (T, Parameters); Vars.Iterate (Release_Definition'Access); end Rewrite; ---------------------- -- Default_Callback -- ---------------------- function Default_Callback (Name : String; Params : Parameter_Set) return String is function Parameters return String; -- Returns parameters ---------------- -- Parameters -- ---------------- function Parameters return String is R : Unbounded_String; begin for K in Params'Range loop Append (R, Params (K)); if K /= Params'Last then Append (R, ","); end if; end loop; return To_String (R); end Parameters; begin return To_String (Begin_Tag) & Name & "(" & Parameters & ")" & To_String (End_Tag); end Default_Callback; begin Callback := Default_Callback'Access; end Macro; libtemplates-parser-11.6.orig/src/templates_parser-print_tree.adb0000644000175000017500000001304611637170657025222 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 1999-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; separate (Templates_Parser) procedure Print_Tree (T : Tree; Level : Natural := 0) is use type Expr.Tree; procedure Print_Indent (L : Natural); -- Output proper number of spaces for identation ------------------ -- Print_Indent -- ------------------ procedure Print_Indent (L : Natural) is use Ada.Strings.Fixed; begin Text_IO.Put ((L * 2) * ' '); end Print_Indent; begin if T = null then return; end if; Print_Indent (Level); case T.Kind is when Info => Text_IO.Put_Line ("[INFO] " & To_String (T.Filename)); declare I : Tree := T.I_File; begin while I /= null loop Text_IO.Put (" -> "); if I.File = Null_Static_Tree then Data.Print_Tree (I.I_Filename); else Text_IO.Put_Line (To_String (I.File.Info.Filename)); end if; I := I.Next; end loop; end; Print_Tree (T.Next, Level); when C_Info => Text_IO.Put_Line ("[C_INFO] " & Natural'Image (T.Used) & ' ' & Boolean'Image (T.Obsolete)); Print_Tree (T.Next, Level); when Text => Text_IO.Put ("[TEXT] "); Data.Print_Tree (T.Text); Print_Tree (T.Next, Level); when Set_Stmt => Text_IO.Put ("[SET] "); Definitions.Print_Tree (T.Def); Text_IO.New_Line; Print_Tree (T.Next, Level); when If_Stmt => Text_IO.Put ("[IF] "); Expr.Print_Tree (T.Cond); Text_IO.New_Line; Print_Tree (T.N_True, Level + 1); if T.N_False /= null then Print_Indent (Level); Text_IO.Put_Line ("[ELSE]"); Print_Tree (T.N_False, Level + 1); end if; Print_Indent (Level); Text_IO.Put_Line ("[END_IF]"); Print_Tree (T.Next, Level); when Table_Stmt => Text_IO.Put ("[TABLE]"); if T.Terminate_Sections then Text_IO.Put (" TERMINATE_SECTIONS"); end if; if T.Reverse_Index then Text_IO.Put (" REVERSE"); end if; if T.Terse then Text_IO.Put (" TERSE"); end if; Text_IO.New_Line; Print_Tree (T.Blocks, Level + 1); Print_Indent (Level); Text_IO.Put_Line ("[END_TABLE]"); Print_Tree (T.Next, Level); when Section_Block => Text_IO.Put_Line ("[BLOCK]"); if T.Common /= null then Print_Indent (Level + 1); Text_IO.Put_Line ("[COMMON]"); Print_Tree (T.Common, Level + 2); end if; if T.Sections /= null then Print_Tree (T.Sections, Level + 1); end if; Print_Indent (Level); Text_IO.Put_Line ("[END_BLOCK]"); Print_Tree (T.Next, Level); when Section_Stmt => Text_IO.Put_Line ("[SECTION]"); Print_Tree (T.Next, Level + 1); Print_Tree (T.N_Section, Level); when Include_Stmt => Text_IO.Put ("[INCLUDE] "); if T.File = Null_Static_Tree then Data.Print_Tree (T.I_Filename); else Text_IO.Put_Line (To_String (T.File.Info.Filename)); end if; declare use type Data.Tree; begin for K in T.I_Params'Range loop if T.I_Params (K) /= null then Print_Indent (Level + 2); Text_IO.Put ("$" & Utils.Image (K) & " = "); Data.Print_Tree (T.I_Params (K)); end if; end loop; end; Print_Tree (T.File.Info, Level + 1); Print_Tree (T.Next, Level); when Inline_Stmt => Text_IO.Put_Line ("[INLINE] (" & To_String (T.Sep) & ')'); Print_Tree (T.I_Block, Level + 1); Text_IO.Put_Line ("[END_INLINE]"); Print_Tree (T.Next, Level); end case; end Print_Tree; libtemplates-parser-11.6.orig/src/templates_parser-query.adb0000644000175000017500000000512211637170657024210 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2003-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ package body Templates_Parser.Query is --------------- -- Composite -- --------------- function Composite (Association : Templates_Parser.Association) return Tag is begin if Association.Kind = Composite then return Association.Comp_Value; else raise Constraint_Error with Variable (Association) & " is not a composite tag."; end if; end Composite; ---------- -- Kind -- ---------- function Kind (Association : Templates_Parser.Association) return Association_Kind is begin return Association.Kind; end Kind; ------------------ -- Nested_Level -- ------------------ function Nested_Level (T : Tag) return Positive is begin return T.Data.Nested_Level; end Nested_Level; -------------- -- Variable -- -------------- function Variable (Association : Templates_Parser.Association) return String is begin return To_String (Association.Variable); end Variable; end Templates_Parser.Query; libtemplates-parser-11.6.orig/src/templates_parser-query.ads0000644000175000017500000000433611637170657024237 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2003-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ package Templates_Parser.Query is function Kind (Association : Templates_Parser.Association) return Association_Kind; -- Returns the kind for this association function Variable (Association : Templates_Parser.Association) return String; -- Returns the variable name for Association function Composite (Association : Templates_Parser.Association) return Tag; -- Returns the vector tag for this association, raises Constraint_Error -- if it is not a vector. function Nested_Level (T : Tag) return Positive; -- Returns the nested level for tag T, 1 means that this is a vector tag, -- 2 that it is a matrix. end Templates_Parser.Query; libtemplates-parser-11.6.orig/src/templates_parser-simplifier.adb0000644000175000017500000002136511637170657025215 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ separate (Templates_Parser) package body Simplifier is procedure Run (T : in out Tree) is procedure Rewrite (T : in out Data.Tree); -- Optimize data tree T procedure Link_End (T, To : Tree; Link : out Tree); -- Link To at end of tree T, Link is the pointer to the last node -------------- -- Link_End -- -------------- procedure Link_End (T, To : Tree; Link : out Tree) is N : Tree := T; begin while N.Next /= null loop N := N.Next; end loop; N.Next := To; Link := N; end Link_End; ------------- -- Rewrite -- ------------- procedure Rewrite (T : in out Data.Tree) is use type Data.Tree; use type Data.NKind; use type Nkind; D, Prev : Data.Tree; Moved : Boolean := False; Old : Data.Tree; begin D := T; while D /= null loop case D.Kind is when Data.Text => if Prev = null and then T.Kind = Data.Text and then D /= T then Append (T.Value, D.Value); Old := T.Next; T.Next := D.Next; D := D.Next; Moved := True; Data.Release (Old, Single => True); elsif Prev /= null and then Prev.Kind = Data.Text then Append (Prev.Value, D.Value); Old := Prev.Next; Prev.Next := D.Next; D := D.Next; Moved := True; Data.Release (Old, Single => True); end if; when Data.Var => -- Rewrite also the macro if any if D.Var.Is_Macro then Run (D.Var.Def); -- Check if we have a single resulting TEXT node if D.Var.Def /= null and then D.Var.Def.Kind = Text and then D.Var.Def.Text.Kind = Data.Text and then D.Var.Def.Text.Next = null and then D.Var.Def.Next = null then declare C : aliased Filter.Filter_Context (P_Size => 0); begin if Prev = null then -- First node is a variable (line starting with -- a tag variable), replace it by the -- corresponding text node. Old := T; T := new Data.Node' (Kind => Data.Text, Next => D.Var.Def.Text.Next, Value => To_Unbounded_String (Data.Translate (D.Var, To_String (D.Var.Def.Text.Value), C'Access))); D := D.Next; Moved := True; Data.Release (Old, Single => True); elsif Prev.Kind = Data.Text then -- First node was a text, merge the values Append (Prev.Value, D.Var.Def.Text.Value); Old := Prev.Next; Prev.Next := D.Next; D := D.Next; Moved := True; Data.Release (Old, Single => True); end if; end; end if; end if; end case; if not Moved then Prev := D; D := D.Next; else Moved := False; end if; end loop; end Rewrite; N : Tree := T; Prev, P : Tree; Moved : Boolean := False; begin T := N; while N /= null loop case N.Kind is when Text => Rewrite (N.Text); when Table_Stmt => Run (N.Blocks); when Section_Block => Run (N.Common); Run (N.Sections); when Section_Stmt => Run (N.N_Section); when If_Stmt => declare V : constant String := Expr.Analyze (N.Cond); begin if V = Expr.Unknown then Run (N.N_True); Run (N.N_False); elsif (Expr.Is_True (V) and then N.N_True = null) or else (not Expr.Is_True (V) and then N.N_False = null) then -- The corresponding branch does not exists, skip IF Expr.Release (N.Cond); Release (N.N_True); Release (N.N_False); declare Old : Tree; begin if Prev = null then Old := T; T := T.Next; else Old := Prev.Next; Prev.Next := N.Next; end if; N := N.Next; Unchecked_Free (Old); end; Moved := True; elsif Expr.Is_True (V) then Expr.Release (N.Cond); Release (N.N_False); Run (N.N_True); if Prev = null then Link_End (N.N_True, T.Next, Link => P); Unchecked_Free (T); T := N.N_True; else Link_End (N.N_True, N.Next, Link => P); Unchecked_Free (Prev.Next); Prev.Next := N.N_True; end if; Prev := P; N := N.Next; Moved := True; else Expr.Release (N.Cond); Release (N.N_True); Run (N.N_False); if Prev = null then Link_End (N.N_False, T.Next, Link => P); Unchecked_Free (T); T := N.N_False; else Link_End (N.N_False, N.Next, Link => P); Unchecked_Free (Prev.Next); Prev.Next := N.N_False; end if; Prev := P; N := N.Next; Moved := True; end if; end; when others => null; end case; if Moved then Moved := False; else Prev := N; N := N.Next; end if; end loop; end Run; end Simplifier; libtemplates-parser-11.6.orig/src/templates_parser-utils.adb0000644000175000017500000003326111637170657024210 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Command_Line; with Ada.Directories; with Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; package body Templates_Parser.Utils is -------------------------- -- Executable_Extension -- -------------------------- function Executable_Extension return String is begin if Is_Windows then return "exe"; else return ""; end if; end Executable_Extension; --------------------------- -- Get_Program_Directory -- --------------------------- function Get_Program_Directory return String is function Locate_On_Path (Filename : String) return String; -- Returns the full pathname for filename or the empty string if not -- found. function Is_Full_Pathname (Filename : String) return Boolean; -- Returns True is Filename is a full pathname function Get_Command_Name return String; -- Returns the normalized command string function Containing_Directory (Filename : String) return String; -- Containing directory without directory separator, this can happen -- with GNAT when returning the current working directory? -------------------------- -- Containing_Directory -- -------------------------- function Containing_Directory (Filename : String) return String is CD : constant String := Directories.Containing_Directory (Filename); begin if CD (CD'Last) = Directory_Separator then return CD (CD'First .. CD'Last - 1); else return CD; end if; end Containing_Directory; ---------------------- -- Get_Command_Name -- ---------------------- function Get_Command_Name return String is N : constant String := Command_Line.Command_Name; E : constant String := Executable_Extension; begin if N'Length > E'Length and then N (N'Last - E'Length + 1 .. N'Last) = E then return N; else return N & E; end if; end Get_Command_Name; ---------------------- -- Is_Full_Pathname -- ---------------------- function Is_Full_Pathname (Filename : String) return Boolean is F : String renames Filename; begin return F (F'First) = Directory_Separator or else (F'Length > 2 and then (F (F'First) in 'a' .. 'z' or else F (F'First) in 'A' .. 'Z') and then F (F'First + 1) = ':' and then F (F'First + 2) = Directory_Separator); end Is_Full_Pathname; -------------------- -- Locate_On_Path -- -------------------- function Locate_On_Path (Filename : String) return String is PATH : constant String := Environment_Variables.Value ("PATH"); First, Last : Natural; Idx : Natural; begin First := PATH'First; loop Last := Strings.Fixed.Index (PATH, String'(1 => Path_Separator), From => First); if Last = 0 then Idx := PATH'Last; else Idx := Last - 1; end if; declare Full_Pathname : constant String := Directories.Compose (PATH (First .. Idx) & Directory_Separator, Filename); begin if Directories.Exists (Full_Pathname) then return Full_Pathname; end if; end; First := Last + 1; exit when Last = 0 or else First > PATH'Last; end loop; return ""; end Locate_On_Path; Command_Name : constant String := Get_Command_Name; begin if Command_Name = "" then -- Command name can be empty on OS not supporting command line -- options like VxWorks. return "."; else declare Dir : constant String := Containing_Directory (Command_Name); begin -- On UNIX command_name doesn't include the directory name -- when the command was found on the PATH. On Windows using -- the standard shell, the command is never passed using a -- full pathname. In such a case, which check on the PATH -- ourselves to find it. if Directories.Exists (Command_Name) then -- Command is found if Is_Full_Pathname (Command_Name) or else Is_Full_Pathname (Dir) then -- And we have a full pathname use it return Dir & Directory_Separator; else -- A relative pathname, catenate the current directory return Directories.Current_Directory & Directory_Separator & Dir & Directory_Separator; end if; else -- Command does not exists, try checkin it on the PATH declare Full_Pathname : constant String := Locate_On_Path (Directories.Simple_Name (Command_Name)); begin if Full_Pathname = "" then -- Not found on the PATH, nothing we can do return Dir; else return Directories.Containing_Directory (Full_Pathname) & Directory_Separator; end if; end; end if; end; end if; end Get_Program_Directory; ----------- -- Image -- ----------- function Image (T : Tag) return String is function Quote (Str : String) return String; pragma Inline (Quote); -- Quote Str and double quote inside Str if needed ----------- -- Quote -- ----------- function Quote (Str : String) return String is Result : Unbounded_String; begin Append (Result, """"); for K in Str'Range loop if Str (K) = '"' then Append (Result, """"""); else Append (Result, Str (K)); end if; end loop; Append (Result, """"); return To_String (Result); end Quote; Result : Unbounded_String; N : Tag_Node_Access := T.Data.Head; begin while N /= null loop if N.Kind = Value then if Result /= Null_Unbounded_String then Append (Result, ","); end if; Append (Result, Quote (To_String (N.V))); else Append (Result, Image (N.VS.all)); end if; N := N.Next; end loop; return "(" & To_String (Result) & ")"; end Image; function Image (N : Integer) return String is N_Img : constant String := Integer'Image (N); begin if N_Img (N_Img'First) = '-' then return N_Img; else return N_Img (N_Img'First + 1 .. N_Img'Last); end if; end Image; --------------- -- Is_Number -- --------------- function Is_Number (S : String) return Boolean is begin return Strings.Fixed.Index (S, Strings.Maps.Constants.Decimal_Digit_Set, Test => Strings.Outside) = 0; end Is_Number; ----------- -- Value -- ----------- function Value (T : String) return Tag is function Value (T : String) return Tag; -- Returns the Tag for T string function Clear_Quote (Str : String) return String; pragma Inline (Clear_Quote); -- Removes double quote in Str ----------------- -- Clear_Quote -- ----------------- function Clear_Quote (Str : String) return String is Result : Unbounded_String; begin for K in Str'Range loop if Str (K) /= '"' or else (K < Str'Last and then Str (K + 1) /= '"') then Append (Result, Str (K)); end if; end loop; return To_String (Result); end Clear_Quote; ----------- -- Value -- ----------- function Value (T : String) return Tag is Result : Tag; K : Natural := T'First; N : Natural; Last : Natural; begin while K < T'Last loop if T (K) = '(' then -- This is a nested Tag, Look for corresponding closing parent Last := K + 1; N := 0; Nested_Tag : loop if T (Last) = ')' then if N = 0 then -- Matching parent found, add it to the result Result := Result & Value (T (K + 1 .. Last)); K := Last; -- and leave this loop exit Nested_Tag; else N := N - 1; end if; elsif T (Last) = '(' then N := N + 1; end if; if Last = T'Last then -- Matching parent not found raise Constraint_Error; else Last := Last + 1; end if; end loop Nested_Tag; elsif T (K) = '"' then -- This is a value, Look for corresponding closing quote Last := K + 1; Quoted_Value : loop if T (Last) = '"' and then Last < T'Last and then T (Last + 1) = '"' then -- Skip this quote Last := Last + 1; elsif T (Last) = '"' and then (Last = T'Last or else T (Last + 1) /= '"') then -- Found matching quote, add this value Result := Result & Clear_Quote (T (K + 1 .. Last - 1)); K := Last; -- and leave loop exit Quoted_Value; elsif Last = T'Last then -- No matching quote raise Constraint_Error; end if; Last := Last + 1; end loop Quoted_Value; -- Here we must have either a ',' or ")" if Last /= T'Last and then T (Last + 1) /= ',' and then T (Last + 1) /= ')' then raise Constraint_Error; end if; end if; K := K + 1; end loop; return Result; end Value; begin if T'Length > 1 and then T (T'First) = '(' and then T (T'Last) = ')' then return Value (T (T'First + 1 .. T'Last - 1)); else raise Constraint_Error; end if; end Value; ---------------- -- Web_Escape -- ---------------- function Web_Escape (S : String) return String is Result : Unbounded_String; Last : Integer := S'First; procedure Append_To_Result (Str : String; From, To : Integer); -- Append S (From .. To) to Result if not empty concatenated with Str -- and update Last. ---------------------- -- Append_To_Result -- ---------------------- procedure Append_To_Result (Str : String; From, To : Integer) is begin if From <= To then Append (Result, S (From .. To) & Str); else Append (Result, Str); end if; Last := To + 2; end Append_To_Result; begin for I in S'Range loop case S (I) is when '&' => Append_To_Result ("&", Last, I - 1); when '>' => Append_To_Result (">", Last, I - 1); when '<' => Append_To_Result ("<", Last, I - 1); when '"' => Append_To_Result (""", Last, I - 1); when others => null; end case; end loop; if Last <= S'Last then Append (Result, S (Last .. S'Last)); end if; return To_String (Result); end Web_Escape; end Templates_Parser.Utils; libtemplates-parser-11.6.orig/src/templates_parser-utils.ads0000644000175000017500000000624211637170657024230 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Environment_Variables; package Templates_Parser.Utils is use Ada; function Image (N : Integer) return String; pragma Inline (Image); -- Returns N image without leading blank function Image (T : Tag) return String; -- Returns a string representation for this tag function Value (T : String) return Tag; -- Give a string representation of a tag (as encoded with Image above), -- build the corresponding Tag object. Raises Constraint_Error if T is -- not a valid tag representation. function Get_Program_Directory return String; -- Returns the directory full path name for the current running program Is_Windows : constant Boolean := Environment_Variables.Exists ("OS") and then Environment_Variables.Value ("OS") = "Windows_NT"; Directory_Separator : constant Character; Path_Separator : constant Character; function Executable_Extension return String; -- Return the executable exetension for the running host function Web_Escape (S : String) return String; -- Encode all characters that cannot be used as-is into an HTML page function Is_Number (S : String) return Boolean; -- Returns true if S is composed of digits only private subtype Windows_Host is Boolean; type C_Array is array (Windows_Host) of Character; DS : C_Array := C_Array'(True => '\', False => '/'); PS : C_Array := C_Array'(True => ';', False => ':'); Directory_Separator : constant Character := DS (Is_Windows); Path_Separator : constant Character := PS (Is_Windows); end Templates_Parser.Utils; libtemplates-parser-11.6.orig/src/templates_parser.adb0000644000175000017500000056156211637170657023064 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 1999-2011, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Exceptions; with Ada.Characters.Handling; with Ada.Calendar; with Ada.IO_Exceptions; with Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; with Ada.Unchecked_Deallocation; with GNAT.Calendar.Time_IO; with GNAT.Regpat; with Templates_Parser.Configuration; with Templates_Parser.Input; with Templates_Parser.Utils; package body Templates_Parser is use Ada.Exceptions; use Ada.Strings; Internal_Error : exception; Blank : constant Maps.Character_Set := Maps.To_Set (' ' & ASCII.HT); function Get_Parameters (Parameters : String) return Parameter_Set; -- Returns the parameters set as parsed into Parameters. This routines -- handles both positional and named parameters. It is currently used for -- include and macro parameters. -------------- -- Tag Info -- -------------- Begin_Tag : Unbounded_String := To_Unbounded_String (Default_Begin_Tag); End_Tag : Unbounded_String := To_Unbounded_String (Default_End_Tag); Set_Token : constant String := "@@SET@@"; Table_Token : constant String := "@@TABLE@@"; Terminate_Sections_Token : constant String := "@@TERMINATE_SECTIONS@@"; Begin_Token : constant String := "@@BEGIN@@"; End_Token : constant String := "@@END@@"; Section_Token : constant String := "@@SECTION@@"; End_Table_Token : constant String := "@@END_TABLE@@"; Macro_Token : constant String := "@@MACRO@@"; End_Macro_Token : constant String := "@@END_MACRO@@"; If_Token : constant String := "@@IF@@"; Elsif_Token : constant String := "@@ELSIF@@"; Else_Token : constant String := "@@ELSE@@"; End_If_Token : constant String := "@@END_IF@@"; Include_Token : constant String := "@@INCLUDE@@"; Inline_Token : constant String := "@@INLINE@@"; End_Inline_Token : constant String := "@@END_INLINE@@"; A_Terminate_Sections_Token : constant String := "TERMINATE_SECTIONS"; A_Reverse_Token : constant String := "REVERSE"; A_Terse_Token : constant String := "TERSE"; ------------ -- Filter -- ------------ package Filter is ---------------------- -- Filters setting -- ---------------------- -- A filter appear just before a tag variable (e.g. @_LOWER:SOME_VAR_@ -- and means that the filter LOWER should be applied to SOME_VAR before -- replacing it in the template file. type Mode is (Multiply, -- Multiply the given parameter to the string (operator "*") Plus, -- Add the given parameter to the string (operator "+") Minus, -- Substract the given parameter to the string (operator "-") Divide, -- Divide the given parameter to the string (operator "/") Absolute, -- Returns the abosulte value Add, -- Add the given parameter to the string Add_Param, -- Add an HTTP parameter to the string, add the '&' parameter -- separator if needed. BR_2_EOL, -- Replaces all
HTML tags by a given end-of-line sequence BR_2_LF, -- Replaces all
HTML tags by LF characters Capitalize, -- Lower case except char before spaces and underscores Clean_Text, -- Only letter/digits all other chars are changed to spaces Coma_2_Point, -- Replaces comas by points Contract, -- Replaces a suite of spaces by a single space character Del_Param, -- Delete an HTTP parameter from the string, removes the '&' -- Parameter separator if needed. Div, -- Divide the given parameter to the string Exist, -- Returns "TRUE" if var is not empty and "FALSE" otherwise File_Exists, -- Returns "TRUE" if var is the name of an existing file and "FALSE" -- otherwise. Format_Date, -- Returns the date formatted using the format parameter. This -- format is following the GNU/date as implemented in -- GNAT.Calendar.Time_IO. The date must be in the ISO format -- YYYY-MM-DD eventually followed by a space and the time with the -- format HH:MM:SS. So the string must be either 10 or 19 characters -- long. Format_Number, -- Returns the number with a space added between each 3 digits -- blocks. The decimal part is not transformed. If the data is not a -- number nothing is done. The data is trimmed before processing it. Is_Empty, -- Returns "TRUE" if var is empty and "FALSE" otherwise LF_2_BR, -- Replaces all LF character to
HTML tag Lower, -- Lower case Match, -- Returns "TRUE" if var match the pattern passed as argument Max, -- Returns the max between the filter parameter and the value Min, -- Returns the min between the filter parameter and the value Modulo, -- Returns current value modulo N (N is the filter parameter) Mult, -- Multiply the given parameter to the string Neg, -- Change the size of the value No_Digit, -- Replace all digits by spaces No_Dynamic, -- This is a command filter, it indicates that the variable even if -- not found in the translation table will not be looked up into the -- dynamic context (Lazy_Tag). This filter just returns the string -- as-is. No_Letter, -- Removes all letters by spaces No_Space, -- Removes all spaces found in the value Oui_Non, -- If True return Oui, If False returns Non, else do nothing Point_2_Coma, -- Replaces points by comas Repeat, -- Returns N copy of the original string. The number of copy is -- passed as parameter. Replace, -- Replaces part of the string using a regultar expression. This is -- equivalent to the well known "s///" sed -- command. It replaces only the first match. Replace_All, -- Idem as above, but replace all matches. This equivalent to the -- well known "s///g" sed command. Replace_Param, -- Idem as @_ADD_PARAM(key=value):DEL_PARAM(key):VAR_@ Invert, -- Reverse string Size, -- Returns the number of characters in the string value Slice, -- Returns a slice of the string Sub, -- Substract the given parameter to the string Trim, -- Trim leading and trailing space Upper, -- Upper case User_Defined, -- A user's defined filter Web_Encode, -- Idem as Web_Escape and also encode non 7-bit ASCII characters as -- &#xxx;. Web_Escape, -- Convert characters <>&" to HTML equivalents: <, > and & -- and " Web_NBSP, -- Convert spaces to HTML   - non breaking spaces Wrap, -- Wrap lines longer than a given number of characters Yes_No -- If True return Yes, If False returns No, else do nothing ); type User_CB_Type is (With_Param, No_Param, As_Tagged); type User_CB (Typ : User_CB_Type := With_Param) is record case Typ is when With_Param => CBP : Callback; when No_Param => CB : Callback_No_Param; when As_Tagged => CBT : User_Filter_Access; end case; end record; type Parameter_Mode is (Str, Regexp, Regpat, Slice, User_Callback); function Parameter (Mode : Filter.Mode) return Parameter_Mode; -- Returns the parameter mode for the given filter type Pattern_Matcher_Access is access GNAT.Regpat.Pattern_Matcher; type Parameter_Data (Mode : Parameter_Mode := Slice) is record case Mode is when Str => S : Unbounded_String; when Regexp => R_Str : Unbounded_String; Regexp : Pattern_Matcher_Access; when Regpat => P_Str : Unbounded_String; Regpat : Pattern_Matcher_Access; Param : Unbounded_String; when Slice => First : Integer; Last : Integer; when User_Callback => Handler : User_CB; P : Unbounded_String; end case; end record; No_Parameter : constant Parameter_Data := Parameter_Data'(Slice, 0, -1); function Image (P : Parameter_Data) return String; -- Returns parameter string representation procedure Release (P : in out Parameter_Data); pragma Inline (Release); -- Release all memory allocated P type Filter_Context (P_Size : Natural) is record Translations : Translate_Set; Lazy_Tag : Dynamic.Lazy_Tag_Access; I_Parameters : Parameter_Set (1 .. P_Size); end record; type Callback is access function (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; -- P is the filter parameter, no parameter by default. Parameter are -- untyped and will be parsed by the filter function if needed. type Routine is record Handle : Callback; Parameters : Parameter_Data; end record; type Set is array (Positive range <>) of Routine; type Set_Access is access Set; procedure Release (S : in out Set); -- Release all memory allocated P type String_Access is access constant String; type Filter_Record is record Name : String_Access; Handle : Callback; end record; -- User's filter procedure Register (Name : String; Handler : Templates_Parser.Callback); procedure Register (Name : String; Handler : Callback_No_Param); procedure Register (Name : String; Handler : not null access User_Filter'Class); procedure Free_Filters; function User_Handle (Name : String) return User_CB; -- Returns the registered user's callback for the given filter name -- filter functions, see above procedure Check_Null_Parameter (P : Parameter_Data); -- Raises Template_Error if P is not equal to Null_Parameter function Absolute (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Add_Param (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function BR_2_EOL (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function BR_2_LF (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Capitalize (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Clean_Text (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Coma_2_Point (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Contract (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Del_Param (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Exist (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function File_Exists (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Format_Date (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Format_Number (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Is_Empty (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function LF_2_BR (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Lower (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Match (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Max (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Min (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Neg (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function No_Digit (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function No_Dynamic (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function No_Letter (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function No_Space (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Oui_Non (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Point_2_Coma (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Repeat (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Replace (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Replace_All (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Replace_Param (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Reverse_Data (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Size (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Slice (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Trim (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Upper (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function User_Defined (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Web_Encode (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Web_Escape (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Web_NBSP (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Wrap (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Yes_No (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Plus (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Minus (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Divide (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Multiply (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Modulo (S : String; C : not null access Filter_Context; P : Parameter_Data := No_Parameter) return String; function Handle (Name : String) return Callback; -- Returns the filter function for the given filter name function Handle (Mode : Filter.Mode) return Callback; -- Returns the filter function for the given filter mode function Mode_Value (Name : String) return Mode; -- Returns the Mode for filter named Name. This is the internal -- representation for this filter name. function Name (Handle : Callback) return String; -- Returns the filter name for the given filter function function Is_No_Dynamic (Filters : Set_Access) return Boolean; -- Returns True if Filters contains NO_CONTEXT end Filter; --------------- -- Main tree -- --------------- type Node; type Tree is access Node; ---------- -- Data -- ---------- package Data is type Node; type Tree is access Node; type NKind is (Text, Var); type Attribute is (Nil, Length, Line, Min_Column, Max_Column, Up_Level); type Internal_Tag is (No, Now, Year, Month, Month_Name, Day, Day_Name, Hour, Minute, Second, Number_Line, Table_Line, Table_Level, Up_Table_Line); type Attribute_Data is record Attr : Attribute := Nil; Value : Integer; end record; No_Attribute : constant Attribute_Data := (Nil, 0); type Parameter_Set is array (Natural range <>) of Tree; type Parameters is access all Parameter_Set; type Tag_Var is record Name : Unbounded_String; Filters : Filter.Set_Access; Attribute : Attribute_Data; N : Integer; -- Include variable index Internal : Internal_Tag; -- No if not an internal variable Is_Macro : Boolean := False; -- True if this is a macro call Parameters : Data.Parameters; Def : Templates_Parser.Tree; end record; type Node (Kind : NKind) is record Next : Tree; case Kind is when Text => Value : Unbounded_String; when Var => Var : Tag_Var; end case; end record; function Is_Include_Variable (T : Tag_Var) return Boolean; pragma Inline (Is_Include_Variable); -- Returns True if T is an include variable (Name is $) function To_Data_Parameters (Parameters : Templates_Parser.Parameter_Set) return Data.Parameters; -- Returns Parameters as a Data.Tree set function Build (Str : String) return Tag_Var; -- Create a Tag from Str. A tag is composed of a name and a set of -- filters. function Image (T : Tag_Var) return String; -- Returns string representation for the Tag variable function Translate (T : Tag_Var; Value : String; Context : not null access Filter.Filter_Context) return String; -- Returns the result of Value after applying all filters for tag T procedure Release (T : in out Tag_Var); -- Release all memory associated with Tag procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Parameter_Set, Parameters); function Parse (Line : String) return Tree; -- Parse text line and returns the corresponding tree representation procedure Print_Tree (D : Tree); -- Decend the text tree and print it to the standard output procedure Release (D : in out Tree; Single : Boolean := False); -- Release all memory used by the tree or only the pointed node if -- Single is set to True. function Clone (D : Tree) return Tree; -- Returns a Clone of D function Clone (V : Tag_Var) return Tag_Var; -- Returns a Clone of V end Data; ----------------- -- Definitions -- ----------------- package Definitions is type NKind is (Const, Ref, Ref_Default); type Node (Kind : NKind := Const) is record Value : Unbounded_String; Ref : Positive; end record; type Def is record Name : Unbounded_String; N : Node; end record; type Tree is access Def; function Parse (Line : String) return Tree; -- Returns a defintion data package Def_Map is new Containers.Indefinite_Hashed_Maps (String, Node, Ada.Strings.Hash, "=", "="); subtype Map is Def_Map.Map; procedure Print_Tree (D : Tree); -- Decend the text tree and print it to the standard output procedure Release (D : in out Tree); -- Release all memory used by the tree function Clone (D : Tree) return Tree; -- Returns a Clone of D end Definitions; ------------------ -- Expressions -- ------------------ package Expr is type Ops is (O_And, O_Or, O_Xor, O_Sup, O_Inf, O_Esup, O_Einf, O_Equal, O_Diff, O_In); function Image (O : Ops) return String; -- Returns Ops string representation type U_Ops is (O_Not); function Image (O : U_Ops) return String; -- Returns U_Ops string representation type Node; type Tree is access Node; type NKind is (Value, Var, Op, U_Op); -- The node is a value, a variable a binary operator or an unary -- operator. type Node (Kind : NKind) is record case Kind is when Value => V : Unbounded_String; when Var => Var : Data.Tag_Var; when Op => O : Ops; Left, Right : Tree; when U_Op => U_O : U_Ops; Next : Tree; end case; end record; function Is_True (Str : String) return Boolean; pragma Inline (Is_True); -- Return True if Str is one of "TRUE" or "T", the test is not -- case sensitive. function Parse (Expression : String) return Tree; -- Parse Expression and returns the corresponding tree representation procedure Print_Tree (E : Tree); -- Decend the expression's tree and print the expression. It outputs the -- expression with all parenthesis to show without ambiguity the way the -- expression has been parsed. procedure Release (E : in out Tree; Single : Boolean := False); -- Release all associated memory with the tree function Clone (E : Tree) return Tree; -- Returns a Clone of E Unknown : constant String := "*"; -- Value returned when the expression cannot be determined statically function Analyze (E : Expr.Tree) return String; -- Static analysis of expresssion E, returns TRUE, FALSE or value -- Unknown if the value cannot be determined statically (some variables -- are in the expression). end Expr; -------------------------------- -- Template Tree definitions -- -------------------------------- type Nkind is (Info, -- first node is tree infos C_Info, -- second node is cache tree info Text, -- this is a text line Set_Stmt, -- a definition statement If_Stmt, -- an IF tag statement Table_Stmt, -- a TABLE tag statement Section_Block, -- a TABLE block (common, section) Section_Stmt, -- a TABLE section Include_Stmt, -- an INCLUDE tag statement Inline_Stmt); -- an INLINE tag statement -- A template line is coded as a suite of Data and Var elements -- The first node in the tree is of type Info and should never be release -- and changed. This ensure that included tree will always be valid -- otherwise will would have to parse all the current trees in the cache -- to update the reference. -- -- Static_Tree represent a Tree immune to cache changes. Info point to the -- first node and C_Info to the second one. C_Info could be different to -- Info.Next in case of cache changes. This way we keep a pointer to the -- old tree to be able to release it when not used anymore. This way it is -- possible to use the cache in multitasking program without trouble. The -- changes in the cache are either because more than one task is parsing -- the same template at the same time, they will update the cache with the -- same tree at some point, or because a newer template was found in the -- file system. type Static_Tree is record Info : Tree; C_Info : Tree; end record; Null_Static_Tree : constant Static_Tree := (null, null); type Node (Kind : Nkind) is record Next : Tree; Line : Natural; case Kind is when Info => Filename : Unbounded_String; -- Name of the file Timestamp : Configuration.Time_Stamp; -- Date/Time of last change I_File : Tree; -- Included file references when C_Info => Obsolete : Boolean := False; -- True if newer version in cache Used : Natural := 0; -- >0 if currently used when Text => Text : Data.Tree; when Set_Stmt => Def : Definitions.Tree; when If_Stmt => Cond : Expr.Tree; N_True : Tree; N_False : Tree; when Table_Stmt => Terminate_Sections : Boolean; Reverse_Index : Boolean; Terse : Boolean; Blocks : Tree; Blocks_Count : Natural; -- Number if blocks when Section_Block => Common : Tree; Sections : Tree; Sections_Count : Natural; -- Number of sections when Section_Stmt => N_Section : Tree; when Include_Stmt => File : Static_Tree; I_Filename : Data.Tree; I_Params : Data.Parameters; when Inline_Stmt => Before : Unbounded_String; Sep : Unbounded_String; After : Unbounded_String; I_Block : Tree; end case; end record; procedure Release (T : in out Tree; Include : Boolean := True); -- Release all memory associated with the tree function Clone (T : Tree) return Tree; -- Returns a Clone of T procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Node, Tree); ------------------- -- Cached Files -- ------------------- -- Cached_Files keep the parsed Tree for a given file in memory. This -- package has two implementations one is thread safe so it is possible to -- use the cache in a multitasking program. The other is meant to be used -- for configuration that do not want to drag the tasking runtime. package Cached_Files is procedure Add (Filename : String; T : Tree; Old : out Tree); -- Add Filename/T to the list of cached files. If Filename is -- already in the list, replace the current tree with T. Furthermore -- if Filename tree is already in use, Old will be set with the -- previous C_Info node otherwise Old will be T.Next (C_Info node -- for current tree). procedure Get (Filename : String; Result : out Static_Tree); -- Returns the Tree for Filename or Null_Static_Tree if Filename has -- not been cached or is obsolete. procedure Release (T : in out Static_Tree); -- After loading a tree and using it, it is required that it be -- released. This will ensure that a tree marked as obsolete (a new -- version being now in the cache) will be released from the memory. procedure Release; -- Release the internal cache. This free the memory used for all -- currently loaded template trees. end Cached_Files; ----------- -- Macro -- ----------- package Macro is procedure Register (Name : String; T : Tree); -- Register a new macro definition, if previous definition exists, -- replace with the new definition. function Get (Name : String) return Tree; -- Get macro tree, returns null if this macro has no definition procedure Rewrite (T : in out Tree; Parameters : not null access Data.Parameter_Set); -- Rewrite the macro tree with the given parameters. All @_1_@ -- parameters in the macro definition are replaced with the -- corresponding value in the parameter set. procedure Print_Defined_Macros; -- Print the defined macros (for debug purpose) Callback : Macro_Callback; end Macro; ---------------- -- Simplifier -- ---------------- package Simplifier is procedure Run (T : in out Tree); -- Execute a tree simplifier pass, removes statically known IF branch -- and merges all consecutive TEXT node. end Simplifier; --------- -- Tag -- --------- procedure Field (T : Tag; N : Positive; Result : out Tag_Node_Access; Found : out Boolean); -- Returns the Nth item in Tag procedure Field (T : Tag; Cursor : Indices; Up_Value : Natural; Result : out Unbounded_String; Found : out Boolean); -- Returns Value in Tag at position Cursor. Found is set to False if -- there is no such value in Tag. function No_Quote (Str : String) return String; -- Removes quotes around Str. If Str (Str'First) and Str (Str'Last) -- are quotes return Str (Str'First + 1 .. Str'Last - 1) otherwise -- return Str as-is. function Quote (Str : String) return String; -- Returns Str quoted if it contains spaces, otherwise just returns Str function Is_Number (S : String) return Boolean; pragma Inline (Is_Number); -- Returns True if S is a decimal number procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Integer, Integer_Access); procedure Unchecked_Free is new Unchecked_Deallocation (Tag_Node_Arr, Tag_Node_Arr_Access); function Build_Include_Pathname (Filename, Include_Filename : String) return String; -- Returns the full pathname to the include file (Include_Filename). It -- returns Include_Filename if there is a pathname specified, or the -- pathname of the main template file as a prefix of the include -- filename. function Load (Filename : String; Cached : Boolean := False; Include_File : Boolean := False) return Static_Tree; -- Load a template file and returns the semantic tree. The template file is -- cached if Cached is set to true. If cached next Load will use the -- preparsed tree. procedure Print_Tree (T : Tree; Level : Natural := 0); -- Print the semantic tree, this is mostly for debugging purpose --------- -- "&" -- --------- function "&" (T : Tag; Value : String) return Tag is Item : constant Tag_Node_Access := new Tag_Node' (Templates_Parser.Value, null, V => To_Unbounded_String (Value)); begin T.Ref_Count.all := T.Ref_Count.all + 1; Unchecked_Free (T.Data.Tag_Nodes); if T.Data.Head = null then T.Data.all := (T.Data.Count + 1, Min => Natural'Min (T.Data.Min, 1), Max => Natural'Max (T.Data.Max, 1), Nested_Level => 1, Separator => To_Unbounded_String (Default_Separator), Head => Item, Last => Item, Tag_Nodes => null, Values => null); return (Ada.Finalization.Controlled with T.Ref_Count, Data => T.Data); else T.Data.Last.Next := Item; T.Data.all := (T.Data.Count + 1, Min => Natural'Min (T.Data.Min, 1), Max => Natural'Max (T.Data.Max, 1), Nested_Level => T.Data.Nested_Level, Separator => T.Data.Separator, Head => T.Data.Head, Last => Item, Tag_Nodes => null, Values => null); return (Ada.Finalization.Controlled with T.Ref_Count, Data => T.Data); end if; end "&"; function "&" (Value : String; T : Tag) return Tag is Item : constant Tag_Node_Access := new Tag_Node' (Templates_Parser.Value, T.Data.Head, V => To_Unbounded_String (Value)); begin T.Ref_Count.all := T.Ref_Count.all + 1; Unchecked_Free (T.Data.Tag_Nodes); if T.Data.Head = null then T.Data.all := (T.Data.Count + 1, Min => Natural'Min (T.Data.Min, 1), Max => Natural'Max (T.Data.Max, 1), Nested_Level => 1, Separator => To_Unbounded_String (Default_Separator), Head => Item, Last => Item, Tag_Nodes => null, Values => null); return (Ada.Finalization.Controlled with T.Ref_Count, T.Data); else T.Data.all := (T.Data.Count + 1, Min => Natural'Min (T.Data.Min, 1), Max => Natural'Max (T.Data.Max, 1), Nested_Level => T.Data.Nested_Level, Separator => T.Data.Separator, Head => Item, Last => T.Data.Last, Tag_Nodes => null, Values => null); return (Ada.Finalization.Controlled with T.Ref_Count, T.Data); end if; end "&"; function "&" (T : Tag; Value : Tag) return Tag is Item : constant Tag_Node_Access := new Tag_Node'(Value_Set, null, new Tag'(Value)); T_Size : constant Natural := Size (Value); begin T.Ref_Count.all := T.Ref_Count.all + 1; Unchecked_Free (T.Data.Tag_Nodes); if T.Data.Head = null then T.Data.all := (T.Data.Count + 1, Min => Natural'Min (T.Data.Min, T_Size), Max => Natural'Max (T.Data.Max, T_Size), Nested_Level => Value.Data.Nested_Level + 1, Separator => To_Unbounded_String ((1 => ASCII.LF)), Head => Item, Last => Item, Tag_Nodes => null, Values => null); return (Ada.Finalization.Controlled with T.Ref_Count, T.Data); else T.Data.Last.Next := Item; T.Data.all := (T.Data.Count + 1, Min => Natural'Min (T.Data.Min, T_Size), Max => Natural'Max (T.Data.Max, T_Size), Nested_Level => Positive'Max (T.Data.Nested_Level, Value.Data.Nested_Level + 1), Separator => T.Data.Separator, Head => T.Data.Head, Last => Item, Tag_Nodes => null, Values => null); return (Ada.Finalization.Controlled with T.Ref_Count, T.Data); end if; end "&"; function "&" (T : Tag; Value : Character) return Tag is begin return T & String'(1 => Value); end "&"; function "&" (T : Tag; Value : Boolean) return Tag is begin return T & Boolean'Image (Value); end "&"; function "&" (T : Tag; Value : Unbounded_String) return Tag is begin return T & To_String (Value); end "&"; function "&" (T : Tag; Value : Integer) return Tag is begin return T & Utils.Image (Value); end "&"; function "&" (Value : Character; T : Tag) return Tag is begin return String'(1 => Value) & T; end "&"; function "&" (Value : Boolean; T : Tag) return Tag is begin return Boolean'Image (Value) & T; end "&"; function "&" (Value : Unbounded_String; T : Tag) return Tag is begin return To_String (Value) & T; end "&"; function "&" (Value : Integer; T : Tag) return Tag is begin return Utils.Image (Value) & T; end "&"; function "&" (Left : Association; Right : Association) return Translate_Set is T : Translate_Set; begin Insert (T, Left); Insert (T, Right); return T; end "&"; function "&" (Set : Translate_Set; Item : Association) return Translate_Set is T : Translate_Set := Set; begin Insert (T, Item); return T; end "&"; --------- -- "+" -- --------- function "+" (Value : String) return Tag is Item : constant Tag_Node_Access := new Tag_Node'(Templates_Parser.Value, null, V => To_Unbounded_String (Value)); begin return (Ada.Finalization.Controlled with Ref_Count => new Integer'(1), Data => new Tag_Data' (Count => 1, Min => 1, Max => 1, Nested_Level => 1, Separator => To_Unbounded_String (Default_Separator), Head => Item, Last => Item, Tag_Nodes => null, Values => null)); end "+"; function "+" (Value : Character) return Tag is begin return +String'(1 => Value); end "+"; function "+" (Value : Boolean) return Tag is begin return +Boolean'Image (Value); end "+"; function "+" (Value : Unbounded_String) return Tag is begin return +To_String (Value); end "+"; function "+" (Value : Integer) return Tag is begin return +Utils.Image (Value); end "+"; function "+" (Value : Tag) return Tag is Result : Tag; begin Result := Result & Value; -- This is an embedded tag, set separator to LF Set_Separator (Result, (1 => ASCII.LF)); return Result; end "+"; function "+" (Item : Association) return Translate_Set is T : Translate_Set; begin Insert (T, Item); return T; end "+"; ------------ -- Adjust -- ------------ overriding procedure Adjust (Set : in out Translate_Set) is begin Templates_Parser_Tasking.Lock; if Set.Ref_Count = null then -- This is a not yet initialized null set. This case happens when -- assigning Null_Set to a Translate_Set variable for example. Initialize (Set); else Set.Ref_Count.all := Set.Ref_Count.all + 1; end if; Templates_Parser_Tasking.Unlock; end Adjust; overriding procedure Adjust (T : in out Tag) is begin Templates_Parser_Tasking.Lock; T.Ref_Count.all := T.Ref_Count.all + 1; Templates_Parser_Tasking.Unlock; end Adjust; ------------ -- Append -- ------------ procedure Append (T : in out Tag; Value : Tag) is Item : constant Tag_Node_Access := new Tag_Node'(Value_Set, null, new Tag'(Value)); T_Size : constant Natural := Size (Value); begin if T.Data.Head = null then T.Data.Nested_Level := Value.Data.Nested_Level + 1; T.Data.Separator := To_Unbounded_String ((1 => ASCII.LF)); T.Data.Head := Item; else T.Data.Last.Next := Item; T.Data.Nested_Level := Positive'Max (T.Data.Nested_Level, Value.Data.Nested_Level + 1); end if; Unchecked_Free (T.Data.Tag_Nodes); T.Data.Tag_Nodes := null; T.Data.Count := T.Data.Count + 1; T.Data.Min := Natural'Min (T.Data.Min, T_Size); T.Data.Max := Natural'Max (T.Data.Max, T_Size); T.Data.Last := Item; end Append; procedure Append (T : in out Tag; Value : Unbounded_String) is Item : constant Tag_Node_Access := new Tag_Node'(Templates_Parser.Value, null, Value); begin if T.Data.Head = null then T.Data.Head := Item; T.Data.Nested_Level := 1; T.Data.Separator := To_Unbounded_String (Default_Separator); else T.Data.Last.Next := Item; end if; Unchecked_Free (T.Data.Tag_Nodes); T.Data.Tag_Nodes := null; T.Data.Count := T.Data.Count + 1; T.Data.Min := Natural'Min (T.Data.Min, 1); T.Data.Max := Natural'Max (T.Data.Max, 1); T.Data.Last := Item; end Append; procedure Append (T : in out Tag; Value : String) is begin Append (T, To_Unbounded_String (Value)); end Append; procedure Append (T : in out Tag; Value : Character) is begin Append (T, To_Unbounded_String (String'(1 => Value))); end Append; procedure Append (T : in out Tag; Value : Boolean) is begin Append (T, To_Unbounded_String (Boolean'Image (Value))); end Append; procedure Append (T : in out Tag; Value : Integer) is begin Append (T, To_Unbounded_String (Utils.Image (Value))); end Append; ----------- -- Assoc -- ----------- function Assoc (Variable : String; Value : String) return Association is begin return Association' (Std, Variable => To_Unbounded_String (Variable), Value => To_Unbounded_String (Value)); end Assoc; function Assoc (Variable : String; Value : Ada.Strings.Unbounded.Unbounded_String) return Association is begin return Assoc (Variable, To_String (Value)); end Assoc; function Assoc (Variable : String; Value : Integer) return Association is begin return Assoc (Variable, Utils.Image (Value)); end Assoc; function Assoc (Variable : String; Value : Boolean) return Association is begin if Value then return Assoc (Variable, "TRUE"); else return Assoc (Variable, "FALSE"); end if; end Assoc; function Assoc (Variable : String; Value : Tag; Separator : String := Default_Separator) return Association is T : Tag := Value; begin if Separator /= Default_Separator then Set_Separator (T, Separator); end if; return Association' (Composite, Variable => To_Unbounded_String (Variable), Comp_Value => T); end Assoc; ---------------------------- -- Build_Include_Pathname -- ---------------------------- function Build_Include_Pathname (Filename, Include_Filename : String) return String is Dir_Seps : constant Maps.Character_Set := Maps.To_Set ("/\"); begin if Include_Filename'Length > 1 and then Maps.Is_In (Include_Filename (Include_Filename'First), Dir_Seps) then -- Include filename is an absolute path, return it without the -- leading directory separator. return Include_Filename (Include_Filename'First + 1 .. Include_Filename'Last); else declare K : constant Natural := Fixed.Index (Filename, Dir_Seps, Going => Strings.Backward); begin if K = 0 then return Include_Filename; else return Filename (Filename'First .. K) & Include_Filename; end if; end; end if; end Build_Include_Pathname; ------------------ -- Cached_Files -- ------------------ package body Cached_Files is separate; ----------- -- Macro -- ----------- package body Macro is separate; ---------------- -- Simplifier -- ---------------- package body Simplifier is separate; ----------- -- Clear -- ----------- procedure Clear (T : in out Tag) is NT : Tag; begin -- Here we just separate current vector from the new one T := NT; end Clear; ----------- -- Clone -- ----------- function Clone (T : Tree) return Tree is N : Tree; begin if T /= null then N := new Node'(T.all); case N.Kind is when Text => N.Text := Data.Clone (N.Text); when Info => N.I_File := Clone (N.I_File); when If_Stmt => N.Cond := Expr.Clone (N.Cond); N.N_True := Clone (N.N_True); N.N_False := Clone (N.N_False); when Table_Stmt => N.Blocks := Clone (N.Blocks); when Section_Block => N.Common := Clone (N.Common); N.Sections := Clone (N.Sections); when Section_Stmt => N.N_Section := Clone (N.N_Section); when Inline_Stmt => N.I_Block := Clone (N.I_Block); when Set_Stmt => N.Def := Definitions.Clone (N.Def); when Include_Stmt => N.I_Filename := Data.Clone (N.I_Filename); N.I_Params := new Data.Parameter_Set'(N.I_Params.all); for K in N.I_Params'Range loop N.I_Params (K) := Data.Clone (N.I_Params (K)); end loop; when C_Info => null; end case; N.Next := Clone (N.Next); end if; return N; end Clone; --------------- -- Composite -- --------------- function Composite (T : Tag; N : Positive) return Tag is Result : Tag; Found : Boolean; begin Field (T, N, Result, Found); if Found then return Result; else raise Constraint_Error; end if; end Composite; ---------- -- Data -- ---------- package body Data is separate; ----------------- -- Definitions -- ----------------- package body Definitions is separate; ------------ -- Exists -- ------------ function Exists (Set : Translate_Set; Variable : String) return Boolean is begin return Set.Set.Contains (Variable); end Exists; ---------- -- Expr -- ---------- package body Expr is separate; ----------- -- Field -- ----------- procedure Field (T : Tag; N : Positive; Result : out Tag_Node_Access; Found : out Boolean) is begin Found := True; -- First check that the array access is present if T.Data.Tag_Nodes = null then T.Data.Tag_Nodes := new Tag_Node_Arr (1 .. T.Data.Count); declare P : Tag_Node_Access := T.Data.Head; begin for K in T.Data.Tag_Nodes'Range loop T.Data.Tag_Nodes (K) := P; P := P.Next; end loop; end; end if; if N > T.Data.Count then -- No such item for this position Result := null; Found := False; else Result := T.Data.Tag_Nodes (N); end if; end Field; procedure Field (T : Tag; N : Positive; Result : out Tag; Found : out Boolean) is R : Tag_Node_Access; begin Field (T, N, R, Found); if Found and then R.Kind = Value_Set then -- There is a Tag at this position, return it Result := R.VS.all; else Found := False; end if; end Field; procedure Field (T : Tag; Cursor : Indices; Up_Value : Natural; Result : out Unbounded_String; Found : out Boolean) is function Image (T : Tag) return Unbounded_String; -- Returns T string representation ----------- -- Image -- ----------- function Image (T : Tag) return Unbounded_String is function Image (N : Tag_Node) return Unbounded_String; -- Returns N string representation ----------- -- Image -- ----------- function Image (N : Tag_Node) return Unbounded_String is begin if N.Kind = Value then return N.V; else return Image (N.VS.all); end if; end Image; Result : Unbounded_String; N : Tag_Node_Access := T.Data.Head; begin while N /= null loop if Result /= Null_Unbounded_String then Append (Result, T.Data.Separator); end if; Append (Result, Image (N.all)); N := N.Next; end loop; return Result; end Image; C : Natural := 0; P : Natural := 0; R : Tag_Node_Access; Inlined : Boolean := False; begin Found := True; if Cursor'Length <= Up_Value then -- The current cursor length is smaller than the up_level attribute -- in this case we just inline the tag. Inlined := True; elsif Cursor'Length > T.Data.Nested_Level then C := Cursor'Last - T.Data.Nested_Level + 1 - Up_Value; P := Cursor (C); elsif Cursor'Length /= 0 then C := Cursor'First; P := Cursor (C); end if; if Inlined then Result := Image (T); else Field (T, P, R, Found); end if; if R /= null then -- We have found something at this indice if C + Up_Value = Cursor'Last then -- This is the last position if R.Kind = Value then -- Found a leaf, just return the value Result := R.V; else Result := Image (R.VS.all); end if; else -- There is more position to look for in the cursor if R.Kind = Value then -- This is a leaf, there is nothing more to look for Found := False; Result := Null_Unbounded_String; else -- Look into next dimension Field (R.VS.all, Cursor (C + 1 .. Cursor'Last), Up_Value, Result, Found); end if; end if; else Found := False; end if; end Field; ------------ -- Filter -- ------------ package body Filter is separate; -------------- -- Finalize -- -------------- overriding procedure Finalize (Set : in out Translate_Set) is procedure Unchecked_Free is new Unchecked_Deallocation (Association_Map.Map, Map_Access); Ref_Count : Integer_Access := Set.Ref_Count; begin -- Ensure call is idempotent Set.Ref_Count := null; if Ref_Count /= null then Templates_Parser_Tasking.Lock; Ref_Count.all := Ref_Count.all - 1; if Ref_Count.all = 0 then Unchecked_Free (Ref_Count); Unchecked_Free (Set.Set); end if; Templates_Parser_Tasking.Unlock; end if; end Finalize; overriding procedure Finalize (T : in out Tag) is Ref_Count : Integer_Access := T.Ref_Count; begin -- Ensure call is idempotent T.Ref_Count := null; if Ref_Count /= null then Templates_Parser_Tasking.Lock; Ref_Count.all := Ref_Count.all - 1; if Ref_Count.all = 0 then Templates_Parser_Tasking.Unlock; declare procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Tag_Node, Tag_Node_Access); procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Tag, Tag_Access); procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Tag_Data, Tag_Data_Access); procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Tag_Values.Set, Tag_Values_Access); P, N : Tag_Node_Access; begin P := T.Data.Head; while P /= null loop N := P.Next; if P.Kind = Value_Set then Unchecked_Free (P.VS); end if; Unchecked_Free (P); P := N; end loop; T.Data.Head := null; T.Data.Last := null; Unchecked_Free (Ref_Count); Unchecked_Free (T.Data.Tag_Nodes); Unchecked_Free (T.Data.Values); Unchecked_Free (T.Data); end; else Templates_Parser_Tasking.Unlock; end if; end if; end Finalize; --------------------------- -- For_Every_Association -- --------------------------- procedure For_Every_Association (Set : Translate_Set) is Pos : Association_Map.Cursor; Quit : Boolean := False; begin Pos := Set.Set.First; while Association_Map.Has_Element (Pos) loop Action (Association_Map.Element (Pos), Quit); exit when Quit; Pos := Association_Map.Next (Pos); end loop; end For_Every_Association; --------- -- Get -- --------- function Get (Set : Translate_Set; Name : String) return Association is Pos : Association_Map.Cursor; begin Pos := Set.Set.all.Find (Name); if Association_Map.Has_Element (Pos) then return Association_Map.Element (Pos); else return Null_Association; end if; end Get; function Get (Assoc : Association) return Tag is begin if Assoc.Kind = Composite then return Assoc.Comp_Value; else raise Constraint_Error; end if; end Get; function Get (Assoc : Association) return String is begin if Assoc.Kind = Std then return To_String (Assoc.Value); else raise Constraint_Error; end if; end Get; ---------------- -- Initialize -- ---------------- overriding procedure Initialize (Set : in out Translate_Set) is begin Set.Ref_Count := new Integer'(1); Set.Set := new Association_Map.Map; end Initialize; overriding procedure Initialize (T : in out Tag) is begin T.Ref_Count := new Integer'(1); T.Data := new Tag_Data; T.Data.Count := 0; T.Data.Min := Natural'Last; T.Data.Max := 0; T.Data.Nested_Level := 1; end Initialize; ------------ -- Insert -- ------------ procedure Insert (Set : in out Translate_Set; Item : Association) is begin Set.Set.Include (To_String (Item.Variable), Item); end Insert; procedure Insert (Set : in out Translate_Set; Items : Translate_Set) is Pos : Association_Map.Cursor; begin if Items.Set = null then return; end if; Pos := Items.Set.First; while Association_Map.Has_Element (Pos) loop Insert (Set, Association_Map.Element (Pos)); Pos := Association_Map.Next (Pos); end loop; end Insert; --------------- -- Is_Number -- --------------- function Is_Number (S : String) return Boolean is use Strings.Maps; begin return S'Length > 0 and then Is_Subset (To_Set (S), Constants.Decimal_Digit_Set or To_Set ("-")); end Is_Number; ---------- -- Item -- ---------- function Item (T : Tag; N : Positive) return String is Result : Unbounded_String; Found : Boolean; begin Field (T, (1 => N), 0, Result, Found); if not Found then raise Constraint_Error; else return To_String (Result); end if; end Item; ---------- -- Load -- ---------- function Load (Filename : String; Cached : Boolean := False; Include_File : Boolean := False) return Static_Tree is use type Definitions.NKind; File : Input.File_Type; -- file beeing parsed Buffer : String (1 .. 2_048); -- current line content Last : Natural; -- index of last characters read in buffer First : Natural; -- first non blank characters in buffer Line : Natural := 0; I_File : Tree; -- list of includes Error_Include_Message : Unbounded_String; -- Message as reported while parsing the include file -- Line handling procedure Fatal_Error (Message : String); pragma No_Return (Fatal_Error); -- raise Template_Error exception with message function Get_Next_Line return Boolean; -- Get new line in File and set Buffer, Last and First. Returns True if -- end of file reached. function Get_First_Parameter return Unbounded_String; -- Get first parameter in current line (second word), words being -- separated by a set of blank characters (space or horizontal -- tabulation). function Get_All_Parameters (At_Least_One : Boolean := True) return String; -- Get all parameters on the current line function Count_Tag_Attributes return Natural; -- Returns the number of tag attributes present function Get_Tag_Attribute (N : Positive) return String; -- Returns the Nth tag attribute function Get_Tag_Parameter (N : Positive) return String; -- Returns the Nth tag parameter found between parenthesis function Get_Tag_Parameter_Count return Natural; -- Returns the number of parameter function Is_Stmt (Stmt : String; Extended : Boolean := False) return Boolean; pragma Inline (Is_Stmt); -- Returns True if Stmt is found at the begining of the current line -- ignoring leading blank characters. If Extended is True it recognize -- statement attributes or parameter. function EOF return Boolean; pragma Inline (EOF); -- Returns True if the end of file has been reach type Parse_Mode is (Parse_Std, -- in standard line Parse_If, -- in a if statement Parse_Elsif, -- in elsif part of a if statement Parse_Else, -- in else part of a if statement Parse_Table, -- in a table statement Parse_Block, -- in a table block statement Parse_Section, -- in new section Parse_Section_Content, -- in section content Parse_Inline, -- in an inline block statement Parse_Macro -- in a macro definition ); function Parse (Mode : Parse_Mode; In_If : Boolean; No_Read : Boolean := False) return Tree; -- Get a line in File and returns the Tree -------------------------- -- Count_Tag_Attributes -- -------------------------- function Count_Tag_Attributes return Natural is K : constant Natural := Strings.Fixed.Index (Buffer (First + 2 .. Last), "@@"); begin return Strings.Fixed.Count (Buffer (First + 2 .. K), "'"); end Count_Tag_Attributes; --------- -- EOF -- --------- function EOF return Boolean is begin return Last = 0; end EOF; ----------------- -- Fatal_Error -- ----------------- procedure Fatal_Error (Message : String) is begin if Message (Message'Last) /= '.' then raise Template_Error with Message & ", in " & Filename & " at line" & Natural'Image (Line); else raise Template_Error with Message & ", included from " & Filename & " at line" & Natural'Image (Line); end if; end Fatal_Error; ------------------------ -- Get_All_Parameters -- ------------------------ function Get_All_Parameters (At_Least_One : Boolean := True) return String is Start : Natural; begin -- Skip first word (tag statement, or include file name) Start := Strings.Fixed.Index (Buffer (First .. Last), Blank); if Start = 0 then if At_Least_One then Fatal_Error ("missing parameter"); else Start := Last + 1; end if; end if; if Buffer (Last) = ASCII.CR then -- Last character is a DOS CR (certainly because the template -- file is in DOS format), ignore it as this is not part of the -- parameter. Last := Last - 1; end if; return Strings.Fixed.Trim (Buffer (Start .. Last), Strings.Both); end Get_All_Parameters; ------------------------- -- Get_First_Parameter -- ------------------------- function Get_First_Parameter return Unbounded_String is Start, Stop : Natural; begin Start := Strings.Fixed.Index (Buffer (First .. Last), Blank); if Start = 0 then return Null_Unbounded_String; end if; Start := Strings.Fixed.Index (Buffer (Start .. Last), Blank, Outside); if Start = 0 then -- We have only spaces after the first word, there is no -- parameter in this case. return Null_Unbounded_String; end if; Stop := Strings.Fixed.Index (Buffer (Start .. Last), Blank); if Stop = 0 then Stop := Last; else Stop := Stop - 1; end if; return To_Unbounded_String (Buffer (Start .. Stop)); end Get_First_Parameter; ------------------- -- Get_Next_Line -- ------------------- function Get_Next_Line return Boolean is use type Maps.Character_Set; Skip_End : constant Maps.Character_Set := Blank or Maps.To_Set (ASCII.CR); begin if Input.End_Of_File (File) then Last := 0; return True; else loop Line := Line + 1; Input.Get_Line (File, Buffer, Last); First := Strings.Fixed.Index (Buffer (1 .. Last), Blank, Outside); exit when First + 3 > Last or else (First >= Buffer'First and then Buffer (First .. First + 3) /= "@@--"); if Input.End_Of_File (File) then -- We have reached the end of file, exit now Last := 0; return True; end if; end loop; if First = 0 then -- There is only spaces on this line, this is an empty line -- we just have to skip it. Last := 0; return False; end if; -- Skip ending comments declare C : Natural; begin C := Strings.Fixed.Index (Buffer (First .. Last), "@@--"); if C /= 0 then Last := C - 1; end if; end; Last := Strings.Fixed.Index (Buffer (First .. Last), Skip_End, Outside, Strings.Backward); return False; end if; end Get_Next_Line; ----------------------- -- Get_Tag_Attribute -- ----------------------- function Get_Tag_Attribute (N : Positive) return String is S : Positive := First + 2; L : constant Natural := Strings.Fixed.Index (Buffer (S .. Last), "@@"); E : Natural; begin for I in 1 .. N loop S := Strings.Fixed.Index (Buffer (S + 1 .. L), "'"); end loop; -- Check for the end of this attribute E := Strings.Fixed.Index (Buffer (S + 1 .. L), "'"); if E = 0 then E := L; end if; return Buffer (S + 1 .. E - 1); end Get_Tag_Attribute; ----------------------- -- Get_Tag_Parameter -- ----------------------- function Get_Tag_Parameter (N : Positive) return String is I_Last : constant Natural := Strings.Fixed.Index (Buffer (First .. Last), ")@@"); function Find_Matching (From : Natural; Char : Character) return Natural; -- Returns the position of Char in Buffer, handle escaped characters ------------------- -- Find_Matching -- ------------------- function Find_Matching (From : Natural; Char : Character) return Natural is K : Natural := From; Level : Integer; Escape : Integer := 0; begin if Char = ')' and then Buffer (K) = '(' then Level := 0; elsif Char = '(' then Level := -1; else Level := 1; end if; Look_For_Char : while K < I_Last loop if Buffer (K) = '\' and then Escape = 0 then Escape := 2; elsif Escape /= 0 then Escape := Escape - 1; end if; if Escape = 0 then if Buffer (K) = '(' then Level := Level + 1; elsif Buffer (K) = ')' then Level := Level - 1; end if; exit Look_For_Char when Buffer (K) = Char and then Level = 0; end if; K := K + 1; end loop Look_For_Char; return K; end Find_Matching; F, L : Natural; begin if I_Last = 0 then Fatal_Error ("No tag parameter"); else F := First; L := First - 1; for K in 1 .. N loop F := Find_Matching (L + 1, '('); if F = 0 then Fatal_Error ("Missing parenthesis in tag command"); else -- Look for matching closing parenthesis L := Find_Matching (F, ')'); if Buffer (L) /= ')' then Fatal_Error ("Missing closing parenthesis in tag command"); end if; end if; end loop; return Buffer (F + 1 .. L - 1); end if; end Get_Tag_Parameter; ----------------------------- -- Get_Tag_Parameter_Count -- ----------------------------- function Get_Tag_Parameter_Count return Natural is I_Last : constant Natural := Strings.Fixed.Index (Buffer (First .. Last), ")@@"); Count : Natural := 0; Level : Natural := 0; Escape : Integer := 0; begin if I_Last = 0 then return 0; else for K in First .. I_Last loop if Buffer (K) = '\' and then Escape = 0 then Escape := 2; elsif Escape /= 0 then Escape := Escape - 1; end if; if Escape = 0 then if Buffer (K) = '(' then if Level = 0 then Count := Count + 1; end if; Level := Level + 1; elsif Buffer (K) = ')' then Level := Level - 1; end if; end if; end loop; return Count; end if; end Get_Tag_Parameter_Count; ------------- -- Is_Stmt -- ------------- function Is_Stmt (Stmt : String; Extended : Boolean := False) return Boolean is Offset : Natural := 0; begin if Extended then Offset := 2; end if; return Last /= 0 and then Buffer (First .. First + Stmt'Length - 1 - Offset) = Stmt (Stmt'First .. Stmt'Last - Offset) and then (not Extended or else (Buffer (First + Stmt'Length - Offset) = ''' or else Buffer (First + Stmt'Length - Offset) = '(' or else Buffer (First + Stmt'Length - Offset) = '@')); end Is_Stmt; ----------- -- Parse -- ----------- function Parse (Mode : Parse_Mode; In_If : Boolean; No_Read : Boolean := False) return Tree is use type Data.NKind; use type Data.Tree; function Count_Sections (T : Tree) return Natural; pragma Inline (Count_Sections); -- Returns the number of sections in T (Section_Stmt) function Count_Blocks (T : Tree) return Natural; pragma Inline (Count_Blocks); -- Returns the number of sections in T (Table_Stmt) procedure Rewrite_Inlined_Block (T : Tree; Sep : String); -- Recursive procedure that rewrite all text nodes in an inlined -- block. In such a block the spaces before and after text are -- meaningless and LF are replaced by the given separator. ------------------ -- Count_Blocks -- ------------------ function Count_Blocks (T : Tree) return Natural is C : Natural := 0; S : Tree := T; begin while S /= null loop C := C + 1; S := S.Next; end loop; return C; end Count_Blocks; -------------------- -- Count_Sections -- -------------------- function Count_Sections (T : Tree) return Natural is C : Natural := 0; S : Tree := T; begin while S /= null loop C := C + 1; S := S.N_Section; end loop; return C; end Count_Sections; --------------------------- -- Rewrite_Inlined_Block -- --------------------------- procedure Rewrite_Inlined_Block (T : Tree; Sep : String) is procedure Rewrite (T : Tree; Last, In_Table : Boolean); -- Last is set to True if we are checking the last node ------------- -- Rewrite -- ------------- procedure Rewrite (T : Tree; Last, In_Table : Boolean) is N : Tree := T; D : Data.Tree; begin while N /= null loop case N.Kind is when Text => D := N.Text; -- Trim leading blanks if D /= null and then D.Kind = Data.Text then Trim (D.Value, Side => Left); end if; while D /= null loop case D.Kind is when Data.Text => declare Len : constant Natural := Length (D.Value); -- Len can be 0 here because of the -- trimming above. begin if Len /= 0 and then Element (D.Value, Len) = ASCII.LF and then (not Last or else N.Next /= null or else D.Next /= null or else In_Table) then Delete (D.Value, Len, Len); if not In_Table then -- Inside a table we do no want to -- add the separator, this must be -- done during the rendering as we -- need to have the actual vector -- values. Append (D.Value, Sep); end if; end if; end; when Data.Var => null; end case; D := D.Next; end loop; when If_Stmt => Rewrite (N.N_True, N.Next = null, In_Table); Rewrite (N.N_False, N.Next = null, In_Table); when Table_Stmt => Rewrite (N.Blocks, N.Next = null, In_Table => True); when Section_Block => Rewrite (N.Common, Last, In_Table); Rewrite (N.Sections, Last, In_Table); when Section_Stmt => Rewrite (N.N_Section, Last, In_Table); when others => null; end case; N := N.Next; end loop; end Rewrite; begin Rewrite (T, Last => True, In_Table => False); end Rewrite_Inlined_Block; T : Tree; begin if not No_Read and then Mode /= Parse_Section and then Mode /= Parse_Elsif and then Mode /= Parse_Block then if Get_Next_Line then return null; end if; end if; case Mode is when Parse_Std => if Is_Stmt (End_If_Token) then Fatal_Error ("@@END_IF@@ found outside an @@IF@@ statement"); end if; if Is_Stmt (End_Table_Token) then Fatal_Error ("@@END_TABLE@@ found outside a @@TABLE@@ statement"); end if; if Is_Stmt (End_Inline_Token) then Fatal_Error ("@@END_INLINE@@ found outside an @@INLINE@@ statement"); end if; if Is_Stmt (End_Token) then Fatal_Error ("@@END@@ found outside a @@BEGIN@@ block statement"); end if; if Is_Stmt (End_Macro_Token) then Fatal_Error ("@@END_MACRO@@ found outside a @@MACRO@@ statement"); end if; when Parse_If => if Is_Stmt (Else_Token) or else Is_Stmt (Elsif_Token) or else Is_Stmt (End_If_Token) then return null; end if; if Is_Stmt (End_Table_Token) then Fatal_Error ("@@END_TABLE@@ found, @@END_IF@@ expected"); end if; when Parse_Elsif => if Is_Stmt (Else_Token) or else Is_Stmt (End_If_Token) then return null; end if; if Is_Stmt (End_Table_Token) then Fatal_Error ("@@END_TABLE@@ found, @@END_IF@@ expected"); end if; when Parse_Else => if Is_Stmt (End_If_Token) then return null; end if; if Is_Stmt (End_Table_Token) then Fatal_Error ("@@END_TABLE@@ found, @@END_IF@@ expected"); end if; if Is_Stmt (Elsif_Token) then Fatal_Error ("@@ELSIF@@ found after @@ELSE@@"); end if; when Parse_Block => if Is_Stmt (End_Table_Token) then return null; end if; T := new Node (Section_Block); T.Line := Line; declare Tmp : Tree; begin Tmp := Parse (Parse_Section, In_If); if Tmp = null then -- This section is empty return null; end if; if Is_Stmt (Begin_Token) then -- It means that the section parsed above was common T.Common := Tmp.Next; -- Now free the Section_Stmt container Unchecked_Free (Tmp); T.Sections := Parse (Parse_Section, In_If); else T.Common := null; T.Sections := Tmp; end if; end; -- Count the number of section T.Sections_Count := Count_Sections (T.Sections); if T.Sections_Count = 1 and then T.Common = null then -- A single section and no common section, rewrite it as a -- simple common section. T.Common := T.Sections.Next; Unchecked_Free (T.Sections); T.Sections_Count := 0; end if; if Is_Stmt (End_Table_Token) then T.Next := null; else T.Next := Parse (Parse_Block, In_If); end if; return T; when Parse_Section => if Is_Stmt (End_If_Token) then Fatal_Error ("@@END_IF@@ found, @@END_TABLE@@ expected"); end if; T := new Node (Section_Stmt); T.Line := Line; T.Next := Parse (Parse_Section_Content, In_If); if Is_Stmt (End_Table_Token) and then T.Next = null then -- Check if this section was empty, this happen when -- we parse a section after @@END@@ followed by the end -- of the table. Unchecked_Free (T); return null; end if; if Is_Stmt (End_Table_Token) or else Is_Stmt (Begin_Token) or else Is_Stmt (End_Token) then T.N_Section := null; elsif EOF then Fatal_Error ("EOF found, @@END_TABLE@@ expected"); else T.N_Section := Parse (Parse_Section, In_If); end if; return T; when Parse_Section_Content => if Is_Stmt (Section_Token) or else Is_Stmt (End_Table_Token) or else Is_Stmt (Begin_Token) or else Is_Stmt (End_Token) then return null; end if; if Is_Stmt (End_If_Token) then Fatal_Error ("@@END_IF@@ found, @@END_TABLE@@ expected"); end if; when Parse_Table => if Is_Stmt (End_Table_Token) then return null; end if; if Is_Stmt (End_If_Token) then Fatal_Error ("@@END_IF@@ found, @@END_TABLE@@ expected"); end if; when Parse_Inline => if Is_Stmt (End_Inline_Token) then return null; end if; when Parse_Macro => if Is_Stmt (End_Macro_Token) then return null; end if; if Is_Stmt (End_If_Token) then Fatal_Error ("@@END_IF@@ found, @@END_MACRO@@ expected"); end if; end case; if Is_Stmt (If_Token) or else Is_Stmt (Elsif_Token) then T := new Node (If_Stmt); T.Line := Line; T.Cond := Expr.Parse (Get_All_Parameters); T.N_True := Parse (Parse_If, In_If => True); if Is_Stmt (End_If_Token) then T.N_False := null; elsif Is_Stmt (Elsif_Token) then T.N_False := Parse (Parse_Elsif, In_If => True); elsif EOF then Fatal_Error ("EOF found, @@END_IF@@ expected"); else T.N_False := Parse (Parse_Else, In_If => True); end if; T.Next := Parse (Mode, In_If); return T; elsif Is_Stmt (Table_Token, Extended => True) then T := new Node (Table_Stmt); T.Line := Line; T.Terminate_Sections := False; T.Reverse_Index := False; T.Terse := False; -- Check if first parameter is @@TERMINATE_SECTION@@, note that -- this is an obsolescent feature. It is better now to use the -- tag command attributes. declare Param : constant Unbounded_String := Get_First_Parameter; begin if Param = Null_Unbounded_String then T.Terminate_Sections := False; elsif Param = Terminate_Sections_Token then T.Terminate_Sections := True; else Fatal_Error ("Unknown table parameter " & To_String (Param)); end if; end; -- Check attributes for K in 1 .. Count_Tag_Attributes loop declare Att : constant String := Get_Tag_Attribute (K); begin if Att = A_Terminate_Sections_Token then T.Terminate_Sections := True; elsif Att = A_Reverse_Token then T.Reverse_Index := True; elsif Att = A_Terse_Token then T.Terse := True; else Fatal_Error ("Unknown table attributes " & Att); end if; end; end loop; T.Blocks := Parse (Parse_Block, In_If); T.Next := Parse (Mode, In_If); T.Blocks_Count := Count_Blocks (T.Blocks); -- Check now that if we have TERMINATE_SECTIONS option set and -- that there is more than one block, all blocks have the same -- number of section. if T.Terminate_Sections and then T.Blocks_Count >= 1 then declare Size : constant Natural := T.Blocks.Sections_Count; Max : Natural := Size; B : Tree := T.Blocks.Next; begin while B /= null loop Max := Natural'Max (Max, B.Sections_Count); if B.Sections_Count /= Size and then B.Sections_Count /= 0 then Fatal_Error ("All sections must have the same size " & "when using TERMINATE_SECTIONS option"); end if; B := B.Next; end loop; -- Check wether we have sections with the TERMINATE_SECTION -- attribute. if Max = 0 then Fatal_Error ("TERMINATE_SECTIONS attribute given, but no section" & " defined"); end if; end; end if; return T; elsif Is_Stmt (Include_Token) then T := new Node (Include_Stmt); T.Line := Line; declare File : constant String := To_String (Get_First_Parameter); begin T.I_Filename := Data.Parse (File); if T.I_Filename.Kind = Data.Text and then T.I_Filename.Next = null then -- In the case of static strings we load the include file -- now. declare I_Filename : constant String := Build_Include_Pathname (Filename, File); begin T.File := Load (I_Filename, Cached, True); exception when IO_Exceptions.Name_Error => -- File not found, this is an error only if we are not -- inside a conditional. if not In_If then Error_Include_Message := To_Unbounded_String ("Include file " & I_Filename & " not found."); Unchecked_Free (T); return null; end if; when E : others => -- Error while parsing the include file, record this -- error. Let the parser exit properly from the -- recursion to be able to release properly the memory -- before raising an exception. Error_Include_Message := To_Unbounded_String (Exception_Message (E)); Unchecked_Free (T); return null; end; -- We do not need to keep reference to the include file in -- this case. The filename is static and already loaded. Data.Release (T.I_Filename); end if; -- Move past @@INCLUDE@@ First := First + 11; while First < Last and then Buffer (First) = ' ' loop First := First + 1; end loop; declare P_Set : constant Parameter_Set := (0 => To_Unbounded_String (File)) & Get_Parameters (Get_All_Parameters (At_Least_One => False)); begin T.I_Params := Data.To_Data_Parameters (P_Set); end; end; I_File := new Node' (Include_Stmt, I_File, Line, T.File, T.I_Filename, T.I_Params); T.Next := Parse (Mode, In_If); return T; elsif Is_Stmt (Macro_Token, Extended => True) then -- Parse a macro definition and register it declare Name : constant String := Get_Tag_Parameter (1); T : constant Tree := Parse (Parse_Macro, In_If); procedure Move_To_Last (T : in out Tree); -- Move to last node procedure Rewrite (T : in out Tree); -- Rewrite this node, this is used to remove all CR/LF for -- the last lines which could be output for this tree. ------------------ -- Move_To_Last -- ------------------ procedure Move_To_Last (T : in out Tree) is begin while T.Next /= null loop T := T.Next; end loop; end Move_To_Last; ------------- -- Rewrite -- ------------- procedure Rewrite (T : in out Tree) is D : Data.Tree; begin if T /= null then Move_To_Last (T); case T.Kind is when Text => -- A text node D := T.Text; -- Move to the end of this line while D.Next /= null loop D := D.Next; end loop; if D.Kind = Data.Text then Strings.Unbounded.Trim (D.Value, Left => Maps.Null_Set, Right => Maps.To_Set (ASCII.CR & ASCII.LF)); end if; when If_Stmt => Rewrite (T.N_True); Rewrite (T.N_False); when others => null; end case; end if; end Rewrite; N : Tree := T; begin -- We want to trim CR/LF from the last text node Rewrite (N); Macro.Register (Name, T); end; -- Then continue parsing the remaining of the file return Parse (Mode, In_If); elsif Is_Stmt (Set_Token) then -- We want to handle multiple SET lines to avoid deep recursion declare Root, N : Tree; begin loop N := new Node (Set_Stmt); if Root = null then Root := N; else T.Next := N; end if; T := N; T.Line := Line; T.Def := Definitions.Parse (Get_All_Parameters); if Get_Next_Line then -- Nothing more, returns the result now return Root; end if; -- If this is not a SET statement, just call the parsing -- routine and return the root note. if not Is_Stmt (Set_Token) then T.Next := Parse (Mode, In_If, No_Read => True); return Root; end if; end loop; end; elsif Is_Stmt (Inline_Token, Extended => True) then T := new Node (Inline_Stmt); declare function Inline_Parameter (Index : Positive) return Unbounded_String; -- Returns Inline_Parameter with the given index ---------------------- -- Inline_Parameter -- ---------------------- function Inline_Parameter (Index : Positive) return Unbounded_String is P : constant String := Get_Tag_Parameter (Index); N : Natural := P'First; R : String (P'Range); K : Natural := R'First - 1; begin while N <= P'Last loop if P (N) = '\' and then N < P'Last then case P (N + 1) is when '\' => K := K + 1; R (K) := '\'; N := N + 1; when 'n' => if Utils.Is_Windows then K := K + 2; R (K - 1 .. K) := (ASCII.CR, ASCII.LF); else K := K + 1; R (K) := ASCII.LF; end if; N := N + 1; when 'r' => K := K + 1; R (K) := ASCII.LF; N := N + 1; when others => K := K + 1; R (K) := P (N + 1); N := N + 1; end case; else K := K + 1; R (K) := P (N); end if; N := N + 1; end loop; return To_Unbounded_String (R (R'First .. K)); end Inline_Parameter; begin case Get_Tag_Parameter_Count is when 0 => T.Sep := To_Unbounded_String (" "); when 1 => T.Sep := Inline_Parameter (1); when 3 => T.Before := Inline_Parameter (1); T.Sep := Inline_Parameter (2); T.After := Inline_Parameter (3); when others => Fatal_Error ("Wrong number of tag parameters for INLINE " & "command (0, 1 or 3)"); end case; end; T.I_Block := Parse (Parse_Inline, In_If); -- Now we have parsed the full tree to inline. Rewrite this tree -- to replace all text node by a stripped version. Rewrite_Inlined_Block (T.I_Block, To_String (T.Sep)); T.Next := Parse (Mode, In_If); return T; else declare Root, N : Tree; begin loop N := new Node (Text); if Root = null then Root := N; else T.Next := N; end if; T := N; T.Line := Line; if Input.LF_Terminated (File) and then (not Input.End_Of_File (File) or else Include_File) then -- Add a LF if the read line is terminated by a LF. Do -- not add this LF if we reach the end of file except for -- included files. T.Text := Data.Parse (Buffer (1 .. Last) & ASCII.LF); else T.Text := Data.Parse (Buffer (1 .. Last)); end if; if Get_Next_Line then -- Nothing more, returns the result now return Root; end if; -- If this is a statement just call the parsing routine if Is_Stmt (If_Token) or else Is_Stmt (Elsif_Token) or else Is_Stmt (Else_Token) or else Is_Stmt (End_If_Token) or else Is_Stmt (Include_Token) or else Is_Stmt (Table_Token, Extended => True) or else Is_Stmt (Section_Token) or else Is_Stmt (End_Table_Token) or else Is_Stmt (Begin_Token) or else Is_Stmt (End_Token) or else Is_Stmt (Set_Token) or else Is_Stmt (Inline_Token, Extended => True) or else Is_Stmt (End_Inline_Token) or else Is_Stmt (Macro_Token, Extended => True) or else Is_Stmt (End_Macro_Token) then T.Next := Parse (Mode, In_If, No_Read => True); return Root; end if; end loop; end; end if; end Parse; T : Static_Tree; New_T : Tree; Old : Tree; begin Templates_Parser_Tasking.Lock; if Cached then Cached_Files.Get (Filename, Result => T); if T /= Null_Static_Tree then pragma Assert (T.C_Info /= null); Templates_Parser_Tasking.Unlock; return T; end if; end if; Input.Open (File, Filename, Form => "shared=no"); begin New_T := Parse (Parse_Std, False); Simplifier.Run (New_T); Input.Close (File); exception when others => Input.Close (File); raise; end; -- T is the tree file, add two nodes (Info and C_Info) in front of -- the tree. -- Add second node (cache info) Old := new Node'(Kind => C_Info, Next => New_T, Line => 0, Obsolete => False, Used => 1); -- Add first node (info about tree) New_T := new Node'(Kind => Info, Next => Old, Line => 0, Filename => To_Unbounded_String (Filename), Timestamp => Configuration.File_Time_Stamp (Filename), I_File => I_File); if Error_Include_Message /= Null_Unbounded_String then -- An include filename was not found, release the memory now and -- raise a fatal error. Release (New_T); Fatal_Error (To_String (Error_Include_Message)); end if; if Cached then Cached_Files.Add (Filename, New_T, Old); pragma Assert (Old /= null); end if; Templates_Parser_Tasking.Unlock; return Static_Tree'(New_T, Old); exception when E : Internal_Error => Templates_Parser_Tasking.Unlock; Fatal_Error (Exceptions.Exception_Message (E)); when others => Templates_Parser_Tasking.Unlock; raise; end Load; -------------------- -- Get_Parameters -- -------------------- function Get_Parameters (Parameters : String) return Parameter_Set is function Get (Count : Natural) return Parameter_Set; -- Load the Count parameters from Parameters string function Next (Char : Character; From : Positive) return Natural; -- Returns the position of the next character Char starting from -- position From. Returns 0 if the character is not found. This routine -- skips characters inside quoted string. --------- -- Get -- --------- function Get (Count : Natural) return Parameter_Set is procedure Get_Named_Parameters (Parameters : String); -- Load parameters specified with a name: -- (param_a, 5 => param_b, 3 => param_c) -- Set Result variable accordingly. procedure Get_Next_Parameter (Parameters : String; First : in out Positive; Last : out Natural; Next_Last : out Natural); -- Look for next parameter starting at position First, set First and -- Last to the index of this parameter. Next_Last is set to the next -- value to assigned to last. Result : Parameter_Set (1 .. Count); Index : Positive := Result'First; First, Last : Natural := 0; Next_Last : Natural; ------------------------ -- Get_Next_Parameter -- ------------------------ procedure Get_Next_Parameter (Parameters : String; First : in out Positive; Last : out Natural; Next_Last : out Natural) is begin -- Skip blanks while First < Parameters'Last and then (Parameters (First) = ' ' or else Parameters (First) = ASCII.HT) loop First := First + 1; end loop; -- Look for end of parameter Next_Last := First + 1; if Parameters (First) = '"' then -- Look for closing quote while Next_Last < Parameters'Last and then Parameters (Next_Last) /= '"' loop Next_Last := Next_Last + 1; end loop; if Parameters (Next_Last) /= '"' then raise Internal_Error with "Missing closing quote in include parameters"; end if; -- Skip quotes First := First + 1; Last := Next_Last - 1; else -- Look for end of word while Next_Last < Parameters'Last and then Parameters (Next_Last) /= ' ' and then Parameters (Next_Last) /= ASCII.HT loop Next_Last := Next_Last + 1; end loop; if Next_Last /= Parameters'Last then Last := Next_Last - 1; else Last := Next_Last; end if; end if; end Get_Next_Parameter; -------------------------- -- Get_Named_Parameters -- -------------------------- procedure Get_Named_Parameters (Parameters : String) is procedure Parse (Parameter : String); -- Parse one parameter Named : Boolean := False; First, Last : Natural; ----------- -- Parse -- ----------- procedure Parse (Parameter : String) is use type Data.Tree; Sep : constant Natural := Strings.Fixed.Index (Parameter, "=>"); Ind : Natural; begin if Sep = 0 then -- A positional parameter, this is valid only if we have not -- yet found a named parameter. if Named then raise Internal_Error with "Can't have a positional parameter after a named one"; else Result (Index) := To_Unbounded_String (Parameter); Index := Index + 1; end if; else -- A named parameter, get index Named := True; declare Ind_Str : constant String := Strings.Fixed.Trim (Parameter (Parameter'First .. Sep - 1), Strings.Both); First, Last : Natural; Next_Last : Natural; pragma Unreferenced (Next_Last); begin if Is_Number (Ind_Str) then Ind := Natural'Value (Ind_Str); if Result (Ind) = Null_Unbounded_String then -- This parameter has not yet been found First := Sep + 2; Get_Next_Parameter (Parameter, First, Last, Next_Last); Result (Ind) := To_Unbounded_String (Parameter (First .. Last)); else raise Internal_Error with "Parameter" & Natural'Image (Ind) & " defined multiple time"; end if; else raise Internal_Error with "Wrong number in named parameter"; end if; end; end if; end Parse; begin if Parameters (Parameters'Last) /= ')' then raise Internal_Error with "Missing closing parenthesis in named include parameters"; end if; First := Parameters'First + 1; -- Skip the parenthesis loop Last := Strings.Fixed.Index (Parameters (First .. Parameters'Last), ","); exit when Last = 0; Parse (Strings.Fixed.Trim (Parameters (First .. Last - 1), Strings.Both)); First := Last + 1; end loop; -- Handle last parameter Parse (Strings.Fixed.Trim (Parameters (First .. Parameters'Last - 1), Strings.Both)); end Get_Named_Parameters; begin First := Parameters'First; while First <= Parameters'Last loop -- Skip blanks while First < Parameters'Last and then (Parameters (First) = ' ' or else Parameters (First) = ASCII.HT) loop First := First + 1; end loop; -- Check if parameters are specified with a name if Index = 1 and then Parameters (First) = '(' then -- Stop current processing, load as named parameters Get_Named_Parameters (Parameters (First .. Parameters'Last)); return Result; end if; Get_Next_Parameter (Parameters, First, Last, Next_Last); Result (Index) := To_Unbounded_String (Parameters (First .. Last)); Index := Index + 1; Last := Next_Last; First := Last + 1; end loop; return Result; end Get; ---------- -- Next -- ---------- function Next (Char : Character; From : Positive) return Natural is In_Quote : Boolean := False; Index : Natural := 0; begin for K in From .. Parameters'Last loop if Parameters (K) = '"' then In_Quote := not In_Quote; elsif Parameters (K) = Char and then not In_Quote then Index := K; exit; end if; end loop; return Index; end Next; Count : Natural := 0; Index : Natural := Parameters'First - 1; begin -- Count parameters if Parameters'First <= Parameters'Last then Count := 1; if Parameters (Parameters'First) = '(' then -- We are using the parentherized form with parameters separated -- with coma and possibly using the named notation. -- Count positional parameters loop Index := Next (',', Index + 1); exit when Index = 0; Count := Count + 1; end loop; -- Then check for named ones declare Sep, SP, EP : Natural := Parameters'First; begin loop Sep := Strings.Fixed.Index (Parameters, "=>", From => Sep); exit when Sep = 0; EP := Sep - 1; -- Skip spaces while EP > Parameters'First and then Parameters (EP) = ' ' loop EP := EP - 1; end loop; SP := EP; -- Get number while SP > Parameters'First and then Strings.Maps.Is_In (Parameters (SP - 1), Strings.Maps.Constants.Decimal_Digit_Set) loop SP := SP - 1; end loop; if EP >= SP and then Parameters (EP) in '0' .. '9' then Count := Natural'Max (Count, Natural'Value (Parameters (SP .. EP))); end if; Sep := Sep + 1; end loop; end; else -- We are using the standard form, parameters are separated by -- spaces. loop Index := Next (' ', Index + 1); exit when Index = 0; -- Skip multiple spaces while Index < Parameters'Last and then Parameters (Index + 1) = ' ' loop Index := Index + 1; end loop; Count := Count + 1; end loop; end if; end if; return Get (Count); end Get_Parameters; -------------- -- No_Quote -- -------------- function No_Quote (Str : String) return String is begin if Str'Length > 1 and then Str (Str'First) = '"' and then Str (Str'Last) = '"' then return Str (Str'First + 1 .. Str'Last - 1); else return Str; end if; end No_Quote; ----------- -- Parse -- ----------- function Parse (Filename : String; Translations : Translate_Table := No_Translation; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return String is begin return To_String (Parse (Filename, Translations, Cached, Keep_Unknown_Tags, Lazy_Tag, Cursor_Tag)); end Parse; function Parse (Filename : String; Translations : Translate_Table := No_Translation; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return Unbounded_String is begin return Parse (Filename, To_Set (Translations), Cached, Keep_Unknown_Tags, Lazy_Tag, Cursor_Tag); end Parse; function Parse (Filename : String; Translations : Translate_Set; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return String is begin return To_String (Parse (Filename, Translations, Cached, Keep_Unknown_Tags, Lazy_Tag, Cursor_Tag)); end Parse; function Parse (Filename : String; Translations : Translate_Set; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return Unbounded_String is Max_Nested_Levels : constant := 10; -- The maximum number of table nested levels type Block_State is record Section_Number : Positive; Section : Tree; end record; Empty_Block_State : constant Block_State := (1, null); type Parse_State; type Parse_State_Access is access constant Parse_State; type Parse_State (P_Size : Natural) is record Cursor : Indices (1 .. Max_Nested_Levels); Max_Lines : Natural; Max_Expand : Natural; Reverse_Index : Boolean; Table_Level : Natural; Inline_Sep : Unbounded_String; Filename : Unbounded_String; Blocks_Count : Natural; I_Params : Data.Parameters; F_Params : Parameter_Set (1 .. P_Size); Block : Block_State; Terse_Table : Boolean; Parent : Parse_State_Access; end record; Empty_State : constant Parse_State := (0, (1 .. Max_Nested_Levels => 0), 0, 0, False, 0, Null_Unbounded_String, Null_Unbounded_String, 0, null, No_Parameter, Empty_Block_State, False, null); Results : Unbounded_String := Null_Unbounded_String; Buffer : String (1 .. 4 * 1_024); Last : Natural := 0; -- Cache to avoid too many reallocation using Append on Results above Last_Was_Sep : Boolean := False; -- Used to avoid two consecutive separators Now : Calendar.Time; D_Map : Definitions.Map; Lazy_Set : Translate_Set; Output : Boolean; procedure Analyze (T : Tree; State : Parse_State); -- Parse T and build results file. State is needed for Vector_Tag and -- Matrix_Tag expansion. function Get_Association (Var : Data.Tag_Var) return Association; -- Returns association for Name or Null_Association if not found. This -- routine also handles lazy tags by calling the appropriate callback -- routine. Lazy tag values are then recorded into Lazy_Set. ------------- -- Analyze -- ------------- procedure Analyze (T : Tree; State : Parse_State) is use type Association_Map.Cursor; use type Data.Tree; function Analyze (E : Expr.Tree) return String; -- Analyse the expression tree and returns the result as a boolean -- The conditional expression must be equal to either TRUE or -- FALSE. Note that a string is True if it is equal to string "TRUE" -- and False otherwise. procedure Analyze (D : Data.Tree); -- Analyse the data tree and replace all variables by the -- correspinding value specified in Translations. This procedure -- catenate the result into Results variable. procedure Get_Max (T : Tree; Max_Lines : out Natural; Max_Expand : out Natural); -- Returns the maximum number of lines (Max_Lines) into the -- table. This correspond to the length of the shortest vector tag -- into the table or the shortest number of lines in sub-table -- matrix tag. -- Returns also the number of time the table will be expanded -- (Max_Expand), this is equal to Max_Lines + offset to terminate -- the sections. function Translate (Var : Data.Tag_Var; State : Parse_State; Is_Composite : access Boolean) return String; -- Translate Tag variable using Translation table and apply all -- Filters and Atribute recorded for this variable. function I_Translate (Var : Data.Tag_Var; State : Parse_State) return String; -- As above but for an include variable procedure Add (S : String; Sep : Boolean := False); -- Add S into Results (using Buffer cache if possible). If Sep is -- true S is a separator. We keep track of this as we do not want to -- have two separators side by side. procedure Flush; pragma Inline (Flush); -- Flush buffer to Results function Get_Mark return Natural; pragma Inline (Get_Mark); -- Get a mark on the current text buffer function Get_Marked_Text (Mark : Natural) return String; -- Returns the text from the mark to the end of the buffer procedure Rollback (Activate : Boolean; Mark : Natural); pragma Inline (Rollback); -- Commit or rollback added texts for terse output. If no text added -- from the vector tag we rollback to the previous mark otherwise the -- current result stays. The mark is cleared. function Flatten_Parameters (I : Data.Parameter_Set) return Parameter_Set; -- Returns a flat representation of the include parameters, only the -- name or the value are kept. The tree are replaced by an empty -- value. function Flatten_Parameters (I : Data.Parameters) return Parameter_Set; -- As above but for an access to a Parameter_Set function Inline_Cursor_Tag (Cursor_Tag : Dynamic.Cursor_Tag_Access; Var_Name : String; Dim : Positive; Path : Dynamic.Path) return Unbounded_String; -- Returns the Cursor_Tag Var_Name inlined for all dimensions -- starting from Path. procedure Push_Sep (State : Parse_State); pragma Inline (Push_Sep); -- Append a separator into the current buffer procedure Pop_Sep (State : Parse_State); pragma Inline (Pop_Sep); -- Remove the separator if it is the last input into the buffer L_State : aliased constant Parse_State := State; --------- -- Add -- --------- procedure Add (S : String; Sep : Boolean := False) is begin if Last + S'Length > Buffer'Last then -- Not enough cache space, flush buffer Flush; end if; if S'Length >= Buffer'Length then Append (Results, S); else Buffer (Last + 1 .. Last + S'Length) := S; Last := Last + S'Length; end if; Last_Was_Sep := Sep; end Add; ------------- -- Analyze -- ------------- procedure Analyze (D : Data.Tree) is T : Data.Tree := D; begin while T /= null loop case T.Kind is when Data.Text => Add (To_String (T.Value)); when Data.Var => if Data.Is_Include_Variable (T.Var) then Add (I_Translate (T.Var, State)); else declare Is_Composite : aliased Boolean; Value : constant String := Translate (T.Var, State, Is_Composite'Access); begin -- Only adds to the buffer if variable value is not -- empty. This is needed as we want to track empty -- values to be able to rollback if necessary on -- the terse mode. Note that we handle only -- composite tags which are part of the table -- expansion. if Value /= "" then Add (Value); Output := Is_Composite; end if; end; end if; end case; T := T.Next; end loop; end Analyze; ------------- -- Analyze -- ------------- function Analyze (E : Expr.Tree) return String is type Ops_Fct is access function (L, R : Expr.Tree) return String; function F_And (L, R : Expr.Tree) return String; function F_Or (L, R : Expr.Tree) return String; function F_Xor (L, R : Expr.Tree) return String; function F_Sup (L, R : Expr.Tree) return String; function F_Esup (L, R : Expr.Tree) return String; function F_Einf (L, R : Expr.Tree) return String; function F_Inf (L, R : Expr.Tree) return String; function F_Equ (L, R : Expr.Tree) return String; function F_Diff (L, R : Expr.Tree) return String; function F_In (L, R : Expr.Tree) return String; type U_Ops_Fct is access function (N : Expr.Tree) return String; function F_Not (N : Expr.Tree) return String; ----------- -- F_And -- ----------- function F_And (L, R : Expr.Tree) return String is begin if Expr.Is_True (Analyze (L)) and then Expr.Is_True (Analyze (R)) then return "TRUE"; else return "FALSE"; end if; end F_And; ------------ -- F_Diff -- ------------ function F_Diff (L, R : Expr.Tree) return String is begin if Analyze (L) /= Analyze (R) then return "TRUE"; else return "FALSE"; end if; end F_Diff; ------------ -- F_Einf -- ------------ function F_Einf (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if Utils.Is_Number (LV) and then Is_Number (RV) then if Integer'Value (LV) <= Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV <= RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Einf; ----------- -- F_Equ -- ----------- function F_Equ (L, R : Expr.Tree) return String is begin if Analyze (L) = Analyze (R) then return "TRUE"; else return "FALSE"; end if; end F_Equ; ------------ -- F_Esup -- ------------ function F_Esup (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if Utils.Is_Number (LV) and then Is_Number (RV) then if Integer'Value (LV) >= Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV >= RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Esup; ---------- -- F_In -- ---------- function F_In (L, R : Expr.Tree) return String is use type Expr.NKind; procedure Build_Set (Data : in out Tag_Data); -- Returns TRUE or FALSE depending if Value is found in the tag --------------- -- Build_Set -- --------------- procedure Build_Set (Data : in out Tag_Data) is procedure Process (N : Tag_Node_Access); -- Insert all values pointed to by N ------------- -- Process -- ------------- procedure Process (N : Tag_Node_Access) is L : Tag_Node_Access := N; begin while L /= null loop if L.Kind = Templates_Parser.Value then Data.Values.Include (To_String (L.V)); elsif L.Kind = Value_Set then Process (L.VS.Data.Head); end if; L := L.Next; end loop; end Process; begin Process (Data.Head); end Build_Set; begin if R.Kind = Expr.Var then declare LL : constant String := Analyze (L); Tk : constant Association := Get_Association (R.Var); begin case Tk.Kind is when Std => if LL = To_String (Tk.Value) then return "TRUE"; else return "FALSE"; end if; when Composite => if Tk.Comp_Value.Data.Values = null then -- Build map of values for fast test Tk.Comp_Value.Data.Values := new Tag_Values.Set; Build_Set (Tk.Comp_Value.Data.all); end if; if Tk.Comp_Value.Data.Values.Contains (LL) then return "TRUE"; else return "FALSE"; end if; end case; end; else raise Template_Error with "in operator right operand must be a tag"; end if; end F_In; ----------- -- F_Inf -- ----------- function F_Inf (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if Utils.Is_Number (LV) and then Is_Number (RV) then if Integer'Value (LV) < Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV < RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Inf; ----------- -- F_Not -- ----------- function F_Not (N : Expr.Tree) return String is begin if Expr.Is_True (Analyze (N)) then return "FALSE"; else return "TRUE"; end if; end F_Not; ---------- -- F_Or -- ---------- function F_Or (L, R : Expr.Tree) return String is begin if Expr.Is_True (Analyze (L)) or else Expr.Is_True (Analyze (R)) then return "TRUE"; else return "FALSE"; end if; end F_Or; ----------- -- F_Sup -- ----------- function F_Sup (L, R : Expr.Tree) return String is LV : constant String := Analyze (L); RV : constant String := Analyze (R); begin if Utils.Is_Number (LV) and then Is_Number (RV) then if Integer'Value (LV) > Integer'Value (RV) then return "TRUE"; else return "FALSE"; end if; else if LV > RV then return "TRUE"; else return "FALSE"; end if; end if; end F_Sup; ----------- -- F_Xor -- ----------- function F_Xor (L, R : Expr.Tree) return String is begin if Expr.Is_True (Analyze (L)) xor Expr.Is_True (Analyze (R)) then return "TRUE"; else return "FALSE"; end if; end F_Xor; Op_Table : constant array (Expr.Ops) of Ops_Fct := (Expr.O_And => F_And'Access, Expr.O_Or => F_Or'Access, Expr.O_Xor => F_Xor'Access, Expr.O_Sup => F_Sup'Access, Expr.O_Inf => F_Inf'Access, Expr.O_Esup => F_Esup'Access, Expr.O_Einf => F_Einf'Access, Expr.O_Equal => F_Equ'Access, Expr.O_Diff => F_Diff'Access, Expr.O_In => F_In'Access); U_Op_Table : constant array (Expr.U_Ops) of U_Ops_Fct := (Expr.O_Not => F_Not'Access); Is_Composite : aliased Boolean; begin case E.Kind is when Expr.Value => return To_String (E.V); when Expr.Var => if Data.Is_Include_Variable (E.Var) then return I_Translate (E.Var, State); else return Translate (E.Var, State, Is_Composite'Access); end if; when Expr.Op => return Op_Table (E.O) (E.Left, E.Right); when Expr.U_Op => return U_Op_Table (E.U_O) (E.Next); end case; end Analyze; -------------- -- Rollback -- -------------- procedure Rollback (Activate : Boolean; Mark : Natural) is begin if Activate then -- Rollback Rollback : declare To_Delete : constant Natural := Length (Results) + Last - Mark; begin if To_Delete > 0 then if Last >= To_Delete then -- Enough data into the buffer, remove from it Last := Last - To_Delete; else -- Remove remaining data from results Delete (Results, From => Length (Results) - To_Delete + Last + 1, Through => Length (Results)); -- Clear buffer Last := 0; end if; end if; end Rollback; end if; end Rollback; ------------------------ -- Flatten_Parameter -- ------------------------ function Flatten_Parameters (I : Data.Parameter_Set) return Parameter_Set is F : Parameter_Set (I'Range); Is_Composite : aliased Boolean; begin for K in I'Range loop if I (K) = null then F (K) := Null_Unbounded_String; else case I (K).Kind is when Data.Text => F (K) := I (K).Value; when Data.Var => F (K) := To_Unbounded_String (Translate (I (K).Var, State, Is_Composite'Access)); end case; end if; end loop; return F; end Flatten_Parameters; function Flatten_Parameters (I : Data.Parameters) return Parameter_Set is use type Data.Parameters; begin if I = null then return No_Parameter; else return Flatten_Parameters (I.all); end if; end Flatten_Parameters; ----------- -- Flush -- ----------- procedure Flush is begin Append (Results, Buffer (1 .. Last)); Last := 0; end Flush; --------------------- -- Get_Marked_Text -- --------------------- function Get_Marked_Text (Mark : Natural) return String is Len : constant Natural := Length (Results) + Last - Mark; begin if Len > 0 then if Last >= Len then -- Enough data into the buffer return Buffer (Last - Len + 1 .. Last); else -- Get part from result return Slice (Results, Low => Length (Results) - Len + Last + 1, High => Length (Results)) & Buffer (1 .. Last); end if; else return ""; end if; end Get_Marked_Text; ------------- -- Get_Max -- ------------- procedure Get_Max (T : Tree; Max_Lines : out Natural; Max_Expand : out Natural) is function Get_Max_Lines (T : Tree; N : Positive) return Natural; -- Recursivelly descends the tree and compute the max lines that -- will be displayed into the table. N is the variable embedded -- level regarding the table statement. N=1 means that the -- variable is just under the analysed table. N=2 means that the -- variable is found inside a nested table statement. And so on. ------------------- -- Get_Max_Lines -- ------------------- function Get_Max_Lines (T : Tree; N : Positive) return Natural is function Check (T : Data.Tree) return Natural; -- Returns the length of the largest vector tag found on the -- subtree. function Check (T : Expr.Tree) return Natural; -- Idem for an expression subtree as found in a condition function Check (T : Data.Tag_Var) return Natural; -- Returns the length of Tag T for the current context function Check (I : not null access Data.Parameter_Set) return Natural; -- Returns the length of the largest vector tag found on the -- include parameters. ----------- -- Check -- ----------- function Check (T : Data.Tag_Var) return Natural is Table_Level : constant Positive := State.Table_Level + 1; -- This is the current table level, State.Table_Level is -- not yet updated when calling this routine hence the +1. Var_Level : constant Natural := State.Table_Level + N; -- This is the variable nested table level. O means that the -- variable is not inside a table statement. function Max (T : Tag; N : Natural) return Natural; -- Returns the maximum number of items for the Nth Tag level function Max (Name : String; N : Natural; Path : Dynamic.Path) return Natural; -- Idem for a Cursor_Tag --------- -- Max -- --------- function Max (T : Tag; N : Natural) return Natural is Result : Natural := 0; P : Tag_Node_Access := T.Data.Head; begin while P /= null loop if P.Kind = Value_Set then if N = 1 then Result := Natural'Max (Result, P.VS.Data.Count); else Result := Natural'Max (Result, Max (P.VS.all, N - 1)); end if; end if; P := P.Next; end loop; return Result; end Max; function Max (Name : String; N : Natural; Path : Dynamic.Path) return Natural is use type Dynamic.Path; Result : Natural := 0; L : Natural; begin L := Dynamic.Length (Cursor_Tag, Name, Path); for K in 1 .. L loop if Path'Length = N then Result := Natural'Max (Result, Dynamic.Length (Cursor_Tag, Name, Path & K)); else Result := Natural'Max (Result, Max (Name, N, Path & K)); end if; end loop; return Result; end Max; begin declare use type Dynamic.Cursor_Tag_Access; Tk : constant Association := Get_Association (T); begin if Tk = Null_Association then if Cursor_Tag /= Dynamic.Null_Cursor_Tag then -- Check the Cursor_Tag declare Name : constant String := To_String (T.Name); D, K : Natural; L1 : Natural; begin D := Dynamic.Dimension (Cursor_Tag, Name); if N > D then -- Ignore this variable as it is deeper than -- its dimension. return 0; elsif D /= 0 then -- This is a Cursor_Tag K := D - N + 1; -- K is the variable indice for which -- the number of items is looked for. if D > Table_Level then -- The variable dimensions is bigger than -- the current table level. This means -- that the index needs to be updated so -- that the outer table tag statement will -- be the first var index. K := K - (D - Var_Level); end if; L1 := Dynamic.Length (Cursor_Tag, Name, Path => (1 => 1)); if D = 1 and then L1 = 1 then -- Not a composite tag return 0; elsif K = 1 then return L1; else return Max (Name, K - 1, (1 => 1)); end if; end if; end; end if; else if Tk.Kind = Composite then if N > Tk.Comp_Value.Data.Nested_Level then -- Ignore this variable as it is deeper than -- its nested level. return 0; end if; -- We look first at two common cases to handle -- more efficiently tag into a single or two -- table statements. if Table_Level = 1 or else Tk.Comp_Value.Data.Nested_Level = 1 then -- First table level, or flat composite, the -- number of iterations corresponds to the -- number of item into this tag. return Size (Tk.Comp_Value); elsif Table_Level = 2 and then N = 1 then -- Table level 2 while looking to nested -- variable. return Tk.Comp_Value.Data.Max; else -- All other cases here declare K : constant Positive := Tk.Comp_Value.Data.Nested_Level - N + 1; -- K is the variable indice for which -- the number of items is looked for. begin if K = 1 then return Size (Tk.Comp_Value); elsif K = 2 then return Tk.Comp_Value.Data.Max; else return Max (Tk.Comp_Value, K - 1); end if; end; end if; end if; end if; end; return 0; end Check; function Check (T : Data.Tree) return Natural is use type Data.NKind; use type Data.Attribute; Iteration : Natural := Natural'First; D : Data.Tree := T; begin while D /= null loop if D.Kind = Data.Var and then D.Var.Attribute.Attr = Data.Nil then Iteration := Natural'Max (Iteration, Check (D.Var)); end if; D := D.Next; end loop; return Iteration; end Check; function Check (T : Expr.Tree) return Natural is begin case T.Kind is when Expr.Var => return Natural'Max (0, Check (T.Var)); when Expr.Op => return Natural'Max (Check (T.Left), Check (T.Right)); when Expr.U_Op => return Natural'Max (0, Check (T.Next)); when Expr.Value => return 0; end case; end Check; function Check (I : not null access Data.Parameter_Set) return Natural is Iteration : Natural := Natural'First; begin for K in I'Range loop if I (K) /= null then Iteration := Natural'Max (Iteration, Check (I (K))); end if; end loop; return Iteration; end Check; begin if T = null then return Natural'First; end if; case T.Kind is when Info | C_Info | Set_Stmt => return Get_Max_Lines (T.Next, N); when Text => return Natural'Max (Check (T.Text), Get_Max_Lines (T.Next, N)); when If_Stmt => return Natural'Max (Check (T.Cond), Natural'Max (Get_Max_Lines (T.Next, N), Natural'Max (Get_Max_Lines (T.N_True, N), Get_Max_Lines (T.N_False, N)))); when Table_Stmt => return Natural'Max (Get_Max_Lines (T.Blocks, N + 1), Get_Max_Lines (T.Next, N)); when Section_Block => return Natural'Max (Get_Max_Lines (T.Next, N), Natural'Max (Get_Max_Lines (T.Common, N), Get_Max_Lines (T.Sections, N))); when Section_Stmt => return Natural'Max (Get_Max_Lines (T.Next, N), Get_Max_Lines (T.N_Section, N)); when Include_Stmt => return Natural'Max (Get_Max_Lines (T.File.Info, N), Natural'Max (Check (T.I_Params), Get_Max_Lines (T.Next, N))); when Inline_Stmt => return Natural'Max (Get_Max_Lines (T.Next, N), Get_Max_Lines (T.I_Block, N)); end case; end Get_Max_Lines; Result : Natural := Get_Max_Lines (T.Blocks, 1); begin pragma Assert (T.Kind = Table_Stmt); Max_Lines := Result; if T.Terminate_Sections then -- ??? This part of code handle properly only table with a -- single block. What should be done if there is multiple -- blocks ? Should all blocks be of the same size ? declare N_Section : constant Natural := T.Blocks.Sections_Count; begin if Result mod N_Section /= 0 then Result := Result + N_Section - (Result mod N_Section); end if; end; end if; Max_Expand := Result; end Get_Max; ----------------- -- I_Translate -- ----------------- function I_Translate (Var : Data.Tag_Var; State : Parse_State) return String is use type Data.NKind; use type Data.Attribute; use type Data.Parameters; begin pragma Assert (Var.N /= -1); if State.I_Params /= null and then Var.N <= State.I_Params'Last and then State.I_Params (Var.N) /= null then declare T : constant Data.Tree := State.I_Params (Var.N); -- T is the data tree that should be evaluated in place -- of the include variable. C : aliased Filter.Filter_Context := (State.F_Params'Length, Translations, Lazy_Tag, State.F_Params); Is_Composite : aliased Boolean; begin if T.Next = null and then T.Kind = Data.Var then -- Here we have a special case where the include -- variable is replaced by a single variable. declare V : Data.Tag_Var := T.Var; begin if V.N = -1 then -- First thing we want to do is to inherit -- attributes from the include variable if we -- have no attribute. if V.Attribute.Attr = Data.Nil then V.Attribute := Var.Attribute; end if; -- Note that below we pass the parent state. This -- is required as if the variable is an alias to -- to an include parameter we need to get the -- value for this variable in parent state. If the -- variable is a standard one (from a translate -- table) the state will not be used. return Data.Translate (Var, Translate (V, State.Parent.all, Is_Composite'Access), C'Access); else -- This variable reference a parent include -- variable. return I_Translate (V, State.Parent.all); end if; end; else -- Here we flush the buffer and then we analyse the -- include parameter. The result is contained into -- the buffer which is large enough for an include -- variable. Flush; Analyze (T); declare L : constant Natural := Last; begin Last := 0; return Data.Translate (Var, Buffer (Buffer'First .. L), C'Access); end; end if; end; else return ""; end if; end I_Translate; ----------------------- -- Inline_Cursor_Tag -- ----------------------- function Inline_Cursor_Tag (Cursor_Tag : Dynamic.Cursor_Tag_Access; Var_Name : String; Dim : Positive; Path : Dynamic.Path) return Unbounded_String is use type Dynamic.Path; Result : Unbounded_String; L : Natural; begin L := Dynamic.Length (Cursor_Tag, Var_Name, 1 & Path); for K in 1 .. L loop if Result /= Null_Unbounded_String then Append (Result, ' '); end if; if Dim = Path'Length + 1 then Append (Result, Dynamic.Value (Cursor_Tag, Var_Name, Path & K)); else Append (Result, Inline_Cursor_Tag (Cursor_Tag, Var_Name, Dim, Path & K)); end if; end loop; return Result; end Inline_Cursor_Tag; -------------- -- Get_Mark -- -------------- function Get_Mark return Natural is begin Output := False; return Length (Results) + Last; end Get_Mark; ------------- -- Pop_Sep -- ------------- procedure Pop_Sep (State : Parse_State) is begin if Last_Was_Sep then Last := Last - Length (State.Inline_Sep); Last_Was_Sep := False; end if; end Pop_Sep; -------------- -- Push_Sep -- -------------- procedure Push_Sep (State : Parse_State) is begin if State.Inline_Sep /= Null_Unbounded_String then Add (To_String (State.Inline_Sep), Sep => True); end if; end Push_Sep; --------------- -- Translate -- --------------- function Translate (Var : Data.Tag_Var; State : Parse_State; Is_Composite : access Boolean) return String is use type Filter.Set_Access; use type Data.Parameters; C : aliased Filter.Filter_Context := (State.F_Params'Length, Translations, Lazy_Tag, State.F_Params); D_Pos : Definitions.Def_Map.Cursor; Up_Value : Natural := 0; begin Is_Composite.all := False; if Var.Is_Macro then -- Two possibilities, either we have a macro inlined here or a -- user macro. if Var.Def = null then -- A user defined macro, use callback if any if Macro.Callback /= null then declare Name : constant String := To_String (Var.Name); Params : Parameter_Set (Var.Parameters'Range); begin -- Set parameters for K in Params'Range loop Flush; Analyze (Var.Parameters (K)); Params (K) := To_Unbounded_String (Buffer (Buffer'First .. Last)); Last := 0; end loop; return Data.Translate (Var, Macro.Callback (Name, Params), C'Access); end; end if; else declare Mark : constant Natural := Get_Mark; begin Analyze (Var.Def, State); -- Apply filters if any to the result if Var.Filters /= null then declare V : constant String := Get_Marked_Text (Mark); begin Rollback (True, Mark); return Data.Translate (Var, V, C'Access); end; else return ""; end if; end; end if; end if; D_Pos := Definitions.Def_Map.Find (D_Map, To_String (Var.Name)); if Definitions.Def_Map.Has_Element (D_Pos) then -- We have a definition for this variable in the template declare N : constant Definitions.Node := Definitions.Def_Map.Element (D_Pos); V : Data.Tag_Var := Var; begin case N.Kind is when Definitions.Const => return Data.Translate (Var, To_String (N.Value), C'Access); when Definitions.Ref => V.N := N.Ref; return I_Translate (V, State); when Definitions.Ref_Default => if State.I_Params = null or else N.Ref > State.I_Params'Last or else State.I_Params (N.Ref) = null then -- This include parameter does not exists, use -- default value. return Data.Translate (Var, To_String (N.Value), C'Access); else V.N := N.Ref; return I_Translate (V, State); end if; end case; end; end if; declare use type Data.Attribute; use type Dynamic.Cursor_Tag_Access; use type Dynamic.Path; Tk : constant Association := Get_Association (Var); begin if Tk = Null_Association then if Cursor_Tag /= Dynamic.Null_Cursor_Tag then -- Check the Cursor_Tag declare Name : constant String := To_String (Var.Name); D, L : Natural; Valid_Cursor : Boolean := True; begin D := Dynamic.Dimension (Cursor_Tag, Name); if D /= 0 then if Var.Attribute.Attr /= Data.Nil then -- ??? Would be nice to remove this restriction raise Template_Error with "Attributes not supported for Cursor_Tag."; end if; -- This is a Cursor_Tag, check that the current -- table cursor is valid for it. for K in 1 .. D loop if State.Cursor (K) > Dynamic.Length (Cursor_Tag, Name, 1 & State.Cursor (1 .. K - 1)) then Valid_Cursor := False; end if; end loop; if Valid_Cursor then L := Dynamic.Length (Cursor_Tag, Name, 1 & State.Cursor (1 .. State.Table_Level - 1)); if D = 1 and then L = 1 then -- A standard tag (single value) return Data.Translate (Var, Dynamic.Value (Cursor_Tag, Name, (1 => 1)), C'Access); else -- A composite tag, check that the dimension -- of the tag correspond to the current table -- nested level. if D = State.Table_Level then return Data.Translate (Var, Dynamic.Value (Cursor_Tag, Name, State.Cursor (1 .. D)), C'Access); else -- Otherwise we inline the structure return To_String (Inline_Cursor_Tag (Cursor_Tag, Name, D, State.Cursor (1 .. State.Table_Level))); end if; end if; end if; end if; end; end if; else case Tk.Kind is when Std => if Var.Attribute.Attr = Data.Nil then return Data.Translate (Var, To_String (Tk.Value), C'Access); else raise Template_Error with "Attribute not valid on a discrete tag (" & Data.Image (Var) & ')'; end if; when Composite => Is_Composite.all := True; if Tk.Comp_Value.Data.Nested_Level = 1 then -- This is a vector if Var.Attribute.Attr = Data.Length then return Data.Translate (Var, Utils.Image (Tk.Comp_Value.Data.Count), C'Access); elsif Var.Attribute.Attr = Data.Up_Level then Up_Value := Var.Attribute.Value; elsif Var.Attribute.Attr /= Data.Nil then raise Template_Error with "This attribute is not valid for a " & "vector tag (" & Data.Image (Var) & ')'; end if; elsif Tk.Comp_Value.Data.Nested_Level = 2 then if Var.Attribute.Attr = Data.Line then -- 'Line on a matrix return Data.Translate (Var, Utils.Image (Tk.Comp_Value.Data.Count), C'Access); elsif Var.Attribute.Attr = Data.Min_Column then -- 'Min_Column on a matrix return Data.Translate (Var, Utils.Image (Tk.Comp_Value.Data.Min), C'Access); elsif Var.Attribute.Attr = Data.Max_Column then -- 'Max_Column on a matrix return Data.Translate (Var, Utils.Image (Tk.Comp_Value.Data.Max), C'Access); elsif Var.Attribute.Attr /= Data.Nil then raise Template_Error with "This attribute is not valid for a " & "matrix tag (" & Data.Image (Var) & ')'; end if; end if; declare Result : Unbounded_String; Found : Boolean; begin Field (Tk.Comp_Value, State.Cursor (1 .. State.Table_Level), Up_Value, Result, Found); return Data.Translate (Var, To_String (Result), C'Access); end; end case; end if; end; case Var.Internal is when Data.Up_Table_Line => if State.Table_Level < 2 then return Data.Translate (Var, "0", C'Access); else return Data.Translate (Var, Utils.Image (State.Cursor (State.Table_Level - 1)), C'Access); end if; when Data.Table_Line => if State.Table_Level = 0 then return Data.Translate (Var, "0", C'Access); else return Data.Translate (Var, Utils.Image (State.Cursor (State.Table_Level)), C'Access); end if; when Data.Number_Line => return Data.Translate (Var, Utils.Image (State.Max_Lines), C'Access); when Data.Table_Level => return Data.Translate (Var, Utils.Image (State.Table_Level), C'Access); when Data.Now => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%Y-%m-%d %H:%M:%S"), C'Access); when Data.Year => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%Y"), C'Access); when Data.Month => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%m"), C'Access); when Data.Day => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%d"), C'Access); when Data.Hour => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%H"), C'Access); when Data.Minute => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%M"), C'Access); when Data.Second => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%S"), C'Access); when Data.Month_Name => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%B"), C'Access); when Data.Day_Name => return Data.Translate (Var, GNAT.Calendar.Time_IO.Image (Now, "%A"), C'Access); when Data.No => null; end case; -- The tag was not found in the Translation_Table, we either -- returns the empty string or we keep the tag as is. if Keep_Unknown_Tags then return Data.Image (Var); else return Data.Translate (Var, "", C'Access); end if; end Translate; begin if T = null then return; end if; case T.Kind is when Info | C_Info => Analyze (T.Next, State); when Text => declare N : Tree := T; begin begin -- Handles all consecutive Text nodes while N /= null and then N.Kind = Text loop Analyze (N.Text); N := N.Next; end loop; exception when E : others => raise Template_Error with Exceptions.Exception_Message (E) & " In " & Filename & " at line" & Natural'Image (N.Line); end; Analyze (N, State); end; when Set_Stmt => declare N : Tree := T; begin begin -- Handles all consecutive Set nodes while N /= null and then N.Kind = Set_Stmt loop Handle_Set : declare Name : constant String := To_String (N.Def.Name); Pos : Definitions.Def_Map.Cursor; Success : Boolean; begin Pos := D_Map.Find (Name); if Definitions.Def_Map.Has_Element (Pos) then D_Map.Replace_Element (Pos, New_Item => N.Def.N); else D_Map.Insert (Name, N.Def.N, Pos, Success); end if; end Handle_Set; N := N.Next; end loop; end; Analyze (N, State); end; when If_Stmt => begin if Expr.Is_True (Analyze (T.Cond)) then Analyze (T.N_True, State); else Analyze (T.N_False, State); end if; exception when E : others => raise Template_Error with Exceptions.Exception_Message (E) & " In " & Filename & " at line" & Natural'Image (T.Line); end; Analyze (T.Next, State); when Table_Stmt => declare Max_Lines, Max_Expand : Natural; begin Get_Max (T, Max_Lines, Max_Expand); Analyze (T.Blocks, Parse_State'(State.F_Params'Length, State.Cursor, Max_Lines, Max_Expand, T.Reverse_Index, State.Table_Level + 1, State.Inline_Sep, State.Filename, T.Blocks_Count, State.I_Params, State.F_Params, Empty_Block_State, T.Terse, L_State'Unchecked_Access)); end; Push_Sep (State); Analyze (T.Next, State); Pop_Sep (State); when Section_Block => declare B_State : array (1 .. State.Blocks_Count) of Block_State; B : Positive; Mark : Natural := 0; begin for K in 1 .. State.Max_Expand loop if State.Terse_Table then Mark := Get_Mark; end if; declare New_Cursor : Indices := State.Cursor; Block : Tree := T; begin if State.Reverse_Index then New_Cursor (State.Table_Level) := State.Max_Expand - K + 1; else New_Cursor (State.Table_Level) := K; end if; B := 1; while Block /= null loop -- For all blocks in this table if B_State (B).Section = null or else B_State (B).Section.N_Section = null then B_State (B) := (1, Block.Sections); else B_State (B) := (B_State (B).Section_Number + 1, B_State (B).Section.N_Section); end if; Analyze (Block.Common, Parse_State'(State.F_Params'Length, New_Cursor, State.Max_Lines, State.Max_Expand, State.Reverse_Index, State.Table_Level, State.Inline_Sep, State.Filename, State.Blocks_Count, State.I_Params, State.F_Params, Empty_Block_State, State.Terse_Table, L_State'Unchecked_Access)); if Block.Common /= null then Pop_Sep (State); Push_Sep (State); end if; Analyze (Block.Sections, Parse_State'(State.F_Params'Length, New_Cursor, State.Max_Lines, State.Max_Expand, State.Reverse_Index, State.Table_Level, State.Inline_Sep, State.Filename, State.Blocks_Count, State.I_Params, State.F_Params, B_State (B), State.Terse_Table, L_State'Unchecked_Access)); Pop_Sep (State); Push_Sep (State); Block := Block.Next; B := B + 1; end loop; if State.Terse_Table then Rollback (Activate => Output = False, Mark => Mark); end if; end; end loop; Pop_Sep (State); end; when Section_Stmt => Analyze (State.Block.Section.Next, Parse_State'(State.F_Params'Length, State.Cursor, State.Max_Lines, State.Max_Expand, State.Reverse_Index, State.Table_Level, State.Inline_Sep, State.Filename, State.Blocks_Count, State.I_Params, State.F_Params, State.Block, State.Terse_Table, L_State'Unchecked_Access)); when Include_Stmt => if T.I_Filename /= null then -- This is a deferred include file load as the name of the -- include file was not a static string. Flush; Analyze (T.I_Filename); declare Filename : constant String := Buffer (1 .. Last); S_File : Static_Tree; begin Last := 0; -- Removes include filename from the buffer S_File := Load (Build_Include_Pathname (To_String (State.Filename), Filename), Cached, True); if S_File /= T.File then if Cached then if T.File.C_Info /= null then Cached_Files.Release (T.File); end if; else Release (T.File.Info); end if; end if; T.File := S_File; end; end if; Analyze (T.File.Info, Parse_State'(T.I_Params'Length, Cursor => State.Cursor, Max_Lines => State.Max_Lines, Max_Expand => State.Max_Expand, Reverse_Index => State.Reverse_Index, Table_Level => State.Table_Level, Inline_Sep => State.Inline_Sep, Filename => State.Filename, Blocks_Count => State.Blocks_Count, I_Params => T.I_Params, F_Params => Flatten_Parameters (T.I_Params), Block => State.Block, Terse_Table => State.Terse_Table, Parent => L_State'Unchecked_Access)); Analyze (T.Next, State); when Inline_Stmt => Add (To_String (T.Before)); Analyze (T.I_Block, Parse_State'(State.F_Params'Length, Cursor => State.Cursor, Max_Lines => State.Max_Lines, Max_Expand => State.Max_Expand, Reverse_Index => State.Reverse_Index, Table_Level => State.Table_Level, Inline_Sep => T.Sep, Filename => State.Filename, Blocks_Count => State.Blocks_Count, I_Params => State.I_Params, F_Params => State.F_Params, Block => State.Block, Terse_Table => State.Terse_Table, Parent => L_State'Unchecked_Access)); Add (To_String (T.After)); Analyze (T.Next, State); end case; end Analyze; --------------------- -- Get_Association -- --------------------- function Get_Association (Var : Data.Tag_Var) return Association is use type Data.Internal_Tag; use type Dynamic.Lazy_Tag_Access; Name : constant String := To_String (Var.Name); Pos : Association_Map.Cursor; begin Pos := Translations.Set.Find (Name); if Association_Map.Has_Element (Pos) then return Association_Map.Element (Pos); elsif Lazy_Tag /= Dynamic.Null_Lazy_Tag and then not Filter.Is_No_Dynamic (Var.Filters) and then Var.Internal = Data.No then -- Look into the Lazy_Set for the cached value Pos := Lazy_Set.Set.Find (Name); if Association_Map.Has_Element (Pos) then return Association_Map.Element (Pos); else -- Check for Lazy tag Dynamic.Value (Lazy_Tag, Name, Lazy_Set); return Get (Lazy_Set, Name); end if; else return Null_Association; end if; end Get_Association; T : Static_Tree; begin T := Load (Filename, Cached); Now := Ada.Calendar.Clock; -- Used for the time related variable Analyze (T.C_Info, Empty_State); if Cached then Cached_Files.Release (T); else Release (T.Info); end if; -- Flush buffer and return result Append (Results, Buffer (1 .. Last)); return Results; end Parse; ---------------- -- Print_Tree -- ---------------- procedure Print_Tree (T : Tree; Level : Natural := 0) is separate; procedure Print_Tree (Filename : String) is T : Static_Tree; begin T := Load (Filename); Print_Tree (T.Info); Release (T.Info); end Print_Tree; -------------------------- -- Print_Defined_Macros -- -------------------------- procedure Print_Defined_Macros is begin Macro.Print_Defined_Macros; end Print_Defined_Macros; ----------- -- Quote -- ----------- function Quote (Str : String) return String is K : constant Natural := Strings.Fixed.Index (Str, " "); begin if K = 0 and then Str'Length > 0 then return Str; else return '"' & Str & '"'; end if; end Quote; --------------------- -- Register_Filter -- --------------------- procedure Register_Filter (Name : String; Handler : Callback) renames Filter.Register; procedure Register_Filter (Name : String; Handler : Callback_No_Param) renames Filter.Register; procedure Register_Filter (Name : String; Filter : not null access User_Filter'Class) renames Filter.Register; procedure Free_Filters renames Filter.Free_Filters; ----------- -- Macro -- ----------- procedure Register_Macro_Handler (Callback : Macro_Callback) is begin Macro.Callback := Callback; end Register_Macro_Handler; ------------- -- Release -- ------------- procedure Release (T : in out Tree; Include : Boolean := True) is use type Data.Tree; begin if T = null then return; end if; case T.Kind is when Info => declare I : Tree := T.I_File; O : Tree; begin while I /= null loop O := I; I := I.Next; Unchecked_Free (O); end loop; end; Release (T.Next, Include); when C_Info => Release (T.Next, Include); when Text => declare N : Tree := T; Tmp : Tree; begin -- Handles all consecutive Text nodes while N /= null and then N.Kind = Text loop Data.Release (N.Text); Tmp := N; N := N.Next; Unchecked_Free (Tmp); end loop; Release (N, Include); end; T := null; -- T has been freed, we set the pointer to null to avoid double -- deallocation by the call to Free at the end of this routine. when Set_Stmt => Definitions.Release (T.Def); Release (T.Next, Include); when If_Stmt => Expr.Release (T.Cond); Release (T.N_True, Include); Release (T.N_False, Include); Release (T.Next, Include); when Table_Stmt => Release (T.Blocks, Include); Release (T.Next, Include); when Section_Block => Release (T.Sections, Include); Release (T.Common, Include); Release (T.Next, Include); when Section_Stmt => Release (T.Next, Include); Release (T.N_Section, Include); when Include_Stmt => if Include then Release (T.File.Info, Include); for K in T.I_Params'Range loop Data.Release (T.I_Params (K)); end loop; Data.Unchecked_Free (T.I_Params); end if; Release (T.Next, Include); when Inline_Stmt => Release (T.I_Block, Include); Release (T.Next, Include); end case; Unchecked_Free (T); end Release; ------------------- -- Release_Cache -- ------------------- procedure Release_Cache is begin Cached_Files.Release; end Release_Cache; ------------ -- Remove -- ------------ procedure Remove (Set : in out Translate_Set; Name : String) is begin if Set.Set.Contains (Name) then Set.Set.Delete (Name); end if; end Remove; ------------------- -- Set_Separator -- ------------------- procedure Set_Separator (T : in out Tag; Separator : String) is begin T.Data.Separator := To_Unbounded_String (Separator); end Set_Separator; ------------------------ -- Set_Tag_Separators -- ------------------------ procedure Set_Tag_Separators (Start_With : String := Default_Begin_Tag; Stop_With : String := Default_End_Tag) is begin Begin_Tag := To_Unbounded_String (Start_With); End_Tag := To_Unbounded_String (Stop_With); end Set_Tag_Separators; ---------- -- Size -- ---------- function Size (T : Tag) return Natural is begin return T.Data.Count; end Size; function Size (Set : Translate_Set) return Natural is begin return Natural (Set.Set.Length); end Size; ------------------- -- Tag_From_Name -- ------------------- function Tag_From_Name (Name : String) return String is begin return To_String (Begin_Tag) & Name & To_String (End_Tag); end Tag_From_Name; ------------ -- To_Set -- ------------ function To_Set (Table : Translate_Table) return Translate_Set is Set : Translate_Set; begin for K in Table'Range loop Insert (Set, Table (K)); end loop; return Set; end To_Set; --------------- -- Translate -- --------------- function Translate (Template : String; Translations : Translate_Table := No_Translation) return String is begin return Translate (Template, To_Set (Translations)); end Translate; function Translate (Template : String; Translations : Translate_Set) return String is T : Data.Tree := Data.Parse (Template); P : Data.Tree := T; Results : Unbounded_String; function Translate (Var : Data.Tag_Var) return String; -- Returns translation for Var --------------- -- Translate -- --------------- function Translate (Var : Data.Tag_Var) return String is Pos : Association_Map.Cursor; C : aliased Filter.Filter_Context := (0, Translations, null, No_Parameter); begin -- ??? we should probably handle macros there too Pos := Translations.Set.Find (To_String (Var.Name)); if Association_Map.Has_Element (Pos) then declare Item : constant Association := Association_Map.Element (Pos); begin case Item.Kind is when Std => return Data.Translate (Var, To_String (Item.Value), C'Access); when others => return ""; end case; end; end if; return ""; end Translate; use type Data.Tree; begin while P /= null loop case P.Kind is when Data.Text => Append (Results, P.Value); when Data.Var => Append (Results, Translate (P.Var)); end case; P := P.Next; end loop; Data.Release (T); return To_String (Results); end Translate; end Templates_Parser; libtemplates-parser-11.6.orig/src/templates_parser.ads0000644000175000017500000005436311637170657023101 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 1999-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Finalization; with Ada.Strings.Unbounded; private with Ada.Containers.Indefinite_Hashed_Maps; private with Ada.Containers.Indefinite_Hashed_Sets; private with Ada.Strings.Hash; with Templates_Parser_Tasking; pragma Elaborate_All (Templates_Parser_Tasking); pragma Warnings (Off, Templates_Parser_Tasking); -- This unit is not used in the spec but is placed here to force proper -- finalization order. package Templates_Parser is use Ada.Strings.Unbounded; Template_Error : exception; Default_Begin_Tag : constant String := "@_"; Default_End_Tag : constant String := "_@"; Default_Separator : constant String := ", "; procedure Set_Tag_Separators (Start_With : String := Default_Begin_Tag; Stop_With : String := Default_End_Tag); -- Set the tag separators for the whole session. This should be changed as -- the very first API call and should not be changed after. function Tag_From_Name (Name : String) return String; -- Returns the tag given the Name, default is @_NAME_@ ----------------- -- Generic Tag -- ----------------- type Tag is private; -- A tag is using a by reference semantic function "+" (Value : String) return Tag; function "+" (Value : Character) return Tag; function "+" (Value : Boolean) return Tag; function "+" (Value : Unbounded_String) return Tag; function "+" (Value : Integer) return Tag; function "+" (Value : Tag) return Tag; -- Tag constructors function "&" (T : Tag; Value : String) return Tag; function "&" (T : Tag; Value : Character) return Tag; function "&" (T : Tag; Value : Boolean) return Tag; function "&" (T : Tag; Value : Unbounded_String) return Tag; function "&" (T : Tag; Value : Integer) return Tag; function "&" (T : Tag; Value : Tag) return Tag; -- Add Value at the end of the tag, note that "&" will modify its -- first parameter. It is intended to be used as [T := T & "val"], -- doing [T1 := T2 & "val"] will add val to T2 and set T1 as an -- alias. This is designed this way for efficiency. function "&" (Value : String; T : Tag) return Tag; function "&" (Value : Character; T : Tag) return Tag; function "&" (Value : Boolean; T : Tag) return Tag; function "&" (Value : Unbounded_String; T : Tag) return Tag; function "&" (Value : Integer; T : Tag) return Tag; -- Add Value at the front of the tag, see note above procedure Append (T : in out Tag; Value : String); procedure Append (T : in out Tag; Value : Character); procedure Append (T : in out Tag; Value : Boolean); procedure Append (T : in out Tag; Value : Unbounded_String); procedure Append (T : in out Tag; Value : Integer); procedure Append (T : in out Tag; Value : Tag); -- Add Value at the end of tag procedure Set_Separator (T : in out Tag; Separator : String); -- Set separator to be used when building a flat representation of -- a composite tag. procedure Clear (T : in out Tag); -- Removes all values in the tag. Current tag T is not released but -- the returned object is separated (not using the same reference) than -- the original one. function Size (T : Tag) return Natural; -- Returns the number of value into T function Item (T : Tag; N : Positive) return String; -- Returns the Nth Tag's item. Raises Constraint_Error if there is -- no such Item in T (i.e. T length < N). function Composite (T : Tag; N : Positive) return Tag; -- Returns the Nth Tag's item. Raises Constraint_Error if there is -- no such Item in T (i.e. T length < N). subtype Vector_Tag is Tag; subtype Matrix_Tag is Tag; ------------------ -- Associations -- ------------------ type Association is private; Null_Association : constant Association; type Association_Kind is (Std, Composite); -- The kind of association which is either Std (a simple value), a vector -- tag or a Matrix tag. function Assoc (Variable : String; Value : String) return Association; -- Build an Association (Variable = Value) to be added to a -- Translate_Set. This is a standard association, value is a string. function Assoc (Variable : String; Value : Unbounded_String) return Association; -- Build an Association (Variable = Value) to be added to a -- Translate_Set. This is a standard association, value is an -- Unbounded_String. function Assoc (Variable : String; Value : Integer) return Association; -- Build an Association (Variable = Value) to be added to a -- Translate_Set. This is a standard association, value is an Integer. -- It will be displayed without leading space if positive. function Assoc (Variable : String; Value : Boolean) return Association; -- Build an Association (Variable = Value) to be added to a -- Translate_Set. It set the variable to TRUE or FALSE depending on -- value. function Assoc (Variable : String; Value : Tag; Separator : String := Default_Separator) return Association; -- Build an Association (Variable = Value) to be added to Translate_Set. -- This is a tag association. Separator will be used when outputting the -- a flat representation of the Tag (outside a table statement). function Get (Assoc : Association) return Tag; -- Returns the Tag in Assoc, raise Constraint_Error if Assoc is not -- containing a Tag (Association_Kind is Std). -- See also the Templates_Parser.Query package for other functions to -- manipulate associations. function Get (Assoc : Association) return String; -- Returns the value in Assoc, raise Constraint_Error if Assoc is not -- containing a simple value (Association_Kind is Composite). -- See also the Templates_Parser.Query package for other functions to -- manipulate associations. --------------------------- -- Association table/set -- --------------------------- type Translate_Table is array (Positive range <>) of Association; -- A table with a set of associations, note that it is better to use -- Translate_Set below as it is more efficient. No_Translation : constant Translate_Table; type Translate_Set is private; -- This is a set of association like Translate_Table but it is possible to -- insert item into this set more easily, furthermore there is no need to -- know the number of item before hand. This is the object used internally -- by the templates engine as it is far more efficient to retrieve a -- specific item from it. Null_Set : constant Translate_Set; procedure Insert (Set : in out Translate_Set; Item : Association); -- Add Item into the translate set. If an association for this variable -- already exists it just replaces it by the new item. procedure Insert (Set : in out Translate_Set; Items : Translate_Set); -- Add Items into the translate set. If an association for variables in -- Items already exists it just replaces it by the new one. function "&" (Left : Association; Right : Association) return Translate_Set; pragma Inline ("&"); -- Returns new translate set created from 2 associations. If names of -- both associations are the same, the returned translate set will -- contain only Right. function "&" (Set : Translate_Set; Item : Association) return Translate_Set; pragma Inline ("&"); -- Adds Item into Set. If an association with the same name already exists -- in Set it is replaced by the new one. Note that "&" will modify its -- first parameter. It is intended to be used as [T := T & Assoc], -- doing [T1 := T2 & Assoc] will add Assoc into T2 and set T1 as an -- alias. This is designed this way for efficiency. function "+" (Item : Association) return Translate_Set; pragma Inline ("+"); -- Create translate set from one association procedure Remove (Set : in out Translate_Set; Name : String); -- Removes association named Name from the Set. Does nothing if there is -- not such association in the set. function Get (Set : Translate_Set; Name : String) return Association; -- Returns the association named Name in the Set. Returns Null_Association -- is no such association if found in Set. function Size (Set : Translate_Set) return Natural; -- Returns size of the translate set function Exists (Set : Translate_Set; Variable : String) return Boolean; -- Returns True if an association for Variable exists into the Set generic with procedure Action (Item : Association; Quit : in out Boolean); procedure For_Every_Association (Set : Translate_Set); -- Iterates through all associations in the set, call Action for each one. -- Set Quit to True to stop the iteration. function To_Set (Table : Translate_Table) return Translate_Set; -- Convert a Translate_Table into a Translate_Set ------------- -- Dynamic -- ------------- package Dynamic is -------------- -- Lazy_Tag -- -------------- type Lazy_Tag is abstract tagged private; type Lazy_Tag_Access is access all Lazy_Tag'Class; procedure Value (Lazy_Tag : not null access Dynamic.Lazy_Tag; Var_Name : String; Translations : in out Translate_Set) is abstract; -- Value is called by the Parse routines below if a tag variable was not -- found in the set of translations. This routine must then add the -- association for variable Name. It is possible to add other -- associations in the translation table but a check is done to see if -- the variable Name as been set or not. The default implementation does -- nothing. Null_Lazy_Tag : constant Lazy_Tag_Access; ---------------- -- Cursor_Tag -- ---------------- type Cursor_Tag is abstract tagged private; type Cursor_Tag_Access is access all Cursor_Tag'Class; -- In some cases it is difficult and not efficient to have to map all -- Ada data into a template Tag. A Cursor_Tag object gives the ability -- to iterate through a data structure which is living on the Ada side -- only. function Dimension (Cursor_Tag : not null access Dynamic.Cursor_Tag; Var_Name : String) return Natural is abstract; -- Must return the number of dimensions for the given variable name. For -- a matrix this routine should return 2 for example. type Path is array (Positive range <>) of Natural; -- A Path gives the full position of a given element in the cursor tag function Length (Cursor_Tag : not null access Dynamic.Cursor_Tag; Var_Name : String; Path : Dynamic.Path) return Natural is abstract; -- Must return the number of item for the given path. The first -- dimension is given by the Path (1), for the second column the Path is -- (1, 2). Note that each dimension can have a different length. For -- example a Matrix is not necessary square. function Value (Cursor_Tag : not null access Dynamic.Cursor_Tag; Var_Name : String; Path : Dynamic.Path) return String is abstract; -- Must return the value for the variable at the given Path. Note that -- this routine will be called only for valid items as given by the -- Dimension and Length above. Null_Cursor_Tag : constant Cursor_Tag_Access; private type Lazy_Tag is abstract tagged null record; Null_Lazy_Tag : constant Lazy_Tag_Access := null; type Cursor_Tag is abstract tagged null record; Null_Cursor_Tag : constant Cursor_Tag_Access := null; end Dynamic; package Dyn renames Dynamic; -------------------- -- User's Filters -- -------------------- type Filter_Context is record Translations : Translate_Set; Lazy_Tag : Dynamic.Lazy_Tag_Access; end record; type Callback is access function (Value : String; Parameters : String; Context : Filter_Context) return String; -- User's filter callback type Callback_No_Param is access function (Value : String; Context : Filter_Context) return String; -- User's filter callback procedure Register_Filter (Name : String; Handler : Callback); -- Register user's filter Name using the specified Handler procedure Register_Filter (Name : String; Handler : Callback_No_Param); -- Register user's filter Name using the specified Handler type User_Filter is abstract tagged private; type User_Filter_Access is access all User_Filter'Class; function Execute (Filter : not null access User_Filter; Value : String; Parameters : String; Context : Filter_Context) return String is abstract; -- User filters can also be implemented through a tagged type, which allows -- you to add your own user data and reuse a filter in several -- applications, perhaps with a slightly different behavior each time. -- It is possible for the callback to modify the data stored in Filter, but -- this needs to be done with care, since multiple concurrent calls to -- Callback might happen. procedure Register_Filter (Name : String; Filter : not null access User_Filter'Class); -- Register a new filter. Filter must not be freed by the caller, since no -- copy is made. procedure Free_Filters; -- Free all user filters registered above. This is mostly intended when -- you are testing memory leaks in your application. ----------- -- Macro -- ----------- type Parameter_Set is array (Natural range <>) of Unbounded_String; No_Parameter : constant Parameter_Set; type Macro_Callback is access function (Name : String; Parameters : Parameter_Set) return String; procedure Register_Macro_Handler (Callback : Macro_Callback); -- Use the given callbacks for every unknown macro in the template. The -- default implementation of this routine just displays the macro (name -- and parameters). ----------------------------- -- Parsing and Translating -- ----------------------------- function Parse (Filename : String; Translations : Translate_Table := No_Translation; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return String; -- Parse the Template_File replacing variables' occurrences by the -- corresponding values. If Cached is set to True, Filename tree will be -- recorded into a cache for quick retrieval. If Keep_Unknown_Tags is set -- to True then tags that are not in the translate table are kept -- as-is if it is part of the template data. If this tags is part of a -- condition (in an IF statement tag), the condition will evaluate to -- False. function Parse (Filename : String; Translations : Translate_Table := No_Translation; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return Unbounded_String; -- Idem but returns an Unbounded_String function Parse (Filename : String; Translations : Translate_Set; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return String; -- Idem with a Translation_Set function Parse (Filename : String; Translations : Translate_Set; Cached : Boolean := False; Keep_Unknown_Tags : Boolean := False; Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag; Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag) return Unbounded_String; -- Idem with a Translation_Set function Translate (Template : String; Translations : Translate_Table := No_Translation) return String; -- Just translate the discrete variables in the Template string using the -- Translations table. This function does not parse the command tag (TABLE, -- IF, INCLUDE). All composite tags are replaced by the empty string. function Translate (Template : String; Translations : Translate_Set) return String; -- Idem with a Translation_Set procedure Release_Cache; -- Release the internal cache. This free the memory used for all currently -- loaded template trees. private use Ada; type Integer_Access is access Integer; ------------------ -- Generic Tags -- ------------------ type Node_Kind is (Value, Value_Set); type Tag_Access is access Tag; type Tag_Node (Kind : Node_Kind); type Tag_Node_Access is access Tag_Node; type Tag_Node (Kind : Node_Kind) is record Next : Tag_Node_Access; case Kind is when Value => V : Unbounded_String; when Value_Set => VS : Tag_Access; end case; end record; type Tag_Node_Arr is array (Positive range <>) of Tag_Node_Access; type Tag_Node_Arr_Access is access Tag_Node_Arr; package Tag_Values is new Containers.Indefinite_Hashed_Sets (String, Strings.Hash, "="); type Tag_Values_Access is access Tag_Values.Set; -- Map for all tag values to speed-up "in" operator type Tag_Data is record Count : Natural; -- Number of items Min, Max : Natural; -- Min/Max item's sizes, equal to 1 if leaf Nested_Level : Positive; -- Number of composite structures Separator : Unbounded_String; Head : Tag_Node_Access; Last : Tag_Node_Access; Tag_Nodes : Tag_Node_Arr_Access; -- This array will be setup during parsing to ensure fast iteration -- in reverse order. Values : Tag_Values_Access; end record; type Tag_Data_Access is access Tag_Data; type Tag is new Ada.Finalization.Controlled with record Ref_Count : Integer_Access; Data : Tag_Data_Access; end record; overriding procedure Initialize (T : in out Tag); overriding procedure Finalize (T : in out Tag); overriding procedure Adjust (T : in out Tag); subtype Indices is Dynamic.Path; -- Set of indices that reference a specific item into a composite tag. -- Used by the parser. procedure Field (T : Tag; N : Positive; Result : out Tag; Found : out Boolean); -- Returns the N'th item in Tag. Found is set to False is there is no -- such item. ------------------ -- Association -- ------------------ type Association (Kind : Association_Kind := Std) is record Variable : Unbounded_String; case Kind is when Std => Value : Unbounded_String; when Composite => Comp_Value : Tag; end case; end record; Null_Association : constant Association := (Std, Null_Unbounded_String, Null_Unbounded_String); No_Translation : constant Translate_Table := (2 .. 1 => Null_Association); ----------- -- Debug -- ----------- Expand_Macro : Boolean := False; -- If set to true the macro will be displayed inline instead of the named -- reference. procedure Print_Tree (Filename : String); -- Use for debugging purpose only, it will output the internal tree -- representation. procedure Print_Defined_Macros; -- Use for debugging purpose only, output all defined macros -------------------- -- Translate_Set -- -------------------- package Association_Map is new Containers.Indefinite_Hashed_Maps (String, Association, Strings.Hash, "=", "="); type Map_Access is access Association_Map.Map; type Translate_Set is new Ada.Finalization.Controlled with record Ref_Count : Integer_Access; Set : Map_Access; end record; overriding procedure Initialize (Set : in out Translate_Set); overriding procedure Finalize (Set : in out Translate_Set); overriding procedure Adjust (Set : in out Translate_Set); Null_Set : constant Translate_Set := (Ada.Finalization.Controlled with null, null); ------------------ -- User filters -- ------------------ type User_Filter is abstract tagged null record; No_Parameter : constant Parameter_Set := (1 .. 0 => <>); end Templates_Parser; libtemplates-parser-11.6.orig/src/templates_parser_tasking.ads0000755000175000017500000000372411637170657024617 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ package Templates_Parser_Tasking is -- Implements a simple semaphore. There is two implementations for this -- unit, one that is based on a protected object that is required for -- tasking applications and one that does nothing (the tasking runtime is -- not dragged in this configuration). procedure Lock; -- Lock all tasks procedure Unlock; -- Unlock tasks end Templates_Parser_Tasking; libtemplates-parser-11.6.orig/src/templates_parser_tasking__no_tasking.adb0000755000175000017500000000362411637170657027150 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2008 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ package body Templates_Parser_Tasking is ---------- -- Lock -- ---------- procedure Lock is begin null; end Lock; ------------ -- Unlock -- ------------ procedure Unlock is begin null; end Unlock; end Templates_Parser_Tasking; libtemplates-parser-11.6.orig/src/templates_parser_tasking__standard_tasking.adb0000755000175000017500000000603711637170657030335 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2005-2008 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Task_Identification; package body Templates_Parser_Tasking is use Ada.Task_Identification; -- Simple semaphore protected Semaphore is entry Lock; procedure Unlock; private entry Lock_Internal; TID : Task_Id := Null_Task_Id; Lock_Count : Natural := 0; end Semaphore; ---------- -- Lock -- ---------- procedure Lock is begin Semaphore.Lock; end Lock; --------------- -- Semaphore -- --------------- protected body Semaphore is ---------- -- Lock -- ---------- entry Lock when True is begin if TID = Lock'Caller then Lock_Count := Lock_Count + 1; else requeue Lock_Internal; end if; end Lock; ------------------- -- Lock_Internal -- ------------------- entry Lock_Internal when Lock_Count = 0 is begin TID := Lock_Internal'Caller; Lock_Count := 1; end Lock_Internal; ------------ -- Unlock -- ------------ procedure Unlock is begin if TID = Current_Task then Lock_Count := Lock_Count - 1; else raise Tasking_Error; end if; end Unlock; end Semaphore; ------------ -- Unlock -- ------------ procedure Unlock is begin Semaphore.Unlock; end Unlock; end Templates_Parser_Tasking; libtemplates-parser-11.6.orig/templates_parser.gpr0000755000175000017500000000450411637170657022326 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 1999-2008 -- -- AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "tp_xmlada"; with "tp_shared"; project Templates_Parser is for Source_Dirs use ("src"); for Object_Dir use TP_Shared'Exec_Dir & "/obj"; for Library_Dir use TP_Shared'Exec_Dir & "/lib"; for Library_Name use "templates_parser"; for Library_Kind use TP_Shared.Library_Type; case TP_Shared.XMLAda is when "Installed" => for Source_Dirs use project'Source_Dirs & ("xsrc"); when "Disabled" => null; end case; package Naming renames TP_Shared.Naming; package Compiler renames TP_Shared.Compiler; package Binder renames TP_Shared.Binder; package Builder renames TP_Shared.Builder; package Ide renames TP_Shared.Ide; end Templates_Parser; libtemplates-parser-11.6.orig/tools/0000755000175000017500000000000011637170657017374 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/tools/all_urls.thtml0000644000175000017500000000260411637170657022265 0ustar lbrentalbrenta@@-- See extensive documentation for the templates2ada tool in templates.tads @@-- This file is another example of a possible output from templates2ada. @@-- It generates a template that can be included in your own templates to ensure @@-- that links in the HTML code are valid. @@-- @@-- For instance, your templates @@-- would look like: @@-- @@INCLUDE@@ all_urls.html @@-- @@-- which, although less readable, ensures that your links are valid. @@-- @@-- Since this template cannot contain special templates parser commands for the @@-- generated template, you need to post-process the generated file. One example @@-- for this is: @@-- templates2ada -d templates_dir/ -o generated -r -t all_urls.thtml @@-- sed -e 's/^@@ /@@/' generated > all_urls.html @@-- @@-- @@TABLE@@ @@ ---------------------------------------------------------------------------------- @@ -- ------- @_BASENAME_@ @@ ---------------------------------------------------------------------------------- @@TABLE@@ @@IF@@ not @_IS_EMPTY:URL_@ @@ SET@@ URI_@_CAPITALIZE:REPLACE_ALL(\./_):BASENAME'UP_LEVEL_@ = "@_URL_@" @@END_IF@@ @@END_TABLE@@ @@TABLE@@ @@IF@@ not @_IS_EMPTY:HTTP_@ and @_FROM_GET_@ @@ SET@@ HTTP_@_CAPITALIZE:REPLACE_ALL(\./_):BASENAME'UP_LEVEL_@__@_HTTP_@ = "@_HTTP_@" @@END_IF@@ @@END_TABLE@@ @@END_TABLE@@ libtemplates-parser-11.6.orig/tools/templates.tads0000644000175000017500000002606311637170657022256 0ustar lbrentalbrenta@@-- This template is intended as a model of how to generate an Ada package @@-- describing all the variables used in a set of AWS templates. @@-- These Ada packages can then be used in your application to avoid @@-- hard-coded strings, and help maintain the templates and the code to @@-- parse them in sync. @@-- @@-- This template contains two possible behaviors, chosen through the @@-- following variable: @@SET@@ SINGLE_FILE = False @@-- If you set it to True, then a single Ada package with its nested @@-- packages is generated. If you set it to False, then the file generated @@-- should be further processed through gnatchop, to generate several @@-- Ada files organized into several files. This latter organization @@-- avoids recompiling all your source files every time at least one @@-- template changes. @@-- @@-- The following variable should be changed to set the name of the @@-- generated packages. @@SET@@ PACKAGE = Templates @@-- @@-- @@-- When designing your own template for Ada packages, you should take @@-- into account that the variables in your templates might not necessarily @@-- be valid Ada identifier names, and you should therefore update the calls @@-- to @_REPLACE:..._@ below. @@-- @@-- This template example also assumes a convention for Lazy_Tags. If you @@-- are using such types, they are generally shared among templates, and @@-- the Ada package should reflect that fact. Assuming all such tags start @@-- with the prefix LAZY_, we generate one special package for them, and @@-- omit them in all the other packages. @@-- @@-- Likewise, the templates2ada tool will not generate tag entries for tags @@-- that are set through a @@SET@@ statement, since these are purely internal @@-- to your template file and have no impact on your source code. @@-- @@-- For the best use of this tool, it is recommended that your template not @@-- use @@INCLUDE@@ statements, but instead use a tag, set in the Ada code @@-- to the preprocessed result of the same template file. This allows you to @@-- better control unset tags. For instance, instead of using: @@-- @@INCLUDE@@ foo.thtml @@-- use something like: @@-- @_BLOCK_FOO_@ @@-- and in your Ada code set BLOCK_FOO to the result of Parse ("foo.thtml"). @@-- @@-- The templates2ada tool is able to generate constants for the HTTP @@-- parameters set in your page, so that you can process them in your Ada @@-- code. A few conventions must be followed, however: @@-- - The name should be on a single line, preceded by "name=", as in @@-- name="FOO" @@-- - The name should use only letters, underscores and digits, unless you @@-- enhance the regular expressions below to also remove other special @@-- characters. @@-- - In some cases, you must use a AWS tag in the name of an HTTP param, @@-- for instance for checkboxes for which names should be unique (or you @@-- won't know when the parameter is set to false). In this case, the @@-- tag must be at the beginning or end of the name, not in the middle. @@-- If there are multiple tags, they should be separated by non-letters, @@-- as in: @@-- name="PN_@_TAG1_@:@_TAG2_" @@-- In this case, the following constant is generated: @@-- PN_Prefix : constant String := "PN"; @@-- - The name mustn't be only an AWS tag. The following is invalid: @@-- name="@_TAG_@" @@-- To avoid generating constants for , you must put the name @@-- attribute right after the " Ext'Length and then Simple (Simple'Last - Ext'Length + 1 .. Simple'Last) = Ext then Process_Template (Directories.Compose (Relative_Directory, Directories.Simple_Name (Dir_Ent))); end if; end; String_Lists.Next (C); end loop; end if; end loop; Directories.End_Search (Search); exception when Text_IO.Name_Error => Text_IO.Put_Line ("Can't find template directory " & Relative_Directory); end Foreach_Template; --------------- -- Next_Line -- --------------- function Next_Line (Str : String; Index : Integer) return Integer is Result : Integer := Index; begin while Result <= Str'Last and then Str (Result) /= ASCII.LF loop Result := Result + 1; end loop; return Result + 1; end Next_Line; --------------- -- Next_Word -- --------------- procedure Next_Word (Str : String; Index : Integer; Starts_At : out Integer; Ends_At : out Integer) is begin Find_Token (Str (Index .. Str'Last), N_Word_Set, Strings.Outside, Starts_At, Ends_At); if Ends_At = 0 then Ends_At := Str'Last; end if; end Next_Word; ----------------- -- Output_File -- ----------------- procedure Output_File is use Maps, Sets; Template : constant String := To_String (Opt_Template); Output : Text_IO.File_Type; T : Translate_Set; C : Maps.Cursor := First (All_Templates); C2 : Sets.Cursor := First (All_Variables); Variables : Tag; Filenames : Tag; Bases : Tag; Variables_List : Tag; Includes : Tag; HTTPS : Tag; URLs : Tag; From_Get : Tag; Ajax_Event : Tag; Ajax_Action : Tag; Ajax_File : Tag; Set_Var, Set_Val : Tag; begin while Has_Element (C) loop Append (Variables, Element (C).Variables); Append (Filenames, Element (C).Filename); Append (Bases, Key (C)); Append (Includes, Element (C).Included); Append (HTTPS, Element (C).HTTP); Append (From_Get, Element (C).From_Get); Append (URLs, Element (C).URL); Append (Ajax_Event, Element (C).Ajax_Event); Append (Ajax_Action, Element (C).Ajax_Action); Append (Ajax_File, Element (C).Ajax_File); Append (Set_Var, Element (C).Set_Var); Append (Set_Val, Element (C).Set_Val); Next (C); end loop; while Has_Element (C2) loop Variables_List := Variables_List & Element (C2); Next (C2); end loop; Insert (T, Assoc ("VARIABLE", Variables)); Insert (T, Assoc ("FILENAME", Filenames)); Insert (T, Assoc ("BASENAME", Bases)); Insert (T, Assoc ("VARIABLE_LIST", Variables_List)); Insert (T, Assoc ("INCLUDE", Includes)); Insert (T, Assoc ("HTTP", HTTPS)); Insert (T, Assoc ("FROM_GET", From_Get)); Insert (T, Assoc ("URL", URLs)); Insert (T, Assoc ("AJAX_EVENT", Ajax_Event)); Insert (T, Assoc ("AJAX_ACTION", Ajax_Action)); Insert (T, Assoc ("AJAX_FILE", Ajax_File)); Insert (T, Assoc ("SET_VAR", Set_Var)); Insert (T, Assoc ("SET_VAL", Set_Val)); Text_IO.Create (Output, Text_IO.Out_File, To_String (Opt_Output)); if Directories.Exists (Template) then Text_IO.Put (Output, Parse (Template, T)); else Text_IO.Put (Output, Parse (Utils.Get_Program_Directory & ".." & Directory_Separator & "share" & Directory_Separator & "examples" & Directory_Separator & "aws" & Directory_Separator & "templates" & Directory_Separator & Template, T)); end if; Text_IO.Close (Output); exception when Text_IO.Name_Error => Text_IO.Put_Line ("Can't find template file : " & To_String (Opt_Template)); end Output_File; ---------------------- -- Process_Template -- ---------------------- procedure Process_Template (Relative_Name : String) is use Ada.Streams, Ada.Streams.Stream_IO; use Sets; Result : Unbounded_String; File : Ada.Streams.Stream_IO.File_Type; Seen, Include, HTTP, URL : Sets.Set; To_Ignore : Sets.Set; Variables, Includes, HTTPS : Tag; URLs, From_Get : Tag; Ajax_Event, Ajax_Action : Tag; Ajax_File : Tag; Set_Var, Set_Val : Tag; C : Sets.Cursor; Inserted : Boolean; pragma Unreferenced (Result); procedure Process_Tag (Str : String; S : in out Integer); -- Process some text surrounded by @_..._@, and add it to the proper -- output tags. S points to the "@_" in Str, and is modified to -- point after the closing "_@". procedure Process_Tags (Str : String; First, Last : Integer); -- Process all tags referenced in Str (First .. Last) ----------------- -- Process_Tag -- ----------------- procedure Process_Tag (Str : String; S : in out Integer) is First : Integer := S + 2; Last : Integer := First; Parents_Nesting : Natural := 0; Macro : Boolean := False; begin while Last < Str'Last loop if Str (Last) = ':' then First := Last + 1; elsif Str (Last .. Last + 2) = ")_@" then Macro := True; exit; elsif Str (Last .. Last + 1) = "_@" then exit; end if; Last := Last + 1; end loop; if Macro then -- First word is the macro name, check if this is a AWS/Ajax macro S := S + 2; Next_Word (Str, S, First, Last); S := Last + 1; if Str (First .. Last) = "JS_ACTION" then -- First parameter is the event Next_Word (Str, S, First, Last); Append (Ajax_Event, Str (First .. Last)); S := Last + 1; -- Second parameter is the action Next_Word (Str, S, First, Last); Append (Ajax_Action, Str (First .. Last)); S := Last + 1; -- Record Ajax file location Append (Ajax_File, Directories.Base_Name (Relative_Name)); end if; else -- Special case: a convention is that user-defined scripts -- might accept arguments that reference other tags, by using -- the syntax @_FILTER(@param):..._@, ie the parameter starts -- with a single @ sign. In this case, we want to make sure -- there is a entry made for the argument as well. Such -- filters might have multiple arguments. Multiple arguments -- must be comma-separated. for A in S + 2 .. Last - 1 loop if Str (A) = '(' then Parents_Nesting := Parents_Nesting + 1; elsif Str (A) = ')' then Parents_Nesting := Parents_Nesting - 1; elsif Str (A) = '@' and then Parents_Nesting > 0 and then (Str (A - 1) = ',' or else Str (A - 1) = '(') then for B in A + 1 .. Last - 1 loop if Str (B) = ',' or else Str (B) = ')' then Insert (Seen, Str (A + 1 .. B - 1), C, Inserted); Insert (All_Variables, Str (A + 1 .. B - 1), C, Inserted); exit; end if; end loop; end if; end loop; -- Remove attributes (can't be done in the loop above, because -- of complex structures like ADD_PARAM(AI='...'):PARAMETERS. for F in reverse First .. Last - 1 loop if Str (F) = ''' then Last := F; exit; end if; end loop; if Str (First) /= '$' and then Str (First .. Last - 1) /= "TABLE_LINE" and then Str (First .. Last - 1) /= "UP_TABLE_LINE" and then Str (First .. Last - 1) /= "NUMBER_LINE" then Insert (Seen, Str (First .. Last - 1), C, Inserted); Insert (All_Variables, Str (First .. Last - 1), C, Inserted); end if; S := Last + 2; end if; end Process_Tag; ------------------ -- Process_Tags -- ------------------ procedure Process_Tags (Str : String; First, Last : Integer) is S : Integer := First; begin while S < Last loop if Str (S .. S + 1) = "@_" then Process_Tag (Str, S); else S := S + 1; end if; end loop; end Process_Tags; begin -- We cannot use the templates parser, since it wouldn't process -- correctly the @@IF@@ statements, and would only see one branch of -- them. Open (File, In_File, Relative_Name); declare Last, Last_Save : Integer; S, First : Integer; Str : String (1 .. Integer (Size (File))); begin String'Read (Stream (File), Str); S := Str'First; while S < Str'Last loop if S + 13 <= Str'Last and then Str (S .. S + 13) = "@@-- HTTP_GET(" then Next_Word (Str, S + 14, First, Last); if not Contains (HTTP, Str (First .. Last)) then Insert (HTTP, Str (First .. Last) & HTTP_Get_Suffix, C, Inserted); end if; S := Next_Line (Str, Last + 1); elsif S + 13 <= Str'Last and then Str (S .. S + 13) = "@@-- HTTP_URL(" then Next_Word (Str, S + 14, First, Last); Insert (URL, Str (First .. Last), C, Inserted); S := Next_Line (Str, Last + 1); elsif S + 4 <= Str'Last and then Str (S .. S + 3) = "@@--" then S := Next_Line (Str, S + 4); elsif S + 11 <= Str'Last and then Str (S .. S + 11) = "@@SET@@ SET_" then Next_Word (Str, S + 7, First, Last); Append (Set_Var, Str (First .. Last)); S := Last + 1; Next_Word (Str, S, First, Last); S := Last + 1; Next_Word (Str, S, First, Last); Append (Set_Val, Str (First .. Last)); elsif S + 6 <= Str'Last and then Str (S .. S + 6) = "@@SET@@" then Next_Word (Str, S + 7, First, Last); Insert (To_Ignore, Str (First .. Last), C, Inserted); -- The value of the variable could be either static or come -- from one or more other tags. We need to parse it, as a -- result. S := Next_Line (Str, Last + 1); Process_Tags (Str, Last + 1, S - 1); elsif Str (S .. S + 1) = "@_" then Process_Tag (Str, S); elsif S + 10 < Str'Last and then Str (S .. S + 10) = "@@INCLUDE@@" then Next_Word (Str, S + 12, First, Last); -- We could either have "@@INCLUDE@@ static_name.html" -- or "@@INCLUDE@@ @_TAG_@". In the latter case we need to -- handle the tag as usual. Process_Tags (Str, First, Last); Insert (Include, Directories.Base_Name (Str (First .. Last)), C, Inserted); S := Last + 2; -- Check for AWS/Ajax actions. AWS/Ajax is based on include -- files whose name is starting with "aws_action_". The first -- parameter being the event and the second the action. We use -- this naming scheme here. -- -- @@INCLUDE@@ aws_action_xml.tjs (onclick, form_enter ...) if Index (Str (First .. Last), "aws_action_") /= 0 then -- First parameter is the event Next_Word (Str, S, First, Last); Append (Ajax_Event, Str (First .. Last)); S := Last + 1; -- Second parameter is the action Next_Word (Str, S, First, Last); Append (Ajax_Action, Str (First .. Last)); S := Last + 1; -- Record Ajax file location Append (Ajax_File, Directories.Base_Name (Relative_Name)); end if; elsif S + 8 < Str'Last and then Str (S .. S + 8) = "= Str'First and then Str (Last) = '@' loop Last := Search (Str, Last, "@_", Forward => False) - 1; while Last in Str'Range and then not Is_Letter (Str (Last)) and then Str (Last) /= '@' loop Last := Last - 1; end loop; end loop; if Opt_Verbose and then Last - First < 0 then Text_IO.Put_Line ("Can't process HTTP parameter: " & Str (S + 6 .. Last_Save) & " in template " & Relative_Name); end if; -- We do not insert the parameter in case a matching -- HTTP_GET parameter has already been inserted otherwise -- we end up with duplicated constants in the HTTP package. if First in Str'Range and then Last in Str'Range and then Last - First >= 0 and then not Contains (HTTP, Str (First .. Last) & HTTP_Get_Suffix) then Insert (HTTP, Str (First .. Last), C, Inserted); end if; S := Last + 2; else S := S + 1; end if; end loop; end; C := First (Seen); while Has_Element (C) loop if not Contains (To_Ignore, Element (C)) then Variables := Variables & Element (C); end if; Next (C); end loop; C := First (Include); while Has_Element (C) loop Includes := Includes & Element (C); Next (C); end loop; C := First (HTTP); while Has_Element (C) loop declare Name : constant String := Element (C); begin if Name'Length > 2 and then Name (Name'Last - HTTP_Get_Suffix'Length + 1 .. Name'Last) = HTTP_Get_Suffix then HTTPS := HTTPS & Name (Name'First .. Name'Last - HTTP_Get_Suffix'Length); From_Get := From_Get & True; else HTTPS := HTTPS & Name; From_Get := From_Get & False; end if; end; Next (C); end loop; C := First (URL); while Has_Element (C) loop URLs := URLs & Element (C); Next (C); end loop; Maps.Insert (All_Templates, Directories.Base_Name (Relative_Name), (+Relative_Name, Variables, Includes, HTTPS, From_Get, URLs, Ajax_Event, Ajax_Action, Ajax_File, Set_Var, Set_Val)); exception when Text_IO.Name_Error => Text_IO.Put_Line ("Can't open template file : " & Relative_Name); end Process_Template; ------------ -- Search -- ------------ function Search (Str : String; Index : Integer; Pattern : String; Forward : Boolean := True) return Integer is Result : Integer; begin if Forward then Result := Index; while Result <= Str'Last - Pattern'Length + 1 loop if Str (Result .. Result + Pattern'Length - 1) = Pattern then return Result; end if; Result := Result + 1; end loop; else Result := Index - Pattern'Length + 1; while Result >= Str'First loop if Str (Result .. Result + Pattern'Length - 1) = Pattern then return Result; end if; Result := Result - 1; end loop; end if; return Integer'First; end Search; begin loop case Getopt ("o: d: e: t: r v h") is when 'd' => Opt_Templates_Dir := +Parameter; when 'o' => Opt_Output := +Parameter; when 'e' => Opt_Templates_Ext.Append (Parameter); when 't' => Opt_Template := +Parameter; when 'r' => Opt_Recursive := True; when 'v' => Opt_Verbose := True; when 'h' => Help := True; when others => exit; end case; end loop; if Opt_Templates_Ext.Is_Empty then Opt_Templates_Ext.Append (Default_Template_Extension); end if; if Help or else Ada.Command_Line.Argument_Count = 0 then Text_IO.New_Line; Text_IO.Put_Line ("Usage: templates2ada [options]"); Text_IO.New_Line; Text_IO.Put_Line (" -d dir : template directory"); Text_IO.Put_Line (" -o file : output filename (" & To_String (Opt_Output) & ')'); Text_IO.Put_Line (" -e ext : template filename's extension (" & Default_Template_Extension & ')'); Text_IO.Put_Line (" -t tmplt : template filename (" & To_String (Opt_Template) & ')'); Text_IO.Put_Line (" -r : search for templates file recursively"); Text_IO.Put_Line (" -v : verbose mode"); Text_IO.Put_Line (" -h : display this help message"); Text_IO.New_Line; else Foreach_Template (To_String (Opt_Templates_Dir)); Output_File; end if; end Templates2Ada; libtemplates-parser-11.6.orig/tools/templatespp.adb0000644000175000017500000000701611637170657022406 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2008-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- This tool parses a file specified on the command line, and generates -- another file. It can be used as a preprocessor. with Ada.Command_Line; with Ada.Strings.Unbounded; with Ada.Text_IO; with GNAT.Command_Line; with Templates_Parser; procedure TemplatesPP is use Ada; use Ada.Command_Line; use Ada.Strings.Unbounded; use GNAT.Command_Line; procedure Help; -- Print help message procedure Process (In_File : String; Output : Text_IO.File_Type); -- Parses In_File, and print the result to Output ---------- -- Help -- ---------- procedure Help is begin Text_IO.Put_Line ("Pre-processor based on the templates parser"); Text_IO.Put_Line (Command_Name & " [-o output] file"); Text_IO.Put_Line (" Parses file and generate output file (or display on stdout)"); end Help; ------------- -- Process -- ------------- procedure Process (In_File : String; Output : Text_IO.File_Type) is begin Text_IO.Put_Line (Output, Templates_Parser.Parse (In_File)); end Process; F : Text_IO.File_Type; Output_File : Unbounded_String; begin loop case Getopt ("o: h -help") is when 'h' => Help; return; when '-' => if Full_Switch = "-help" then Help; return; end if; when 'o' => Output_File := To_Unbounded_String (Parameter); when others => exit; end case; end loop; declare Input : constant String := Get_Argument; begin if Input = "" then Help; elsif Output_File = Null_Unbounded_String then Process (Input, Text_IO.Standard_Output); else Text_IO.Create (F, Text_IO.Out_File, To_String (Output_File)); Process (Input, F); Text_IO.Close (F); end if; end; exception when Text_IO.Name_Error => Text_IO.Put_Line ("Input file not found"); end TemplatesPP; libtemplates-parser-11.6.orig/tools/tools.gpr0000644000175000017500000000377011637170657021255 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2008-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with "../templates_parser"; with "../tp_shared"; project Tools is for Source_Dirs use ("."); for Object_Dir use "../" & TP_Shared'Exec_Dir & "/tobj"; for Exec_Dir use "../" & TP_Shared'Exec_Dir & "/bin"; for Main use ("templates2ada", "templatespp"); package Builder renames TP_Shared.Builder; package Compiler renames TP_Shared.Compiler; package Binder renames TP_Shared.Binder; package Ide renames TP_Shared.Ide; end Tools; libtemplates-parser-11.6.orig/tp_shared.gpr0000644000175000017500000001076511637170657020730 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2008-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ project TP_Shared is for Source_Dirs use (); type Build_Type is ("Debug", "Release"); Build : Build_Type := external ("PRJ_BUILD", "Debug"); type Tasking_Type is ("No_Tasking", "Standard_Tasking"); Tasking : Tasking_Type := external ("TP_TASKING", "Standard_Tasking"); type XMLAda_Type is ("Installed", "Disabled"); XMLAda : XMLAda_Type := external ("TP_XMLADA", "Disabled"); type Library_Kind is ("relocatable", "static"); Library_Type : Library_Kind := external ("LIBRARY_TYPE", "static"); type Target_Type is ("native", "vxworks"); Target : Target_Type := external ("PLATFORM", "native"); Processors := External ("PROCESSORS", "2"); ----------------------- -- Build directories -- ----------------------- for Exec_Dir use ".build/" & Target; case Build is when "Debug" => for Exec_Dir use Project'Exec_Dir & "/debug"; when "Release" => for Exec_Dir use Project'Exec_Dir & "/release"; end case; case Library_Type is when "static" => for Exec_Dir use Project'Exec_Dir & "/static"; when "relocatable" => for Exec_Dir use Project'Exec_Dir & "/relocatable"; end case; ------------ -- Naming -- ------------ package Naming is for Specification ("Templates_Parser.Configuration") use "templates_parser-configuration__standalone.ads"; for Implementation ("Templates_Parser.Input") use "templates_parser-input__standalone.adb"; case Tasking is when "No_Tasking" => for Implementation ("Templates_Parser_Tasking") use "templates_parser_tasking__no_tasking.adb"; when "Standard_Tasking" => for Implementation ("Templates_Parser_Tasking") use "templates_parser_tasking__standard_tasking.adb"; end case; end Naming; -------------- -- Compiler -- -------------- Common_Options := ("-gnat05", "-gnatwcfijkmruv", "-gnaty3abcefhiIklmnoprstx", "-Wall"); -- Common options used for the Debug and Release modes Debug_Options := ("-g", "-gnata", "-gnatVa", "-gnatQ", "-gnato", "-gnatwe", "-gnatyO"); Release_Options := ("-O2", "-gnatn"); package Compiler is case Build is when "Release" => for Default_Switches ("Ada") use Common_Options & Release_Options; when "Debug" => for Default_Switches ("Ada") use Common_Options & Debug_Options; end case; end Compiler; ------------ -- Binder -- ------------ package Binder is for Default_Switches ("Ada") use ("-E"); end Binder; ------------- -- Builder -- ------------- package Builder is for Default_Switches ("Ada") use ("-m", "-j" & Processors); end Builder; --------- -- Ide -- --------- type VCS_Type is ("Subversion", "Git"); VCS_Kind : VCS_Type := external ("PRJ_VCS", "Git"); package Ide is for VCS_Kind use VCS_Kind; end Ide; end TP_Shared; libtemplates-parser-11.6.orig/xsrc/0000755000175000017500000000000011637170657017213 5ustar lbrentalbrentalibtemplates-parser-11.6.orig/xsrc/ChangeLog0000755000175000017500000000126411637170657020773 0ustar lbrentalbrenta2005-09-16 Pascal Obry * templates_parser-xml.adb: Fix call to Replace_Element to conform to the latest spec. Fix build failure with recent GNAT versions. Minor reformatting. 2005-09-14 Pascal Obry * templates_parser-xml.adb: Use Ada.Containers instead of internal AI302. Update copyright notice. 2005-05-14 Pascal Obry * templates_parser-xml.adb: (Output_Tag): Add use type clause for Indices to fix build failure when building in XML/Ada mode. 2005-02-12 Pascal Obry * templates_parser-xml.ads templates_parser-xml.adb: Moved here from top xsrc/ directory. Update copyright notice. libtemplates-parser-11.6.orig/xsrc/templates_parser-xml.adb0000755000175000017500000010355711637170657024051 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2010, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Fixed; with Ada.Text_IO; with DOM.Core.Nodes; with DOM.Readers; with Input_Sources.File; with Input_Sources.Strings; with Sax.Readers; with Unicode.CES.Basic_8bit; with Unicode.CES.Utf8; with Templates_Parser.Utils; package body Templates_Parser.XML is Labels_Suffix : constant String := "_LABELS"; Description_Suffix : constant String := "_DESCRIPTION"; package Str_Map is new Containers.Indefinite_Hashed_Maps (String, Unbounded_String, Strings.Hash, "=", "="); function Parse_Document (Doc : DOM.Core.Node) return Translate_Set; -- Parse a document node and return the corresponding Translate_Set ----------- -- Image -- ----------- function Image (Translations : Translate_Set) return Unbounded_String is Result : Unbounded_String; procedure Process (Cursor : Association_Map.Cursor); -- Iterator procedure Add (Str : String); pragma Inline (Add); -- Add a new line (str) into Result, a LF is added at the end of Str function To_Utf8 (Str : Unbounded_String) return String; -- Convert Str to UTF8 --------- -- Add -- --------- procedure Add (Str : String) is begin Append (Result, Str & ASCII.LF); end Add; ------------- -- Process -- ------------- procedure Process (Cursor : Association_Map.Cursor) is Item : constant Association := Association_Map.Element (Cursor); -- Current item Var : constant String := To_Utf8 (Item.Variable); -- Item variable name procedure Process_Std; -- Handles standard variables procedure Process_Composite; -- Handles composite variables procedure Add_Description (Var : String); -- Add var description for Var if found in the translation set function Is_Labels return Boolean; -- Returns True if Item is a Label entry function Is_Description return Boolean; -- Returns True if Item is a Description entry --------------------- -- Add_Description -- --------------------- procedure Add_Description (Var : String) is Var_Description : constant String := Var & Description_Suffix; begin if Translations.Set.Contains (Var_Description) then -- There is probably a label encoded into this set declare Description : constant Association := Translations.Set.Element (Var_Description); begin if Description.Kind = Std and then Description.Value /= "" then -- Definitly a label for this variable Add (" " & To_Utf8 (Description.Value) & ""); end if; end; end if; end Add_Description; -------------------- -- Is_Description -- -------------------- function Is_Description return Boolean is N, L : Natural; begin if Var'Length > Description_Suffix'Length and then Var (Var'Last - Description_Suffix'Length + 1 .. Var'Last) = Description_Suffix and then Translations.Set.Contains (Var (Var'First .. Var'Last - Description_Suffix'Length)) then return True; end if; -- Nested tag description N := Strings.Fixed.Index (Var, "_DIM"); if N = 0 or else Var (N + 4) not in '0' .. '9' then return False; else L := N - 1; -- Last character for the tag name N := N + 4; -- First character after _DIM loop N := N + 1; exit when Var (N) = '_' or else N = Var'Last; if Var (N) not in '0' .. '9' then -- Not a digit here, this is not a label return False; end if; end loop; return Var (N .. Var'Last) = Description_Suffix and then Translations.Set.Contains (Var (Var'First .. L)); end if; end Is_Description; --------------- -- Is_Labels -- --------------- function Is_Labels return Boolean is N, L : Natural; begin N := Strings.Fixed.Index (Var, "_DIM"); if N = 0 or else Var (N + 4) not in '0' .. '9' then return False; else L := N - 1; -- Last character for the tag name N := N + 4; -- First character after _DIM loop N := N + 1; exit when Var (N) = '_' or else N = Var'Last; if Var (N) not in '0' .. '9' then -- Not a digit here, this is not a label return False; end if; end loop; return Var (N .. Var'Last) = Labels_Suffix and then Translations.Set.Contains (Var (Var'First .. L)); end if; end Is_Labels; ----------------------- -- Process_Composite -- ----------------------- procedure Process_Composite is Null_Indice : constant Indices := (2 .. 1 => 0); procedure Output_Tag (T : Tag; Pos : Indices := Null_Indice); -- Output recursively tag T, Pos is the current indices for the -- parsed items. procedure Output_Axis (N : Positive; T : Tag); -- Output labels and description for axis number N. Labels are -- found in tag T. T must be a vector tag (Nested_Level = 1). ----------------- -- Output_Axis -- ----------------- procedure Output_Axis (N : Positive; T : Tag) is P : Tag_Node_Access := T.Data.Head; K : Positive := 1; begin pragma Assert (T.Data.Nested_Level = 1); Add (" "); Add_Description (Var & "_DIM" & Utils.Image (N)); Add (" "); while P /= null loop Add (" "); K := K + 1; P := P.Next; end loop; Add (" "); Add (" "); end Output_Axis; ---------------- -- Output_Tag -- ---------------- procedure Output_Tag (T : Tag; Pos : Indices := Null_Indice) is use type Indices; procedure Output_Value (Pos : Indices; Value : String); -- Output value whose Tag indices is given by Pos ------------------ -- Output_Value -- ------------------ procedure Output_Value (Pos : Indices; Value : String) is V : Unbounded_String; begin Append (V, " "); for K in Pos'Range loop Append (V, "" & Utils.Image (Pos (K)) & ""); end loop; Append (V, "" & Value & ""); Add (To_Utf8 (V)); end Output_Value; N : Tag_Node_Access := T.Data.Head; P : Positive := 1; begin while N /= null loop if N.Kind = Value then Output_Value (Pos & Indices'(1 => P), To_Utf8 (N.V)); else Output_Tag (N.VS.all, Pos & Indices'(1 => P)); end if; P := P + 1; N := N.Next; end loop; end Output_Tag; begin Add (" "); Add (" "); Add (" " & Var & ""); Add_Description (Var); Add (" "); -- Output axis labels for K in 1 .. Item.Comp_Value.Data.Nested_Level loop declare Label_Var : constant String := Var & "_DIM" & Utils.Image (K) & Labels_Suffix; begin if Translations.Set.Contains (Label_Var) then declare Item : constant Association := Translations.Set.Element (Label_Var); begin if Item.Kind = Composite and then Item.Comp_Value.Data.Nested_Level = 1 then -- This is a vector tag, labels are expected to -- be found on this vector. Output_Axis (K, Item.Comp_Value); end if; end; end if; end; end loop; -- Output values Output_Tag (Item.Comp_Value); Add (" "); end Process_Composite; ----------------- -- Process_Std -- ----------------- procedure Process_Std is begin Add (" "); Add (" "); Add (" " & Var & ""); Add_Description (Var); Add (" "); Add (" " & To_Utf8 (Item.Value) & ""); Add (" "); end Process_Std; begin -- Do not process labels encoded for another variable if not Is_Labels and then not Is_Description then case Item.Kind is when Std => Process_Std; when Composite => Process_Composite; end case; end if; end Process; ------------- -- To_Utf8 -- ------------- function To_Utf8 (Str : Unbounded_String) return String is use Unicode.CES; begin return Utf8.From_Utf32 (Basic_8bit.To_Utf32 (To_String (Str))); end To_Utf8; begin -- XML header Add (""); Add (""); Translations.Set.Iterate (Process'Access); -- XML footer Add (""); return Result; end Image; ---------- -- Load -- ---------- function Load (Filename : String) return Translate_Set is use DOM.Core; use DOM.Core.Nodes; use DOM.Readers; use Input_Sources; use Sax.Readers; Reader : Tree_Reader; Input : File.File_Input; Doc : DOM.Core.Document; Result : Translate_Set; begin File.Open (Filename, Input); Set_Feature (Reader, Sax.Readers.Namespace_Prefixes_Feature, True); Parse (Reader, Input); File.Close (Input); Doc := Get_Tree (Reader); Result := Parse_Document (Doc); Free (Doc); return Result; end Load; -------------------- -- Parse_Document -- -------------------- function Parse_Document (Doc : DOM.Core.Node) return Translate_Set is use DOM.Core; use DOM.Core.Nodes; use DOM.Readers; use Input_Sources; use Sax.Readers; procedure Error (Node : DOM.Core.Node; Message : String); pragma No_Return (Error); -- Raises Constraint_Error with the Message as exception message function First_Child (Parent : DOM.Core.Node) return DOM.Core.Node; -- Returns first child, skips #text node function Next_Sibling (N : DOM.Core.Node) return DOM.Core.Node; -- Returns next sibling, skip #text nodes function Parse_Tagged (N : DOM.Core.Node) return Translate_Set; -- Parse tagged entity function Parse_SimpleTag (N : DOM.Core.Node) return Translate_Set; -- Parse a SimpleTag entity function Parse_CompositeTag (N : DOM.Core.Node) return Translate_Set; -- Parse CompositeTag entity procedure Parse_Tag (N : DOM.Core.Node; Name, Description : out Unbounded_String); -- Parse a Tag node, set Name and Description function Get_Value (N : DOM.Core.Node) return String; -- Returns N value or the empty string if N is null ----------- -- Error -- ----------- procedure Error (Node : DOM.Core.Node; Message : String) is Name : constant String := Local_Name (Node); begin raise Constraint_Error with Name & " - " & Message; end Error; ----------------- -- First_Child -- ----------------- function First_Child (Parent : DOM.Core.Node) return DOM.Core.Node is N : DOM.Core.Node; begin N := DOM.Core.Nodes.First_Child (Parent); while N /= null and then DOM.Core.Nodes.Node_Name (N) = "#text" loop N := DOM.Core.Nodes.Next_Sibling (N); end loop; return N; end First_Child; --------------- -- Get_Value -- --------------- function Get_Value (N : DOM.Core.Node) return String is use Unicode.CES; begin if N = null then return ""; else return Basic_8bit.From_Utf32 (Utf8.To_Utf32 (Node_Value (N))); end if; end Get_Value; ------------------ -- Next_Sibling -- ------------------ function Next_Sibling (N : DOM.Core.Node) return DOM.Core.Node is M : DOM.Core.Node := N; begin loop M := DOM.Core.Nodes.Next_Sibling (M); exit when M = null or else DOM.Core.Nodes.Node_Name (M) /= "#text"; end loop; return M; end Next_Sibling; ------------------------ -- Parse_CompositeTag -- ------------------------ function Parse_CompositeTag (N : DOM.Core.Node) return Translate_Set is function Parse_Dim (N : DOM.Core.Node) return Translate_Set; -- Parse a Dim node procedure Parse_Entry (N : DOM.Core.Node); -- Parse an Entry node function Build_Tag return Tag; -- Build tag from Data map Name : Unbounded_String; -- current tag name Description : Unbounded_String; -- current tag description Data : Str_Map.Map; -- All data inserted into this map from Entry nodes, the key is the -- indexes separated with '_'. Level : Natural := 0; -- Number of nested level for the data --------------- -- Build_Tag -- --------------- function Build_Tag return Tag is function B_Tag (Key : String; N : Positive) return Tag; -- Recursive routine, will build the Tag in the right order with -- the right nested levels. ----------- -- B_Tag -- ----------- function B_Tag (Key : String; N : Positive) return Tag is use type Str_Map.Cursor; Max_Key : constant String := Utils.Image (N) & "_MAX"; Cursor : Str_Map.Cursor; Max : Natural; T : Tag; begin Cursor := Data.Find (Max_Key); Max := Natural'Value (To_String (Str_Map.Element (Cursor))); if N = Level then -- We have reached the last level for K in 1 .. Max loop Cursor := Data.Find (Key & "_" & Utils.Image (K)); exit when Cursor = Str_Map.No_Element; T := T & Str_Map.Element (Cursor); end loop; else for K in 1 .. Max loop T := T & B_Tag ("_" & Utils.Image (K), N + 1); end loop; end if; return T; end B_Tag; begin return B_Tag ("", 1); end Build_Tag; --------------- -- Parse_Dim -- --------------- function Parse_Dim (N : DOM.Core.Node) return Translate_Set is function Parse_Labels (N : DOM.Core.Node) return Translate_Set; -- Parse Labels node D : Positive; -- current Dim level ------------------ -- Parse_Labels -- ------------------ function Parse_Labels (N : DOM.Core.Node) return Translate_Set is use Str_Map; C : DOM.Core.Node := First_Child (N); Result : Translate_Set; T : Tag; Max : Natural := 0; Map : Str_Map.Map; K : Positive; Cursor : Str_Map.Cursor; Success : Boolean; begin while C /= null loop declare N_Name : constant String := Local_Name (C); Atts : constant DOM.Core.Named_Node_Map := DOM.Core.Nodes.Attributes (C); begin if N_Name = "Label" then if Length (Atts) = 1 and then Local_Name (Item (Atts, 0)) = "ind" then K := Positive'Value (Node_Value (Item (Atts, 0))); Max := Natural'Max (Max, K); Map.Insert (Node_Value (Item (Atts, 0)), To_Unbounded_String (Get_Value (DOM.Core.Nodes.First_Child (C))), Cursor, Success); if not Success then Error (C, "Duplicate label for ind " & Node_Value (Item (Atts, 0))); end if; else Error (C, "A single attribute ind expected"); end if; else Error (C, "Entity Label expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; -- Now we have all labels indexed into the Map (key being the -- order number. Place them in the right order into T. for K in 1 .. Max loop declare K_Img : constant String := Utils.Image (K); begin Cursor := Map.Find (K_Img); if Str_Map.Has_Element (Cursor) then T := T & Str_Map.Element (Cursor); else T := T & ""; end if; end; end loop; -- The vector tag is now ready, build the association Insert (Result, Assoc (To_String (Name) & "_DIM" & Utils.Image (D) & "_LABELS", T)); return Result; end Parse_Labels; Atts : constant DOM.Core.Named_Node_Map := DOM.Core.Nodes.Attributes (N); Result : Translate_Set; C : DOM.Core.Node; begin if Length (Atts) /= 1 then Error (N, "A Dim node can have a single attribute"); end if; declare A : constant DOM.Core.Node := Item (Atts, 0); Name : constant String := Local_Name (A); Value : constant String := Node_Value (A); begin if Name = "n" then D := Positive'Value (Value); else Error (A, "Attribute name n expected, found " & Name); end if; end; -- Now look for all nodes C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Description" then Insert (Result, Assoc (To_String (Name) & "_DIM" & Utils.Image (D) & "_DESCRIPTION", Get_Value (DOM.Core.Nodes.First_Child (C)))); elsif N_Name = "Labels" then Insert (Result, Parse_Labels (C)); end if; end; C := Next_Sibling (C); end loop; return Result; end Parse_Dim; ----------------- -- Parse_Entry -- ----------------- procedure Parse_Entry (N : DOM.Core.Node) is procedure Insert (Key, Value : String); -- Insert key/value into Map and keep Max value found for this -- key inside Data map. C : DOM.Core.Node; Map : Str_Map.Map; V : Unbounded_String; Max : Natural := 0; Count : Natural := 0; ------------ -- Insert -- ------------ procedure Insert (Key, Value : String) is Max_Key : constant String := Key & "_MAX"; Cursor : Str_Map.Cursor; Success : Boolean; begin Map.Insert (Key, To_Unbounded_String (Value), Cursor, Success); if not Success then Error (C, "Duplicate attribute found for n " & Key); end if; -- Set Max Cursor := Data.Find (Max_Key); if Str_Map.Has_Element (Cursor) then declare Item : constant Natural := Natural'Value (To_String (Str_Map.Element (Cursor))); begin Data.Replace_Element (Cursor, To_Unbounded_String (Utils.Image (Natural'Max (Item, Natural'Value (Value))))); end; else Data.Insert (Max_Key, To_Unbounded_String (Value), Cursor, Success); end if; end Insert; begin -- We need first to set V, value for this entry C := First_Child (N); declare Found : Boolean := False; begin while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "V" then V := To_Unbounded_String (Get_Value (DOM.Core.Nodes.First_Child (C))); Found := True; end if; end; C := Next_Sibling (C); end loop; if not Found then Error (N, "Entity V not found"); end if; end; -- Now check for the indexes C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Ind" then Count := Count + 1; declare Atts : constant DOM.Core.Named_Node_Map := DOM.Core.Nodes.Attributes (C); K : Natural; begin if Length (Atts) = 1 and then Local_Name (Item (Atts, 0)) = "n" then K := Positive'Value (Node_Value (Item (Atts, 0))); Max := Natural'Max (Max, K); Insert (Node_Value (Item (Atts, 0)), Get_Value (DOM.Core.Nodes.First_Child (C))); else Error (C, "A single attribute named n expected"); end if; end; elsif N_Name = "V" then null; else Error (C, "Entity Ind or V expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; -- Check validity if Level = 0 and then Max = Count then Level := Max; elsif Level /= Max or else Max /= Count then Error (N, "This entity has a wrong number of indices"); end if; -- Insert corresponding entry into Data declare Key : Unbounded_String; Cursor : Str_Map.Cursor; Success : Boolean; begin for K in 1 .. Level loop Cursor := Map.Find (Utils.Image (K)); Append (Key, "_" & To_String (Str_Map.Element (Cursor))); end loop; Data.Insert (To_String (Key), V, Cursor, Success); if not Success then Error (N, "Duplicate entry found"); end if; end; end Parse_Entry; C : DOM.Core.Node; Result : Translate_Set; begin -- First we need to look for the Tag entity C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Tag" then Parse_Tag (C, Name, Description); end if; end; C := Next_Sibling (C); end loop; if Name = Null_Unbounded_String then Error (N, "Missing entity Tag"); end if; -- Add tag description Insert (Result, Assoc (To_String (Name) & "_DESCRIPTION", To_String (Description))); -- Now handles other nodes C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Tag" then -- Already parsed above null; elsif N_Name = "Dim" then Insert (Result, Parse_Dim (C)); elsif N_Name = "Entry" then Parse_Entry (C); else Error (C, "Entity Tag, Dim or Entry expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; -- Now we have all entities in the Data map Insert (Result, Assoc (To_String (Name), Build_Tag)); return Result; end Parse_CompositeTag; --------------------- -- Parse_SimpleTag -- --------------------- function Parse_SimpleTag (N : DOM.Core.Node) return Translate_Set is C : DOM.Core.Node; Name : Unbounded_String; Description : Unbounded_String; Value : Unbounded_String; Result : Translate_Set; begin C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Tag" then Parse_Tag (C, Name, Description); elsif N_Name = "V" then Value := To_Unbounded_String (Get_Value (DOM.Core.Nodes.First_Child (C))); else Error (C, "Entity Tag or V expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; Insert (Result, Assoc (To_String (Name), To_String (Value))); if Description /= Null_Unbounded_String then Insert (Result, Assoc (To_String (Name) & "_DESCRIPTION", To_String (Description))); end if; return Result; end Parse_SimpleTag; --------------- -- Parse_Tag -- --------------- procedure Parse_Tag (N : DOM.Core.Node; Name, Description : out Unbounded_String) is C : DOM.Core.Node := First_Child (N); begin while C /= null loop declare N_Name : constant String := Local_Name (C); N_Value : constant String := Get_Value (DOM.Core.Nodes.First_Child (C)); begin if N_Name = "Name" then Name := To_Unbounded_String (N_Value); elsif N_Name = "Description" then Description := To_Unbounded_String (N_Value); else Error (N, "Entity Name or Description expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; end Parse_Tag; ------------------ -- Parse_Tagged -- ------------------ function Parse_Tagged (N : DOM.Core.Node) return Translate_Set is C : DOM.Core.Node; T : Translate_Set; begin C := First_Child (N); while C /= null loop declare Name : constant String := Local_Name (C); begin if Name = "SimpleTag" then Insert (T, Parse_SimpleTag (C)); elsif Name = "CompositeTag" then Insert (T, Parse_CompositeTag (C)); else Error (C, "SimpleTag or CompositeTag expected, found" & Name); end if; end; C := Next_Sibling (C); end loop; return T; end Parse_Tagged; NL : constant DOM.Core.Node_List := Child_Nodes (Doc); begin if Length (NL) = 1 then return Parse_Tagged (First_Child (Doc)); else Error (Doc, "Document must have a single node, found " & Natural'Image (Length (NL))); end if; end Parse_Document; ---------- -- Save -- ---------- procedure Save (Filename : String; Translations : Translate_Set) is File : Text_IO.File_Type; begin Text_IO.Create (File, Text_IO.Out_File, Filename); Text_IO.Put (File, To_String (Image (Translations))); Text_IO.Close (File); end Save; ----------- -- Value -- ----------- function Value (Translations : String) return Translate_Set is use DOM.Core.Nodes; use DOM.Readers; Reader : Tree_Reader; Input : Input_Sources.Strings.String_Input; Doc : DOM.Core.Document; Result : Translate_Set; begin Input_Sources.Strings.Open (Translations'Unrestricted_Access, Unicode.CES.Utf8.Utf8_Encoding, Input); Set_Feature (Reader, Sax.Readers.Namespace_Prefixes_Feature, True); Parse (Reader, Input); Input_Sources.Strings.Close (Input); Doc := Get_Tree (Reader); Result := Parse_Document (Doc); Free (Doc); return Result; end Value; function Value (Translations : Unbounded_String) return Translate_Set is use DOM.Core.Nodes; use DOM.Readers; S : String_Access := new String (1 .. Length (Translations)); begin -- Copy XML content to local S string for I in 1 .. Length (Translations) loop S (I) := Element (Translations, I); end loop; declare Result : constant Translate_Set := Value (S.all); begin Free (S); return Result; end; end Value; end Templates_Parser.XML; libtemplates-parser-11.6.orig/xsrc/templates_parser-xml.ads0000755000175000017500000001000411637170657024052 0ustar lbrentalbrenta------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2009, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- This API provides a way to save a Translate_Set as an XML document. -- There is special rules to know about composite tags. -- -- Composite tags : -- -- If a tag named TAG exists, then the name TAG_DESCRIPTION is used as a -- description for this specific tag. -- -- Composite tags (more than one nested level) -- -- If a tag named TAG exists, then the names TAG_DIM[n]_LABELS is used as -- a set of labels for the tag's nth axis. In this case TAG_DIM[n]_LABELS -- must be a vector tag, each entry corresponds to a label on this -- axis. Also TAG_DIM[n]_DESCRIPTION is used as a description for this -- axis. -- -- Here is the DTD : -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- package Templates_Parser.XML is function Image (Translations : Translate_Set) return Unbounded_String; -- Returns a string representation encoded in XML for this -- translate table. function Value (Translations : String) return Translate_Set; -- Returns a translate set for this string representation function Value (Translations : Unbounded_String) return Translate_Set; -- Save as above but based on an Ubounded_String function Load (Filename : String) return Translate_Set; -- Read XML document Filename and create the corresponding Translate_set procedure Save (Filename : String; Translations : Translate_Set); -- Write the translate table into filename end Templates_Parser.XML;