This commit is contained in:
Владимир Фёдоров 2024-04-01 16:30:13 +07:00
parent e5a0ad11cf
commit 8e189e779f
6 changed files with 78 additions and 1 deletions

2
.gitignore vendored
View File

@ -40,3 +40,5 @@ bin/
### Mac OS ### ### Mac OS ###
.DS_Store .DS_Store
src/main/gen

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>

View File

@ -11,6 +11,13 @@ repositories {
mavenCentral() mavenCentral()
} }
// Include the generated files in the source set
sourceSets {
main {
kotlin.srcDirs("src/main/gen")
}
}
// Configure Gradle IntelliJ Plugin // Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html // Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij { intellij {

View File

@ -0,0 +1,32 @@
{
parserClass="ru.crabs.sjson.parser.SJsonParser"
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix="SJson"
psiImplClassSuffix="Impl"
psiPackage="ru.crabs.sjson"
psiImplPackage="ru.crabs.sjson.impl"
elementTypeHolderClass="ru.crabs.sjson.SJsonTypes"
elementTypeClass="ru.crabs.sjson.SJsonElementType"
tokenTypeClass="ru.crabs.sjson.SJsonTokenType"
tokens = [
space='regexp:\s+'
string = "regexp:\"[^$][^\"]*\""
number = "regexp:\d*"
]
}
root ::= object
object ::= "{" (prop ",")* prop "}"
array ::= "[" (item ",")* item "]"
prop ::= pair | mixin
pair ::= string ":" item
mixin ::= var ":" item
item ::= (object | array | var | string | number)
var ::= "regexp:\"\$[^\"]*\""

View File

@ -0,0 +1,13 @@
package ru.crabs.sjson
import com.intellij.psi.tree.IElementType
class SJsonTokenType(debugName: String) : IElementType(debugName, SJsonLanguage.INSTANCE) {
override fun toString(): String {
return "SimpleTokenType." + super.toString();
}
}
class SJsonElementType(debugName: String) : IElementType(debugName, SJsonLanguage.INSTANCE)

View File

@ -0,0 +1,22 @@
{
"@vars": {
"varName": "value"
},
"@mixins": {
"mixinNameObj": {
"name": "title"
},
"mixinNameArr": [
"title"
]
},
"@template": {
"test": [
{
"$mixin": "$mixinName"
},
"$varName",
"$mixinNameArr"
]
}
}