# Freestajlo

Freestajlo is a Turing-complete programming language made by User:LEOMOK. Its name comes from https://www.youtube.com/watch?v=EygTFFhVBf8, which is the first video uploaded by the music YouTuber Waterflame. It is inspired by other stack-based programming languages like FALSE. Whitespace is a nop and allowed anywhere.

Freestajlo operates on an array of stacks of and indexed by unbounded, signed integers, as well as an unnumbered one for temporary storage and to transport values between stacks. Popping off an empty stack returns 0.

## Instructions

Unless specified, "the stack" refers to the stack currently being operated on.

### Literals

• `0`-`9` - push a nonnegative integer onto the stack, multidigit allowed.
• `'` - push the next character's Unicode value onto the stack.
• `"` - push 0, then the Unicode values of each character after the quote reversed (a null-terminated string).

### Arithmetic Operators

• `+` - pop a, b, push a+b.
• `-` - pop a, b, push b-a.
• `*` - pop a, b, push a*b.
• `/` - pop a, b, push b/a, rounded towards 0.
• `%` - pop a, b, push b%a, with the sign of a.
• `^` - pop a, b, push b^a, negative exponents return 0.
• `_` - pop a, push -a.

### Logical And Bitwise Operators

• `=` - pop a, b, push -1 if a==b, else 0.
• `<` - pop a, b, push -1 if b>a, else 0.
• `>` - pop a, b, push -1 if b<a, else 0.
• ``` - pop two values and push their bitwise NOR.

### Stack Operations

• `\$` - duplicate the top stack value.
• `#` - pop the stack and discard.
• `\` - swap top two stack values.
• `&` - pop a, dup stack item a from the top, 0-indexed.
• `~` - pop a, b, insert b at position a of stack from the top, 0-indexed
• `|` - push the current stack length.

### Input And Output

• `:` - print the top of the stack as decimal, popping it.
• `.` - print the top of the stack mod 0x10FFFF as a Unicode character, popping it.
• `;` - scan the input stream until a valid decimal integer is found, then push it onto the stack. 0 on EOF.
• `,` - get a codepoint of input and push its Unicode value. -1 on EOF.

### Control Flow

Zero is falsy, all other values are truthy.

• `{`...`}` - codeblocks.
• `?` - if statement (pops first). Syntax: `?{`then`}` or `?{`then`}{`else`}`
• `@` - while loop (does not pop). Syntax: `@{`loop body`}`

### Interstack Management

• `!` - pop a, move to stack number a.
• `(` - pop a value from the unnumbered stack and push it onto the stack.
• `)` - pop a value from the stack and push it onto the unnumbered stack.

### Functions

• `A`-`Z`, `a`-`z`: if followed by a codeblock, define a function, else run said function.

### Miscellaneous

• `[`...`]` - a comment.

## Turing-Completeness Proof

Branflakes programs can be translated into Freestajlo this way:

Branflakes Translation
`<` `1_!1+`
`>` `1_!1-`
`+` `1_!\$!1+`
`-` `1_!\$!1-`
`.` `1_!\$!.`
`,` `1_!\$!,`
`[` `1_!\$!@{`
`]` `1_!\$!}`

(sorry for any mistakes)

## Examples

### Hello, World!

```   "Hello, World!"@{.}
```

### Truth-Machine

```   ;@{\$:}:
```

### FizzBuzz until input value

```   1!;0! [set up input value]
0 1! [set up loop]
@{
\$15%0=?{"FizzBuzz"@{.}\$} [15 = 3*5]
{\$3%0=?{"Fizz"@{.}\$}
{\$5%0=?{"Buzz"@{.}}
{\$:}}}
10. [print newline]
1+0!1-1! [next iteration]
}
```

### Never Gonna Give You Up

```   [print newline]
N{10.}
[print null-terminated string from stack followed by a newline]
S{@{.}\$}N
[after each verse, chorus or whatever, print an extra newline]
[verse 1]
V{"We're no strangers to love"S
"You know the rules and so do I"S
"A full commitment's what I'm thinking of"S
"You wouldn't get this from any other guy"SN
}
[pre-chorus 1]
P{"I just wanna tell you how I'm feeling"S
"Gotta make you understand"SN
}
[chorus]
C{"Never gonna give you up"S
"Never gonna let you down"S
"Never gonna run around and desert you"S
"Never gonna make you cry"S
"Never gonna say goodbye"S
"Never gonna tell a lie and hurt you"SN
}
[verse 2]
v{"We've known each other for so long"S
"Your heart's been aching but you're too shy to say it"S
"Inside we both know what's been going on"S
"We know the game and we're gonna play it"SN
}
[pre-chorus 2]
p{"And if you ask me how I'm feeling"S
"Don't tell me you're too blind to see"SN
}
[bridge]
B{"(Ooh, give you up)"S
"(Ooh, give you up)"S
"(Ooh) Never gonna give, never gonna give"S
"(Give you up)"S
"(Ooh) Never gonna give, never gonna give"S
"(Give you up)"SN
}
[print lyrics]
VPCvpCBvP3@{C1-}
```

(also sorry for any mistakes)