You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f31adc0
Browse filesBrowse the repository at this point in the historyBrowse files
A Lua 5.3 lexer, parser, AST, and semantic-analysis toolkit written in pure Kotlin.
6
6
7
-
The current project scope is Lua 5.3 support plus ongoing Android-Lua/LuaJava analysis, JVM reflection interop, and a JVM language-server path. These areas are active work; README examples describe the intended integration surface without claiming final serialized verification has completed.
8
-
9
-
Semantic analysis uses the `SemanticPipeline` API; the former legacy analyzer entry points have been retired.
7
+
The project scope covers Lua 5.3 plus Android-Lua/LuaJava analysis, JVM reflection interop, and a JVM language-server path. Semantic analysis uses the `SemanticPipeline` API.
10
8
11
9
## Features
12
10
13
-
-[X] Kotlin Multiplatform support (JVM / JS / Native)
11
+
-[x] Kotlin Multiplatform support (JVM / JS / Native)
14
12
-[x] Parse source to AST
15
13
-[x] Transform AST to source code
16
-
-[ ] Semantic analysis. Provide type information (Work in progress)
14
+
-[ ] Semantic analysis: provide type information (work in progress)
17
15
18
16
## Setup
19
17
20
-
Use JDK 17 for local JVM work. On macOS, a typical session sets `JAVA_HOME` (Corretto 17) before invoking Gradle or IDE import:
For Android-Lua and LuaJava analysis, keep the Android-Lua source checkout outside this repository and record its path in your worker notes or IDE run configuration. The historical analysis docs use that checkout as read-only reference material for import, LuaJava, JNI, asset, and helper-library behavior.
28
-
29
-
For Android framework reflection, point the JVM workspace configuration at the platform jar for the API level you want to model. On this macOS host (2026-07-11 re-check) the Android SDK platform jar is **present** at:
Optional alternate host path when the SDK tree is not used: `/Users/dingyi/Downloads/android.jar` (currently absent on this machine). Prefer the SDK path above; never hard-code Windows `G:/` paths. See `docs/android-platform-setup.md` for discovery, skip policy, and metadata keys.
36
-
37
-
Use the `jvm.androidJar` metadata key or `JvmWorkspaceConfiguration.androidJar` for that path. Keep application/library jars in `jvm.classpath`, and reserve `jvm.androidJar` for the Android platform jar.
38
-
18
+
Use JDK 17 for local JVM work.
39
19
40
-
### Documentation map
41
-
42
-
-[Production readiness guide](docs/production-readiness.md): setup, usage, Android-Lua inputs, verification boundaries, known limitations, and extension points.
43
-
-[Android-Lua architecture notes](docs/android-lua-architecture.md): read-only source layout and fixture candidates from `/Users/dingyi/projects/java_projects/Android-Lua/app/src/main`.
44
-
-[Android-Lua import and LuaJava behavior](docs/android-lua-import-luajava.md): runtime patterns modeled by parser, semantic, interop, and LSP work.
45
-
-[Android-Lua compatibility matrix](docs/android-lua-compatibility-matrix.md): supported, partial, deferred, and out-of-scope behavior.
46
-
-[Android-Lua library model notes](docs/android-lua-library-models.md): helper modules, overlays, stubs, and type-model priorities.
47
-
-[Android-Lua corpus verification](docs/android-lua-verification.md): external corpus manifest usage and TASK-043 verification command.
48
-
-[Android platform setup](docs/android-platform-setup.md): `android.jar` acquisition, metadata keys, and classloader expectations.
49
-
-[Java interop model guide](docs/java-interop-model.md): Java type shapes, LuaJava helper mapping, and extension points.
50
-
-[JVM reflection and classloader design](docs/jvm-reflection-classloader-design.md): provider loading, package scanning, Android jar behavior, and limitations.
-[Semantic compatibility policy](docs/semantic-compat.md): retired legacy API surface and migration notes.
53
-
-[Serialized verification workflow](docs/serialized-verification.md): one-at-a-time Gradle/test execution and lock rules.
54
-
-[Test strategy and inventory](docs/test-strategy.md): parser, semantic, workspace, interop, LSP, and TDD inventory accounting.
20
+
For Android framework reflection, point the JVM workspace configuration at the platform jar for the API level you want to model, via the `jvm.androidJar` metadata key or `JvmWorkspaceConfiguration.androidJar`. Keep application/library jars in `jvm.classpath`, and reserve `jvm.androidJar` for the Android platform jar. See `docs/android-platform-setup.md` for details.
-**Kotlin consumer floor: Kotlin >= 2.1.** This library is compiled with the Kotlin 2.2.0 compiler, so consumers must build with a Kotlin Gradle plugin of 2.1 or newer to read its metadata; Kotlin 1.9 (and older) consumers fail with "compiled with an incompatible version of Kotlin".
67
-
- Runtime dependencies: the Kotlin stdlib. On JVM, `org.eclipse.lsp4j` is an `api` dependency because its types appear in the public `LuaLanguageService` surface.
30
+
**Requires Kotlin 2.1 or newer** — the library is compiled with Kotlin 2.2.0, and older Kotlin toolchains reject its metadata.
The public no-argument `LuaParser()` constructor intentionally defaults to `LuaVersion.ANDROLUA_5_3`. That keeps Android-Lua/AndroLua 5.3 syntax available by default for current parser, semantic, interop, and language-server work.
89
-
90
-
For strict Lua 5.3 grammar, construct the parser explicitly:
51
+
The no-argument `LuaParser()` constructor defaults to `LuaVersion.ANDROLUA_5_3`, keeping Android-Lua/AndroLua 5.3 syntax available by default. For strict Lua 5.3 grammar:
91
52
92
53
```kotlin
93
54
val parser =LuaParser(luaVersion =LuaVersion.LUA_5_3)
@@ -121,23 +82,21 @@ fun main() {
121
82
}
122
83
```
123
84
124
-
The returned `SemanticAnalysisResult` exposes the `SemanticModel` plus a lightweight summary.
125
-
126
-
The former `SemanticAnalyzer` / `AnalysisResult` / legacy symbol-table API has been retired; `SemanticPipeline` and its `SemanticAnalysisResult` / `SemanticModel` are the single public semantic entry point. See `docs/semantic-compat.md` for the retirement note.
85
+
The returned `SemanticAnalysisResult` exposes the `SemanticModel` plus a lightweight summary. The former `SemanticAnalyzer` / `AnalysisResult` / legacy symbol-table API has been retired; see `docs/semantic-compat.md`.
127
86
128
87
### JVM workspace interop
129
88
130
89
`JvmWorkspaceEngine` can reflect JVM classes into synthetic Lua modules so `require("String")`, `require("Arrays")`, and similar patterns resolve through the workspace graph.
131
90
132
-
For metadata-driven integration, use these keys:
91
+
Metadata-driven integration keys:
133
92
134
93
-`jvm.classes`: fully-qualified class names to mount directly
135
-
-`androlua.imports`: AndroLua-style simple import names that should be resolved through JVM import prefixes
94
+
-`androlua.imports`: AndroLua-style simple import names resolved through JVM import prefixes
136
95
-`jvm.classpath`: newline-separated jar or directory entries used to build a reflective class loader
137
-
-`jvm.androidJar`: optional path to an Android platform `android.jar`; appended to the effective reflective classpath
96
+
-`jvm.androidJar`: optional path to an Android platform `android.jar`, appended to the effective reflective classpath
138
97
-`jvm.importPrefixes`: newline-separated prefix list used for simple-name import resolution
139
98
140
-
You can also configure the JVM engine directly with `JvmWorkspaceConfiguration`:
Source-level Android-Lua patterns are also recognized by the JVM workspace layer:
152
+
Source-level Android-Lua patterns recognized by the JVM workspace layer:
194
153
195
154
-`import "java.lang.String"` exposes `String` as a visible reflected module symbol.
196
-
-`import "java.util.*"` resolves all top-level classes discoverable from that package on the active JVM classpath/runtime image, making them available as reflected module symbols.
155
+
-`import "java.util.*"` resolves top-level classes discoverable from that package on the active JVM classpath/runtime image.
197
156
-`local import = require("import")` followed by `import("java.util.Locale")` resolves the reflected class type for the assigned local.
198
157
-`luajava.bindClass("java.util.Locale")` resolves the reflected class type for the assigned local.
199
158
200
-
### Android and AndroLua setup notes
201
-
202
-
To reproduce Android class resolution on the JVM side, point `jvm.androidJar` at the platform jar for the SDK level you want to model. If you already have a combined classpath, place your dependency jars in `jvm.classpath` and the platform jar in `jvm.androidJar` so the reflective provider can resolve Android framework classes alongside your own libraries.
203
-
204
-
Example metadata payload:
205
-
206
-
```kotlin
207
-
val metadata =mapOf(
208
-
"androlua.imports" to "String\nLinearLayout",
209
-
"jvm.classpath" to "build/test-libs/app.jar",
210
-
"jvm.androidJar" to "/opt/android/platforms/android-34/android.jar",
211
-
"jvm.importPrefixes" to "java.lang\nandroid.widget"
212
-
)
213
-
```
214
-
215
159
### Language server
216
160
217
-
A JVM `lsp4j` server is now available under `io.github.dingyi222666.luaparser.lsp` and can be launched over stdio with:
161
+
A JVM `lsp4j` server is available under `io.github.dingyi222666.luaparser.lsp` and can be launched over stdio:
218
162
219
163
```bash
220
164
./gradlew runLuaLanguageServer
221
165
```
222
166
223
-
The current server implementation maps workspace-backed diagnostics, hover, completion, and goto-definition queries through `LuaWorkspaceQueryFacade`.
224
-
225
-
Workspace symbol search (`workspace/symbol`) matches case-insensitively on symbol names and ranks name-prefix matches ahead of mid-name substring matches before capping results at 500 entries; each bucket keeps the deterministic (name, path, line, column) order of the workspace index, so short queries return stable, prefix-first results instead of an arbitrary alphabetical slice.
167
+
The server maps workspace-backed diagnostics, hover, completion, and goto-definition queries through `LuaWorkspaceQueryFacade`. Workspace symbol search (`workspace/symbol`) matches case-insensitively and ranks name-prefix matches ahead of mid-name substring matches.
226
168
227
169
Example client settings payload:
228
170
@@ -235,40 +177,39 @@ Example client settings payload:
235
177
}
236
178
```
237
179
238
-
This configuration is consumed by the workspace service and serialized into the same metadata keys used by the reflective JVM workspace engine.
239
-
240
-
### Representative verification path
180
+
See `docs/language-server-usage.md` for capabilities and request examples.
241
181
242
-
A minimal end-to-end local verification flow, to be run only in the serialized verification phase during coordinated waves, is:
182
+
## Documentation
243
183
244
-
1. Start the language server with `./gradlew runLuaLanguageServer`.
245
-
2. Open a Lua document containing `local String = require("String")` and set client configuration with `androlua.imports = ["String"]`.
246
-
3. Request hover on `String.__class.length` and verify the server reports `java.lang.String`.
247
-
4. Request goto definition on `String.__class` and verify the target URI resolves to `file:///__jvm__/classes/java/lang/String.lua`.
248
-
5. Request completion on `Arrays.` after configuring `jvm.classes = ["java.util.Arrays"]` and verify `asList` is offered.
249
-
250
-
For a fuller setup and acceptance checklist, see `docs/production-readiness.md`.
184
+
-[Production readiness guide](docs/production-readiness.md): setup, usage, verification boundaries, known limitations, and extension points.
-[Test strategy and inventory](docs/test-strategy.md)
251
196
252
197
## Validation
253
198
254
-
- During parallel code and documentation waves, do not run Gradle, tests, or compile tasks. Required checks are deferred to the dedicated serialized verification phase, currently tracked by `TASK-043`.
255
-
- Outside coordinated worker waves, `./gradlew check` remains the supported default local validation path.
256
-
- Semantic validation now lives in shared `commonTest` coverage, including workspace query flows.
199
+
-`./gradlew check` is the default local validation path.
257
200
- Native host test execution is opt-in with `-PrunNativeHostTests=true`.
258
-
- Run Windows Kotlin/Native host tests explicitly with `./gradlew -PrunNativeHostTests=true mingwX64Test`.
259
-
- JVM interop coverage currently lives in `src/jvmTest/kotlin/interop/jvm/JvmWorkspaceEngineTest.kt`.
260
-
- LSP coverage currently lives in `src/jvmTest/kotlin/lsp/LuaLanguageServiceTest.kt`.
261
-
- Runnable JVM language server entry point: `./gradlew runLuaLanguageServer`.
262
-
- Final production acceptance is not claimed until `TASK-043` serialized verification and the `TASK-037` acceptance audit complete.
201
+
- JVM interop coverage lives in `src/jvmTest/kotlin/interop/jvm/JvmWorkspaceEngineTest.kt`; LSP coverage lives in `src/jvmTest/kotlin/lsp/LuaLanguageServiceTest.kt`.
263
202
264
203
## Publishing
265
204
266
-
Releases go to Maven Central through the manual `publish` workflow (`.github/workflows/publish.yml`, "Run workflow" only — it never triggers on push or tag). Before every run, bump `publishVersion` in `build.gradle.kts`(the single source of truth for the published coordinates): Maven Central forbids re-uploading an existing version, so retrying an already-burned version always fails. Consumers need Kotlin 2.1 or newer: the library is compiled with the Kotlin 2.2.0 compiler, and older Kotlin compilers reject its metadata ("compiled with an incompatible version of Kotlin").
205
+
Releases go to Maven Central through the manual `publish` workflow (`.github/workflows/publish.yml`, "Run workflow" only). Bump `publishVersion` in `build.gradle.kts`before every run — Maven Central forbids re-uploading an existing version.
0 commit comments