def eval(s: String)(using ctx: Context): VAny =
if VNum.NumRegex.matches(s) then VNum(s)
else if s.matches(raw"""("(?:[^"\\]|\\.)*["])""") then
s.substring(1, s.length - 1)
else if Lexer.isList(s) then
Lexer.lexLiterate(s) match
case Right(tokens) =>
val tempContext = Context(globals = Globals(settings = ctx.settings))
Interpreter.execute(Lexer.sbcsify(tokens))(using tempContext)
tempContext.peek
case Left(err) => throw RuntimeException(s"Couldn't parse list: $err")
def eval(thing):
if thing matches a number regex: cast to int
else if thing matches a string regex: remove string markers and return
else if thing matches a list regex: listify(thing)
else just return thing
def listify(thing):
remove opening "["
items = []
for char in thing:
if char == "[":
collect until matching "]"
add listify(^) to items
else:
collect until comma
add eval(^) to items
> LLVM function definitions consist of the “define” keyword, an optional linkage type, an optional runtime preemption specifier, an optional visibility style, an optional DLL storage class, an optional calling convention, an optional unnamed_addr attribute, ...
Hacking is problematic so you need to do it quickly. Golf me an IP grabber in the fewest bytes so I can recreate it when I inevitably get my machine taken away
> Note that LLVM itself does not contain a garbage collector, this functionality is restricted to generating machine code which can interoperate with a collector provided externally.
@user I don't think we actually need a GC, since we're not doing anything with multiple references or mutability. When something is popped, it can be freed once used.
Suppose I have a method session.get(str: String): String but you don't know whether it will return you a string or a null, because it comes from Java.
Is there an easier way to treat this in Scala instead of session.get("foo") == null ? Maybe some magic apply like ToOption(session.get("foo")) a...
@Ginger Yeah sbt has a lot more docs, mill if you're adventurous
@Ginger Sorta like macros
Builtin macros (I think Jelly calls them quicks?)
@Ginger It doesn't really have ?. or ?: like Kotlin since most Scala code uses Options. Try making helpers to call Java null-returning methods in Option maybe?
Remember the elements.py file in Vyxal 2? It's like that. It has every single element implementation
@Ginger We should probably add a doc comment there
symbol is the symbol from the codepage for the Element (e.g. + or :)
name is a short description of the element, e.g. "Bit Length | Matrix Inverse"
keywords is a list of keywords that you can use to refer to the element in literate mode, e.g. add and plus for +
arity is how many arguments it takes. It's an Option because some elements operate directly on the stack
vectorises is whether or not it...vectorises. I'm not sure how to explain this one but I assume you know already
vectorising is like doing a deep flatmap
overloads is a list of strings describing the overloads of the element, e.g. a: num, b: num -> a + b
impl is the actual implementation of the element. It's a function that will (presumably) pop stuff of the stack, do stuff, and pop stuff onto the stack
@lyxal pinging you to verify (also TODO need to add a doc comment explaining what Element is and what it holds)