Skip to content

Commit

Permalink
Wrong global variables declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
Heromyth committed May 14, 2021
1 parent bc6cb0e commit e5386e8
Show file tree
Hide file tree
Showing 23 changed files with 161 additions and 156 deletions.
8 changes: 4 additions & 4 deletions source/hunt/sql/ast/SQLSetQuantifier.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module hunt.sql.ast.SQLSetQuantifier;
public interface SQLSetQuantifier {

// SQL 92
public static int ALL = 1;
public static int DISTINCT = 2;
enum int ALL = 1;
enum int DISTINCT = 2;

public static int UNIQUE = 3;
public static int DISTINCTROW = 4;
enum int UNIQUE = 3;
enum int DISTINCTROW = 4;

// !SetQuantifier
}
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLAggregateExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import hunt.collection;

public class SQLAggregateExpr : SQLExprImpl , SQLReplaceable {

private static long serialVersionUID = 1L;

protected string methodName;
protected long _methodNameHashCod64;

Expand Down
1 change: 0 additions & 1 deletion source/hunt/sql/ast/expr/SQLBetweenExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import hunt.sql.ast.expr.SQLBooleanExpr;
public class SQLBetweenExpr : SQLExprImpl , SQLReplaceable //Serializable,
{

private static long serialVersionUID = 1L;
public SQLExpr testExpr;
private bool not;
public SQLExpr beginExpr;
Expand Down
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLBinaryOpExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import hunt.util.StringBuilder;

public class SQLBinaryOpExpr : SQLExprImpl , SQLReplaceable//, Serializable
{

private static long serialVersionUID = 1L;
public SQLExpr left;
public SQLExpr right;
public SQLBinaryOperator operator;
Expand Down
3 changes: 0 additions & 3 deletions source/hunt/sql/ast/expr/SQLCaseExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import hunt.util.StringBuilder;
public class SQLCaseExpr : SQLExprImpl , SQLReplaceable//, Serializable
{

private static long serialVersionUID = 1L;
private List!Item items;
private SQLExpr valueExpr;
private SQLExpr elseExpr;
Expand Down Expand Up @@ -107,8 +106,6 @@ public class SQLCaseExpr : SQLExprImpl , SQLReplaceable//, Serializable

public static class Item : SQLObjectImpl , SQLReplaceable//, Serializable
{

private static long serialVersionUID = 1L;
private SQLExpr conditionExpr;
private SQLExpr valueExpr;

Expand Down
1 change: 0 additions & 1 deletion source/hunt/sql/ast/expr/SQLCaseStatement.d
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class SQLCaseStatement : SQLStatementImpl //, Serializable
public static class Item : SQLObjectImpl //, Serializable
{

private static long serialVersionUID = 1L;
private SQLExpr conditionExpr;
private SQLStatement statement;

Expand Down
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLContainsExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import hunt.sql.ast.expr.SQLBooleanExpr;

public class SQLContainsExpr : SQLExprImpl , SQLReplaceable//, Serializable
{

private static long serialVersionUID = 1L;
private bool not = false;
private SQLExpr expr;
private List!SQLExpr targetList;
Expand Down
1 change: 0 additions & 1 deletion source/hunt/sql/ast/expr/SQLExistsExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import hunt.sql.ast.SQLObject;
public class SQLExistsExpr : SQLExprImpl //, Serializable
{

private static long serialVersionUID = 1L;
public bool not = false;
public SQLSelect subQuery;

Expand Down
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLInListExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import hunt.sql.ast.expr.SQLBooleanExpr;

public class SQLInListExpr : SQLExprImpl //, Serializable
{

private static long serialVersionUID = 1L;
private bool not = false;
private SQLExpr expr;
private List!SQLExpr targetList;
Expand Down
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLInSubQueryExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import hunt.util.StringBuilder;

public class SQLInSubQueryExpr : SQLExprImpl //, Serializable
{

private static long serialVersionUID = 1L;
private bool not = false;
private SQLExpr expr;

Expand Down
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLMethodInvokeExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import hunt.util.StringBuilder;

public class SQLMethodInvokeExpr : SQLExprImpl , SQLReplaceable//, Serializable
{

private static long serialVersionUID = 1L;
private string name;
private SQLExpr owner;
private List!SQLExpr parameters;
Expand Down
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLNotExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import hunt.util.StringBuilder;

public class SQLNotExpr : SQLExprImpl //, Serializable
{

private static long serialVersionUID = 1L;
public SQLExpr expr;

public this(){
Expand Down
2 changes: 0 additions & 2 deletions source/hunt/sql/ast/expr/SQLQueryExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import hunt.util.StringBuilder;

public class SQLQueryExpr : SQLExprImpl //, Serializable
{

private static long serialVersionUID = 1L;
public SQLSelect subQuery;

public this(){
Expand Down
1 change: 0 additions & 1 deletion source/hunt/sql/ast/expr/SQLUnaryExpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import hunt.sql.ast.SQLObject;
public class SQLUnaryExpr : SQLExprImpl // Serializable
{

private static long serialVersionUID = 1L;
private SQLExpr expr;
private SQLUnaryOperator operator;

Expand Down
48 changes: 24 additions & 24 deletions source/hunt/sql/dialect/mysql/parser/MySqlStatementParser.d
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,30 @@ import hunt.sql.dialect.mysql.parser.MySqlSelectIntoParser;

public class MySqlStatementParser : SQLStatementParser {

private static string AUTO_INCREMENT = "AUTO_INCREMENT";
private static string COLLATE2 = "COLLATE";
private static string CHAIN = "CHAIN";
private static string ENGINES = "ENGINES";
private static string ENGINE = "ENGINE";
private static string BINLOG = "BINLOG";
private static string EVENTS = "EVENTS";
private static string SESSION = "SESSION";
private static string GLOBAL = "GLOBAL";
private static string VARIABLES = "VARIABLES";
private static string STATUS = "STATUS";
private static string RESET = "RESET";
private static string DESCRIBE = "DESCRIBE";
private static string WRITE = "WRITE";
private static string READ = "READ";
private static string LOCAL = "LOCAL";
private static string TABLES = "TABLES";
private static string TEMPORARY = "TEMPORARY";
private static string SPATIAL = "SPATIAL";
private static string LOW_PRIORITY = "LOW_PRIORITY";
private static string CONNECTION = "CONNECTION";
private static string EXTENDED = "EXTENDED";
private static string PARTITIONS = "PARTITIONS";
private static string FORMAT = "FORMAT";
private enum string AUTO_INCREMENT = "AUTO_INCREMENT";
private enum string COLLATE2 = "COLLATE";
private enum string CHAIN = "CHAIN";
private enum string ENGINES = "ENGINES";
private enum string ENGINE = "ENGINE";
private enum string BINLOG = "BINLOG";
private enum string EVENTS = "EVENTS";
private enum string SESSION = "SESSION";
private enum string GLOBAL = "GLOBAL";
private enum string VARIABLES = "VARIABLES";
private enum string STATUS = "STATUS";
private enum string RESET = "RESET";
private enum string DESCRIBE = "DESCRIBE";
private enum string WRITE = "WRITE";
private enum string READ = "READ";
private enum string LOCAL = "LOCAL";
private enum string TABLES = "TABLES";
private enum string TEMPORARY = "TEMPORARY";
private enum string SPATIAL = "SPATIAL";
private enum string LOW_PRIORITY = "LOW_PRIORITY";
private enum string CONNECTION = "CONNECTION";
private enum string EXTENDED = "EXTENDED";
private enum string PARTITIONS = "PARTITIONS";
private enum string FORMAT = "FORMAT";

private int maxIntoClause = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import hunt.text;
import std.uni;

public class PGSQLStatementParser : SQLStatementParser {
public static string TIME_ZONE = "TIME ZONE";
public static string TIME = "TIME";
public static string LOCAL = "LOCAL";
enum string TIME_ZONE = "TIME ZONE";
enum string TIME = "TIME";
enum string LOCAL = "LOCAL";

public this(PGExprParser parser) {
super(parser);
Expand Down
114 changes: 59 additions & 55 deletions source/hunt/sql/parser/CharTypes.d
Original file line number Diff line number Diff line change
@@ -1,65 +1,26 @@
module hunt.sql.parser.CharTypes;

//import hunt.sql.parser.LayoutCharacters.EOI;
import std.conv;
import hunt.sql.parser.LayoutCharacters;

public class CharTypes {

private static bool[] hexFlags = new bool[256];


public static bool isHex(char c) {
return c < 256 && hexFlags[c];
}

public static bool isDigit(char c) {
return c >= '0' && c <= '9';
}

private static bool[] firstIdentifierFlags = new bool[256];


public static bool isFirstIdentifierChar(char c) {
if (c <= firstIdentifierFlags.length) {
return firstIdentifierFlags[c];
}
return c != ' ' && c != '';
}

private static string[] stringCache = new string[256];
private static bool[] identifierFlags = new bool[256];


public static bool isIdentifierChar(char c) {
if (c <= identifierFlags.length) {
return identifierFlags[c];
}
return c != ' ' && c != '' && c != '';
}
import std.conv;
import std.stdio;

public static string valueOf(char ch) {
if (ch < stringCache.length) {
return stringCache[ch];
}
return null;
}
public class CharTypes {

private static bool[] whitespaceFlags = new bool[256];
private __gshared bool[] hexFlags;
private __gshared bool[] firstIdentifierFlags;
private __gshared string[] stringCache;
private __gshared bool[] identifierFlags;
private __gshared bool[] whitespaceFlags;

/**
* @return false if {@link LayoutCharacters#EOI}
*/
public static bool isWhitespace(char c) {
return (c <= whitespaceFlags.length && whitespaceFlags[c]) //
|| c == ' '; // Chinese space
}
shared static this() {
hexFlags = new bool[256];
firstIdentifierFlags = new bool[256];
stringCache = new string[256];
identifierFlags = new bool[256];
whitespaceFlags = new bool[256];

}

static this()
{
import std.stdio;
for (dchar c = 0; c < CharTypes.hexFlags.length; ++c) {
if (c >= 'A' && c <= 'F') {
CharTypes.hexFlags[c] = true;
Expand Down Expand Up @@ -111,6 +72,49 @@ static this()
CharTypes.whitespaceFlags[i] = true;
}

CharTypes.whitespaceFlags[160] = true; // 特别处理
CharTypes.whitespaceFlags[160] = true;
}


public static bool isHex(char c) {
return c < 256 && hexFlags[c];
}

public static bool isDigit(char c) {
return c >= '0' && c <= '9';
}


}
public static bool isFirstIdentifierChar(char c) {
if (c <= firstIdentifierFlags.length) {
return firstIdentifierFlags[c];
}
return c != ' ' && c != '';
}



public static bool isIdentifierChar(char c) {
if (c <= identifierFlags.length) {
return identifierFlags[c];
}
return c != ' ' && c != '' && c != '';
}

public static string valueOf(char ch) {
if (ch < stringCache.length) {
return stringCache[ch];
}
return null;
}


/**
* @return false if {@link LayoutCharacters#EOI}
*/
public static bool isWhitespace(char c) {
return (c <= whitespaceFlags.length && whitespaceFlags[c]) //
|| c == ' '; // Chinese space
}

}
1 change: 0 additions & 1 deletion source/hunt/sql/parser/NotAllowCommentException.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import hunt.sql.parser.ParserException;

public class NotAllowCommentException : ParserException {

private static long serialVersionUID = 1L;

public this(){
this("comment not allow");
Expand Down
15 changes: 10 additions & 5 deletions source/hunt/sql/parser/SymbolTable.d
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@

module hunt.sql.parser.SymbolTable;

import std.concurrency:initOnce;

/**
*/
public class SymbolTable {
// private enum UTF8 = "UTF-8";
// private static bool JVM_16;
static this()
{
global = new SymbolTable(32768);
// static this()
// {
// global = new SymbolTable(32768);
// }

static SymbolTable global() {
__gshared SymbolTable inst;
return initOnce!inst(new SymbolTable(32768));
}

public static SymbolTable global;

private Entry[] entries;
private int indexMask;

Expand Down
Loading

0 comments on commit e5386e8

Please sign in to comment.