Skip to content

Commit

Permalink
Fix intellij lexer (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilmveel authored Nov 24, 2023
1 parent 3a0fce7 commit 35c3f32
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lsp/intellij-plugin/src/main/kotlin/Lexer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class Lexer : IntellijLexer() {

override fun advance() {
index++
state = index
}

override fun getBufferEnd() = buffer.toString().length
Expand Down
26 changes: 22 additions & 4 deletions src/lsp/intellij-plugin/src/main/kotlin/Parser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ class Parser : PsiParser {
}
}

fun parseDef() {
fun parseRef() {
when {
builder.eof() -> return
builder.def() -> return
builder.tokenType == CUSTOM_TYPE -> {
val customTypeMarker = builder.mark()
builder.advanceLexer()
customTypeMarker.done(CustomTypeDef())
parseDef()
customTypeMarker.done(CustomTypeRef())
parseRef()
}

builder.tokenType == LEFT_CURLY -> {
Expand All @@ -74,7 +74,25 @@ class Parser : PsiParser {
parseBody()
bodyMarker.done(Body())
builder.advanceLexer()
parseDef()
parseRef()
}

else -> {
builder.advanceLexer()
parseRef()
}
}
}

fun parseDef() {
when {
builder.eof() -> return
builder.def() -> return
builder.tokenType == CUSTOM_TYPE -> {
val customTypeMarker = builder.mark()
builder.advanceLexer()
customTypeMarker.done(CustomTypeDef())
parseRef()
}

else -> {
Expand Down

0 comments on commit 35c3f32

Please sign in to comment.