EXDotSF

From Esolang
Jump to navigation Jump to search

EXDotSF (EXtended DotSF) is user:Rudolph4268's WIP extension of DotSF by user:ArthroStar11 and maintains backwards compatibility with the latter.

About

EXDotSF started off as an interpreter written in C that implements enough of the original DotSF specification required to be able to run code written in the latter language. In addition to the original DotSF single-character commands, EXDotSF adds basic comparison commands, a ternary-if-else command, some more stack manipulation commands, and even some multi-character commands which are detailed in the next section of this article.

Added and changed commands/syntax

Additional math/logic commands and syntax

  • #c<single-character>: Pushes the ordinal of <single-character> as ASCII to the top of the stack i.e. #cA pushes the value 65 to the top of the stack.
  • #n<signed-int-literal>\: Pushes the value of <singed-int-literal> (MUST BE TERMINATED WITH A BACKSLASH) to the top of the stack i.e. #n123\ pushes the value 123 to the top of the stack.
  • =: Pops two integers off the top of the stack (A and B) and pushes 1 if A == B, 0 if A != B
  • <: A < B
  • >: A > B
  • {: A <= B
  • }: A >= B
  • &: A && B (Boolean AND)

Added stack manipulation commands

  • ~: Pops the value from the bottom of the stack and pushes it to the top of the stack.
  • @: Pops two values from the top of the stack and pushes the two consecutive values to the top of the stack twice.
  • Muti-stack commands:
    • #sns\: Pops two values off the top of the current stack and uses them to create a new stack (first pop is max stack depth and the second pop is the stack index to use.) If the requested stack index is < 0, then find the first unused stack index and use it. The requested maximum stack depth must be > 0. If successful then it pushes the new stack's index to the top of the current stack (this does not change the current stack index.)
    • #sds\: Pops a value off the top of the current stack and uses it to delete a stack (the popped value is index of the stack the user wishes to delete.) The stack index must be non-negative.
    • #stfa\: Pops a value off the top of the current stack (the requested stack index) and pops the top element off that stack and pushes it to the top of the current stack.
    • #stfb\: Pops a value off the top of the current stack (the requested stack index) and copies (without popping it) the top element from that stack and pushes it to the top of the current stack.
    • #stfc\: Vice versa of #stfa\.
    • #stfd\: Vice versa of #stfb\.
    • #stfe\: #stfa\ but pops off the bottom of the other stack instead.
    • #stff\: #stfe\ but peeks into the other stack's bottom instead of popping.
    • #stfg\: Vice versa of #stfe\.
    • #stfh\: Vice versa of #stff\.
    • #gcs\: Pushes the current stack index value to the top of the current stack.
    • #scs\: Pops a value off the top of the current stack (the index of the stack to switch to) and sets the stack the requested index points to as the current stack (if it is valid.)

Added control flow commands

  • ?<if-true>|<else-if-false>': Ternary if-else. Pops a value off the top of the stack and evaluates the code in <if-true> block up to the pipe character if the popped value is non-zero, otherwise skips the <if-true> block and evaluates the <else-if-true> block up to the terminating single quote character.

Added I/O commands

  • ": Asks the user for a line of text and pushes each character to the top of the stack until the first newline character is reached at which an additional 0 is also pushed to the top of the stack as well (Basically pushes a user-provided null-terminated single-line string to the top of the stack)

Added debugging commands

  • `: Prints the contents of the entire stack from bottom to top to standard output

Changed commands

  • $: The regular usage of this tipping command from the original DotSF is not required by EXDotSF as it doesn't require the user to tip it regularly, but still remains valid syntax in the interest of keeping backwards compatibility with the original language. ($ is basically a "do nothing" command in EXDotSF)

Newly added syntax

  • !: Starts a single-line comment in your file (Comments end at either the next newline or at EOF, whichever one comes first.)

Notes and considerations about EXDotSF

  • As of October 10, 2021, the maximum number of stacks that can be active per interpreter is 10 but that value may increase in the future.

Planned new features that have yet to be worked on

There are currently none at the moment.

Planned new features that are currently being worked on and implemented

There are currently none at the moment.

Completed new features

  • Add the ability for EXDotSF programs to have multiple stacks (create new stacks, delete stacks, change/query the current stack number, and transfer data to the current stack from any inactive but allocated stack and vice versa with special # commands.
    • Status: Done! (October 10th, 2021 ~ 9:20 PM MST)
  • Add the ability for the programmer to leave single-line comments in their source files like in Python but using the ! character instead.
    • Status: Done! (December 31st, 2021 ~ 10:15 PM MST)

Example programs utilizing EXDotSF's new features

Print "Hello world!" and then a newline

#n10\#c!#cd#cl#cr#co#cw#c #co#cl#cl#ce#cH;;;;;;;;;;;;; 

A "Hello world!" program with single-line comments detailing almost every operation

! comment_test.txt --- a test for the new single-line comment syntax in EXDotSF.

! This is a comment.
!You can also comment like this too!
!! And also like this!!!!!!!

#cH#ce#cl#cl#co#c #cw#co#cr#cl#cd#c!0     ! Pushes the string "Hello world!\0" onto the stack. 
A       ! Define our label 'A' here.
  ~     ! Move the next character from the bottom of the stack to the top of the stack.
  _     ! Make a copy of the current character for comparison against 0. (because the '[' operator pops off the top of the stack)
  [     ! Goes into here if the character is not zero. if the char IS zero then this block is skipped.
    ;   ! Print the character to stdout as ASCII.
    a   ! Rewinds execution back to A because there's more characters.
  ]     ! block terminator.

#n10\   ! push an ASCII linefeed character to the top of the stack.
;       ! print the linefeed to stdout.

! And we are done here! The program will now terminate.

Cat program

A#n10\;"1[B~_;[b]a]

A more verbose Cat program that prefixes the output with "-> You wrote: " (minus the double quotes)

A#n10\;#c-#c>#c #cY#co#cu#c #cw#cr#co#ct#ce#c:#c "1[B~_;[b]a]

Check if two user-provided integers are equal

..=?#n10\#cl#ca#cu#cq#ce;;;;;;|#n10\#cl#ca#cu#cq#ce#c #ct#co#cn;;;;;;;;;;'

Calculator program (asks user for an operator (+, -, *, /) and two integer operands and outputs the result

,..~_#c+=[[]+:z]_#c-=[[]-:z]_#c*=[[]*:z]_#c/=[[]/:z]#n10\#n13\#cR#cO#cR#cR#cE;;;;;;;Z

Print the smallest of two user provided integers

..@<?[]:|:'

Print the largest of two user provided integers

..@>?[]:|:'

Screenshots

EXDotSF running on Android via Termux
EXDotSF running in MS-DOS via DOSBox

Source code

GitHub repository (Building and running instructions are here in the README): https://github.com/SIGSEGV-666/EXDotSF/

See also