i only really know python, but ive been learning rust. And for anyone interested in programming language development (interpreters and parsers), ill give this link
No i wasnt making an introduction, just replying to this guys post. Sorry for the confusion lol
Hello and thanks for the link. I know it’s been a bit since this topic was started, but I wanted to give a brief update after a week. I’ve been half-following the general ideas in Crafting Interpreters while making my programming language parser. Now I can say that it works fine with the six or so test scripts (nested control flow, variables, function calls and declarations, etc.). As of now, I’m starting interpreter data structures.
P.S: Are links for GitHub repositories okay here?
- Dynamic typing but no type coercion.
- “Fail fast” (error on mismatched types and to replace null errors).
- Procedural style: just data and functions.
- Functions are not first-class though.
- Might have extensions (like CPython’s API to add custom functions in C).
# find bigger number of pair use io proc maxPair(a, b) if (a >= b) return a otherwise return b end end # should be 10 print(maxPair(10, 6))
Very cool. Also, glad your syntax is grammatically correct (
otherwise instead of
Edit: also @DerkWithT will you make 1 line return statements like
return a if (a >= b) otherwise b?
Hmm. I haven’t thought of making 1 line return statements like that before, but I might add syntax sugar after I really test my interpreter. Maybe a
foreach loop of some kind. I also need to support logical operators like
Here is the repository (
main branch only has the parser working): Rubel Language
Thanks for the feedback
Okay, the language is getting some good progress so far. This won’t be the largest update, but the baby steps are good to see. Currently, basic function calls, expressions, and conditional statements work… But I’ll have to fix assignments like
set i = i + 1 to update, say, loop counters.
Here is a little peek of my language working.
Just wondering, how does “use io” work?
For now, the
use (module name) statement marks a module of native C functions as “usable” so that the function lookup code can retrieve a pointer to that module. Otherwise, the algorithm returns
NULL. Then the function object is automatically taken based on its name from the module (like a dictionary with function names as keys). Names with no defined function give
rubel.c file within the repository’s
dev branch, I put C function pointers together in a special structure. Then that would be passed by pointer into the interpreter’s context object before the run. That feature reminds me of how the Duktape JS interpreter allows adding new C functions to call from JS scripts it runs.
It is a bit hacky as a solution though, but I plan to clean up my code later this fall. The C code may be big with almost 6000 lines, but I have a working idea of where things are.
Forgive me for not understanding cause i dont know C lol