Commit Graph

54 Commits

Author SHA1 Message Date
Tomasz Sowa ae6a5c52a1 fixed in Generator: ezc_frames_stack_index was not initialized 2021-07-06 23:56:29 +02:00
Tomasz Sowa b9b9a881e0 added "roman" and "no_sec" parameters when serializing a date 2021-07-06 21:47:42 +02:00
Tomasz Sowa 995cccdace add two new ezc statements: [if-def ...] and [if-not-def ...]
[if-def my_function] returns true if my_function is defined somewhere (either a model, model container, space, date, block, function or variable)
add support for "noescape" or "raw" parameters to Space fields
fixed: CallWrapper() didn't return a status if a model/space/date/container was found
2021-07-02 20:23:20 +02:00
Tomasz Sowa 849b3e9ecc changed the way how we iterate through Models, instead of ModelWrapper now we have Wrapper which has pointers to: model, model container, space or date 2021-07-01 23:21:20 +02:00
Tomasz Sowa acb42f453c added support for two new ezc statements for clearing/trimming text nodes
[ezc clear_all_white_nodes "yes"]...[end] - will clear a text node if the text consists of only white characters
[ezc trim_text_nodes "yes"]...[end] - will trim text nodes (removes white characters at the beginning and at the end)

"yes" is assumed by default if not present, also "no" can be specified to change the behavior
2021-06-29 23:38:38 +02:00
Tomasz Sowa c2283f70d4 Generator when printing Model/Space is recognizing now such parameters:
- "dump" or "dump_to_space" parameters to make a dump in Space format
- "dump_to_json" parameter to make json dump
- "pretty" parameter to make the dump pretty (with new lines and indents)
2021-06-27 22:42:00 +02:00
Tomasz Sowa 3926793a17 fixed in Generator::CallSpace() when a middle field was a table: last_res should be set only for last field
refactoring in Generator::CallSpace()
2021-06-25 16:16:30 +02:00
Tomasz Sowa 16bce07c75 fixed: in Space::CallSpace() we should not increment field index when a new table item is prepared 2021-06-23 21:56:04 +02:00
Tomasz Sowa 526d57b72e added possibility to take a Space struct in Models: Models::Add(const std::wstring & name, pt::Space & space); 2021-06-23 06:53:43 +02:00
Tomasz Sowa eda276356f added possibility to iterate through Space object in Models objects 2021-06-22 18:01:47 +02:00
Tomasz Sowa 615bad7372 renamed macro: EZC_HAS_SPECIAL_STREAM -> EZC_GENERATOR_HAS_PT_STREAM
added macro EZC_GENERATOR_HAS_WINIX_STREAM which is used by Generator::CopyStream(pt::WTextStream & src_stream, StreamType & dst_stream, bool should_escape)
if this macro is defined then Generator is able to escape output stream
2021-06-20 16:54:55 +02:00
Tomasz Sowa 9c4fe51790 Generator uses now pt::Log as a logger
- added method SetLogger(pt::Log & logger)
- removed SetCommentary(...) methods
- added logs when a model is not found

PatternParser uses only pt::Log
- removed SetCommentary(...) methods
2021-06-19 20:18:30 +02:00
Tomasz Sowa d76bb9349b added typename keyword to Generator::CallModelHelper Generator::FindLastModelWrapper(...) 2021-06-18 18:55:39 +02:00
Tomasz Sowa 9022d4a5fc changed how models from morm library are used
now we are using morm::ModelWrapper... classes as wrappers on models and list/vector of models
and Models class is using these wrappers
this allows us to iterate through list/vectors in [for...] statements
2021-06-16 14:16:49 +02:00
Tomasz Sowa e6fd9aad37 added basic support for calling variables and functions from morm::Model objects 2021-05-31 18:37:09 +02:00
Tomasz Sowa 052f803eac renamed [ezc out ...] statement to [ezc frame ...], similar [out ...] to [frame ...] 2021-05-28 16:10:16 +02:00
Tomasz Sowa 0ac8e05c04 changed semantic of [def] statements:
- [def] is used to define a variable (like before)
  but if we assign a string such as [def var "string"] the string is evaluated to bool
  in a different way: empty string is false, not empty string is true
- added [def?] statement - similar like [def] but define a variable only if such
  a variable is not already defined
- added [let] statement - similar like [def] but with lazy evaluation (it is an alias to a function)
  if it is called to assign a string e.g. [let var "string"] then this has the
  same meaning like [def] - an alias is only created when we assign a function e.g. [let var my_function]
  both [def] and [let] are using the same Vars object
- added [let?] - make an alias but only if such a variable is not already defined
- a std::map of variables moved outside of Generator
  added method void SetVariables(Vars & variables);
- fixed: a result status was not correctly propagated when evaluating [def] statements,
  this was in Call(...) function: last_res from variables was set in Find()
  but later was overwritten by Call(...) called for parameters (recursively)
2021-05-23 10:02:51 +02:00
Tomasz Sowa 6f6df9524c updated to the new pikotools api: changed utf8 functions PascalCase to snake_case 2021-05-21 00:32:05 +02:00
Tomasz Sowa cd1c24d0a5 updated to new pikotools api: namespace PT renamed to pt 2021-05-20 16:12:41 +02:00
Tomasz Sowa bf62d44346 fixed: program_mode was not set in cctor
fixed: container was not correctly parsed (in template mode)




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1139 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-01 21:52:33 +00:00
Tomasz Sowa a6b767a223 some work on a 'program mode'
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1136 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-10-30 20:59:17 +00:00
Tomasz Sowa c825c85878 start working on a 'program mode'
a new syntax for simple scripting



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1134 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-10-29 23:50:10 +00:00
Tomasz Sowa 363605bde5 changed: a function can have a postfix now e.g. [my_function:my_postfix]
this will be mainly used in conjuction with [for ...] statements

[for my_function:xxx]
  [for my_function]
    [my_function_value]
    [my_function_valu:xxx] (references the first loop)
  [end]
[end]

added: to FunInfo<>: a reference to current item from a pattern (const Item & item)
       similary on the stack is added a pointer to an item
       by having this reference you can compare a function's name and its postfix
       added methods:
       Stack * FindLastFor(const std::wstring & name);
       Stack * FindLastFor(const std::wstring & name, const std::wstring & postfix);
       template<class FunUserObject> FunUserObject * FindUserObject(const std::wstring & function_name, Stack ** ezc_stack = 0);




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1038 e52654a7-88a9-db11-a3e9-0013d4bc506e
2016-04-04 15:53:11 +00:00
Tomasz Sowa a1ea2e3ccd changed: OutStreams<>::streams_map should not have null pointers to StreamType objects
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1018 e52654a7-88a9-db11-a3e9-0013d4bc506e
2015-11-16 12:09:34 +00:00
Tomasz Sowa c3deb960c5 fixed: 'typename' keyword is missing in some places
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1015 e52654a7-88a9-db11-a3e9-0013d4bc506e
2015-11-12 11:08:53 +00:00
Tomasz Sowa 7b6f7ad328 changed: [ezc streams "..."] to [ezc out "..."] or just [out "..."]
the syntax has been changed, now [ezc ...] is used with [end] statement
added: OutStreams<StreamType> class with a pool with output streams,
the Generator::Generate() method can take it as its argument
(Generator API has been changed)



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1014 e52654a7-88a9-db11-a3e9-0013d4bc506e
2015-11-12 09:53:20 +00:00
Tomasz Sowa 76490d4c19 added: now ezc functions can be methods of a special object
added: objects.h with a base class for the object
       and Objects container (similar as Functions container)



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1011 e52654a7-88a9-db11-a3e9-0013d4bc506e
2015-06-14 18:20:00 +00:00
Tomasz Sowa 6b42cdf76e changed: the way how functions' arguments are parsed
now this [fun1 fun2 "something" fun3]
         will call fun1 with three arguments: fun2, "something" and fun3
         and this [fun1 [fun2 "something"] fun3]
         will call fun1 with two arguments: [fun2 "something] and fun3
         "something" is an argument for fun2 function
removed: statements: [if-one] [if-any] [if-no] [if-any-no] [if-one-no]



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1004 e52654a7-88a9-db11-a3e9-0013d4bc506e
2015-03-08 02:31:21 +00:00
Tomasz Sowa b519c79a3e removed: statements: [if-index ...] [is ...] and [is-no ...]
we can provide a user definied function which does the same
added:   to FunInfo<>:
         Stack * stack_tab
         size_t stack_index
         a stack table and an index to the current stack item



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@988 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-11-02 17:26:56 +00:00
Tomasz Sowa 6f1e2eb518 removed: svn:executable atribute from files
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@987 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-11-01 17:14:39 +00:00
Tomasz Sowa 0a7bd3159a added: [return ...] statement for a block
changed: a user definied function now is able to get a string and a boolean value (parameters)
changed: we do not longer support aliases for variables
         a variable is only a string and a boolean value now



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@981 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-28 17:46:24 +00:00
Tomasz Sowa 6bd8889456 fixed: in cache.cpp there was headerfile_ezc_cache macro used
(copied from cache.h)
fixed: in Generator: memory leak from block_stack
       objects pointing by block_stack_tab[].out_stream
       were not deleted
fixed: in Item: ClearCache() didn't clear all pointers
       Function::parameters table were not used




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@979 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-21 07:21:20 +00:00
Tomasz Sowa 03fe124ad9 fixed: function and blocks were incorrectly cached
(now we have a tree in Item::Function.parameters too
        and we should go through that tree as well)
fixed: in Generator: Item::Function.par should be cleared
       only if Item::Function.name is not empty
changed: in Generator: use method 'write' of an output stream
       instead of operator<<
added: Clear() method to Blocks class
changed: in Generator
       Generator has its own Vars class now
       we don't need SetVars() method
added: to Generator:
       void CanUseCache(bool can_use_cache);
       // set whether or not we can use cache for functions or blocks
       // true by default

       void CanUseVars(bool can_use_variables);
       // set whether or not we can use variables: [def ...] statement
       // true by default





git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@977 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-19 21:09:34 +00:00
Tomasz Sowa 2fca5f3492 changed: SetCommentary() methods from Pattern were moved to PatternParser and Generator
added:   caching functions and blocks
         caching is added into Pattern and Blocks
         methods: CacheFunctions() and CacheBlocks()
		 




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@975 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-19 05:42:25 +00:00
Tomasz Sowa 00f8af232b fixed: a 'typename' keywords were missing in some places
fixed: removed GetStringFromStream() method 
       it returns a reference to a local object (from stream.str())
       now the code is used directly




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@972 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-17 22:14:28 +00:00
Tomasz Sowa 429021f687 changed: a header info in each source file to:
* This file is a part of EZC -- Easy templating in C++ library
 * and is distributed under the BSD 3-Clause licence.




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@971 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-17 21:48:11 +00:00
Tomasz Sowa 71c5bd11d5 added: possibility to define a block
changed: in Functions
         Functions are only for user-defined functions now
         (before they could remember a string variable too)
added:   class Vars for variables
         a variable can be a string or an alias to an other function or block
added:   now we can have nested functions calls e.g.:
         [function1 [function2]]
         in the above example an output (stream) from function2 will be passed
         as the first argument to funcion1 (will be passed as a string)
removed: UTF8() method from PatternParser
         now it is treated that when we have only std::string (or char*)
         that this is an UTF-8 string




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@970 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-17 21:36:55 +00:00
Tomasz Sowa b5faf171e3 changed: Pattern class has been split into two classes: Pattern and PatternParser
in Pattern we have only the tree
         in PatternParser there is the whole logic used to parse a file


git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@969 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-10-11 19:56:48 +00:00
Tomasz Sowa 5de31cfe41 fixed: renamed a local variable in Generator (it did not compile)
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@446 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-11-17 21:53:53 +00:00
Tomasz Sowa 9215130b9d added: possibility to generate output to more than one stream
Generate() methods can take std::vector with pointers to streams
added: 'ezc' keyword -- currently only for selecting streams
       e.g.
       [ezc stream "0" "3"] - after now the output is generated to streams 0 and 3
  


git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@445 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-11-07 10:16:10 +00:00
Tomasz Sowa ac37982ee7 fixed: in Generator: empty_stream() should be inited with its default cctor
(an error when compiling with clang)



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@420 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-06-30 23:24:09 +00:00
Tomasz Sowa 68c1fb8ef8 fixed: Generator: when making [if-index]
[if-index] statement has to look for a last [for] statement on the stack
       (because the stack is for all items now)


git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@394 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-03-03 20:58:55 +00:00
Tomasz Sowa 787b5e99b2 changed: in Generator:
now we have a stack item for all statements [if...] [normal_fun] etc.
         previously was only for [for ...] statements
changed: FunInfo<> has a pointer to the current stack item
changed: now we have a static number of stack items (default: 300)
         so you can remember a pointer to a stack item and this pointer 
         is always valid


git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@393 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-02-27 17:39:46 +00:00
Tomasz Sowa 4fc842ad91 added: to FunInfo<>:
bool remove_fun_data
       fun_data is removed only when remove_fun_data is true (default)


git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@392 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-02-25 03:29:44 +00:00
Tomasz Sowa 8e85a398d6 added: FunInfo<>::fun_data
now we have a pointer to FunData struct
         by default the pointer is null
         you can create an object of a class derived from FunData
         an set the pointer to the object
         those pointers will be kept on the [for] stack
         and will be auto removed
         (not finished yet -- need some testing)
added:   to FunInfo<>::
         bool is_if;
         bool is_is;
         bool is_normal;
         bool is_filter;
removed: from FunInfo<>:
         bool is_for_first_iter;
changed: in FunInfo<>:
         int iter -> size_t iter
         now it indicates the number of a current iteration for the [for] statement 
         for other statements than [for] this is always zero
         (the same old behaviour as before revision 331)
added:   in FunInfo<>:
         size_t last_iter
         it indicates the number of a previous [for] iteration
         for a [for] it returns not the current iterator but a value from a previous [for]



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@391 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-02-24 12:04:36 +00:00
Tomasz Sowa 4480268172 added: two flags to FunInfo<> struct:
// indicates that this function is from [for ...] statement
       bool is_for;

       // indicates that this function is from [for ...] statement
       // and this is a first iteration (iter=0 too)
       // this is only for convenience -- you don't have to check is_for and iter==0
       bool is_for_first_iter;



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@380 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-01-17 22:57:06 +00:00
Tomasz Sowa 542587e5e8 deleted debug log
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@358 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-07-15 02:09:40 +00:00
Tomasz Sowa fb05eb6860 added some debug log
git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@357 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-07-13 23:15:12 +00:00
Tomasz Sowa 861269383e changed: [is...] statements use only the output string now (when comparing)
previously they used FunInfo::res, now they use FunInfo::out
         and the out string is not put to the main output stream
added:   FunInfo<>::case_sensitive (default true)
         when false then [is] statement is comparing in case insensitive manner
changed: the out stream in [if...] [for] statements
         the output text is ingored now



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@344 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-04-26 17:17:06 +00:00
Tomasz Sowa 542e50d757 added filters:
a new statement [filter]
 syntax:
 [filter funcion_name]....[end]
 everything which is between [filter] and [end] is processed normally and
 at the end it is passed to the function (function_name)
 FunInfo struct has 'in' input stream now



git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@333 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-26 12:42:49 +00:00