T^: Difference between revisions

From Esolang
Jump to navigation Jump to search
Content deleted Content added
m Categories
Tema5002 (talk | contribs)
i eat sand
Tag: Reverted
Line 94: Line 94:
^ "TA" "Hello, World!"
^ "TA" "Hello, World!"
$
$

[*
[*
this is a multi-line comment
this is a multi-line comment
by the way so you can write code like that:
by the way spaces are ignored so you can write code like that:


^
^

Revision as of 10:22, 9 October 2024

T^ Logo
T^ Logo

T^

T^ (T-Glyph) is an esoteric programming language created by tixonochek on July 24, 2024. Its primary interpreter is currently written in Python.

Data Types

  • Number: Double-precision floating-point numbers, specified using commas (,).
  • String: Strings are enclosed within double or single quotation marks.
  • Glyph: Any single character that is not a number or string.

Glyphs

Glyph Name Number of required arguments Purpose
^
Bind Glyph 2 Sets the value of a register (specified as text, e.g., "TA") (first argument) to a given value (second argument). The value must match the register's data type.
&
Register Match Glyph 2 Sets the value of one register (first argument) to the value of another (second argument). Both arguments must be specified as text, e.g., "TA"
$
Output Glyph 0 Outputs the combined values of registers TA and TB.
#
Bookmark Glyph 1 Creates a "bookmark" that can be jumped to later using the Jump glyph (`!`), may be used for making loops. Argument is a name of new bookmark (specified as text, e.g., "bk1").
!
Jump Glyph 1 Jumps to a previously created bookmark. Argument is a name of bookmark (specified as text, e.g., "bk1")
;
Ignore Glyph 0 Enables "Ignore Mode". Makes all following glyphs ignored until another Ignore glyph is encountered. May be used to break from loops.
=
Direct Comparsion Glyph 2 Compares two registers for both data type and value. Sets FA to 1 if equal, 0 otherwise. Both arguments must be specified as text, e.g., "TA"
(
Type Comparsion Glyph 2 Compares two registers for data type. Sets FA to 1 if equal, 0 otherwise. Both arguments must be specified as text, e.g., "TA"
)
Value Comparsion Glyph 2 Compares two registers for value. Sets FA to 1 if equal, 0 otherwise. Both arguments must be specified as text, e.g., "TA". Can compare number and text registers
|
< (less than) Comparsion Glyph 2 Compares two registers for both data type and value. Sets FA to 0 if the first register has a lower value than the second register or if they are equal, 1 otherwise. Both arguments must be specified as text, e.g., "TA". Can compare only number registers
@
When Glyph 1 Executes the following glyph only if FA is 1, skips the glyph otherwise. May be used for loops
+
Add Glyph 0 Adds the value of register MB to the value of register MA.
-
Substract Glyph 0 Subtracts the value of register MB from the value of register MA.
/
Divide Glyph 0 Divides the value of register MA by the value of register MB.
*
Multiply Glyph 0 Multiplies the value of register MA by the value of register MB.
%
Mod Glyph 0 Divides the value of register MA by the value of register MB, and then sets the value of the register MA to what is left after the division (This is a mod, modulus operator).
r
Root Glyph 0 Takes (VALUE OF MB REGISTER)th root of (VALUE OF REGISTER MA), result of the operation is written in the register МА.
l
Log Glyph 0 The result of the log operation is stored in MA, where the log base is the value of the registerr MB, and the log's argument is the value of the register MA.
s
Sin Glyph 0 The result of the operation is stored in МА. Takes sin of a number that is located in the register MA.
c
Cos Glyph 0 The result of the operation is stored in МА. Takes cosine of a number that is located in the register MA.
t
Tan Glyph 0 The result of the operation is stored in МА. Takes tangent of a number that is located in the register MA.
`
Register Reset Glyph 1 Resets the value of a specified register to its initial value. Argument must be name of regiser specified as text, e.g., "TA"
~
NTS-conversion Glyph 0 Converts the number in MA to a text string and stores it in TA.
:
STN-conversion Glyph 0 Converts the text in TA to a number and stores it in MA. Based on the result, sets the register FA to either 1 if success and 0 if couldn't convert.
>
Push Glyph 1 Pushes the value of a register onto the stack. Argument must be name of regiser specified as text, e.g., "TA"
<
Pop Glyph 0 Pops the top value from the stack and assigns it to a register it was pushed by.
?
Input Glyph 0 Asks for the input from the user in the console and stores the input in the register TA.
g
Get File Glyph 1 Argument is the name of an existing file (f.e.: "blahblahblah.*"). Reads the contents of the file and puts them into the register TA.
w
Write File Glyph 1 Argument is the name of an existing file (f.e.: "blahblahblah.*"). If the file with the given name doesn't exist, creates one. Writes whatever is written in the register TA into the file with the given name.
G
Exclusive Get File Glyph 1 Argument is the name of a register written as a string (f.e.: "AA"). Reads the contents of the file called (VALUE OF THE PROVIDED REGISTER) and puts them into the register TA.
W
Exclusive Write File Glyph 1 Argument is the name of a register written as a string (f.e.: "AA"). If the file doesnt exist already, create a file with the name (VALUE OF THE PROVIDED REGISTER) and write whatever is in the register TA into that file.
[* ... *]
Comments 0 Everything that is between them is ignored by the lexer, can be multi-line

Registers

T^ does not have variables in the traditional sense. Instead, it uses pre-created registers.

  • Number Registers: MA and MB
  • String Registers: TA and TB
  • Constant Registers (hold a constant number value): FA (used for bool operations) and FB (used for randomisation, value changes after every glyph execution)
  • General-Purpose Registers: AA, AB, AC, ..., AZ

Stack

Values can be pushed onto a stack from registers. When a value is popped from the stack, it is assigned back to the original register.

Examples

This is a hello world program written in T^:

^ "TA" "Hello, World!"
$

[*
this is a multi-line comment
by the way spaces are ignored so you can write code like that:

^
"TA"
"Hello, World!"
$

and this:

^ "TA" "Hello, World!" $
*]

Fibonacci numbers generator:

[* Initialize registers for the loop *]
^ "AA" ,0,
^ "AB" ,1,
^ "AI" ,1,
^ "AN" ,20,

[* Get input and write it to AN register *]
^ "TA" "How many numbers do you want print: " $
?
:
& "AN" "MA"

[* Reset FA register to false *]
( "TA" "MA"

# "main loop"
@ ;
    [* print AA *]
    & "MA" "AA"
    ~ $
    [* MA = AA *]
    & "MA" "AA"
    [* AA = AB *]
    & "AA" "AB"
    [* AB = MA + AB *]
    & "MB" "AB"
    +
    & "AB" "MA"
    [* AI = AI + 1 *]
    & "MA" "AI"
    ^ "MB" ,1,
    +
    & "AI" "MA"
    [* if AI == AN: break *]
    ) "AI" "AN"
! "main loop"
;

Trivia

  • The name "T^" is derived from the first letter of the author's nickname (tixonochek) and the bind glyph (^).

Implementation