Skip to content

[api] Introduce a parser for Esri arcade expressions - #67951

Merged
nyalldawson merged 21 commits into
qgis:masterfrom
nyalldawson:arcade
Oct 29, 2026
Merged

nyalldawson merged 21 commits into
qgis:masterfrom
nyalldawson:arcade

Conversation

@nyalldawson

Copy link
Copy Markdown
Collaborator

Description

Introduces QgsEsriArcadeScript, which is a parser for the Esri arcade script language.

This language is used in the properties returned by Esri feature servers for definining layer properties, and is too complex to
parse via regex alone. In order to fully support automated conversion of the feature server renderer and label settings, we need a way to convert the Arcade expressions defined in the service properties to an equivalent QGIS expression. A full parser with visitor pattern API is the best way to achieve this.

(Based heavily off the existing QgsSqlStatement API and parser)

This PR is an API addition only, to be used in future work to fix bugs in conversion of FeatureServer styles.

  • I certify that no AI tool(s) (Copilot, Claude, or something similar), LLMs, or agent based workflows were used or supported my development of this PR. See our policy about AI tool use.

No LLM, AI or agent assisted code contributions are allowed in the QGIS repository. If we subsequently discover that you have used an AI, LLM, or any agent-based workflow for your contribution, you will be subject to code reversion and contributor rights sanctioning. See QEP 408 for details.

Introduces QgsEsriArcadeScript, which is a parser for the Esri
arcade script language.

This language is used in the properties returned by Esri feature
servers for definining layer properties, and is too complex to
parse via regex alone. In order to fully support automated conversion
of the feature server renderer and label settings, we need a way
to convert the Arcade expressions defined in the service properties
to an equivalent QGIS expression. A full parser with visitor pattern
API is the best way to achieve this.

Currently supports very basic expressions only.

(Based heavily off the existing QgsSqlStatement API and parser)
Arcade allows single line scripts, where the script is expected
to be an expression. In these cases the "return" and trailing ";"
isn't required, and is just implied.
- some documentation improvements and add missing docs
- rename enum values to remove "uo"/"bo" prefixes. While the other
  parsers this code was copied from use those, it's not a standard
  we usually use in QGIS code and isn't necessary for enum classes
- improve examples
Since this is an API only addition it's not subject to freeze
@nyalldawson nyalldawson added the API API improvement only, no visible user interface changes label Oct 24, 2026
@github-actions github-actions Bot added this to the 4.4.0 milestone Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🍎 MacOS Qt6 builds

Download MacOS Qt6 builds of this PR for testing.
This app is not notarized, run sudo xattr -d com.apple.quarantine /Applications/QGIS*.app to avoid the warning
(Built from commit 766701a)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
To execute locally, unzip the downloaded zip file and run bin\qgis-bin.exe in the extracted directory.
You might be prompted by Windows Defender click "Run anyway"
(Built from commit 766701a)

@nyalldawson nyalldawson reopened this Oct 25, 2026
Which unfortunately considerably complicates things! It also
doesn't mandate the line-ending semi colon, which MAJORLY
complicates things

@domi4484 domi4484 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know just basics of how flex and bison works, but that seems a good extensible approach to me.

@nyalldawson

Copy link
Copy Markdown
Collaborator Author

I've now tested this against my dataset containing thousands of ESRI arcade scripts, and I'm confident it works well across all of them. This should be ready for merge now.

@domi4484

Copy link
Copy Markdown
Contributor

I don't have the rights to approve, but I tested it and looks good to me.

@nyalldawson
nyalldawson merged commit 96ea40d into qgis:master Oct 29, 2026
36 of 38 checks passed
@nyalldawson
nyalldawson deleted the arcade branch October 29, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API API improvement only, no visible user interface changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants