Diff for /parser3/operators.txt between versions 1.260 and 1.273

version 1.260, 2024/12/20 17:37:19 version 1.273, 2026/10/09 18:53:41
Line 156  odbc parser3odbc.dll Line 156  odbc parser3odbc.dll
     ^rem{}      ^rem{}
         a comment, removed at compile time          a comment, removed at compile time
   
       ^syslog[ident;message[;info|warning|error|debug]]
           writes a message to syslog
   
     ^cache[file](seconds){code}[{catch code}]      ^cache[file](seconds){code}[{catch code}]
         relative time assignment          relative time assignment
         caches the string resulting from the code execution for 'seconds' seconds          caches the string resulting from the code execution for 'seconds' seconds
Line 195  odbc parser3odbc.dll Line 198  odbc parser3odbc.dll
     UTF-8 is always available and is the default encoding for request and response      UTF-8 is always available and is the default encoding for request and response
     WARNING: the encoding name is case-insensitive      WARNING: the encoding name is case-insensitive
   
   
 syntax  syntax
     $name[new value]      $name[new value]
     $name(arithmetic expression of new value)      $name(arithmetic expression of new value)
Line 242  int,double Line 244  int,double
          boolean value           boolean value
     ^name.inc(how much +)      ^name.inc(how much +)
     ^name.dec(how much -)      ^name.dec(how much -)
       ^name.++[] output the value, then increment by 1
       ^name.--[] output the value, then decrement by 1
     ^name.mul(how much *)      ^name.mul(how much *)
     ^name.div(how much /)      ^name.div(how much /)
     ^name.mod(how much %)      ^name.mod(how much %)
Line 428  hash Line 432  hash
     ^hash.foreach[key;value]{body}[[delimiter]|{delimiter executed before each non-empty non-first body}]      ^hash.foreach[key;value]{body}[[delimiter]|{delimiter executed before each non-empty non-first body}]
     ^hash.delete[key]      ^hash.delete[key]
         delete key          delete key
     ^hash.contain[key]      ^hash.contains[key]
         checks if hash contains a key (bool)          checks if hash contains a key (bool)
     ^hash.at[first|last][[key|value|hash]]      ^hash.at[first|last][[key|value|hash]]
     ^hash.at([-]N)[[key|value|hash]]      ^hash.at([-]N)[[key|value|hash]]
Line 436  hash Line 440  hash
     ^hash.set[first|last;value]      ^hash.set[first|last;value]
     ^hash.set([-+]N)[value]      ^hash.set([-+]N)[value]
         sets the value of the specified ordered hash element          sets the value of the specified ordered hash element
       ^hash.array[[keys|values]]
           is equivalent to ^array::copy[$hash] or returns an array of the hash’s keys or values
     ^hash.rename[old_key;new_key]      ^hash.rename[old_key;new_key]
     ^hash.rename[ $.old_key[new_key] ...]      ^hash.rename[ $.old_key[new_key] ...]
         renames the specified hash keys          renames the specified hash keys
Line 509  array Line 515  array
         adds an element to the end of the array          adds an element to the end of the array
     ^array.pop[]      ^array.pop[]
         returns the last element and removes it from the array          returns the last element and removes it from the array
     ^array.contain(index)      ^array.contains(index)
         checks if an element exists at the given index (bool)          checks if an element exists at the given index (bool)
     ^array::sql{query}[ $.sparse(false|true) $.distinct(false|true) $.limit(n) $.offset(n) $.type[hash|string|table] ]      ^array::sql{query}[ $.sparse(false|true) $.distinct(false|true) $.limit(n) $.offset(n) $.type[hash|string|table] ]
         creates an array based on a database query          creates an array based on a database query
Line 546  array Line 552  array
     $selected[^array.select[key;value](expression)[ $.limit(N) $.reverse(bool) ]]      $selected[^array.select[key;value](expression)[ $.limit(N) $.reverse(bool) ]]
         selects array elements for which the condition is true          selects array elements for which the condition is true
   
   date
       date type can be used in expressions, substituting the number of days since epoch [1 January 1970 (UTC)], fractional
       the string value is in local time, numerically in UTC, range from 0000-00-00 00:00:00 to 9999-12-31 23:59:59
       by default the OS-defined timezone is used
   
       ^date::now[]
       ^date::now(days offset)
           returns now+offset
       ^date::today[]
           date at 00:00:00 of the current day
       ^date::today(integer days offset)
           date at 00:00:00 of current day+offset
       ^date::create(days since epoch)
       ^date::create(year;month[;day[;hour[;minute[;second[;TZ]]]]])
       ^date::create[date in format %Y-%m-%d %H:%M:%S]
           convenient creation from a value from a database
           format1: %Y[-%m[-%d[ %H[:%M[:%S]]]]]
           format2: %H:%M[:%S]
       ^date::create[date in format %Y-%m-%dT%H:%M[:%S]TZ]
           for creation from ISO 8601 format
           TZ format: Z(UTC) or +-hour[:minute] (offset from UTC)
       ^date::unix-timestamp()
       ^date.unix-timestamp[]
       $date.year month day hour minute second weekday yearday(0...) daylightsaving TZ weekyear
           TZ="" << local zone
       $date.year month day hour minute second can be set to new values, others are read-only
       ^date.double[] ^date.int[]
           the number of days since epoch [1 January 1970 (UTC)], fractional or truncated
       ^date.roll[year|month|day](+-offset)
           shifts the date
       ^date.roll[TZ;New zone]
           says that the date is in such a timezone: affects .hour & Co
       ^date:roll[TZ;New zone]
           says that by default all dates are in that timezone
       ^date.sql-string[[datetime|date|time]]
           datetime or without parameter - %Y-%m-%d %H:%M:%S
           date                          - %Y-%m-%d
           time                          - %H:%M:%S
           where published='^date.sql-string[]'
       ^date:sql-string[[datetime|date|time]]
           sql-string for now
       ^date:calendar[rus|eng](year;month)
           returns an unnamed table, columns: 0..6, week, year
       ^date:calendar[rus|eng](year;month;day)
           returns a named table, columns: year, month, day, weekday
       ^date:last-day(year;month)
           returns the last day of the month
       ^date.last-day[]
           returns the last day of $date's month
       ^date.gmt-string[]
           Fri, 23 Mar 2001 09:32:23 GMT
       ^date:gmt-string[]
           gmt-string for now
       ^date.iso-string[]
           2001-03-23T12:32:23+03
       ^date:iso-string[]
           iso-string for now
   
   file
       $uploaded_file_from_post.name
       $uploaded_file_from_post.size
       $uploaded_file_from_post.text
       ^file.save[text|binary;filename[;$.charset[which charset to save in] $.append(false)]]
       ^file:delete[filename]
       ^file:find[filename][{if not found}]
       ^file:list[path[;pattern-string|pattern-regex]]
           table with columns name dir
       ^file:list[path;$.filter[pattern-string|pattern-regex] $.stat(true)]
           table with columns name dir size [mca]date
       ^file::load[text|binary;big.zip[;domain_press_release_2001_03_01.zip][;options]]
       ^file::create[text|binary;filename;data]
       ^file::create[text|binary;filename;data[;$.charset[charset of the created file] $.content-type[...]]]
       ^file::create[string-or-file-content[;$.name[name] $.mode[text|binary] $.content-type[...] $.charset[...]]]
       $loaded_file.size
       $loaded_or_created_file.mode = text/binary
       ^file::stat[filename]
       $stated_or_loaded_file.size .adate .mdate .cdate
       ^file::cgi[[text|binary;]filename[;env hash +options[;1cmd[;2line[;3ar[;4g[;5s]]]]]]]
           any argument can be string or array of strings
           the returned header is split into $fields
           $status
           $stderr
       ^file::exec[[text|binary;]filename[;env hash[;1cmd[;2line[;3ar[;4g[;5s;...under unix max 50 args]]]]]]]
           any argument can be string or array of strings
           options:
               $.stdin[text|file] if empty, disables automatic passing of HTTP-POST data
       ^file:move[oldfilename;newfilename]
           can rename and move directories [win32: but not across disk boundaries]
           directories for dest are created with 775 permissions
           source directory is removed if empty after move
       ^file:copy[filename;copy_filename[; $.append(1) ]]
           can only copy files
       ^file:lock[filename]{code}
           the file is created if necessary
           locked
           code executed
           unlocked
       ^file:dirname[/a/some.tar.gz|file]=/a (works like *nix command)
       ^file:dirname[/a/b/|file]=/a (works like *nix command)
       ^file:basename[/a/some.tar.gz|file]=some.tar.gz (like *nix)
       ^file:basename[/a/b/|file]=b (like *nix)
       ^file:justname[/a/some.tar.gz|file]=some.tar
       ^file:justext[/a/some.tar.gz|file]=gz
       /some/page.html: ^file:fullpath[a.gif] => /some/a.gif
       ^file.sql-string[]
           inside ^connect gives a correctly escaped string that can be used in queries
       ^file::sql{query}[[ $.name[filename_for_download] $.content-type[user content-type] ]]
           the query result should be "one row".
           columns:
           first column - data
           if second exists - filename
           if third - content-type
       ^file.base64[ $.pad(bool) $.wrap(bool) $.url-safe(bool) ]
           encode
       ^file:base64[filename[; $.pad(bool) $.wrap(bool) $.url-safe(bool) ]]
           encode
       ^file::base64[encoded string[; $.pad(bool) $.strict(bool) $.url-safe(bool) ]]
           decode
       ^file::base64[mode;filename;encoded string[; $.content-type[...] $.pad(bool) $.strict(bool) $.url-safe(bool) ]]
           decode
       ^file:crc32[filename]
           calculates crc32 of the specified file
       ^file.crc32[]
           calculates crc32 of the object
       ^file.md5[], ^file:md5[filename]
           returns the file's digest, 16 bytes as a string,
           bytes in hex, contiguous, lowercase
   
   image
       $image[^image::measure[DATA[; $.exif(bool) $.xmp(bool) $.xmp-charset[] $.video(bool) ]]]
           checks the file extension case-insensitively
           can measure gif, jpg, tiff, bmp, webp and mp4 (mov)
       $image.exif << hash after measure jpeg with exif information and $.exif(true)
           $image.exif.DateTime & co
               [full list see https://exiftool.org/TagNames/EXIF.html]
           numbers as int/double,
           dates as date,
           enumerations as hash with keys 0..count-1
       $image.src .width .height
       $image.line-width  number=line width
       $image.line-style  string=line style '*** * '='*** * *** * *** * '
       ^image.html[[hash]]
           <img ...>
       ^image::load[background.gif]
           only gif so far
       ^image::create(width X;height Y[;background color default white]])
       ^image.line(x0;y0;x1;y1;0xffFFff)
       ^image.fill(x;y;0xffFFff)
       ^image.rectangle(x0;y0;x1;y1;0xffFFff)
       ^image.bar(x0;y0;x1;y1;0xffFFff)
       ^image.replace(hex-color1;hex-color2)[table x:y polygon_vertices]
       ^image.polyline(color)[table x:y points]
       ^image.polygon(color)[table x:y polygon_vertices]
       ^image.polybar(color)[table x;y polygon_vertices]
       ^image.font[set_of_letters;font_file.gif][(space_width[;char_width])]
           the character height = image height/number of letters in the set
           if char_width is specified, then monospaced, if 0, char_width = gif width
       ^image.font[set_of_letters;font_file.gif;
           $.space(space_width)      // default = gif width
           $.width(char_width)       // see above, default proportional
           $.spacing(letter_spacing) // default = 1
       ]
       ^image.text(x;y)[text] AS_IS
       ^image.length[text] AS_IS
       ^image.gif[optional filename]
           encodes to FILE with content-type=image/gif the filename will be used by $response:download
       ^image.arc(center x;center y;width;height;start in degrees;end in degrees;color)
       ^image.sector(center x;center y;width;height;start in degrees;end in degrees;color)
       ^image.circle(center x;center y;r;color)
       ^image.copy[source](src x;src y;src w;src h;dst x;dst y[;dest w[;dest h[;tolerance]]])
           if dest_w/dest_h are specified, resizes the piece
               when reducing size, does resample
               only suitable for simplifying low-color graphics like charts/pie,
               not suitable for thumbnails
           if dest_h is not specified, aspect ratio is kept
           tolerance - a number [square distance in RGB space to the target color],
               defining how greedy the color approximation from the palette is [default=150]
               smaller - more accurate but colors run out quickly
               larger - less accurate approximation, but covers a bigger part
       ^image.pixel(x;y)[(color)]
           get or set pixel color
   
   regex
       in expression
           logical value is always true
           numerical value is equal to the number of bytes of the compiled pattern
       ^regex::create[pattern-string|regex][[search options]]
       ^pattern.size[]
           number of bytes of the compiled pattern
           if the value is very large - it is worth consulting pcre documentation and possibly rewriting the pattern
       ^pattern.study_size[]
           size of the study-structure. if == 0 - the pattern cannot be "studied"
       $pattern.pattern
           the text of the pattern
       $pattern.options
           the string with the original text of the options
   
   amqp
       ^amqp::create[[
           $.host[localhost] $.port(5672) $.user[guest] $.password[guest] $.vhost[/] $.locale[en_US]
           $.heartbeat(30) $.auto_reconnect(seconds)
           $.tls[ $.ca[file] $.cert[file] $.key[file] $.verify(true) ]
       ]]
           connects to a RabbitMQ broker
           auto_reconnect(N): after a lost connection reconnect before the next operation, waiting N seconds
           tls: the server certificate is verified only if ca is specified
       ^amqp.publish[message][[
           $.exchange[] $.routing_key[key]|$.queue[name] $.mandatory(false)
           message properties: $.content_type[] $.content_encoding[] $.delivery_mode(1|2) $.priority(N) $.correlation_id[] $.reply_to[]
               $.expiration[] $.message_id[] $.timestamp(N) $.type[] $.user_id[] $.app_id[] $.cluster_id[] $.headers[hash]
       ]]
       ^amqp.consume[ $.queue[name] $.ack(true) $.count(1) $.timeout(0) $.exclusive(false) $.consumer_tag[] ]
           array of messages ready within timeout seconds (only the first one is waited for)
       ^amqp.consume[ $.queue[name] $.callback[$method] ... ]
           calls @method[message] for each message until ^amqp.stop_consume[], count messages or timeout seconds without messages
           count and timeout are unlimited by default
       message: hash with msg, delivery_tag, routing_key, exchange, redelivered, consumer_tag and the properties set
       ^amqp.ack(delivery_tag)
           with $.ack(true) (default) received messages must be acknowledged
       ^amqp.nack(delivery_tag)[ $.requeue(false) ]
       ^amqp.reject(delivery_tag)[ $.requeue(true) ]
       ^amqp.qos[ $.prefetch_count(N) ]
       ^amqp.declare[ $.queue[name] $.durable(false) $.exclusive(false) $.auto_delete(false) $.passive(false) $.arguments[hash] ]
           for an empty name the server creates a queue with its own name, which is returned
       ^amqp.declare[ $.exchange[name] $.type[direct] $.durable(false) $.auto_delete(false) $.internal(false) $.passive(false) $.arguments[hash] ]
       ^amqp.delete[ $.queue[name]|$.exchange[name] $.if_unused(false) $.if_empty(false) ]
       ^amqp.bind[ $.exchange[name] $.queue[name] $.routing_key[] ]
       ^amqp.unbind[ $.exchange[name] $.queue[name] $.routing_key[] ]
       ^amqp.purge[ $.queue[name] ]
           number of deleted messages
       ^amqp.info[ $.queue[name] ]
           hash with queue, messages, consumers
       ^amqp.release[]
           closes the connection
       arguments and headers values: [string], (number), (true|false)
   
   console
       $console:timeout
       $console:line
           read/write string
   
   cookie
       $cookie:name read old or newly set cookie
       $cookie:name[value] for 90 days
       $cookie:name[$.value[value] $.expires[VALUE] $.secure(true) $.domain[domain name] $.httponly(true)]
           the expires field value can be 'session', a date, or a number of days (0days=session)
           if it's a date, it will be converted to "Sun, 25-Aug-2002 12:03:45 GMT"
       $cookie:fields
           hash with all cookies
   
   curl
       ^curl:load[[
           $.url[http://URL]
           $.timeout(N)
           $.ssl_verifypeer(0)
           $.mode[text|binary] type of the created file
       ]]
           downloads a file from a remote server, can be called multiple times within one session;
           any libcurl option can be specified, option names in lowercase without the CURLOPT_ prefix
       ^curl:options[[
           $.library[libcurl.so.4]
           $.charset[UTF-8]
           ...
       ]]
           subsequent ^curl:load calls inherit the specified options, the path to libcurl must be set before using curl
       ^curl:session{code}
           creates a cURL session, common options can be set, multiple downloads performed
       ^curl:info[name], ^curl:info[]
           information about the last request (a value or a hash)
       ^curl:version[]
           the version of the cURL library in use
   
   env
       $env:variable
       $env:fields hash with environment variables
       $env:PARSER_VERSION parser version
   
 form  form
     [the first element with the same name is taken from GET, then from POST]      [the first element with the same name is taken from GET, then from POST]
     $form:field      $form:field
Line 565  form Line 848  form
     $form:imap      $form:imap
         a hash with keys 'x' and 'y' with ?1,2 suffixes when using server-side image map          a hash with keys 'x' and 'y' with ?1,2 suffixes when using server-side image map
   
 env  inet
     $env:variable      ^inet:ntoa(long)
     $env:fields hash with environment variables      ^inet:aton[IP]
     $env:PARSER_VERSION parser version      ^inet:name2ip[name][[ $.ipv[4|6|any] $.table(true) ]]
           direct conversion of a name to an IP address
 cookie      ^inet:ip2name[ip][ $.ipv[4|6|any] ]
     $cookie:name read old or newly set cookie          reverse conversion from IP address to name
     $cookie:name[value] for 90 days      ^inet:hostname[]
     $cookie:name[$.value[value] $.expires[VALUE] $.secure(true) $.domain[domain name] $.httponly(true)]          host name
         the expires field value can be 'session', a date, or a number of days (0days=forever)  
         if it's a date, it will be converted to "Sun, 25-Aug-2002 12:03:45 GMT"  
     $cookie:fields  
         hash with all cookies  
   
 request  
     $request:query  
     $request:uri  
     $request:document-root  
         directory relative to which paths are considered in parser, default = $env:DOCUMENT_ROOT  
     $request:argv  
         hash with command-line parameters. keys 0, 1, ... [0 - name of the processed file]  
     $request:charset  
         the source document encoding  
         used in upper/lower and match[][i]  
         WARNING: you must set $request/response:charset before using form class fields  
     $request:method  
         request method (GET|POST|PUT)  
     $request:body  
         POST-request body as text  
     $request:body-file  
         POST-request body as a file  
     $request:body-charset  
         POST-request encoding  
     $request:headers  
         hash with request headers (without HTTP_ prefix)  
   
 response  
     $response:field[value] and can read old - $response:field  
         the value can be string or hash:  
             $value[abc] field: {abc}<<part  
             $attribute[zzz] field: abc; {attribute=zzz}<<part  
         field or attribute value can be string or date  
             if date, it will be converted to "Sun, 25-Aug-2002 12:03:45 GMT"  
     $response:headers  
          accumulated fields  
     $response:body[DATA]  
         replaces the standard response  
     $response:download[DATA]  
         replaces the standard response, sets a flag causing the browser to suggest download  
     $response:status  
     ^response:clear[] forget all set response fields  
     $response:charset  
         client encoding, i.e.:  
         1) from which $form: fields will be transcoded after retrieval from browser  
         2) into which the document will be transcoded before sending to browser  
         3) into which URI language text will be transcoded  
         does not add anything to content-type; if needed, do it manually  
         WARNING: you must set $request/response:charset before using form class fields  
   
 regex  json
     in expression      ^json:parse[-json-string-[;
         logical value is always true          $.depth(maximum depth, default == 19)
         numerical value is equal to the number of bytes of the compiled pattern          $.double(false)              disable built-in parsing of floating-point numbers (enabled by default)
     ^regex::create[pattern-string|regex][[search options]]                                       in this case they will appear in the resulting object as strings
     ^pattern.size[]          $.int(false)                 disable built-in parsing of integers (enabled by default)
         number of bytes of the compiled pattern                                       in this case they will appear in the resulting object as strings
         if the value is very large - it is worth consulting pcre documentation and possibly rewriting the pattern          $.distinct[first|last|all]   how duplicate keys in objects are handled
     ^pattern.study_size[]                                       first - keep the first encountered element
         size of the study-structure. if == 0 - the pattern cannot be "studied"                                       last  - keep the last encountered element
     $pattern.pattern                                       all   - keep all elements. starting from the 2nd,
         the text of the pattern                                                they get numeric suffixes (key_2 etc)
     $pattern.options                                       by default duplicate keys cause an exception
         the string with the original text of the options          $.object[method-junction]    user method[key;object], called for all parsed
                                        objects and object keys; method returns a new object
           $.array[method-junction]     user method called for arrays
           $.taint[taint language]      sets the transformation language for all result strings
       ]]
           parses a json-string into a hash
   
 reflection      ^json:string[system or user object[;
     ^reflection:create[class;constructor[;pa[;ra[;ms]]]]          $.skip-unknown(false)    disable exception and output 'null' when serializing objects of types
         calls the specified class constructor (no more than 100 parameters)                                   other than void, bool, string, int, double, date, table, hash, and file
     ^reflection:create[ $.class[name] $.constructor[name] $.arguments[ $.1[pa] $.2[ra] $.3[ms] ] ]          $.indent(true)           format the resulting string with indentation according to nesting depth
         calls the specified class constructor          $.date[sql-string|gmt-string|iso-string|unix-timestamp]
     ^reflection:classes[]                                   date output format, default = sql-string
         a hash of all classes. key = class name, value can be methoded (a class with methods) or void          $.table[object|array|compact]
     ^reflection:class[object]                                   format for tables, default=object
         the class of the given object                                   object: [{"c1":"v11","c2":"v12",...},{"c1":"v21","c2":"v22",...},...]
     ^reflection:class_name[object]                                   array:  [["c1","c2",...] || null (for nameless),["v11","v12",...],...]
         the class name of the given object                                   compact: ["v11" || ["v11","v12",...],...]
     ^reflection:base[object]          $.file[text|base64|stat] output file content in the specified mode (by default file content
         the parent class of the given object                                   is not included in output)
     ^reflection:base_name[object]          $.xdoc[hash]             parameters for converting xdoc to string (as in ^xdoc.string[])
         the parent class name of the given object          $.type[method-junction]  any type can be output using a user method
     ^reflection:class_by_name[class name]                                   that must take 3 parameters: key, object of that type, and options
         obtains the class by name                                   of the ^json:string[] call
     ^reflection:class_alias[class name;new class name]          $._default[method]       user method, called to output all user-class objects.
         sets an alias for the specified class                                   The method must take 3 parameters: key, object, and call options.
     ^reflection:def[class;class name]          $._default[method name]  method name of a user method, if present it will be called for serialization
         checks if the class exists          $.void[null|string]      undefined value will be output as null (default)
     ^reflection:methods[class]                                   or as an empty string
         a hash with a list of methods of the specified class, values are strings 'native' or 'parser'      ]]
     ^reflection:method[class or object;method name]          serializes a system or user object into a json-string
         returns the junction-method of the class or object  
     ^reflection:filename[object or class or method]  
         returns the filename where the object, class or method is defined  
     ^reflection:fields[class or object]  
         a hash with the list of static fields of the specified class or dynamic fields of the specified object  
     ^reflection:fields_reference[object]  
         an editable hash of the dynamic fields of the specified object  
     ^reflection:field[class or object;field name]  
         returns the value of the specified field of the class or object. getters are ignored.  
     ^reflection:copy[source;destination]  
         copies fields from one object or class to another  
     ^reflection:uid[class or object]  
         returns the identifier of the object or class  
     ^reflection:method_info[class;method]  
         a hash with parameters of the specified class method  
         $.inherited[class] name of the class where the method was defined (returned only if the method was defined in an ancestor)  
         $.overridden[class] name of the class where the method was defined (returned only if the method was defined in an ancestor)  
         for native classes a hash is returned:  
             .min_params(minimum required number of parameters)  
             .max_params(maximum possible number of parameters)  
             .call_type[dynamic|static|any]  
         for parser classes a hash is returned:  
             key is parameter number (0, 1, ...), value is parameter name  
     ^reflection:dynamical[[object or class, caller if absent]]  
         returns true if the method was called from a dynamic context when passing  
         a parameter returns true if a dynamic object was passed, false if a class  
     ^reflection:delete[class or object;variable name]  
         deletes the variable with the specified name in the specified class or object  
     ^reflection:is[element name;class name][[context]]  
         analogous to the 'is' operator, allowing to determine if the element is code.  
     ^reflection:tainting[[language|tainted|optimized];string]  
         a string in which each character of the original string corresponds to a character with a transformation code  
     ^reflection:stack[ $.args(false/true) $.locals(false/true) $.limit(n) $.offset(o)]  
         the current state of the method call stack in the parser  
     ^reflection:mixin[source; $.to[target] $.name[name] $.methods(true/false) $.fields(true/false) $.overwrite(false/true)]  
         copies methods and fields from one class to another  
   
 mail  mail
     $mail.received=MESSAGE:      $mail.received=MESSAGE:
Line 750  mail Line 953  mail
             $value[FILE]              $value[FILE]
         ]          ]
     ]      ]
     if charset is specified, the email is transcoded to this charset          if charset is specified, the email is transcoded to this charset
     content-type.charset does not affect transcoding          content-type.charset does not affect transcoding
     after the part name a # number can follow          after the part name a # number can follow
   
     ^mail:send[      ^mail:send[
 #       by default, matches the source encoding.  #       by default, matches the source encoding.
Line 826  mail Line 1029  mail
     under Windows, SMTP protocol is used, server is set by      under Windows, SMTP protocol is used, server is set by
         $MAIL.SMTP[smtp.domain.ru]          $MAIL.SMTP[smtp.domain.ru]
   
 image  
     $image[^image::measure[DATA[; $.exif(bool) $.xmp(bool) $.xmp-charset[] $.video(bool) ]]]  
         checks the file extension case-insensitively  
         can measure gif, jpg, tiff, bmp, webp and mp4 (mov)  
     $image.exif << hash after measure jpeg with exif information and $.exif(true)  
         $image.exif.DateTime & co  
             [full list see https://exiftool.org/TagNames/EXIF.html]  
         numbers as int/double,  
         dates as date,  
         enumerations as hash with keys 0..count-1  
     $image.src .width .height  
     $image.line-width  number=line width  
     $image.line-style  string=line style '*** * '='*** * *** * *** * '  
     ^image.html[[hash]]  
         <img ...>  
     ^image::load[background.gif]  
         only gif so far  
     ^image::create(width X;height Y[;background color default white]])  
     ^image.line(x0;y0;x1;y1;0xffFFff)  
     ^image.fill(x;y;0xffFFff)  
     ^image.rectangle(x0;y0;x1;y1;0xffFFff)  
     ^image.bar(x0;y0;x1;y1;0xffFFff)  
     ^image.replace(hex-color1;hex-color2)[table x:y polygon_vertices]  
     ^image.polyline(color)[table x:y points]  
     ^image.polygon(color)[table x:y polygon_vertices]  
     ^image.polybar(color)[table x;y polygon_vertices]  
     ^image.font[set_of_letters;font_file.gif][(space_width[;char_width])]  
         the character height = image height/number of letters in the set  
         if char_width is specified, then monospaced, if 0, char_width = gif width  
     ^image.font[set_of_letters;font_file.gif;  
         $.space(space_width)      // default = gif width  
         $.width(char_width)       // see above, default proportional  
         $.spacing(letter_spacing) // default = 1  
     ]  
     ^image.text(x;y)[text] AS_IS  
     ^image.length[text] AS_IS  
     ^image.gif[optional filename]  
         encodes to FILE with content-type=image/gif the filename will be used by $response:download  
     ^image.arc(center x;center y;width;height;start in degrees;end in degrees;color)  
     ^image.sector(center x;center y;width;height;start in degrees;end in degrees;color)  
     ^image.circle(center x;center y;r;color)  
     ^image.copy[source](src x;src y;src w;src h;dst x;dst y[;dest w[;dest h[;tolerance]]])  
         if dest_w/dest_h are specified, resizes the piece  
             when reducing size, does resample  
             only suitable for simplifying low-color graphics like charts/pie,  
             not suitable for thumbnails  
         if dest_h is not specified, aspect ratio is kept  
         tolerance - a number [square distance in RGB space to the target color],  
             defining how greedy the color approximation from the palette is [default=150]  
             smaller - more accurate but colors run out quickly  
             larger - less accurate approximation, but covers a bigger part  
     ^image.pixel(x;y)[(color)]  
         get or set pixel color  
   
 file  
     $uploaded_file_from_post.name  
     $uploaded_file_from_post.size  
     $uploaded_file_from_post.text  
     ^file.save[text|binary;filename[;$.charset[which charset to save in]]]  
     ^file:delete[filename]  
     ^file:find[filename][{if not found}]  
     ^file:list[path[;pattern-string|pattern-regex]]  
         table with columns name dir  
     ^file:list[path;$.filter[pattern-string|pattern-regex] $.stat(true)]  
         table with columns name dir size [mca]date  
     ^file::load[text|binary;big.zip[;domain_press_release_2001_03_01.zip][;options]]  
     ^file::create[text|binary;filename;data]  
     ^file::create[text|binary;filename;data[;$.charset[charset of the created file] $.content-type[...]]]  
     ^file::create[string-or-file-content[;$.name[name] $.mode[text|binary] $.content-type[...] $.charset[...]]]  
     $loaded_file.size  
     $loaded_or_created_file.mode = text/binary  
     ^file::stat[filename]  
     $stated_or_loaded_file.size .adate .mdate .cdate  
     ^file::cgi[[text|binary;]filename[;env hash +options[;1cmd[;2line[;3ar[;4g[;5s]]]]]]]  
         any argument can be string or array of strings  
         the returned header is split into $fields  
         $status  
         $stderr  
     ^file::exec[[text|binary;]filename[;env hash[;1cmd[;2line[;3ar[;4g[;5s;...under unix max 50 args]]]]]]]  
         any argument can be string or array of strings  
         options:  
             $.stdin[text|file] if empty, disables automatic passing of HTTP-POST data  
     ^file:move[oldfilename;newfilename]  
         can rename and move directories [win32: but not across disk boundaries]  
         directories for dest are created with 775 permissions  
         source directory is removed if empty after move  
     ^file:copy[filename;copy_filename[; $.append(1) ]]  
         can only copy files  
     ^file:lock[filename]{code}  
         the file is created if necessary  
         locked  
         code executed  
         unlocked  
     ^file:dirname[/a/some.tar.gz|file]=/a (works like *nix command)  
     ^file:dirname[/a/b/|file]=/a (works like *nix command)  
     ^file:basename[/a/some.tar.gz|file]=some.tar.gz (like *nix)  
     ^file:basename[/a/b/|file]=b (like *nix)  
     ^file:justname[/a/some.tar.gz|file]=some.tar  
     ^file:justext[/a/some.tar.gz|file]=gz  
     /some/page.html: ^file:fullpath[a.gif] => /some/a.gif  
     ^file.sql-string[]  
         inside ^connect gives a correctly escaped string that can be used in queries  
     ^file::sql{query}[[ $.name[filename_for_download] $.content-type[user content-type] ]]  
         the query result should be "one row".  
         columns:  
         first column - data  
         if second exists - filename  
         if third - content-type  
     ^file.base64[ $.pad(bool) $.wrap(bool) $.url-safe(bool) ]  
         encode  
     ^file:base64[filename[; $.pad(bool) $.wrap(bool) $.url-safe(bool) ]]  
         encode  
     ^file::base64[encoded string[; $.pad(bool) $.strict(bool) $.url-safe(bool) ]]  
         decode  
     ^file::base64[mode;filename;encoded string[; $.content-type[...] $.pad(bool) $.strict(bool) $.url-safe(bool) ]]  
         decode  
     ^file:crc32[filename]  
         calculates crc32 of the specified file  
     ^file.crc32[]  
         calculates crc32 of the object  
     ^file.md5[], ^file:md5[filename]  
         returns the file's digest, 16 bytes as a string,  
         bytes in hex, contiguous, lowercase  
   
 math  math
     $math:PI      $math:PI
     ^math:round floor ceiling      ^math:round floor ceiling
Line 965  math Line 1044  math
     ^math:convert[number|file](base-from)[alphabet][[ $.format[string|file] ]]      ^math:convert[number|file](base-from)[alphabet][[ $.format[string|file] ]]
         converts a string or file with a number from one numeral system to another          converts a string or file with a number from one numeral system to another
         the numeral system can be set by an alphabet, a number from 2 to 16 (equivalent to the alphabet 0123456789ABCDEF), or 256 (all ASCII characters)          the numeral system can be set by an alphabet, a number from 2 to 16 (equivalent to the alphabet 0123456789ABCDEF), or 256 (all ASCII characters)
       ^math:eq(a;b[;max ULP])
           true if difference between doubles less or equal max ULPs (default 3)
     ^math:uuid[ $.lower(bool) $.solid(bool) ]      ^math:uuid[ $.lower(bool) $.solid(bool) ]
         22C0983C-E26E-4169-BD07-77ECE9405BA5          22C0983C-E26E-4169-BD07-77ECE9405BA5
         win32: uses cryptapi          win32: uses cryptapi
Line 991  math Line 1072  math
         combines the ability to use various cryptographic hashing algorithms.          combines the ability to use various cryptographic hashing algorithms.
         $.hmac[key] for verifying the integrity of transmitted data          $.hmac[key] for verifying the integrity of transmitted data
   
 inet  
     ^inet:ntoa(long)  
     ^inet:aton[IP]  
     ^inet:name2ip[name][[ $.ipv[4|6|any] $.table(true) ]]  
         direct conversion of a name to an IP address  
     ^inet:ip2name[ip][ $.ipv[4|6|any] ]  
         reverse conversion from IP address to name  
     ^inet:hostname[]  
         host name  
   
 json  
     ^json:parse[-json-string-[;  
         $.depth(maximum depth, default == 19)  
         $.double(false)              disable built-in parsing of floating-point numbers (enabled by default)  
                                      in this case they will appear in the resulting object as strings  
         $.int(false)                 disable built-in parsing of integers (enabled by default)  
                                      in this case they will appear in the resulting object as strings  
         $.distinct[first|last|all]   how duplicate keys in objects are handled  
                                      first - keep the first encountered element  
                                      last  - keep the last encountered element  
                                      all   - keep all elements. starting from the 2nd,  
                                               they get numeric suffixes (key_2 etc)  
                                      by default duplicate keys cause an exception  
         $.object[method-junction]    user method[key;object], called for all parsed  
                                      objects and object keys; method returns a new object  
         $.array[method-junction]     user method called for arrays  
         $.taint[taint language]      sets the transformation language for all result strings  
     ]]  
         parses a json-string into a hash  
   
     ^json:string[system or user object[;  
         $.skip-unknown(false)    disable exception and output 'null' when serializing objects of types  
                                  other than void, bool, string, int, double, date, table, hash, and file  
         $.indent(true)           format the resulting string with indentation according to nesting depth  
         $.date[sql-string|gmt-string|iso-string|unix-timestamp]  
                                  date output format, default = sql-string  
         $.table[object|array|compact]  
                                  format for tables, default=object  
                                  object: [{"c1":"v11","c2":"v12",...},{"c1":"v21","c2":"v22",...},...]  
                                  array:  [["c1","c2",...] || null (for nameless),["v11","v12",...],...]  
                                  compact: ["v11" || ["v11","v12",...],...]  
         $.file[text|base64|stat] output file content in the specified mode (by default file content  
                                  is not included in output)  
         $.xdoc[hash]             parameters for converting xdoc to string (as in ^xdoc.string[])  
         $.type[method-junction]  any type can be output using a user method  
                                  that must take 3 parameters: key, object of that type, and options  
                                  of the ^json:string[] call  
         $._default[method]       user method, called to output all user-class objects.  
                                  The method must take 3 parameters: key, object, and call options.  
         $._default[method name]  method name of a user method, if present it will be called for serialization  
         $.void[null|string]      undefined value will be output as null (default)  
                                  or as an empty string  
     ]]  
         serializes a system or user object into a json-string  
   
 date  
     date type can be used in expressions, substituting the number of days since epoch [1 January 1970 (UTC)], fractional  
     the string value is in local time, numerically in UTC, range from 0000-00-00 00:00:00 to 9999-12-31 23:59:59  
     by default the OS-defined timezone is used  
   
     ^date::now[]  
     ^date::now(days offset)  
         returns now+offset  
     ^date::today[]  
         date at 00:00:00 of the current day  
     ^date::today(integer days offset)  
         date at 00:00:00 of current day+offset  
     ^date::create(days since epoch)  
     ^date::create(year;month[;day[;hour[;minute[;second[;TZ]]]]])  
     ^date::create[date in format %Y-%m-%d %H:%M:%S]  
         convenient creation from a value from a database  
         format1: %Y[-%m[-%d[ %H[:%M[:%S]]]]]  
         format2: %H:%M[:%S]  
     ^date::create[date in format %Y-%m-%dT%H:%M[:%S]TZ]  
         for creation from ISO 8601 format  
         TZ format: Z(UTC) or +-hour[:minute] (offset from UTC)  
     ^date::unix-timestamp()  
     ^date.unix-timestamp[]  
     $date.year month day hour minute second weekday yearday(0...) daylightsaving TZ weekyear  
         TZ="" << local zone  
     $date.year month day hour minute second can be set to new values, others are read-only  
     ^date.double[] ^date.int[]  
         the number of days since epoch [1 January 1970 (UTC)], fractional or truncated  
     ^date.roll[year|month|day](+-offset)  
         shifts the date  
     ^date.roll[TZ;New zone]  
         says that the date is in such a timezone: affects .hour & Co  
     ^date:roll[TZ;New zone]  
         says that by default all dates are in that timezone  
     ^date.sql-string[[datetime|date|time]]  
         datetime or without parameter - %Y-%m-%d %H:%M:%S  
         date                          - %Y-%m-%d  
         time                          - %H:%M:%S  
         where published='^date.sql-string[]'  
     ^date:calendar[rus|eng](year;month)  
         returns an unnamed table, columns: 0..6, week, year  
     ^date:calendar[rus|eng](year;month;day)  
         returns a named table, columns: year, month, day, weekday  
     ^date:last-day(year;month)  
         returns the last day of the month  
     ^date.last-day[]  
         returns the last day of $date's month  
     ^date.gmt-string[]  
         Fri, 23 Mar 2001 09:32:23 GMT  
     ^date.iso-string[]  
         2001-03-23T12:32:23+03  
   
 console  
     $console:timeout  
     $console:line  
         read/write string  
   
 memory  memory
     ^memory:compact[]      ^memory:compact[]
         collect garbage, freeing space for new data (warning: process memory is never released)          collect garbage, freeing space for new data (warning: process memory is never released)
Line 1110  memory Line 1079  memory
     ^memory:auto-compact(frequency)      ^memory:auto-compact(frequency)
         sets automatic garbage collection frequency, from 0 (off) up to 5 (max)          sets automatic garbage collection frequency, from 0 (off) up to 5 (max)
   
   reflection
       ^reflection:create[class;constructor[;pa[;ra[;ms]]]]
           calls the specified class constructor (no more than 100 parameters)
       ^reflection:create[ $.class[name] $.constructor[name] $.arguments[ $.1[pa] $.2[ra] $.3[ms] ] ]
           calls the specified class constructor
       ^reflection:classes[]
           a hash of all classes. key = class name, value can be methoded (a class with methods) or void
       ^reflection:class[object]
           the class of the given object
       ^reflection:class_name[object]
           the class name of the given object
       ^reflection:base[object]
           the parent class of the given object
       ^reflection:base_name[object]
           the parent class name of the given object
       ^reflection:class_by_name[class name]
           obtains the class by name
       ^reflection:class_alias[class name;new class name]
           sets an alias for the specified class
       ^reflection:def[class;class name]
           checks if the class exists
       ^reflection:methods[class]
           a hash with a list of methods of the specified class, values are strings 'native' or 'parser'
       ^reflection:method[class or object;method name]
           returns the junction-method of the class or object
       ^reflection:filename[object or class or method]
           returns the filename where the object, class or method is defined
       ^reflection:fields[class or object]
           a hash with the list of static fields of the specified class or dynamic fields of the specified object
       ^reflection:fields_reference[object]
           an editable hash of the dynamic fields of the specified object
       ^reflection:field[class or object;field name]
           returns the value of the specified field of the class or object. getters are ignored.
       ^reflection:copy[source;destination]
           copies fields from one object or class to another
       ^reflection:uid[class or object]
           returns the identifier of the object or class
       ^reflection:method_info[class;method]
           a hash with parameters of the specified class method
           $.inherited[class] name of the class where the method was defined (returned only if the method was defined in an ancestor)
           $.overridden[class] name of the class where the method was defined (returned only if the method was defined in an ancestor)
           for native classes a hash is returned:
               .min_params(minimum required number of parameters)
               .max_params(maximum possible number of parameters)
               .call_type[dynamic|static|any]
           for parser classes a hash is returned:
               key is parameter number (0, 1, ...), value is parameter name
       ^reflection:dynamical[[object or class, caller if absent]]
           returns true if the method was called from a dynamic context when passing
           a parameter returns true if a dynamic object was passed, false if a class
       ^reflection:delete[class or object;variable name]
           deletes the variable with the specified name in the specified class or object
       ^reflection:is[element name;class name][[context]]
           analogous to the 'is' operator, allowing to determine if the element is code.
       ^reflection:tainting[[language|tainted|optimized];string]
           a string in which each character of the original string corresponds to a character with a transformation code
       ^reflection:stack[ $.args(false/true) $.locals(false/true) $.limit(n) $.offset(o)]
           the current state of the method call stack in the parser
       ^reflection:mixin[source; $.to[target] $.name[name] $.methods(true/false) $.fields(true/false) $.overwrite(false/true)]
           copies methods and fields from one class to another
       ^reflection:override[method[; $.to[target] $.name[new_name]]]
           overrides or defines a method
   
   redis
       ^redis::open[[
           $.host[localhost] $.port(6379)|$.unix_socket[path]
           $.user[] $.password[] $.db(0) $.timeout(2) $.protocol(3) $.auto_reconnect(seconds)
           $.tls[ $.ca[file] $.cert[file] $.key[file] $.verify(true) ]
       ]]
           connects to a redis server
           timeout in seconds for connecting and for each command, 0 - unlimited
           protocol(2) for servers before redis 6
           auto_reconnect(N): after a lost connection reconnect before the next command, waiting N seconds
           tls: the server certificate is verified only if ca is specified
       ^redis.command_name[arguments;...]
           any redis command, e.g. ^redis.set[key;value] ^redis.get[key] ^redis.hgetall[key]
       ^redis.call[command;arguments;...]
       ^redis.f-command_name[arguments;...], ^redis.f-call[command;arguments;...]
           the strings of the reply are files (binary data)
       arguments: string, number, bool as 1/0, file as its content; array - its elements, hash - key value pairs
       reply: string, int, double, bool, void (nil), array, hash (map); an error reply is an exception
       ^redis.release[]
           closes the connection
   
   request
       https://site.name/a%20b/?name=some%20value
       $request:query
           name=some%20value
       $request:uri
           /a%20b/?name=value
       $request:path
           /a b/
       $request:document-root
           directory relative to which paths are considered in parser, default = $env:DOCUMENT_ROOT
       $request:argv
           hash with command-line parameters. keys 0, 1, ... [0 - name of the processed file]
       $request:charset
           the source document encoding
           used in upper/lower and match[][i]
           WARNING: you must set $request/response:charset before using form class fields
       $request:method
           request method (GET|POST|PUT)
       $request:body
           POST-request body as text
       $request:body-file
           POST-request body as a file
       $request:body-charset
           POST-request encoding
       $request:headers
           hash with request headers (without HTTP_ prefix)
   
   response
       $response:field[value] and can read old - $response:field
           the value can be string or hash:
               $value[abc] field: {abc}<<part
               $attribute[zzz] field: abc; {attribute=zzz}<<part
           field or attribute value can be string or date
               if date, it will be converted to "Sun, 25-Aug-2002 12:03:45 GMT"
       $response:headers
            accumulated fields
       $response:body[DATA]
           replaces the standard response
       $response:download[DATA]
           replaces the standard response, sets a flag causing the browser to suggest download
       $response:status
       ^response:clear[] forget all set response fields
       $response:charset
           client encoding, i.e.:
           1) from which $form: fields will be transcoded after retrieval from browser
           2) into which the document will be transcoded before sending to browser
           3) into which URI language text will be transcoded
           does not add anything to content-type; if needed, do it manually
           WARNING: you must set $request/response:charset before using form class fields
   
 status  status
     $status:sql      $status:sql
         cache table          cache table
Line 1390  system error types: Line 1493  system error types:
     http.response        ^file::load[http://ok/there]                host found, connection accepted, bad answer      http.response        ^file::load[http://ok/there]                host found, connection accepted, bad answer
     http.status          ^file::load[http://ok/there]                host found, connection accepted, status!=200      http.status          ^file::load[http://ok/there]                host found, connection accepted, status!=200
     date.range           ^date::create(10000;1;1)                    date out of valid range      date.range           ^date::create(10000;1;1)                    date out of valid range
       amqp                 ^amqp::create[$.port(1)]                    connection failed/error from the broker
       redis                ^redis::open[$.port(1)]                     connection failed/error reply
   
 if $SIGPIPE(1) is defined in MAIN, then if processing was interrupted by the user, a message  if $SIGPIPE(1) is defined in MAIN, then if processing was interrupted by the user, a message
     about this is written to parser3.log      about this is written to parser3.log
   
 if the method description explicitly contains the local variable result (there is also an implicit variable),  if the method description explicitly contains the local variable result (there is also an implicit variable),
     then the code for outputting whitespace literals does not get into the final bytecode      then the code for outputting whitespace literals does not get into the final bytecode
   
   $Id$

Removed from v.1.260  
changed lines
  Added in v.1.273


E-mail: