--- parser3/operators.txt 2024/12/20 17:39:37 1.261 +++ parser3/operators.txt 2026/11/29 17:53:21 1.280 @@ -19,6 +19,7 @@ operators e.g., "is the method parameter not a hash?" -f checks if a file exists on disk, -d checks if a directory exists on disk, + -l checks if a symbolic link exists on disk, a quoted string (double or single quotes) is treated as a string, unquoted text is a string until the nearest whitespace numeric literals can be in hex format like 0xABC priorities: @@ -28,7 +29,7 @@ operators %left "&&" %left '<' '>' "<=" ">=" "lt" "gt" "le" "ge" %left "==" "!=" "eq" "ne" - %left "is" "def" "in" "-f" "-d" + %left "is" "def" "in" "-f" "-d" "-l" %left '!' /* bitwise */ @@ -156,6 +157,9 @@ odbc parser3odbc.dll ^rem{} a comment, removed at compile time + ^syslog[ident;message[;info|warning|error|debug]] + writes a message to syslog + ^cache[file](seconds){code}[{catch code}] relative time assignment caches the string resulting from the code execution for 'seconds' seconds @@ -163,6 +167,11 @@ odbc parser3odbc.dll in the catch code, $exception.handled[cache] ^rem{flag that exception is handled} ^cache[file][expires date]{code}[{catch code}] absolute time assignment + ^cache[file][ $.expires(seconds)|[expires date] $.extend(seconds) ]{code}[{catch code}] + the same, with the options + $.extend(seconds) if the cache expired no more than 'seconds' ago [$MAIN:LIMITS.lock_wait_timeout by default], one request renews it, the others get the old copy meanwhile + for no more than 'seconds': if the code runs longer or fails, the next request renews the cache + if cache expired more than 'seconds' ago, there is no copy, or with $.extend(0), the others wait for the result: the code does not run twice ^cache[file] deletes the file [no error if it doesn't exist] ^cache(seconds) @@ -195,7 +204,6 @@ odbc parser3odbc.dll UTF-8 is always available and is the default encoding for request and response WARNING: the encoding name is case-insensitive - syntax $name[new value] $name(arithmetic expression of new value) @@ -242,6 +250,8 @@ int,double boolean value ^name.inc(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.div(how much /) ^name.mod(how much %) @@ -296,6 +306,11 @@ string ^string.pos[substring] ^string.pos[substring](position from which to search) <0 = not found + ^string.rpos[substring] + the last substring in the string + ^string.rpos[substring](maximum position of the substring start) + the last substring that starts at or before the position + <0 = not found ^string.replace[$table_of_substitutions_string_to_string] ^string.replace[$what;$to] ^string.save[[append;]path] @@ -361,9 +376,9 @@ table ^table.count[cells] number of cells in the current row ^table.sort{{string-key-maker}|(numeric-key-maker)}[{desc|asc}] default=asc - ^table.append{data} + ^table.append{data}[[$.separator[^#09] $.encloser[]]] ^table.append[ $.column_name[column_value] ] - ^table.insert{data} add a record at the current position + ^table.insert{data}[[$.separator[^#09] $.encloser[]]] add a record at the current position ^table.insert[ $.column_name[column_value] ] ^table.delete[] deletes the record at the current position @@ -428,7 +443,7 @@ hash ^hash.foreach[key;value]{body}[[delimiter]|{delimiter executed before each non-empty non-first body}] ^hash.delete[key] delete key - ^hash.contain[key] + ^hash.contains[key] checks if hash contains a key (bool) ^hash.at[first|last][[key|value|hash]] ^hash.at([-]N)[[key|value|hash]] @@ -436,6 +451,8 @@ hash ^hash.set[first|last;value] ^hash.set([-+]N)[value] 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] ...] renames the specified hash keys @@ -509,7 +526,7 @@ array adds an element to the end of the array ^array.pop[] 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) ^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 @@ -546,6 +563,286 @@ array $selected[^array.select[key;value](expression)[ $.limit(N) $.reverse(bool) ]] 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:rmdir[dirname[; $.exception(false) ]] + removes the empty directory + ^file:find[filename][{if not found}] + ^file:list[path[;pattern-string|pattern-regex]] + table with columns name dir symlink + ^file:list[path;$.filter[pattern-string|pattern-regex] $.stat(true)] + table with columns name dir symlink 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 files and directories, but not across disk boundaries + the existing file is replaced, as well as the empty directory if a directory is moved + 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]] + + ^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 [the first element with the same name is taken from GET, then from POST] $form:field @@ -565,140 +862,60 @@ form $form:imap a hash with keys 'x' and 'y' with ?1,2 suffixes when using server-side image map -env - $env:variable - $env:fields hash with environment variables - $env:PARSER_VERSION parser version - -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=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}< - ^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:PI ^math:round floor ceiling ^math:trunc frac ^math:abs sign + ^math:min(a;b[;c...]) max(a;b[;c...]) ^math:exp log log10 ^math:sin asin cos acos tan atan atan2 ^math:degrees radians @@ -965,6 +1062,8 @@ math ^math:convert[number|file](base-from)[alphabet][[ $.format[string|file] ]] 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) + ^math:eq(a;b[;max ULP]) + true if difference between doubles less or equal max ULPs (default 3) ^math:uuid[ $.lower(bool) $.solid(bool) ] 22C0983C-E26E-4169-BD07-77ECE9405BA5 win32: uses cryptapi @@ -990,118 +1089,8 @@ math ^math:digest[[md5|sha1|sha256|sha512];string or file][[ $.format[hex|base64|file] $.hmac[key string|key file] ]] combines the ability to use various cryptographic hashing algorithms. $.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 + ^math:xxhash[xxh32|32|xxh64|64;string or file][[ $.format[hex|base64|file] ]] + fast non-cryptographic xxHash, 4 or 8 bytes, the most significant byte first memory ^memory:compact[] @@ -1110,6 +1099,140 @@ memory ^memory:auto-compact(frequency) 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}<