Skip to content

Commit 14a4d5e

Browse files
feat: create a lexer (#2)
* feat: basic parser state instantiated * refactor: string and file types in separate states * refactor: updated to k2 and migrated state related classes to state package * refactor: re-wrote the state classes to work with tokens * feat: first token, EOF with dummy lexical parsing * feat: added lexer's initial configuration * fix: make Position class internal * chore: update docs * feat: defining data sources for the lexer * feat: defining data sources for the lexer * feat: Lexer is now able to classify identifier tokens * docs: updated the config for docs generation * refactor: migrate to package name without core * refactor: renamed skipCharacters to tokenSeparators * docs: rearranged the docs for Lexer to make each property private * feat: lexer re-written to keep a list of tokens * feat: testing token positions * feat: added basic functionality to ignore comments * fix: combines all token separators to split potential tokens properly * docs: updated to include lexer constructor parameters * feat: lexer can skip over multiline comments * feat!: removed tokenSeparator and converted the strings to regexes * feat: returns EOF when multiline comments do not end * feat: LexicalException for custom exception messages * refactor: changed var names and added comments * fix: able to return 3 tokens from the same line * refactor: remove redundant setter * feat: introduce ignorePattern and improve documentation * docs: explain operators and separators restriction * refactor: changed how to detect and work with comments * refactor: changed the way how tokens are extracted * chore: update docs * chore: changed parkour name * chore: updated docs * feat: added code for hardKeywords * feat: added support for operators and separators * test: added separator test cases * refactor: common function for long tokens * chore: bumping version to 0.1.0 0.1.0 will be the release version number of the lexer when merged to main. * chore: update docs [skip ci] * feat: revamped Token sealed class and introduced integer literals * fix: floating literals are detected properly * wip: setup lexer to detect string literals [skip ci] * tests: floating points with underscores * feat: basic character capturing * style: add docs to private functions for reference * feat: escape sequences in the lexer * docs: updated for literals
1 parent 8c9bc77 commit 14a4d5e

File tree

45 files changed

+2282
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2282
-314
lines changed

.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/Parkour.main.iml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/uiDesigner.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import com.vanniktech.maven.publish.KotlinJvm
33
import com.vanniktech.maven.publish.SonatypeHost
44
import org.jetbrains.dokka.gradle.DokkaTask
55
import java.net.URI
6+
import java.util.*
67

78
plugins {
89
kotlin("jvm") version "2.0.0"
@@ -33,13 +34,14 @@ kotlin {
3334
}
3435

3536
tasks.withType<DokkaTask>().configureEach {
36-
moduleName.set(project.name)
37+
val projectName = project.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
38+
moduleName.set(projectName)
3739
moduleVersion.set(project.version.toString())
3840
outputDirectory.set(docsDir)
3941
dokkaSourceSets.configureEach {
4042
sourceLink {
4143
localDirectory.set(projectDir.resolve("src"))
42-
remoteUrl.set(URI.create("https://github.com/cybercoder-naj/Parkour/blob/main/src").toURL())
44+
remoteUrl.set(URI.create("https://github.com/cybercoder-naj/parkour/tree/main/src").toURL())
4345
remoteLineSuffix.set("#L")
4446
}
4547
}
@@ -68,14 +70,14 @@ mavenPublishing {
6870
coordinates(project.group.toString(), project.name, project.version.toString())
6971

7072
pom {
71-
name.set("Parkour")
73+
name.set("parkour")
7274
description.set("Parser Combinator library for Kotlin")
7375
inceptionYear.set("2024")
74-
url.set("https://github.com/cybercoder-naj/Parkour/")
76+
url.set("https://github.com/cybercoder-naj/parkour/")
7577
licenses {
7678
license {
7779
name.set("MIT License")
78-
url.set("https://github.com/cybercoder-naj/Parkour/blob/main/LICENSE")
80+
url.set("https://github.com/cybercoder-naj/parkour/tree/main/LICENSE")
7981
distribution.set("repo")
8082
}
8183
}
@@ -87,9 +89,9 @@ mavenPublishing {
8789
}
8890
}
8991
scm {
90-
url.set("https://github.com/cybercoder-naj/Parkour/")
91-
connection.set("scm:git:git://github.com/cybercoder-naj/Parkour.git")
92-
developerConnection.set("scm:git:ssh://[email protected]/cybercoder-naj/Parkour.git")
92+
url.set("https://github.com/cybercoder-naj/parkour/")
93+
connection.set("scm:git:git://github.com/cybercoder-naj/parkour.git")
94+
developerConnection.set("scm:git:ssh://[email protected]/cybercoder-naj/parkour.git")
9395
}
9496
}
9597
}

docs/-parkour/io.github.cybercodernaj.parkour/-parser/-parser.html renamed to docs/-parkour/io.github.cybercodernaj.parkour.exceptions/-lexical-exception/-lexical-exception.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html class="no-js">
33
<head>
44
<meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
5-
<title>Parser</title>
5+
<title>LexicalException</title>
66
<link href="../../../images/logo-icon.svg" rel="icon" type="image/svg">
77
<script>var pathToRoot = "../../../";</script>
88
<script>document.documentElement.classList.replace("no-js","js");</script>
@@ -45,7 +45,7 @@
4545
</a>
4646
</div>
4747
<div class="library-version">
48-
0.0.6 </div>
48+
0.1.0 </div>
4949
</div>
5050
<div class="filter-section" id="filter-section">
5151
<button class="platform-tag platform-selector jvm-like" data-active="" data-filter=":dokkaHtml/main">jvm</button>
@@ -61,12 +61,12 @@
6161
<div class="sidebar--inner" id="sideMenu"></div>
6262
</div>
6363
<div id="main">
64-
<div class="main-content" data-page-type="member" id="content" pageIds="Parkour::io.github.cybercodernaj.parkour/Parser/Parser/#/PointingToDeclaration//769193423">
65-
<div class="breadcrumbs"><a href="../../../index.html">Parkour</a><span class="delimiter">/</span><a href="../index.html">io.github.cybercodernaj.parkour</a><span class="delimiter">/</span><a href="index.html">Parser</a><span class="delimiter">/</span><span class="current">Parser</span></div>
64+
<div class="main-content" data-page-type="member" id="content" pageIds="Parkour::io.github.cybercodernaj.parkour.exceptions/LexicalException/LexicalException/#kotlin.String?#kotlin.Throwable?/PointingToDeclaration//769193423">
65+
<div class="breadcrumbs"><a href="../../../index.html">Parkour</a><span class="delimiter">/</span><a href="../index.html">io.github.cybercodernaj.parkour.exceptions</a><span class="delimiter">/</span><a href="index.html">LexicalException</a><span class="delimiter">/</span><span class="current">LexicalException</span></div>
6666
<div class="cover ">
67-
<h1 class="cover"><span><span>Parser</span></span></h1>
67+
<h1 class="cover"><span>Lexical</span><wbr></wbr><span><span>Exception</span></span></h1>
6868
</div>
69-
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":dokkaHtml/main"><div class="symbol monospace"><span class="token keyword">constructor</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="clearfix"><span class="floating-right">(<a href="https://github.com/cybercoder-naj/Parkour/blob/main/src/main/kotlin/io/github/cybercodernaj/parkour/Parser.kt#L9">source</a>)</span></span></div></div></div>
69+
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":dokkaHtml/main"><div class="symbol monospace"><span class="token keyword">constructor</span><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">message<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a><span class="token operator">?</span><span class="token operator"> = </span>null<span class="token punctuation">, </span></span><span class="parameter ">cause<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html">Throwable</a><span class="token operator">?</span><span class="token operator"> = </span>null</span></span><span class="token punctuation">)</span><span class="clearfix"><span class="floating-right">(<a href="https://github.com/cybercoder-naj/parkour/tree/main/src/main/kotlin/io/github/cybercodernaj/parkour/exceptions/LexicalException.kt#L12">source</a>)</span></span></div></div></div>
7070
</div>
7171
<div class="footer">
7272
<span class="go-to-top-icon"><a href="#content" id="go-to-top-link"></a></span><span>© 2024 Copyright</span><span

0 commit comments

Comments
 (0)