{"id":19004825,"url":"https://github.com/dhis2/expression-parser","last_synced_at":"2025-04-22T18:34:01.593Z","repository":{"id":43170623,"uuid":"509006335","full_name":"dhis2/expression-parser","owner":"dhis2","description":"DHIS2 expression language parser","archived":false,"fork":false,"pushed_at":"2025-03-17T12:13:44.000Z","size":716,"stargazers_count":4,"open_issues_count":2,"forks_count":5,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-17T10:24:23.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhis2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-06-30T09:00:07.000Z","updated_at":"2025-03-21T13:53:39.000Z","dependencies_parsed_at":"2023-11-14T12:24:20.644Z","dependency_job_id":"f1b59a3a-97b7-4c13-81bb-20866a355448","html_url":"https://github.com/dhis2/expression-parser","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhis2%2Fexpression-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhis2%2Fexpression-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhis2%2Fexpression-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhis2%2Fexpression-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhis2","download_url":"https://codeload.github.com/dhis2/expression-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250297475,"owners_count":21407215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T18:24:39.846Z","updated_at":"2025-04-22T18:34:01.571Z","avatar_url":"https://github.com/dhis2.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.hisp.dhis.lib.expression/expression-parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.hisp.dhis.lib.expression/expression-parser)\n[![NPM Version](https://img.shields.io/npm/v/@dhis2/expression-parser)](https://www.npmjs.com/package/@dhis2/expression-parser)\n[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://dhis2.github.io/expression-parser/api/)\n\n# Expression Parser\n\nA parser for the DHIS2 expression language.\n\nThe parser is implemented as a kotlin multiplatform project in order to yield\na Java and JS library that can be used in client and server of DHIS2.\n\nThe parsing follows the PEG approach. \nEssentially this means for each building block there is a corresponding function implementing its\nparsing which has this shape:\n\n```kotlin\n// e.g. to deal with the 'expr' fragment of the grammar\nfun expr(expr: Expr, ctx: ParseContext) {\n    // ...\n}\n```\n\nEach such method accepts two arguments:\n1. the `Expr` representing the parsed input expression and the position in it\n2. the `ParseContext` to emit AST nodes and lookup named fragments\n\nThe parsing is implemented on 4 levels (high to low):\n1. `ExpressionGrammar`: high level composition of named fragments\n2. `Expr`: specific hard coded fragments (like `expr`), operators and brackets\n3. `Literals`: terminals of the language; string, number, date literals etc.\n4. `Chars`: named character sets of the language as used by `Literals`\n\nFor an equivalent of a (ANTLR) grammar definition look at `ExpressionGrammar`.\n\n### API\nThe public API of the library is encapsulated by `Expression` which refers to types \nin the `org.hisp.dhis.lib.expression.spi` package.\n\nFor JavaScript the main entry point to the API is called `ExpressionJs`.\n\n### Modes\nDHIS2 has several expression language, each supporting a different set of functions.\nTo select which expression is used the `Expression` is parameterized with a `Mode`.\n\n* `VALIDATION_RULE_EXPRESSION`: Computes a number for a validation rule\n* `VALIDATION_RULE_RESULT_TEST`: Computes a boolean for a validation rule result\n* `PREDICTOR_GENERATOR_EXPRESSION`: Computes a number or string data value for a predictor expression\n* `PREDICTOR_SKIP_TEST`: Computes a boolean to test if a data section should be skipped when evaluating predictor expressions\n* `INDICATOR_EXPRESSION`: Computes a number for an indicator expression (ad-hoc aggregate data computation)\n* `PROGRAM_INDICATOR_EXPRESSION`: Computes a number for a program indicator expression (persisted aggregate data computation)\n* `RULE_ENGINE_CONDITION`: Computes a boolean to check if a rule applies\n* `RULE_ENGINE_ACTION`: Computes a boolean, string, number or date from a rule\n\n## Development\n\n### API Validator\nThis library uses the [Binary Compatibility Validator plugin](https://github.com/Kotlin/binary-compatibility-validator), which verifies that there are no changes in the public API of the library.\n\nThe way of work is: there is a file generated by the plugin (`api/expression-parser.api`) with the binary representation of the expected public API. The plugin has a task (`apiCheck`) that verifies that the public API of the code matches the expected API in the file.\n\nIf there is an intentional change in the public API, this file must be updated to reflect the changes and included as part of the pull request. It can be updated running the task `apiDump`. This task can be run in the command line (`./gradlew apiDump`) or using Gradle window in Intellij.\n\n### Version\nLibrary version is defined in the file `build.gradle.kts`. The version must be manually increased \nand include the `-SNAPSHOT` suffix. Please make sure the version is updated before opening the PR.\n\n### Publications\n\nOn merged pull request to `main`:\n- Production release to Maven.\n- Production release to NPMJS.\n\nOn pull request creation/update:\n- Snapshot release to Maven.\n\nOn demand:\n- Beta releases to NPMJS can be triggered on demand by using the action \"Publish NPM beta\". \nPlease make sure you select the right branch in the selector.\n\nPublication can be skipped by adding `[skip publish]` to the pull request title.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhis2%2Fexpression-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhis2%2Fexpression-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhis2%2Fexpression-parser/lists"}