Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ransack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Mentat
ransack
Commits
8ee05652
Verified
Commit
8ee05652
authored
2 months ago
by
Rajmund Hruška
Browse files
Options
Downloads
Patches
Plain Diff
Docs: Add very basic syntax reference
parent
431b3caf
No related branches found
No related tags found
No related merge requests found
Pipeline
#19261
passed
2 months ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/index.rst
+1
-0
1 addition, 0 deletions
docs/index.rst
docs/language.rst
+137
-0
137 additions, 0 deletions
docs/language.rst
with
138 additions
and
0 deletions
docs/index.rst
+
1
−
0
View file @
8ee05652
...
...
@@ -8,5 +8,6 @@ Python library for filtering, querying or inspecting almost arbitrary data struc
:maxdepth: 1
:caption: Contents:
language
api
This diff is collapsed.
Click to expand it.
docs/language.rst
0 → 100644
+
137
−
0
View file @
8ee05652
Language reference
==================
This document describes the syntax and semantics of the custom language used in ransack.
.. contents:: Table of Contents
:depth: 2
:local:
Basic Data Types
----------------
- **Number**: Decimal or scientific notation.
- ``42``, ``3.14``, ``1e-5``
- **String**: Enclosed in single or double quotes.
- ``"hello"``, ``'world'``
- **Variable**: Alphanumeric with optional dots, underscores, or hyphens.
- ``Source.IP4``, ``.Description``
- **Datetime**: Combination of date and time, optionally joined by "T".
- Full: ``2025-04-11T14:30:00``, ``2025-04-11 14:30:00Z``
- Date only: ``2025-04-11`` (interpreted as datetime with zeroed time)
- **Timedelta**: Duration formatted as ``[D]HH:MM:SS``
- ``1D12:00:00``, ``23:59:59``
- **IPv4**:
- Single: ``192.168.1.1``
- Range: ``192.168.1.1-192.168.1.100``
- CIDR: ``192.168.1.0/24``
- **IPv6**:
- Single: ``2001:db8::1``
- Range: ``2001:db8::1-2001:db8::ff``
- CIDR: ``2001:db8::/64``
Collections
-----------
- **List**: Comma-separated values in square brackets.
- ``[1, 2, 3.0]``, ``[192.168.0.1, 192.168.0.0/24]``
- **Range**:
- ``1..1024``, ``1.0 .. 0``, ``2025-01-01 .. 2025-12-31``
Arithmetic Operators
--------------------
- ``+`` : Addition
- ``-`` : Subtraction / Negation (unary)
- ``*`` : Multiplication
- ``/`` : Division
- ``%`` : Modulo
Logical Operators
-----------------
- ``and`` / ``&&`` : Logical AND
- ``or`` / ``||`` : Logical OR
- ``not`` / ``!`` : Logical NOT
Comparison Operators
--------------------
- ``=`` : Loose equality
- ``==`` : Strict equality
- ``>`` / ``>=`` : Greater than / Greater than or equal
- ``<`` / ``<=`` : Less than / Less than or equal
- ``like`` / ``LIKE`` : Pattern matching
- ``in`` / ``IN`` : Membership test
- ``contains`` / ``CONTAINS`` : Collection containment
Special Operators
-----------------
- ``??`` : Existence check or default fallback
- ``foo ?? "default"``, ``Source.Port??[]``, ``Description??``
- ``.`` : Concatenation
- ``'abc'.'def'`` , ``[1, 2, 3] . [4, 5, 6]``
Functions
---------
Functions are called with parentheses. Arguments are comma-separated:
.. code-block:: text
func_name(arg1, arg2)
Examples:
.. code-block:: text
len(Source.IP4)
now()
Evaluation Order (Precedence)
-----------------------------
From highest to lowest:
1. Parentheses ``()``
2. Unary minus ``-``
3. Existence ``??``
4. Multiplicative: ``*``, ``/``, ``%``
5. Additive: ``+``, ``-``
6. Concatenation: ``.`` and Ranges: ``..``
7. Comparison: ``=, ==, >, <, >=, <=, like, in, contains``
8. Logical NOT: ``!``, ``not``
9. Logical AND: ``&&``, ``and``
10. Logical OR: ``||``, ``or``
Examples
--------
.. code-block:: text
(3 + 4) * 2
"tcp" in Source.Proto??[]
not (Format == "IDEA0")
Source.IP4 = 192.168.0.1 or 10.0.0.0/8 in Source.IP4
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment