Skip to content

Commit

Permalink
feat(saql): add saql project and related files #16
Browse files Browse the repository at this point in the history
Added a new project "saql" with related files and configurations. This includes the addition of a .gitignore file, modifications to build.gradle.kts and settings.gradle.kts, and the creation of new Kotlin files. Also, renamed and modified some existing files for compatibility with the new project.
  • Loading branch information
phodal committed Jun 21, 2024
1 parent a4479c3 commit 572694e
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 3 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,48 @@ project(":shirelang") {
}
}

project(":saql") {
apply {
plugin("org.jetbrains.grammarkit")
}

intellij {
version.set(prop("platformVersion"))
plugins.set((listOf<String>() + "org.intellij.plugins.markdown" + "com.jetbrains.sh" + "Git4Idea"))
}

dependencies {
implementation(project(":"))
implementation(project(":core"))
}

// tasks {
// generateLexer {
// sourceFile.set(file("src/main/grammar/_SAQLLexer.flex"))
// targetOutputDir.set(file("src/gen/com/phodal/shirelang/saql/lexer"))
// purgeOldFiles.set(true)
// }
//
// generateParser {
// sourceFile.set(file("src/main/grammar/SAQLParser.bnf"))
// targetRootOutputDir.set(file("src/gen"))
// pathToParser.set("com/phodal/shirelang/saql/parser/ShireParser.java")
// pathToPsiRoot.set("com/phodal/shirelang/saql/psi")
// purgeOldFiles.set(true)
// }
//
// withType<KotlinCompile> {
// dependsOn(generateLexer, generateParser)
// }
// }

sourceSets {
main {
java.srcDirs("src/gen")
}
}
}

project(":plugin") {
apply {
plugin("org.jetbrains.changelog")
Expand Down
1 change: 1 addition & 0 deletions saql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/gen
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ where_clause ::= WHERE expression
from_clause ::= FROM table_or_subquery ( join_operator table_or_subquery join_constraint? )*

result_columns ::= result_column ( ',' result_column )* {
implements="com.phodal.shirelang.saql.psi.AndroidSqlTableElement"
implements="com.phodal.shirelang.saql.psi.SaqlTableElement"
methods=[getSqlTable]
}

Expand All @@ -165,12 +165,12 @@ select_core_values ::= VALUES '(' expression ( ',' expression )* ')' ( ',' '(' e
table_or_subquery ::= from_table | select_subquery | '(' table_or_subquery ')'

from_table ::= ( database_name '.' )? defined_table_name ( ( AS )? table_alias_name )? ( INDEXED BY index_name | NOT INDEXED )? {
implements="com.phodal.shirelang.saql.psi.AndroidSqlTableElement"
implements="com.phodal.shirelang.saql.psi.SaqlTableElement"
methods=[getSqlTable]
}

select_subquery ::= '(' &(SELECT|VALUES|WITH) subquery_greedy ')' ( ( AS )? table_alias_name )? {
implements="com.phodal.shirelang.saql.psi.AndroidSqlTableElement"
implements="com.phodal.shirelang.saql.psi.SaqlTableElement"
methods=[getSqlTable]
pin=2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@

package com.phodal.shirelang.saql.lexer;

import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;
//import static com.phodal.shirelang.saql.psi.ShireTypes.*;
import com.intellij.psi.TokenType;

%%

%{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.phodal.shirelang.saql.parser

import com.intellij.lang.PsiBuilder

Check warning on line 3 in saql/src/main/kotlin/com/phodal/shirelang/saql/parser/SaqlParserUtil.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.lang.parser.GeneratedParserUtilBase

class SaqlParserUtil: GeneratedParserUtilBase() {
// fun parseFunctionName(builder: PsiBuilder, level: Int): Boolean {
// if (!recursion_guard_(builder, level, "function_name")) return false
// var result: Boolean
// result = name(builder, level + 1)
// if (!result && builder.tokenType === REPLACE) {
// builder.remapCurrentToken(IDENTIFIER)
// builder.advanceLexer()
// result = true
// }
// return result
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.phodal.shirelang.saql.psi

import com.intellij.psi.PsiElement

interface SaqlNameElement : PsiElement {
val nameAsString: String

Check warning on line 6 in saql/src/main/kotlin/com/phodal/shirelang/saql/psi/AndroidSqlNameElement.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "nameAsString" is never used
val nameIsQuoted: Boolean

Check warning on line 7 in saql/src/main/kotlin/com/phodal/shirelang/saql/psi/AndroidSqlNameElement.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "nameIsQuoted" is never used
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.phodal.shirelang.saql.psi

import com.intellij.psi.PsiElement

internal interface SaqlTableElement : PsiElement {
// val sqlTable: SaqlTable?
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include(
// cross-platform core?
"core-api",
"shirelang",
"saql",

"languages:java",

Expand Down

0 comments on commit 572694e

Please sign in to comment.