-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Enhanced Keywords #1382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Enhanced Keywords #1382
Changes from 8 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
834dab1
Enhanced Keywords
manticore-projects 7a885a1
Fix incorrect tests
manticore-projects 1b69d25
Merge remote-tracking branch 'origin/master' into Keywords
manticore-projects 5d20d06
Define Reserved Keywords explicitly
manticore-projects df9c56e
Fix test resources
manticore-projects de805ab
Adjust Gradle to JUnit 5
manticore-projects d5a6dca
Do not mark SpeedTest for concurrent execution
manticore-projects a9d0503
Remove unused imports
manticore-projects 6dfa05f
Adjust Gradle to JUnit 5
manticore-projects 8f0bfe6
Do not mark SpeedTest for concurrent execution
manticore-projects 5cd0974
Remove unused imports
manticore-projects 5f11d3f
Merge remote-tracking branch 'origin/master'
manticore-projects 2af3cd5
Merge remote-tracking branch 'origin/Keywords' into Keywords
manticore-projects 4bef952
Merge remote-tracking branch 'origin/master' into Keywords
manticore-projects 1fd56ac
Keyword test adopt JUnit5
manticore-projects 873dfd4
Merge Master
manticore-projects 1a9db26
CheckStyle sanitation of method names
manticore-projects 3ab04b0
Merge https://github.com/JSQLParser/JSqlParser
manticore-projects de94651
Merge branch 'JSQLParser:master' into master
manticore-projects 84709a9
Merge branch 'master' of github.com:JSQLParser/JSqlParser
manticore-projects dc3ef91
Merge github.com:JSQLParser/JSqlParser into Keywords
manticore-projects 0e0662d
Merge Master
manticore-projects 3c8da30
Merge branch 'master' of github.com:JSQLParser/JSqlParser
manticore-projects cae7a1f
Merge branch 'master' into Keywords
manticore-projects 886fe59
Add Jupiter Parameters dependency again
manticore-projects 353edb4
Automate the `updateKeywords` Step
manticore-projects 0ad0b79
Update PMD and rules
manticore-projects ae46480
Rewrite test expected to fail
manticore-projects 74c1f71
Appease Codacy
manticore-projects ba9992e
Remove broken rule warning about perfectly fine switch-case statements
manticore-projects 7cad82e
Merge remote-tracking branch 'origin/master' into Keywords
manticore-projects a19b963
Force Changes
manticore-projects 8edf488
Fix Merge Issues
manticore-projects fbf0c8b
Merge remote-tracking branch 'manticore/Keywords' into Keywords
manticore-projects 83b8a03
Read Tokens directly from the Grammar File without invoking JTREE
manticore-projects 452e8a5
Appease PMD/Codacy
manticore-projects bde4da3
Merge Origin/Master
manticore-projects 0ce18dd
Extract the Keywords from the Grammar by using JTRee (instead of Regex)
manticore-projects 546fe16
Appease Codacy/PMD
manticore-projects 81c299f
Merge origin/master
manticore-projects 83166d2
Separate UpdateKeywords Task again
manticore-projects f4284a0
Clean-up the imports
manticore-projects cd462e5
Add JavaCC dependency to Maven for building ParserKeywordsUtils
manticore-projects a86edf5
Add JavaCC dependency to Maven for building ParserKeywordsUtils
manticore-projects 6b07f70
Merge branch 'master' of github.com:JSQLParser/JSqlParser
manticore-projects 8a8b718
Merge remote-tracking branch 'origin/master' into Keywords
manticore-projects d54c1fb
Merge Upstream
manticore-projects 1d89095
Merge remote-tracking branch 'manticore/Keywords' into Keywords
manticore-projects ab6f9d5
Merge Master
manticore-projects 39a3476
Merge github.com:JSQLParser/JSqlParser
manticore-projects 61bfb68
Merge Master
manticore-projects 796893d
Fixes broken PR #1524 and Commit fb6e950ce0e62ebcd7a44ba9eea679da2b04…
manticore-projects 520e1e6
Add AST Visualization
manticore-projects 7f4c510
Merge branch 'master' of github.com:JSQLParser/JSqlParser
manticore-projects a4032a2
Merge remote-tracking branch 'origin/master' into Keywords
manticore-projects 08141a3
Merge branch 'master' into Keywords
manticore-projects c512b8e
Merge branch 'master' of github.com:JSQLParser/JSqlParser into Keywords
manticore-projects 0c6f0e4
build: temporarily reduce the Code Coverage requirements
manticore-projects 6953d8b
Merge remote-tracking branch 'origin/master' into Keywords
manticore-projects a8ffe64
merge Master
manticore-projects 1d4eb9e
Merge branch 'master' into Keywords
manticore-projects b6146cf
build: JSQLParser is a build dependency
manticore-projects b07d839
chore: Update keywords
manticore-projects 1e159ba
Merge remote-tracking branch 'manticore/Keywords' into Keywords
manticore-projects b0d6218
feat: add line count to output
manticore-projects File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -257,5 +257,4 @@ public static int getNestingDepth(String sql) { | |
} | ||
return maxlevel; | ||
} | ||
|
||
} |
101 changes: 101 additions & 0 deletions
101
src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java
This file contains hidden or 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,101 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2021 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.parser; | ||
|
||
import java.util.*; | ||
|
||
public class ParserKeywordsUtils { | ||
public final static int RESTRICTED_FUNCTION = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this works, Java's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for example |
||
public final static int RESTRICTED_SCHEMA = 2; | ||
public final static int RESTRICTED_TABLE = 4; | ||
public final static int RESTRICTED_COLUMN = 8; | ||
public final static int RESTRICTED_EXPRESSION = 16; | ||
public final static int RESTRICTED_ALIAS = 32; | ||
public final static int RESTRICTED_SQL2016 = 64; | ||
|
||
public final static int RESTRICTED_JSQLPARSER = 128 | ||
| RESTRICTED_FUNCTION | ||
| RESTRICTED_SCHEMA | ||
| RESTRICTED_TABLE | ||
| RESTRICTED_COLUMN | ||
| RESTRICTED_EXPRESSION | ||
| RESTRICTED_ALIAS | ||
| RESTRICTED_SQL2016; | ||
|
||
public static List<String> getDefinedKeywords() throws Exception { | ||
return CCJSqlParser.getDefinedKeywords(); | ||
} | ||
|
||
public static List<String> getReservedKeywords(int restriction) { | ||
return CCJSqlParser.getReservedKeywords(restriction); | ||
} | ||
|
||
public final static void main(String[] args) { | ||
try { | ||
System.out.println( buildGrammarForRelObjectNameWithoutValue() ); | ||
System.out.println( buildGrammarForRelObjectName() ); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static String buildGrammarForRelObjectNameWithoutValue() throws Exception { | ||
TreeSet<String> allKeywords = new TreeSet<>(); | ||
allKeywords.addAll(CCJSqlParser.getDefinedKeywords()); | ||
for (String reserved: CCJSqlParser.getReservedKeywords(RESTRICTED_JSQLPARSER)) { | ||
allKeywords.remove(reserved); | ||
} | ||
|
||
StringBuilder builder = new StringBuilder(); | ||
builder.append("String RelObjectNameWithoutValue() :\n" | ||
+ "{ Token tk = null; }\n" | ||
+ "{\n" | ||
+ " ( tk=<S_IDENTIFIER> | tk=<S_QUOTED_IDENTIFIER> | tk=<K_DATE_LITERAL> | tk=<K_DATETIMELITERAL> | tk=<K_STRING_FUNCTION_NAME>\n" | ||
+ " "); | ||
|
||
for (String keyword: allKeywords) { | ||
builder.append(" | tk=\"").append(keyword).append("\""); | ||
} | ||
|
||
builder.append(" )\n" | ||
+ " { return tk.image; }\n" | ||
+ "}"); | ||
|
||
return builder.toString(); | ||
} | ||
|
||
public static String buildGrammarForRelObjectName() throws Exception { | ||
TreeSet<String> allKeywords = new TreeSet<>(); | ||
for (String reserved: CCJSqlParser.getReservedKeywords(RESTRICTED_ALIAS)) { | ||
allKeywords.add(reserved); | ||
} | ||
|
||
for (String reserved: CCJSqlParser.getReservedKeywords(RESTRICTED_JSQLPARSER & ~RESTRICTED_ALIAS)) { | ||
allKeywords.remove(reserved); | ||
} | ||
|
||
StringBuilder builder = new StringBuilder(); | ||
builder.append("String RelObjectName() :\n" | ||
+ "{ Token tk = null; String result = null; }\n" | ||
+ "{\n" | ||
+ " (result = RelObjectNameWithoutValue()\n" | ||
+ " "); | ||
|
||
for (String keyword: allKeywords) { | ||
builder.append(" | tk=\"").append(keyword).append("\""); | ||
} | ||
|
||
builder.append(" )\n" | ||
+ " { return tk!=null ? tk.image : result; }\n" | ||
+ "}"); | ||
|
||
return builder.toString(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I do not use gradle, what does this do?
Maven is the main build engine. You changed some gradle build options. Does the maven build still run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It generates and prints the Source Code Text of the method
RelObjectName()
which you would manually insert/replace in the JSQL Grammar file.This step is optional and does not affect the Maven build. It is executed manually and on demand only.
Although the long term goal was to have a mechanism inside the build tool (Gradle and/or Maven), which during the build:
RelObjectName()
and friends)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might also be implemented in a mojo in Maven, but that might be not worth the effort.