Repository navigation
[api] Introduce a parser for Esri arcade expressions - #67951
Conversation
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.
Since this is an API only addition it's not subject to freeze
🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
This isn't documented, but it does work in Arcade
Which unfortunately considerably complicates things! It also doesn't mandate the line-ending semi colon, which MAJORLY complicates things
domi4484
left a comment
There was a problem hiding this comment.
I know just basics of how flex and bison works, but that seems a good extensible approach to me.
|
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. |
|
I don't have the rights to approve, but I tested it and looks good to me. |
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.
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.