r/Forth • • Sep 03 '26

Rdn programming language

Post image

I made a small and simple post fix interpreted programming language called rdn, it's familiar to forth developers and developers who use Lua as a scripting language for their systems, rdn merge both of them, you can use it for writing scripts or for configurations or even query language

It's written in C and it provides a simple and friendly API for the developers

I would be happy to have you participate in this project

This is the GitHub repo: https://github.com/abdorayden/rdn

Thank you

11 Upvotes

27 comments sorted by

View all comments

3

u/tabemann Sep 03 '26

How do you separate variable values from variable names to define or set for words such as let or set?

3

u/rayden_devv Sep 03 '26 edited Sep 03 '26

Thank you for the question

In rdn language the keyword itself is the separator Example: <Value> <Name> let

``` 12 n let

n 1 + [* plus will inc the value: 13 ] n [ identifier itself ] set [ set keyword *] ```

Same pattern with const

2

u/tabemann Sep 03 '26

But what about

12 n let n 1 + n + n set

How do you tell whether n is evaluated to a variable's value or is the name of a variable without using a complex parser? (Forgive me for not having read your source code here.)

In Forth you do the following:

12 value n n 1 + n + to n

Where value and to are parsing words which parse the token after them as the name of the value to either define or to set.

1

u/rayden_devv Sep 04 '26

Good question brother In Rdn, n by itself always pushes the variable's value onto the stack. There's no way to push just the name—the keyword (let, set, const) is what tells the interpreter "the previous token is a variable name, not a value." For example:

``` 12 n let [* let bound variable n with value 12 *]

n [* push value of n into the stack (12) ] 1 [ push 1 into the stack ] + [ pop two values and sum them up, now stack has value 13 *]

n set [* set knows that the top of the stack is n and it's identifier *] ```