Skip to content

Commit 695e7f4

Browse files
committed
Merge branch 'betterimports'
2 parents 22442ad + e3d98b9 commit 695e7f4

11 files changed

Lines changed: 102 additions & 146 deletions

File tree

‎embedded.html‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<meta name='viewport' content='width=device-width, initial-scale=1'>
99

1010
<link rel='stylesheet' type='text/css' media='screen' href='assets/fonts/fonts.css'>
11-
<script src="lib/pako/pako.js"></script>
11+
<!-- <script src="lib/pako/pako.js"></script>
1212
<script src="lib/zip.js/zip.min.js"></script>
13-
<script src="lib/markdownit/markdownit.min.js"></script>
13+
<script src="lib/markdownit/markdownit.min.js"></script> -->
1414

1515
<script type="module" src="src/client/embedded/EmbeddedStarter.ts"></script>
1616

@@ -34,8 +34,7 @@ <h1>Erstes Beispiel</h1>
3434
<h1>Zweites Beispiel</h1>
3535

3636
<div class="sql-online" style="width: calc(100% - 10px); height: 600px; margin-left: 5px" data-sql-online="{
37-
'id': 'abcde',
38-
'databaseURL': 'assets/databases/world1.sqLite'
37+
'id': 'abcde'
3938
}">
4039
<script type="text/plain" title="Test1.sql" data-type="sql">
4140
select * from test;

‎public/includeIDE.js‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,28 @@ let scripts = [
88
includeJsAndCss(scripts, () => {
99
window.onload = function () {
1010
if(window.jo_doc.startsWith("http")){
11-
$.ajax({
12-
url: window.jo_doc,
13-
type:"get",
14-
dataType:'text',
15-
success: function(data){
16-
initScripts(data);
17-
},
18-
error:function() {
19-
alert("Fehler beim Laden von " + jo_doc);
20-
}
21-
});
11+
12+
fetch(window.jo_doc, {
13+
method: "GET"
14+
}).then((response) => {
15+
response.json().then((data) => {
16+
initScripts(data);
17+
} )
18+
}).catch(() => {
19+
alert("Fehler beim Laden von " + jo_doc)
20+
})
21+
22+
// $.ajax({
23+
// url: window.jo_doc,
24+
// type:"get",
25+
// dataType:'text',
26+
// success: function(data){
27+
// initScripts(data);
28+
// },
29+
// error:function() {
30+
// alert("Fehler beim Laden von " + jo_doc);
31+
// }
32+
// });
2233
} else {
2334
initScripts(window.jo_doc);
2435
}

‎src/client/compiler/lexer/Lexer.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export class Lexer {
4141

4242
tokenTypesToMerge: { first: TokenType, second: TokenType, merged: TokenType }[] = [
4343
{ first: TokenType.keywordNotIn, second: TokenType.keywordIn, merged: TokenType.keywordNotIn },
44+
{ first: TokenType.keywordNot, second: TokenType.keywordBetween, merged: TokenType.keywordNotBetween },
45+
{ first: TokenType.keywordNot, second: TokenType.keywordLike, merged: TokenType.keywordNotLike },
4446
{ first: TokenType.keywordIs, second: TokenType.keywordNot, merged: TokenType.isNot },
4547
{ first: TokenType.isNot, second: TokenType.keywordNull, merged: TokenType.isNotNull },
4648
{ first: TokenType.keywordIs, second: TokenType.keywordNull, merged: TokenType.isNull },
@@ -135,6 +137,17 @@ export class Lexer {
135137

136138
if (specialCharToken != null) {
137139
switch (specialCharToken) {
140+
case TokenType.exclamationMark:
141+
if (this.nextChar == "=") {
142+
this.pushToken(TokenType.notEqual, '!=');
143+
this.next();
144+
this.next();
145+
return;
146+
} else {
147+
this.pushToken(TokenType.exclamationMark, '!');
148+
this.next();
149+
return;
150+
}
138151
case TokenType.leftSquareBracket:
139152
if (this.nextChar == "]") {
140153
this.pushToken(TokenType.leftRightSquareBracket, "[]");

‎src/client/compiler/lexer/Token.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export enum TokenType {
6060
keywordView,
6161
keywordEnum,
6262
keywordBetween,
63+
keywordNotBetween,
64+
keywordNotLike,
6365

6466
keywordOr,
6567
keywordAnd,
@@ -152,6 +154,8 @@ export enum TokenType {
152154
// Comment
153155
comment,
154156

157+
exclamationMark, // !
158+
155159
endofSourcecode, // will be generated after sourcecode end
156160

157161
// Program statement types:
@@ -235,6 +239,8 @@ export var TokenTypeReadable: {[tt: number]: string} = {
235239
[TokenType.keywordView]: "view",
236240
[TokenType.keywordEnum]: "enum",
237241
[TokenType.keywordBetween]: "between",
242+
[TokenType.keywordNotBetween]: "not between",
243+
[TokenType.keywordNotLike]: "not like",
238244

239245

240246
[TokenType.keywordAnd]: "and",
@@ -339,6 +345,8 @@ export var specialCharList: {[keyword: string]:TokenType} = {
339345
'{': TokenType.leftCurlyBracket, // {}
340346
'}': TokenType.rightCurlyBracket,
341347

348+
'!': TokenType.exclamationMark, // !
349+
342350
// operators
343351
'.': TokenType.dot, //.
344352
',': TokenType.comma, //.
@@ -442,6 +450,7 @@ export var keywordList: {[keyword: string]:TokenType} = {
442450
"offset": TokenType.keywordOffset,
443451
"in": TokenType.keywordIn,
444452
"not in": TokenType.keywordNotIn,
453+
"not between": TokenType.keywordNotBetween,
445454
"like": TokenType.keywordLike,
446455
"collate": TokenType.keywordCollate,
447456
"default": TokenType.keywordDefault,

‎src/client/compiler/parser/Parser.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export class Parser {
2121

2222
static operatorPrecedence: TokenType[][] = [
2323
[TokenType.keywordOr], [TokenType.keywordAnd],
24-
[TokenType.keywordBetween],
25-
[TokenType.lower, TokenType.lowerOrEqual, TokenType.greater, TokenType.greaterOrEqual, TokenType.equal, TokenType.notEqual, TokenType.keywordLike],
24+
[TokenType.keywordBetween, TokenType.keywordNotBetween],
25+
[TokenType.lower, TokenType.lowerOrEqual, TokenType.greater, TokenType.greaterOrEqual, TokenType.equal, TokenType.notEqual, TokenType.keywordLike, TokenType.keywordNotLike],
2626
[TokenType.concatenation, TokenType.plus, TokenType.minus], [TokenType.multiplication, TokenType.division, TokenType.modulo],
2727
[TokenType.keywordIn, TokenType.keywordNotIn]
2828
];
@@ -2103,8 +2103,8 @@ export class Parser {
21032103

21042104
let first = true;
21052105

2106-
if(this.tt == TokenType.keywordBetween){
2107-
return this.parseBetween(left);
2106+
if(this.tt == TokenType.keywordBetween || this.tt == TokenType.keywordNotBetween){
2107+
return this.parseBetween(left, this.tt);
21082108
}
21092109

21102110
while (first || operators.indexOf(this.tt) >= 0) {
@@ -2137,7 +2137,7 @@ export class Parser {
21372137

21382138
}
21392139

2140-
parseBetween(left: TermNode): TermNode {
2140+
parseBetween(left: TermNode, tt: TokenType.keywordBetween | TokenType.keywordNotBetween): TermNode {
21412141
let position = this.getCurrentPosition();
21422142
this.nextToken(); // skip "between"
21432143
let secondOperand = this.parseTermBinary(2);

‎src/client/compiler/parser/SQLMethods.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class SQLMethodStore {
5656
this.pushOneParameterMethod("month" , "integer","date");
5757
this.pushOneParameterMethod("day" , "integer","date");
5858
this.pushOneParameterMethod("year" , "integer","date");
59+
this.pushOneParameterMethod("round" , "integer","float");
5960

6061
let countMethod = new SQLMethod("count", true, "integer", [new SQLMethodParameter("spalte", "text")]);
6162
countMethod.acceptsStarParameter = true;
@@ -65,6 +66,10 @@ export class SQLMethodStore {
6566
strftimeMethod.acceptsStarParameter = true;
6667
this.methods.push(strftimeMethod);
6768

69+
let round2Params = new SQLMethod("round", false, "float", [new SQLMethodParameter("number", "float"), new SQLMethodParameter("digits", "integer")]);
70+
round2Params.acceptsStarParameter = false;
71+
this.methods.push(round2Params);
72+
6873
}
6974

7075
getMethods(identifier: string){

‎src/client/compiler/parser/SQLTypes.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class SQLBaseType extends SQLType {
137137
getBinaryResult(operator: TokenType, value1: any, value2: any): any {
138138
switch (operator) {
139139
case TokenType.concatenation:
140-
if (value1 != null && value2 != null) return value1 + value2;
140+
if (value1 != null && value2 != null) return (value1 + "") + (value2 + "");
141141
return value1 != null ? value1 : value2;
142142
case TokenType.plus:
143143
if (value1 != null && value2 != null) return value1 + value2;
@@ -398,11 +398,22 @@ SQLBaseType.addBaseTypes(baseTypes);
398398
varcharType.addBinaryOperation(TokenType.concatenation, varcharType, varcharType);
399399
varcharType.addBinaryOperation(TokenType.concatenation, charType, varcharType);
400400
varcharType.addBinaryOperation(TokenType.concatenation, textType, textType);
401+
varcharType.addBinaryOperation(TokenType.concatenation, floatType, textType);
402+
varcharType.addBinaryOperation(TokenType.concatenation, intType, textType);
403+
404+
401405
textType.addBinaryOperation(TokenType.concatenation, textType, textType);
406+
textType.addBinaryOperation(TokenType.concatenation, floatType, textType);
407+
textType.addBinaryOperation(TokenType.concatenation, intType, textType);
408+
402409
varcharType.addBinaryOperation(TokenType.keywordLike, varcharType, booleanType);
403410
varcharType.addBinaryOperation(TokenType.keywordLike, textType, booleanType);
404411
textType.addBinaryOperation(TokenType.keywordLike, textType, booleanType);
405412

413+
varcharType.addBinaryOperation(TokenType.keywordNotLike, varcharType, booleanType);
414+
varcharType.addBinaryOperation(TokenType.keywordNotLike, textType, booleanType);
415+
textType.addBinaryOperation(TokenType.keywordNotLike, textType, booleanType);
416+
406417
charType.addBinaryOperation(TokenType.concatenation, charType, charType);
407418
charType.addBinaryOperation(TokenType.concatenation, varcharType, charType);
408419
charType.addBinaryOperation(TokenType.concatenation, textType, textType);
@@ -411,6 +422,10 @@ charType.addBinaryOperation(TokenType.keywordLike, charType, booleanType);
411422
charType.addBinaryOperation(TokenType.keywordLike, textType, booleanType);
412423
textType.addBinaryOperation(TokenType.keywordLike, textType, booleanType);
413424

425+
charType.addBinaryOperation(TokenType.keywordNotLike, charType, booleanType);
426+
charType.addBinaryOperation(TokenType.keywordNotLike, textType, booleanType);
427+
textType.addBinaryOperation(TokenType.keywordNotLike, textType, booleanType);
428+
414429
booleanType.addBinaryOperation(TokenType.equal, booleanType, booleanType);
415430

416431
let numericBinaryOperators: TokenType[] = [TokenType.plus, TokenType.minus, TokenType.multiplication, TokenType.division, TokenType.modulo];
@@ -421,6 +436,8 @@ for (let i = 0; i < numericTypes.length; i++) {
421436
numericTypes[i].addBinaryOperation(numericBinaryOperators, numericTypes[j], numericTypes[j]);
422437
numericTypes[i].addBinaryOperation(comparisonOperators, numericTypes[j], booleanType);
423438
}
439+
numericTypes[i].addBinaryOperation(TokenType.concatenation, varcharType, textType);
440+
numericTypes[i].addBinaryOperation(TokenType.concatenation, textType, textType);
424441
numericTypes[i].unaryOperators = [TokenType.minus];
425442
}
426443

‎src/client/includeide/includeIDE.js‎

Lines changed: 0 additions & 103 deletions
This file was deleted.

‎src/client/main/gui/DatabaseExplorer.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export class DatabaseExplorer {
1717
let dbTool = this.main.getDatabaseTool();
1818

1919
dbTool.retrieveDatabaseStructure((dbstructure: DatabaseStructure) => {
20-
2120
this.refreshAfterRetrievingDBStructure();
2221
});
2322

0 commit comments

Comments
 (0)