Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (2)
Showing
with 42320 additions and 79 deletions
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf
# These are Windows script files and should use crlf
*.bat text eol=crlf
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build
{
"java.configuration.updateBuildConfiguration": "interactive",
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m -Xlog:disable"
}
\ No newline at end of file
# github sql finder
# Project set up
1. Clone this repo
1. Follow these steps from this [page](https://cloud.google.com/bigquery/docs/authentication#client-libs)
 
Set up Application Default Credentials (ADC) in your local environment:
* Install the Google Cloud CLI, then initialize it by running the following command:
`gcloud init`
## Getting started
* Create local authentication credentials for your Google Account:
`gcloud auth application-default login`
* A login screen is displayed. After you log in, your credentials are stored in the local credential file used by ADC.
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
For more information about working with ADC in a local environment, see [Local development environment](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev).
 
1. Run `./gradlew build`
You should see: `BUILD SUCCESSFUL`
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
4. Project should be ready
## Add your files
# Usage
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
Project can be run by command: `./gradlew run`
This will be run in default configuration
```
cd existing_repo
git remote add origin https://gitlab.vsb.cz/samuel.vasecka.st/github-sql-finder.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.vsb.cz/samuel.vasecka.st/github-sql-finder/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
To change configuration, you should use command parameters:
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
1. **files** - number of files to fetch from Github
1. **batch** - number of files in one batch
1. **mode**
mode=1 - it will use example files (for testing purposes)
mode=2 - it will fetch files from github
mode=3 - it will delete local DB with queries (for testing purposes)
1. **offset** - number of already processed files (files from github are ordered by repozitory name) so processed files won't be fetched again
1. **sample**
sample=1 - it will use sample github collections (for testing purposes)
sample=2 - it will use original github collection
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
Parameters can be used like this:
* `./gradlew run -Dfiles=100 -Dbatch=50 -Dmode=2 -Doffset=200 -Dsample=2`
* This command will fetch **100 files** in two **50 files batches** from **github** (mode=2) from **offset 200** (so there will be products from 200 to 300) from **original github collection** (sample=2)
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
In the testing process, i found out that most efficient **batch** size is **100**. In this configurrations, it takes around **5 minutes** to fetch this batch (100 files) from github. From this we can assume that **10000 files** will take around **8 hours**.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
Here are some test runs which proves the lines above:
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Batch size: 10
Github total request time: 17,4 min
```
Github requests time in ms: 1049982(98,22%)
ANTLR parsing time in ms: 7533(0,70%)
Parsing tree string finding: 5841(0,55%)
Whole time: 1068991
Number of all found queries: 18(from 100 files)
Number of TSql queries: 0
Number of Postgre SQL queries: 15
Number of PlSql queries: 0
Number of MySql queries: 3
New offset to use for query: 100
```
Batch size: 50
Github total request time: 6,3 min
```
Github requests time in ms: 376292(98,18%)
ANTLR parsing time in ms: 1688(0,44%)
Parsing tree string finding: 448(0,12%)
Whole time: 383269
Number of all found queries: 2(from 100 files)
Number of TSql queries: 0
Number of Postgre SQL queries: 2
Number of PlSql queries: 0
Number of MySql queries: 0
New offset to use for query: 200
```
Batch size: 100
Github total request time: 5,2 min
```
Github requests time in ms: 312213(95,48%)
ANTLR parsing time in ms: 5346(1,63%)
Parsing tree string finding: 5180(1,58%)
Whole time: 326986
Number of all found queries: 36(from 100 files)
Number of TSql queries: 0
Number of Postgre SQL queries: 0
Number of PlSql queries: 0
Number of MySql queries: 36
New offset to use for query: 300
```
\ No newline at end of file
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/8.0.2/userguide/building_java_projects.html
*/
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
antlr
java
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
// This dependency is used by the application.
implementation("com.google.guava:guava:31.1-jre")
implementation(platform("com.google.cloud:libraries-bom:26.37.0"))
implementation("com.google.cloud:google-cloud-bigquery")
antlr("org.antlr:antlr4:4.5")
implementation("org.antlr:antlr4-runtime:4.5")
implementation("org.xerial:sqlite-jdbc:3.45.3.0")
}
tasks.named("generateGrammarSource") {
// Keep a copy of generated sources
doLast {
println("Copying generated grammar lexer/parser files to main directory.")
copy {
from("${buildDir}/generated-src/antlr/main")
into("src/main/java/antlr")
eachFile {
val file = this.file
if (this.getName().endsWith(".java")) {
val content = file.readText()
file.writeText("package antlr;\n\n$content")
}
}
}
file("$buildDir/generated-src").deleteRecursively()
}
}
application {
// Define the main class for the application.
mainClass.set("githubsqlfinder.App")
}
//val mode: String by project.extra
// Set the default value for the parameter
//project.extra["mode"] = "1"
// Define your run task
tasks.named<JavaExec>("run") {
// Pass the custom parameter as an argument to your application
args(System.getProperty("files", "100"), System.getProperty("batch", "100"), System.getProperty("mode", "2"), System.getProperty("offset", "0"), System.getProperty("sample", "1"))
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
File added
This diff is collapsed.
This diff is collapsed.
/*
PHP grammar.
The MIT License (MIT).
Copyright (c) 2015-2020, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies.
Copyright (c) 2019, Thierry Marianne (thierry.marianne@weaving-the-web.org)
Copyright (c) 2019-2020, Student Main for php7, php8 support.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false
// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine
// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true
lexer grammar PhpLexer;
channels {
PhpComments,
ErrorLexem,
SkipChannel
}
options {
superClass = PhpLexerBase;
caseInsensitive = true;
}
// Insert here @header for C++ lexer.
SeaWhitespace : [ \t\r\n]+ -> channel(HIDDEN);
HtmlText : ~[<#]+;
XmlStart : '<?xml' -> pushMode(XML);
PHPStartEcho : PhpStartEchoFragment -> type(Echo), pushMode(PHP);
PHPStart : PhpStartFragment -> channel(SkipChannel), pushMode(PHP);
HtmlScriptOpen : '<script' { this._scriptTag = true; } -> pushMode(INSIDE);
HtmlStyleOpen : '<style' { this._styleTag = true; } -> pushMode(INSIDE);
HtmlComment : '<!' '--' .*? '-->' -> channel(HIDDEN);
HtmlDtd : '<!' .*? '>';
HtmlOpen : '<' -> pushMode(INSIDE);
Shebang : '#' { this.IsNewLineOrStart(-2) }? '!' ~[\r\n]*;
NumberSign : '#' ~'<'* -> more;
Error : . -> channel(ErrorLexem);
// TODO: parse xml attributes.
mode XML;
XmlText : ~'?'+;
XmlClose : '?>' -> popMode;
XmlText2 : '?' -> type(XmlText);
mode INSIDE;
PHPStartEchoInside : PhpStartEchoFragment -> type(Echo), pushMode(PHP);
PHPStartInside : PhpStartFragment -> channel(SkipChannel), pushMode(PHP);
HtmlClose : '>' { this.PushModeOnHtmlClose(); };
HtmlSlashClose : '/>' -> popMode;
HtmlSlash : '/';
HtmlEquals : '=';
HtmlStartQuoteString : '\\'? '\'' -> pushMode(HtmlQuoteStringMode);
HtmlStartDoubleQuoteString : '\\'? '"' -> pushMode(HtmlDoubleQuoteStringMode);
HtmlHex : '#' HexDigit+;
HtmlDecimal : Digit+;
HtmlSpace : [ \t\r\n]+ -> channel(HIDDEN);
HtmlName : HtmlNameStartChar HtmlNameChar*;
ErrorInside : . -> channel(ErrorLexem);
mode HtmlQuoteStringMode;
PHPStartEchoInsideQuoteString : PhpStartEchoFragment -> type(Echo), pushMode(PHP);
PHPStartInsideQuoteString : PhpStartFragment -> channel(SkipChannel), pushMode(PHP);
HtmlEndQuoteString : '\'' '\''? -> popMode;
HtmlQuoteString : ~[<']+;
ErrorHtmlQuote : . -> channel(ErrorLexem);
mode HtmlDoubleQuoteStringMode;
PHPStartEchoDoubleQuoteString : PhpStartEchoFragment -> type(Echo), pushMode(PHP);
PHPStartDoubleQuoteString : PhpStartFragment -> channel(SkipChannel), pushMode(PHP);
HtmlEndDoubleQuoteString : '"' '"'? -> popMode;
HtmlDoubleQuoteString : ~[<"]+;
ErrorHtmlDoubleQuote : . -> channel(ErrorLexem);
// Parse JavaScript with https://github.com/antlr/grammars-v4/tree/master/javascript if necessary.
// Php blocks can exist inside Script blocks too.
mode SCRIPT;
ScriptText: ~'<'+;
// TODO: handle JS strings, but handle <?php tags inside them
//ScriptString: '"' (~'"' | '\\' ('\r'? '\n' | .))* '"' -> type(ScriptText);
//ScriptString2: '\'' (~'\'' | '\\' ('\r'? '\n' | .))* '\'' -> type(ScriptText);
HtmlScriptClose : '</' 'script'? '>' -> popMode;
PHPStartInsideScriptEcho : PhpStartEchoFragment -> type(Echo), pushMode(PHP);
PHPStartInsideScript : PhpStartFragment -> channel(SkipChannel), pushMode(PHP);
ScriptText2 : '<' -> type(ScriptText);
mode STYLE;
StyleBody: .*? '</' 'style'? '>' -> popMode;
mode PHP;
PHPEnd : ('?' | '%' {this.HasAspTags()}?) '>' | '</script>' {this.HasPhpScriptTag()}?;
Whitespace : [ \t\r\n]+ -> channel(SkipChannel);
MultiLineComment : '/*' .*? '*/' -> channel(PhpComments);
SingleLineComment : '//' -> channel(SkipChannel), pushMode(SingleLineCommentMode);
ShellStyleComment : '#' -> channel(SkipChannel), pushMode(SingleLineCommentMode);
AttributeStart: '#[';
Abstract : 'abstract';
Array : 'array';
As : 'as';
BinaryCast : 'binary';
BoolType : 'bool' 'ean'?;
BooleanConstant : 'true' | 'false';
Break : 'break';
Callable : 'callable';
Case : 'case';
Catch : 'catch';
Class : 'class';
Clone : 'clone';
Const : 'const';
Continue : 'continue';
Declare : 'declare';
Default : 'default';
Do : 'do';
DoubleCast : 'real';
DoubleType : 'double';
Echo : 'echo';
Else : 'else';
ElseIf : 'elseif';
Empty : 'empty';
Enum_ : 'enum';
EndDeclare : 'enddeclare';
EndFor : 'endfor';
EndForeach : 'endforeach';
EndIf : 'endif';
EndSwitch : 'endswitch';
EndWhile : 'endwhile';
Eval : 'eval';
Exit : 'die';
Extends : 'extends';
Final : 'final';
Finally : 'finally';
FloatCast : 'float';
For : 'for';
Foreach : 'foreach';
Function_ : 'function';
Global : 'global';
Goto : 'goto';
If : 'if';
Implements : 'implements';
Import : 'import';
Include : 'include';
IncludeOnce : 'include_once';
InstanceOf : 'instanceof';
InsteadOf : 'insteadof';
Int8Cast : 'int8';
Int16Cast : 'int16';
Int64Type : 'int64';
IntType : 'int' 'eger'?;
Interface : 'interface';
IsSet : 'isset';
List : 'list';
LogicalAnd : 'and';
LogicalOr : 'or';
LogicalXor : 'xor';
Match_ : 'match';
Namespace : 'namespace';
New : 'new';
Null : 'null';
ObjectType : 'object';
Parent_ : 'parent';
Partial : 'partial';
Print : 'print';
Private : 'private';
Protected : 'protected';
Public : 'public';
Readonly : 'readonly';
Require : 'require';
RequireOnce : 'require_once';
Resource : 'resource';
Return : 'return';
Static : 'static';
StringType : 'string';
Switch : 'switch';
Throw : 'throw';
Trait : 'trait';
Try : 'try';
Typeof : 'clrtypeof';
UintCast : 'uint' ('8' | '16' | '64')?;
UnicodeCast : 'unicode';
Unset : 'unset';
Use : 'use';
Var : 'var';
While : 'while';
Yield : 'yield';
From : 'from';
LambdaFn : 'fn';
Ticks : 'ticks';
Encoding : 'encoding';
StrictTypes : 'strict_types';
Get : '__get';
Set : '__set';
Call : '__call';
CallStatic : '__callstatic';
Constructor : '__construct';
Destruct : '__destruct';
Wakeup : '__wakeup';
Sleep : '__sleep';
Autoload : '__autoload';
IsSet__ : '__isset';
Unset__ : '__unset';
ToString__ : '__tostring';
Invoke : '__invoke';
SetState : '__set_state';
Clone__ : '__clone';
DebugInfo : '__debuginfo';
Namespace__ : '__namespace__';
Class__ : '__class__';
Traic__ : '__trait__';
Function__ : '__function__';
Method__ : '__method__';
Line__ : '__line__';
File__ : '__file__';
Dir__ : '__dir__';
Spaceship : '<=>';
Lgeneric : '<:';
Rgeneric : ':>';
DoubleArrow : '=>';
Inc : '++';
Dec : '--';
IsIdentical : '===';
IsNoidentical : '!==';
IsEqual : '==';
IsNotEq : '<>' | '!=';
IsSmallerOrEqual : '<=';
IsGreaterOrEqual : '>=';
PlusEqual : '+=';
MinusEqual : '-=';
MulEqual : '*=';
Pow : '**';
PowEqual : '**=';
DivEqual : '/=';
Concaequal : '.=';
ModEqual : '%=';
ShiftLeftEqual : '<<=';
ShiftRightEqual : '>>=';
AndEqual : '&=';
OrEqual : '|=';
XorEqual : '^=';
BooleanOr : '||';
BooleanAnd : '&&';
NullCoalescing : '??';
NullCoalescingEqual : '??=';
ShiftLeft : '<<';
ShiftRight : '>>';
DoubleColon : '::';
ObjectOperator : '->';
NamespaceSeparator : '\\';
Ellipsis : '...';
Less : '<';
Greater : '>';
Ampersand : '&';
Pipe : '|';
Bang : '!';
Caret : '^';
Plus : '+';
Minus : '-';
Asterisk : '*';
Percent : '%';
Divide : '/';
Tilde : '~';
SuppressWarnings : '@';
Dollar : '$';
Dot : '.';
QuestionMark : '?';
OpenRoundBracket : '(';
CloseRoundBracket : ')';
OpenSquareBracket : '[';
CloseSquareBracket : ']';
OpenCurlyBracket : '{';
CloseCurlyBracket : '}' { this.PopModeOnCurlyBracketClose(); };
Comma : ',';
Colon : ':';
SemiColon : ';';
Eq : '=';
Quote : '\'';
BackQuote : '`';
VarName : '$' NameString;
Label : [a-z_][a-z_0-9]*;
Octal : '0' 'o'? OctalDigit+ ('_' OctalDigit+)*;
Decimal : '0' | NonZeroDigit Digit* ('_' Digit+)*;
Real : (LNum '.' LNum? | LNum? '.' LNum) ExponentPart? | LNum+ ExponentPart;
Hex : '0x' HexDigit+ ('_' HexDigit+)*;
Binary : '0b' [01]+ ('_' [01]+)*;
BackQuoteString : '`' ~'`'* '`';
SingleQuoteString : '\'' (~('\'' | '\\') | '\\' .)* '\'';
DoubleQuote : '"' -> pushMode(InterpolationString);
StartNowDoc:
'<<<' [ \t]* '\'' NameString '\'' { this.ShouldPushHereDocMode(1) }? -> pushMode(HereDoc)
;
StartHereDoc : '<<<' [ \t]* NameString { this.ShouldPushHereDocMode(1) }? -> pushMode(HereDoc);
ErrorPhp : . -> channel(ErrorLexem);
mode InterpolationString;
VarNameInInterpolation : '$' NameString -> type(VarName); // TODO: fix such cases: "$people->john"
DollarString : '$' -> type(StringPart);
CurlyDollar:
'{' { this.IsCurlyDollar(1) }? { this.SetInsideString(); } -> channel(SkipChannel), pushMode(PHP)
;
CurlyString : '{' -> type(StringPart);
EscapedChar : '\\' . -> type(StringPart);
DoubleQuoteInInterpolation : '"' -> type(DoubleQuote), popMode;
UnicodeEscape : '\\u{' [a-z0-9][a-z0-9]+ '}';
StringPart : ~[${\\"]+;
mode SingleLineCommentMode;
Comment : ~[\r\n?]+ -> channel(PhpComments);
PHPEndSingleLineComment : '?' '>';
CommentQuestionMark : '?' -> type(Comment), channel(PhpComments);
CommentEnd : [\r\n] -> channel(SkipChannel), popMode; // exit from comment.
mode HereDoc;
// TODO: interpolation for heredoc strings.
HereDocText: ~[\r\n]*? ('\r'? '\n' | '\r');
// fragments.
// '<?=' will be transformed to 'echo' token.
// '<?= "Hello world"; ?>' will be transformed to '<?php echo "Hello world"; ?>'
fragment PhpStartEchoFragment : '<' ('?' '=' | { this.HasAspTags() }? '%' '=');
fragment PhpStartFragment : '<' ('?' 'php'? | { this.HasAspTags() }? '%');
fragment NameString : [a-zA-Z_\u0080-\ufffe][a-zA-Z0-9_\u0080-\ufffe]*;
fragment HtmlNameChar :
HtmlNameStartChar
| '-'
| '_'
| '.'
| Digit
| '\u00B7'
| '\u0300' ..'\u036F'
| '\u203F' ..'\u2040'
;
fragment HtmlNameStartChar :
[:a-zA-Z]
| '\u2070' ..'\u218F'
| '\u2C00' ..'\u2FEF'
| '\u3001' ..'\uD7FF'
| '\uF900' ..'\uFDCF'
| '\uFDF0' ..'\uFFFD'
;
fragment LNum : Digit+ ('_' Digit+)*;
fragment ExponentPart : 'e' [+-]? LNum;
fragment NonZeroDigit : [1-9];
fragment Digit : [0-9];
fragment OctalDigit : [0-7];
fragment HexDigit : [a-f0-9];
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
grammar SQL;
sqlQuery
: (statement | ';')+ EOF
;
statement
: create
| insert
| delete
| select
;
create
: CREATE FILE fileIdentifier columnNames
;
insert
: INSERT INTO FILE fileIdentifier columnNames ROWS values (COMMA values)*
;
delete
: DELETE FILE fileIdentifier
;
select
: SELECT expressionList FROM FILE fileIdentifier (WHERE booleanExpression)?
;
columnNames
: LEFT_PARENTHESIS identifier (COMMA identifier)* RIGHT_PARENTHESIS
;
values
: LEFT_PARENTHESIS constants RIGHT_PARENTHESIS
;
constants
:constant (COMMA constant)*;
expressionList
: expression (COMMA expression)*
;
booleanExpression
: identifier compare expression
| left=booleanExpression operator=AND right=booleanExpression
| left=booleanExpression operator=OR right=booleanExpression
;
compare:
EQUALS | GT | GE| LT| LE | NE;
expression
: ASTERISK
| identifier
| constant
;
identifier
: IDENTIFIER DOT IDENTIFIER
| IDENTIFIER
;
constant
: NULL
| identifier
| (MINUS | PLUS)? INTEGER_VALUE
| (MINUS | PLUS)? DECIMAL_VALUE
| QUOTED_STRING+
;
fileIdentifier
: name=identifier
;
CREATE : 'CREATE' | 'create';
SELECT: 'SELECT' | 'select';
FROM: 'FROM' | 'from';
FILE: 'FILE' | 'file';
INSERT : 'INSERT' | 'insert';
INTO : 'INTO' | 'into';
ROWS : 'ROWS' | 'rows';
UPDATE : 'UPDATE' | 'update';
SET : 'SET' | 'set';
WHERE : 'WHERE' | 'where';
DELETE : 'DELETE' | 'delete';
NULL : 'NULL' | 'null';
DOT: '.';
COMMA: ',';
ASTERISK: '*';
LEFT_PARENTHESIS: '(';
RIGHT_PARENTHESIS: ')';
EQUALS: '=';
NOT : '!';
MINUS : '-';
PLUS: '+';
GT: '>';
GE: '>=';
LT: '<';
LE: '<=';
NE: '!=';
AND: 'AND' | 'and' | '&&';
OR: 'OR' | 'or' | '||';
QUOTED_STRING
: '\'' ( ~('\''|'\\') | ('\\' .) )* '\''
| '"' ( ~('"'|'\\') | ('\\' .) )* '"'
;
INTEGER_VALUE
: DIGIT+
;
DECIMAL_VALUE
: DECIMAL_DIGITS
;
IDENTIFIER
: (LETTER | DIGIT)+
;
fragment DECIMAL_DIGITS
: DIGIT+ '.' DIGIT*
| '.' DIGIT+
;
fragment DIGIT
: [0-9]
;
fragment LETTER
: [a-zA-Z]
;
WS
: [ \r\n\t]+ -> channel(HIDDEN)
;
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
package antlr;
/*
PostgreSQL grammar.
The MIT License (MIT).
Copyright (c) 2021-2023, Oleksii Kovalov (Oleksii.Kovalov@outlook.com).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import java.util.BitSet;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.*;
import org.antlr.v4.runtime.misc.*;
public class LexerDispatchingErrorListener implements ANTLRErrorListener
{
Lexer _parent;
public LexerDispatchingErrorListener(Lexer parent)
{
_parent = parent;
}
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e)
{
var foo = new ProxyErrorListener(_parent.getErrorListeners());
foo.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
}
public void reportAmbiguity(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
boolean exact,
BitSet ambigAlts,
ATNConfigSet configs)
{
var foo = new ProxyErrorListener(_parent.getErrorListeners());
foo.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
}
public void reportAttemptingFullContext(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
BitSet conflictingAlts,
ATNConfigSet configs)
{
var foo = new ProxyErrorListener(_parent.getErrorListeners());
foo.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
}
public void reportContextSensitivity(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
int prediction,
ATNConfigSet configs)
{
var foo = new ProxyErrorListener(_parent.getErrorListeners());
foo.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.