summaryrefslogtreecommitdiff
path: root/src/LispParser.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-08-21 16:15:59 +0200
committernea <nea@nea.moe>2023-08-21 16:15:59 +0200
commit4bbfede4060d38083aafd8a6c7ab2847e0e55ebf (patch)
treef0ab50180d2fa1c872ba8c20a4b055cd87bed3c9 /src/LispParser.kt
parentde694f30b5e2f6fd62a00e5a622abe0a2411afb9 (diff)
downloadnealisp-4bbfede4060d38083aafd8a6c7ab2847e0e55ebf.tar.gz
nealisp-4bbfede4060d38083aafd8a6c7ab2847e0e55ebf.tar.bz2
nealisp-4bbfede4060d38083aafd8a6c7ab2847e0e55ebf.zip
method binding
Diffstat (limited to 'src/LispParser.kt')
-rw-r--r--src/LispParser.kt5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/LispParser.kt b/src/LispParser.kt
index 3341779..48d0d45 100644
--- a/src/LispParser.kt
+++ b/src/LispParser.kt
@@ -10,10 +10,15 @@ class LispParser private constructor(filename: String, string: String) {
fun parse(filename: String, string: String): LispAst.Program {
return LispParser(filename, string).program
}
+
fun parse(file: File): LispAst.Program {
return parse(file.absolutePath, file.readText())
}
+ fun isValidIdentifier(name: String): Boolean {
+ return name.isNotEmpty() && name.first() in validStartingIdentifiers && name.all { it in validIdentifiers }
+ }
+
val digits = "1234567890"
val hexDigits = digits + "abcdefABCDEF"
val alphabet = "abcdefghijklmnopqrstuvwxyz"