From 4bbfede4060d38083aafd8a6c7ab2847e0e55ebf Mon Sep 17 00:00:00 2001 From: nea Date: Mon, 21 Aug 2023 16:15:59 +0200 Subject: method binding --- src/LispParser.kt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/LispParser.kt') 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" -- cgit