begin shift to nim code base

This commit is contained in:
Emile Clark-Boman 2025-06-16 20:47:52 +10:00
parent 33bcffdc69
commit 4b20f9961b
25 changed files with 625 additions and 303 deletions

7
src/noether.nim Normal file
View file

@ -0,0 +1,7 @@
# This is just an example to get you started. A typical hybrid package
# uses this file as the main entry point of the application.
import noether/submodule
when isMainModule:
echo(getWelcomeMessage())

29
src/noether/lexer.nim Normal file
View file

@ -0,0 +1,29 @@
import std/streams
type
nlLexer* = object
stream: Stream
pos: Natural
proc newLexerFromStream(stream: Stream): nlLexer =
result = nlLexer(
stream: stream,
pos: 0,
)
)
proc newLexer*(content: string, isFile: bool): nlLexer =
result = newLexerFromStream(
streamFile(content) if isFile else streamString(content)
)
)
proc streamFile(filename: string): FileStream =
result = newFileStream(filename, fmRead)
proc streamString(str: string): StringStream =
result = newStringStream(str)
proc nextToken*(lexer: nlLexer): nlToken =
result = newToken[]

View file

@ -0,0 +1,6 @@
# This is just an example to get you started. Users of your hybrid library will
# import this file by writing ``import srcpkg/submodule``. Feel free to rename or
# remove this file altogether. You may create additional modules alongside
# this file as required.
proc getWelcomeMessage*(): string = "Hello, World!"