Skip to content

Commit

Permalink
Merge pull request #3586 from szarnyasg/js-archive
Browse files Browse the repository at this point in the history
Archive JS
  • Loading branch information
szarnyasg authored Sep 9, 2024
2 parents d916322 + 137caf4 commit 99978cb
Show file tree
Hide file tree
Showing 53 changed files with 4,274 additions and 0 deletions.
42 changes: 42 additions & 0 deletions js/archive/expressions/aggregate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function GenerateAggregateOrderBy(options = {}) {
return [
Keyword("ORDER"),
Keyword("BY"),
GenerateOrderTerms()
]
}

function GenerateAggregate(options = {}) {
return Diagram([
AutomaticStack([
Expression("aggregate-name"),
Keyword("("),
Choice(0, [
Sequence([
Optional(Keyword("DISTINCT"), "skip"),
OneOrMore(Sequence([
Expression()
]), Keyword(",")),
Optional(Expandable("order-by", options, "order-by", GenerateAggregateOrderBy))
]),
new Skip()
]),
Keyword(")"),
Optional(Sequence(GenerateFilterClause())),
])
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = GenerateAggregate(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

34 changes: 34 additions & 0 deletions js/archive/expressions/case.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

function GenerateCase(options = {}) {
return Diagram([
Sequence([
Keyword("CASE"),
Optional(Expression(), "skip"),
OneOrMore(Sequence([
Keyword("WHEN"),
Expression(),
Keyword("THEN"),
Expression()
])),
Optional(Sequence([
Keyword("ELSE"),
Expression(),
])),
Keyword("END")
])
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = GenerateCase(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

37 changes: 37 additions & 0 deletions js/archive/expressions/cast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

function GenerateCast(options = {}) {
return Diagram([
Choice(0,[
Sequence([
Choice(0, [
Keyword("CAST"),
Keyword("TRY_CAST")
]),
Keyword("("),
Expression(),
Keyword("AS"),
Expression("type-name"),
Keyword(")")
]),
Sequence([
Expression(),
Keyword("::"),
Expression("type-name")
])
])
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = GenerateCast(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

24 changes: 24 additions & 0 deletions js/archive/expressions/collate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

function GenerateFunctions(options = {}) {
return Diagram([
Sequence([
Expression(),
Keyword("COLLATE"),
Expression("collation-name")
])
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = GenerateFunctions(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

47 changes: 47 additions & 0 deletions js/archive/expressions/comparison.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

function GenerateBetween(options = {}) {
return Diagram([
Choice(0, [
Sequence([
Expression(),
Optional(Keyword("NOT"), "skip"),
Keyword("BETWEEN"),
Expression(),
Keyword("AND"),
Expression()
]),
Sequence([
Expression(),
Keyword("IS"),
Optional(Keyword("NOT"), "skip"),
Keyword("NULL"),
])
])
])
}

function GenerateComparison(options = {}) {
return Diagram([
Sequence([
Expression(),
Expression("binary-operator"),
Expression()
])
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram1").classList.add("limit-width");
document.getElementById("rrdiagram1").innerHTML = GenerateBetween(options).toString();
document.getElementById("rrdiagram2").classList.add("limit-width");
document.getElementById("rrdiagram2").innerHTML = GenerateComparison(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

27 changes: 27 additions & 0 deletions js/archive/expressions/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

function GenerateFunctions(options = {}) {
return Diagram([
Sequence([
Expression("function-name"),
Keyword("("),
ZeroOrMore(Sequence([
Expression()
]), Keyword(",")),
Keyword(")")
])
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = GenerateFunctions(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

14 changes: 14 additions & 0 deletions js/archive/expressions/in.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = GenerateIn(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

51 changes: 51 additions & 0 deletions js/archive/expressions/like.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

function GenerateLike(options = {}) {
return Diagram([
Expression("string"),
Optional(Keyword("NOT"), "skip"),
Keyword("LIKE"),
Expression("pattern"),
Optional(
Sequence([
Keyword('ESCAPE'),
Expression('escape_character')
])
)
])
}

function GenerateSimilarTo(options = {}) {
return Diagram([
Expression("string"),
Optional(Keyword("NOT"), "skip"),
Keyword("SIMILAR"),
Keyword("TO"),
Expression("pattern")
])
}

function GenerateGlob(options = {}) {
return Diagram([
Expression("string"),
Keyword("GLOB"),
Expression("pattern")
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram1").classList.add("limit-width");
document.getElementById("rrdiagram1").innerHTML = GenerateLike(options).toString();
document.getElementById("rrdiagram2").classList.add("limit-width");
document.getElementById("rrdiagram2").innerHTML = GenerateSimilarTo(options).toString();
document.getElementById("rrdiagram3").classList.add("limit-width");
document.getElementById("rrdiagram3").innerHTML = GenerateGlob(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

33 changes: 33 additions & 0 deletions js/archive/expressions/logical.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

function GenerateLogicalFunctions(options = {}) {
return Diagram([
Choice(0, [
Sequence([
Expression(),
Choice(0, [
Keyword("AND"),
Keyword("OR")
]),
Expression()
]),
Sequence([
Keyword("NOT"),
Expression()
])
])
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = GenerateLogicalFunctions(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

14 changes: 14 additions & 0 deletions js/archive/expressions/star.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

function Initialize(options = {}) {
document.getElementById("rrdiagram").classList.add("limit-width");
document.getElementById("rrdiagram").innerHTML = Diagram(GenerateStarClause(options)).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

36 changes: 36 additions & 0 deletions js/archive/expressions/subqueries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

function GenerateScalarSubquery(options = {}) {
return Diagram([
Keyword("("),
Expression("select-node"),
Keyword(")")
])
}

function GenerateExists(options = {}) {
return Diagram([
Optional(Keyword("NOT"), "skip"),
Keyword("EXISTS"),
Keyword("("),
Expression("select-node"),
Keyword(")")
])
}

function Initialize(options = {}) {
document.getElementById("rrdiagram1").classList.add("limit-width");
document.getElementById("rrdiagram1").innerHTML = GenerateScalarSubquery(options).toString();
document.getElementById("rrdiagram2").classList.add("limit-width");
document.getElementById("rrdiagram2").innerHTML = GenerateExists(options).toString();
document.getElementById("rrdiagram3").classList.add("limit-width");
document.getElementById("rrdiagram3").innerHTML = GenerateIn(options).toString();
}

function Refresh(node_name, set_node) {
options[node_name] = set_node;
Initialize(options);
}

options = {}
Initialize()

Loading

0 comments on commit 99978cb

Please sign in to comment.