luxmsbi-lpe

Форк
0

README.md

Build Status

LPE parser

Two grammars

Standard LPE grammar

basically follows LISP notation but written with C-like function call semantics. Example:

f1(1,b,c).f2(d,e,f).f3(w)

Dot (

.
) separated function calls will compose to left thread
->
call:
["->",["f1",1,"b","c"],["f2","d","e","f"],["f3","w"]]
Semicolon (
;
) separated function calls will compose to
begin
call:
["begin",["f1",1,"b","c"],["f2","d","e","f"],["f3","w"]]

Arrays notation

[]
will result in
[
call:
[1,2,3]
=>
["[","1","2","3"]

Logical LPE grammar

Some functions will have special syntax for their arguments. Currently only

logical
syntax is supported. For example, it is used for
where
function, which has single logical expression argument with 3 operations:
and
,
or
,
not
. Logical operations may use any LPE expression as argumants. Brackets are preserved with call to obvious
()
function.

where((a and b or c) or (avg(d) < avg(e)) or (e = 20 and parse_kv(locations.src_id)))

[
"where",
[
"or",
[
"()",
[
"and",
"a",
[
"or",
"b",
"c"
]
]
],
[
"or",
[
"()",
[
"<",
[
"avg",
"d"
],
[
"avg",
"e"
]
]
],
[
"()",
[
"and",
[
"=",
"e",
20
],
[
"parse_kv",
[
"->",
"locations",
"src_id"
]
]
]
]
]
]
]

Note, that dot notation in arguments

locations.src_id
is currently interpreted as
->
call.

Run from cli

echo "FIRST([in([6+abc().cba()*3+2,6+8],out()),[45,44],444]).SECOND(.fff(2,3,4,,3+5-987).last())" | npm run cli

Tests

Run tests:

npm install
npm run test
npm run test-sql

Описание

Lux Path Expressions Lexer and Parser implementation in Javascript

Языки

JavaScript

Сообщить о нарушении

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.