Skip to content

Commit

Permalink
released 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cinkhangin committed Oct 7, 2023
1 parent aa75a05 commit 666fcf7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/src/main/java/com/naulian/glow/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class MainActivity : AppCompatActivity() {
binding.apply {
readStringAsset(filename) { result ->
result.onSuccess {
textInput.setText(it)
val highlighted = glowSyntax(it, language, CodeTheme.kotlinLight)
val source = "int foo(int[] numbers) {\n return 0;\n} "
textInput.setText(source)
val highlighted = glowSyntax(source, language, CodeTheme.kotlinLight)
textSource.text = highlighted.raw
textOutput.setCodeTheme(CodeTheme.kotlinLight.normal)
textOutput.text = highlighted.spanned
Expand Down
2 changes: 1 addition & 1 deletion glow/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ afterEvaluate {
from(components["release"])
groupId = "com.github.cinkhangin"
artifactId = "glow"
version = "1.0.0"
version = "1.0.1"
}
}
}
Expand Down
21 changes: 17 additions & 4 deletions glow/src/main/java/com/naulian/glow/tokens/JTokens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,31 @@ object JTokens {
}

//based on next
when(modified.type){
Type.COLON ->{
when (modified.type) {
Type.COLON -> {
if (prevToken.type == Type.ARGUMENT) {
tokens[prevIndex] = prevToken.copy(type = Type.PARAM)
}
}

Type.LEFT_PARENTHESES -> {
if (prevToken.type == Type.VAR_NAME) {
tokens[prevIndex] = prevToken.copy(type = Type.FUNC_NAME)
}

tokens.getOrNull(prevIndex - 1)?.let {
if(it.type == Type.DOT){
if (it.type == Type.DOT) {
tokens[prevIndex] = prevToken.copy(type = Type.FUNC_CALL)
}
}
}

Type.RIGHT_BRACKET -> {
if (prevToken.type == Type.VAR_NAME) {
tokens[prevIndex] = prevToken.copy(type = Type.LEFT_BRACKET)
}
}

else -> Unit
}

Expand All @@ -62,7 +74,7 @@ object JTokens {
}

private fun argumentToken(token: Token): Token {
return if(token.type != Type.IDENTIFIER) token
return if (token.type != Type.IDENTIFIER) token
else token.copy(type = Type.ARGUMENT)
}

Expand Down Expand Up @@ -126,6 +138,7 @@ private class JLexer(private val input: String) {
else -> createToken(Type.SLASH_FORWARD, char.toString())
}
}

'\'' -> readChar()
'\"' -> readString()
in 'a'..'z', in 'A'..'Z', '_' -> readIdentifier()
Expand Down

0 comments on commit 666fcf7

Please sign in to comment.