Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
481b70f
commit acb1721
Showing
3 changed files
with
113 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,42 @@ | ||
# BNF from sequelize due to issue #8 | ||
# This package does not own any rights to this BNF | ||
# After updating this file run: | ||
# yarn run build-bnf | ||
# or | ||
# npx bnf-compile ./packages/core/src/utils/bnf/syntax.bnf | ||
# To update the compiled artifacts | ||
|
||
program ::= switcher+ ; | ||
|
||
switcher ::= ( sw_attr | sw_json ) nl ; | ||
sw_attr ::= "attr: " attribute ; | ||
sw_json ::= "json: " partialJsonPath ; | ||
nl ::= "\r\n" | "\n"; | ||
|
||
|
||
# Entry points | ||
## Used when parsing the attribute | ||
attribute ::= ( ...association | ...identifier ) jsonpath? castormodifiers?; | ||
attribute ::= attributeBegin jsonAccess* transform* ; | ||
attributeBegin ::= association | ...identifier ; | ||
|
||
## Used when parsing a nested JSON path used inside of an attribute | ||
## Difference with "attribute" is in the first part. Instead of accepting: | ||
## $association.attribute$ & attribute | ||
## It accepts: | ||
## key, "quotedKey", and [0] (index access) | ||
partialjsonpath ::= ( ...indexaccess | ...key ) jsonpath? castormodifiers? ; | ||
partialJsonPath ::= key jsonAccess* transform* ; | ||
|
||
# Internals | ||
identifier ::= ( "A"->"Z" | "a"->"z" | digit | "_" )+ ; | ||
digit ::= "0"->"9" ; | ||
number ::= ...digit+ ; | ||
association ::= %"$" identifier ("." identifier)* %"$" ; | ||
jsonpath ::= ( ...indexaccess | ...keyaccess )+ ; | ||
indexaccess ::= %"[" number %"]" ; | ||
identifier ::= ( "A"->"Z"+ | "a"->"z"+ | "0"->"9"+ | "_" )+ ; | ||
digit ::= "0"->"9" ; | ||
number ::= ...digit+ ; | ||
association ::= %"$" ...identifier (%"." ...identifier)* %"$" ; | ||
jsonAccess ::= indexAccess | keyAccess ; | ||
indexAccess ::= %"[" ...number %"]" ; | ||
keyAccess ::= %"." ...key ; | ||
|
||
keyaccess ::= %"." key ; | ||
nonemptystring ::= ...(%"\\" (anyexceptquoteorbackslash | escapedcharacter)+ %"\\") ; | ||
key ::= nonemptystring | ( "A"->"Z" | "a"->"z" | digit | "_" | "-" )+ ; | ||
escapedcharacter ::= %"\\\\" ( "\\" | "\\\\" ); | ||
any ::= !"" ; | ||
anyexceptquoteorbackslash ::= !("\\" | "\\\\"); | ||
castormodifiers ::= (...cast | ...modifier)+; | ||
cast ::= %"::" identifier ; | ||
modifier ::= %":" identifier ; | ||
# path segments accept dashes without needing to be quoted | ||
key ::= nonEmptyString | identifier ; | ||
nonEmptyString ::= ...(%"\"" (anyExceptQuoteOrBackslash | escapedCharacter)+ %"\"") ; | ||
escapedCharacter ::= %"\\" ( "\"" | "\\" ); | ||
anyExceptQuoteOrBackslash ::= !("\"" | "\\"); | ||
transform ::= cast | modifier ; | ||
cast ::= %"::" ...identifier ; | ||
modifier ::= %":" ...identifier ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
attr: data.key | ||
attr: jsonAttr.nested | ||
attr: id | ||
attr: name | ||
attr: creationYear | ||
attr: deletedAt | ||
attr: value | ||
attr: date | ||
attr: uid::text | ||
attr: age | ||
attr: bar | ||
attr: duration | ||
attr: username | ||
attr: data.email | ||
attr: firstName | ||
attr: test_user_id | ||
attr: public | ||
attr: $User.id_user$ | ||
attr: user_id | ||
attr: $Company.owner_id$ | ||
attr: metadata | ||
attr: metadata.pg_rating.dk | ||
attr: profile.id.0.1 | ||
attr: metadata.pg_rating.is | ||
attr: profile | ||
attr: property | ||
attr: profile.id | ||
attr: foo | ||
attr: email | ||
attr: companyId | ||
attr: project_id | ||
attr: status | ||
attr: scopeId | ||
attr: data | ||
attr: $postaliasname.title$ | ||
attr: intAttr1 | ||
attr: dateAttr | ||
attr: stringAttr | ||
attr: binaryAttr | ||
attr: stringAttr::integer | ||
attr: $intAttr1$ | ||
attr: $stringAttr$::integer | ||
attr: $association.attribute$ | ||
attr: $association.attribute$::integer | ||
attr: booleanAttr | ||
attr: nullableIntAttr | ||
attr: intAttr1::integer | ||
attr: $intAttr1$::integer | ||
attr: intAttr1::text | ||
attr: jsonAttr | ||
attr: jsonAttr.nested.twice | ||
attr: $jsonAttr$.nested | ||
attr: $association.jsonAttr$.nested | ||
attr: jsonAttr.nested::STRING | ||
attr: $association.jsonAttr$.nested::STRING | ||
attr: $association.jsonAttr$.nested.deep::STRING | ||
attr: $jsonAttr$ | ||
attr: jsonAttr.nested.attribute | ||
attr: jsonAttr.0 | ||
attr: jsonAttr[0] | ||
attr: jsonAttr.0.attribute | ||
attr: jsonAttr[0].nested.attribute | ||
attr: aliasedJsonAttr.nested.attribute | ||
attr: jsonAttr:unquote | ||
attr: jsonAttr.key:unquote | ||
attr: jsonAttr.nested.key:unquote | ||
attr: jsonAttr[0]:unquote | ||
attr: $bar$ | ||
attr: foo::bar | ||
attr: foo::bar::baz | ||
attr: foo.bar | ||
attr: foo:unquote | ||
attr: foo:unquote:unquote | ||
attr: textAttr::json:unquote::integer | ||
json: foo.bar | ||
json: twice | ||
json: jsonPath |