TO-DO: Allow "cell at pointer" to be specified when doing operations. This can be done in conditionals by writing L6(1) but that doesn't work in math operations. However, since I changed the label syntax and freed up the parentheses, I may allow ) or ( to be shorthand for "pointer row". Not sure yet.
Edit: Still working on this! It's proven to be harder than I originally thought, because I'll have to use different checks for when it happens inside a conditional and outside. In addition, I'll probably have to rewrite the entire conditional code, because right now it follows a really strict format that won't be easy to adapt to the idea of specifying the pointer's cell.
----
Just what it sounds like: An esoteric language that I made on a whim the other day. I've been calling it "Flux", although I don't think that's a very good name for it, so I'm open to suggestions! The interpreter is currently rather buggy, but it works.
Sometimes.
(Code is at the very bottom of this post)

The language is based around a data holder that has 'layers'; the ^ and V commands move up and down a layer, and math operations can only be done within the same cells on different layers. (basically it's a matrix; ^ and V move up/down a matrix row, and math is done by specifying rows in the pointer's column to operate on). For instance, here's a program that adds two user-input numbers together:

Code:
0.V0.1+2!

explanation:

Code:

0. //get input, store to current cell
V //move down a row
0. //get input again
1+2 //add top cell in pointer column to second cell in the column. Store the result to cell 2 (because it's the second operand)
! //output the value at the pointer


Commands/instructions:

. = Input
X.
[where X is a number from 1-9] stores X to the current cell
0. (can also be just . in some cases) stores a user-input number to the current cell
--
! = Output
Outputs the number value in the cell being pointed to.
If I make a computer version of this, ; will print the cell as an ASCII character.
--
<>^V = Pointer movement
Self-explanatory. The pointer moves on a series of stacked 1-dimensional stacks; < & > move the pointer on the stack layer it's currently on, and ^ & V move it up and down between layers. For instance, assuming the stack layers are as such:

{1,1,3,4}
{2,1,4,4} <
   ^

...writing ^ will move the pointer one layer up:

{1,1,3,4} <
{2,1,4,4}
   ^

Math operations (next section) are done between layers, in the column of cells at the pointer. Assuming the stack is the same as the last example, writing 1+2 will produce:

{1,1,3,4} <
{2,2,4,4}
   ^

--
/*-+% = Math operations
Division, multiplication, subtraction, addition and modulo respectively (on the calculator, modulo is represented by the thick [n/d] slash)
Syntax: (layerX)[op](layerY). For instance, 1+2 adds cell 1 to cell 2.
Stores result to the cell at layerY, leaves layerX intact. Because of this, it's possible to chain math ops together, such as 1+2+1+2+3, which will be evaluated as:

Code:

1+2->2
2+1->1
1+2->2
2+3->3

--
?X) = Label
A label for use by a goto. Between the ? and ) can be any token (even a valid Flux command), although I'd recommend against using question marks (it'll work without error currently, but if I decide to save a few bytes by removing the check for the closing parenthesis it could break programs). You can use a closing parenthesis as a label, though.
--
[X = Goto
Again, after the bracket can be any token. Searches the program from the beginning for a label with a matching character, and jumps to it.
--
:(condition)?(code), = Conditional statement
meaning If (condition):Then:(code):End. Syntax:
:(layerX)[>|<|=|≤|≥|≠](layerY)?(code),
Skips (code) if (layerX)[>|<|=|≤|≥|≠](layerY) is false. Both gotos and labels can be embedded inside conditionals.
Examples:

Code:

:1=2?!, //prints the current cell value if cell 1 = cell 2
:1>2?[1, //goes to the label ?1) if the top cell is greater than cell 2.

--
{> and/or < and/or ^ and/or V} = Copy data
Copies data from current cell (without removing it), moves a temporary pointer across the >/</^/V commands (you can have more than one), pastes stored data and restores the original pointer position.
A few examples:

Code:
{^} //copies data from the current cell to the cell above it.
{>>^} //copies data two cells over and one up.
//Although it wasn't intentional, you can also do other things (like ask for input) in the middle of a copy. For instance--
{>.^} //[alternatively {>0.^}] will copy, store input to one cell right, and paste at the cell one right and one up.
//This also gives an easier way to cut-paste one cell right than {>}<<{>}:
{1.>}

that last example assumes that you're fine with it being set to 1. I just realized there's no way to store 0 to a cell other than subtracting it from itself-- all the more reason to find a way to allow "Cell at pointer" to be specified.
--
= and ' = Jump within layer and jump up/down layers, respectively
Jumps the pointer horizontally or vertically (depending on symbol used) to the value at the cell being pointed to.
For instance:

Code:

//pointer: {1,2}; data cell at pointer: [5]
=
//pointer: {1,5}
-----
//pointer: {1,2}; data cell at pointer: [5]
'
//pointer: {5,2}


The code is a mess and sort of buggy, and I'm working on fixing it. Here it is anyway, though:

Code:

DelVar [A]{9,9->dim([A]
{1,1->L6
Input "",Str9
Str9+"~
seq(inString(".!<>^V/*-+n/d[:?{}='0",sub(Ans,X,1)),X,1,length(Ans->L1
For(I,2,dim(Ans
If I>=dim(L1:Return
L1(I->T
L6
If T=1:Then
If L1(I-1:Then
Input V
V->[A](Ans(1),Ans(2
Else
expr(sub(Str9,I-1,1->[A](Ans(1),Ans(2
End
End
If T=2
Disp [A](Ans(1),Ans(2
If max(T={3,4,5,6:Then
{Ans(1)-(T=5)+(T=6),Ans(2)-(T=3)+(T=4->L6
dim([A]
Ans+(L6-Ans)(L6>Ans->dim([A]
End
If T>=7 and T<=11:Then
[A](expr(sub(Str9,I-1,1)),L6(2->X
[A](expr(sub(Str9,I+1,1)),L6(2->Y
expr(sub(Str9,I+1,1
End
If T=7
X/Y->[A](Ans,L6(2
If T=8
XY->[A](Ans,L6(2
If T=9
X-Y->[A](Ans,L6(2
If T=10
X+Y->[A](Ans,L6(2
If T=11
remainder(X,Y->[A](Ans,L6(2)
If T=12
2+inString(Str9,"?"+sub(Str9,I+1,1)+")->I
If T=13:Then
sub(Str9,I+1,inString(Str9,"?",I)-I
"[A]("+sub(Ans,1,1)+",L6(2))"+sub(Ans,2,length(Ans)-1
sub(Ans,1,10)+"[A]("+sub(Ans,11,1)+",L6(2))"+sub(Ans,12,length(Ans)-11
If expr(sub(Ans,1,length(Ans)-1:Then
inString(Str9,"?",I+1->I
Else
1+inString(Str9,",",I+1->I
End
End
If T=14
inString(Str9,"(",I->I
If T=15:Then
L6->L5
[A](Ans(1),Ans(2->S
End
If T=16:Then
S->[A](L6(1),L6(2
L5->L6
End
[A](L6(1),L6(2
If T=17
Ans->L6(2
If T=18
Ans->L6(1
End
I think Flux is a great name.
This is a great idea to get started with programming languages. It is definitely one of the harder things to create, as how you implement things plays a major part in its usage. The syntax looks pretty understandable, at least as far as I can tell, so that's a good thing. Smile It might also be somewhat interesting to see how an interpreter could work using the DCS/E libraries, similar to Merth's turtle graphics project. Keep up the good work; and nice formatting on that post. Wink
Thanks a bunch, Mateo! Definitely agree with that, and I'm glad that it's legible (I was actually able to explain the entire language to a friend, who then helped me understand why a program I wrote was malfunctioning!). I'll try to make a Celtic-compatible version once I get everything working. And yeah, formatting that post was probably harder than writing the actual interpreter Razz

Anyway, here's a simple program that prints the ASCII codes for the characters "hello world":

Code:

9.V1.2+1*14.2+1^!{VV}V3.3-2!VV4.^4+3!!{V}V{>}V3.^5+4!{>^^^}VV4.^4.5*6+5!^^^^>{V}VV8.1+3!^!V3.2+3!V!V8.4-5!
Looking back on this, I wonder if there's a way to simplify the conditional statements. Right now, the only thing stopping me from doing something like If [A](expr(sub(whatever)),expr(sub(whatever)) is the fact that I allow for different types of equality checking (all of the ones available for regular TI-BASIC); because of that, I have to build a string, something like "[A]("+sub(whatever)+")"+sub(inequality symbol)+"[A]("+sub(cell 2)+")", since expr( can't evaluate stuff that doesn't return a value (meaning I can't do expr("=")) if that makes sense.

Any ideas on how I could simplify it?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement