VERPNL
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
- This is still a work in progress. It may be changed in the future.
VERPNL stands for Vietnamese "Extendable" Reverse Polish Notation Language. The specific meaning of "Extendable" is not specified, but the language idea and name is created 6 months ago and now I'm creating the page.
It is a imperative stack-based language.
Syntax
Every line is like this:
[header] [code]
or
[label]:
No you can't put labels and code on the same line (not if you use the original, you can make preprocessors to make writing code 200% easier)
Comments
Anything after a semicolon in a line will not be parsed.
headers
Headers must begin every non-label-line.
There is the standard header: #
, it just executes the code after the header.
The conditional header: ?[label]
. It excutes the code, pops a value, and if it is nonzero, it jumps to the label.
The subroutine header: @[label]
. Like the conditional header, but you can return.
Return header: R
: Return from the subroutine header. The behaviour if there are no subroutines to return from is undefined.
There is no uncond jump header, unless you use preprocessors.
Code after the header
Here are the defined commands, as of V1.0. You're free to suggest extensions.
Command | Function |
---|---|
dup drop pop swap over roll | Runs the corresponding Forth Stack Word. |
Any floating-point number | Push the number on the stack |
+ * | Does addition or multiplication, popping 2 numbers on the stack and pushing a result. |
- / | Does negation or reciprocal. Modifies the top element of the stack. |
and or xor not | Bitwise operators |
print putchar | Pop the top element and print it as integer/character. |
input getchar | Input a/an integer/character and push it(s ascii) to the stack. |
Any string quote by double quote | Push the ASCII code corresponding to all characters of the entire string into the stack. |
$ | Reverse the stack. |
someone pls help me do variables | ... |
Variables
(OPTIONAL EXTENSION)
Now all elements on the stack are strings. All numeral operators tries to convert any string into a number, unless the operator have a special string handling procedure.
In addition, storage is now not only a stack but a stack AND a dictionary (or map<string><string> if you use C++)
Additional Operators:
? Pops the string on top of stack, then pushes the value in the dictionary, with the key being the popped value.
= Pops 2 values, set the value at key [first popped] to [second popped].
R pops a string (a) and a string (b). Returns the (a)th character of (b). S pops a character (a), a index (b) and a string (c). Pushes (c) with the (b)th char changed to (a). L pop a string, pushes its length.
You could make variables, and arrays(if you try hard enough).
Credits
User:Xyzzy for the language idea and control structure and for the variables
User:PrySigneToFry for the output command, string operations and reversing stack
put your names here if you make a contribrution, do not delete my lines