pql-parser
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

pql-parser

node.js.yml npm-publish.yml npm

Plot query language parser library.

A simple CSV visualizer tool made with this parser is hosted at https://devtools.joeyshi.xyz/csv_vis.

Syntax

PLOT (BAR(category_column, value_column) | LINE(x_column, y_column) | SCATTER(x_column, y_column))
[WHERE <condition>]
[GROUP BY <column>]
[HAVING <condition>]
[LIMIT <limit> [OFFSET <offset>]]

EBNF

<plot_statement> ::= "PLOT" <plot_call> [<where_clause>] [<group_by_clause>] [<having_clause>] [<limit_and_offset_clause>]

<plot_clause> ::= <bar_call> | <line_call> | <scatter_call>

<bar_call> ::= "BAR" "(" <attribute> "," <attribute> ")"

<line_call> ::= "LINE" "(" <attribute> "," <attribute> ")"

<scatter_call> ::= "SCATTER" "(" <attribute> "," <attribute> ")"

<where_clause> ::= "WHERE" <where_condition>

<group_by_clause> ::= "GROUP BY" <identifier>

<having_clause> ::= "HAVING" <having_condition>

<limit_and_offset_clause> ::= "LIMIT" <number> ["OFFSET" <number>]

<boolean_operator> ::= "OR" | "AND"

<attribute> ::= <aggregated_column> ["AS" <identifier>]

<aggregated_column> ::= <aggregation_function> "(" <identifier> ")" | <identifier>

<aggregation_function> ::= "MIN" | "MAX" | "AVG" | "COUNT" | "SUM"

<identifier> ::= <alphabetic> { <alphabetic> | <digit> | "_" }

<where_condition> ::= <where_condition_group> { "OR" <where_condition_group> } | <where_condition_group> { "AND" <where_condition_group> }

<where_condition_group> ::= <identifier> <comparison_operator> <value> | "(" <where_condition> ")"

<having_condition> ::= <having_condition_group> { "OR" <having_condition_group> } | <having_condition_group> { "AND" <having_condition_group> }

<having_condition_group> ::= <aggregated_column> <comparison_operator> <value> | "(" <having_condition> ")"

<comparison_operator> ::= ">" | "<" | ">=" | "<=" | "="

<value> ::= <number> | <string> | "NULL"

<number> ::= <digit> {<digit>}

<string> ::= "'" <alphabetic> {<alphabetic>} "'"

<digit> ::= "0" | ... | "9"

<alphabetic> ::= "A" | ... | "Z" | "a" | ... | "z"

Readme

Keywords

Package Sidebar

Install

npm i pql-parser

Weekly Downloads

2

Version

0.3.1

License

MIT

Unpacked Size

45 kB

Total Files

19

Last publish

Collaborators

  • joeyshi12