add bnf
This commit is contained in:
parent
e5a0ad11cf
commit
8e189e779f
|
@ -39,4 +39,6 @@ bin/
|
|||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
|
||||
src/main/gen
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
|
|
@ -11,6 +11,13 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
// Include the generated files in the source set
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin.srcDirs("src/main/gen")
|
||||
}
|
||||
}
|
||||
|
||||
// Configure Gradle IntelliJ Plugin
|
||||
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
|
||||
intellij {
|
||||
|
|
|
@ -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:\"\$[^\"]*\""
|
|
@ -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)
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"@vars": {
|
||||
"varName": "value"
|
||||
},
|
||||
"@mixins": {
|
||||
"mixinNameObj": {
|
||||
"name": "title"
|
||||
},
|
||||
"mixinNameArr": [
|
||||
"title"
|
||||
]
|
||||
},
|
||||
"@template": {
|
||||
"test": [
|
||||
{
|
||||
"$mixin": "$mixinName"
|
||||
},
|
||||
"$varName",
|
||||
"$mixinNameArr"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue