Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add random operator #130

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@inseefr/trevas-js",
"version": "0.1.14",
"version": "0.2.0",
"description": "JavaScript tools & engine for the [Validation and Transformation Language](https://sdmx.org/?page_id=5096)",
"repository": {
"type": "git",
Expand Down
4 changes: 3 additions & 1 deletion vtl-sources/Vtl-2.0/Vtl.g4
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// VTL 2.0 06/2020 SDMX
// Remove component duplication
// Add distance operators (levenshtein)
// Add random operator (optionalNumeric group)

grammar Vtl;
import VtlTokens;
Expand Down Expand Up @@ -187,7 +188,8 @@ stringOperators:
//;

numericOperators:
op=(CEIL | FLOOR | ABS | EXP | LN | SQRT) LPAREN expr RPAREN # unaryNumeric
op=RANDOM LPAREN (optionalExpr)? RPAREN # optionalNumeric
| op=(CEIL | FLOOR | ABS | EXP | LN | SQRT) LPAREN expr RPAREN # unaryNumeric
| op=(ROUND | TRUNC) LPAREN expr (COMMA optionalExpr)? RPAREN # unaryWithOptionalNumeric
| op=(MOD | POWER|LOG) LPAREN left=expr COMMA right=expr RPAREN # binaryNumeric
;
Expand Down
1 change: 1 addition & 0 deletions vtl-sources/Vtl-2.0/VtlTokens.g4
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ lexer grammar VtlTokens;
CEIL : 'ceil';
FLOOR : 'floor';
SQRT : 'sqrt';
RANDOM : 'random';
ANY : 'any';
SETDIFF : 'setdiff';
STDDEV_POP : 'stddev_pop';
Expand Down