Skip to content

luxms/luxmsbi-lpe

Repository files navigation

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

About

Lux Path Expressions Lexer and Parser implementation in Javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •