This is a high level overview of redditlang’s syntax and features. It is organized by the header being the feature, a list of implementation notes, the actual syntax and then footnotes.
If you are ever confused please see the official PEG grammar file that should be included with this document.
Aight, peeps, let's kick off with some slangs:
The stuff between < and > like refers to:
IDENT
Alphabetic character followed by a series of Alphanumeric or_
characters Example:ident - It's legit. 2ident - Nah, fam. Not cool. ide_nt - Yeah, it's vibing. _ident - Nah, total fail.
DECLARATION
Goes like<IDENT> no cap <TYPE>
or just<IDENT>
if you're not into types. TYPE is just<IDENT>(<IDENT*>)?
, where the second IDENT and brackets are optional and you can drop some commas between them.
All other <...> - They're like headers with a different vibe.
- Just chill, they're infinite like love for pizza.
- They vibe like Rust.
repeatdatshid { # Opens a loop
sthu # Breaks the loop
}
- Blocks are like online squads - you got them with curly brackets.
{ # This is a block
# Statements can appear inside blocks
} # This ends the block
- They're lone wolves, always on a separate line.
- No need for semicolons, no cap.
- Statement may only appear at the top level of the file and inside of blocks
- The top level statements are regarded first by the implementation
statement
next_statement
- When you wanna declare a function, just hit it with
callmeonmycellphone
- Got modifiers, arguments, a name, and a return type.
- Modifiers - just space 'em out.
- The declaration's type is the return type and the Ident is the name of the function
- The arguments are comma seprated
<FUNCTION_MOD*> callmeonmycellphone <DECLARATION>(<DECLARATION*>) <BLOCK>
Fullest example
debug bar callmeonmycellphone name damn Type(arg1 damn Type) {
}
- To call a function, drop a call.
call <IDENT>(<EXPR*>)
Where <EXPR*>
is a comma seperated list of expressions
- Use the
spez
keyword followed by the return value. - The type of the return value( if specified ) must match the type of the value after
spez
spez <EXPR>
debug
modifier: Will spill the tea on every variable. Works in debug builds withJesse
debugger andWalter
.bar
modifier: Makes the function viral in its squad.
<IDENT>
is a 25-characters max thing. If you break this rule, get ready for an AntiJavaException bullet.
- Errors are like bullets, shot with shoot and caught with wall. Try is test. Finally? Nah, it's not a thing.
- You import a module with
weneed
orbringme
- You specify a string module name after the keyword in quotes
weneed "module_name"
bringme "module_name"
- To set a module, use subreddit. You gotta drop an r/ before the name.
- This can only appear once at the top of each file
subreddit r/<IDENT>
Walter
is your dude for the build system.walter cook <target>
Default build target ismeth
Build files have ninja syntaxjesse
is the standard debugger
- You create 'em with meth.
- They can only be defined at the top level of modules or in blocks.
meth <DECLARATION> ∑ <EXPR>
is
, isnt
, and but
are all used for if
, else
, and elseif
respectfly
is <EXPR> {
}
but <EXPR> {
}
isnt {
}
You got:
- Conditional:
<TERM> <CONDITIONAL_OPERATOR> <TERM>
- Binary:
<TERM> <MATH_OPERATOR> <TERM>
- Indexing:
<TERM>[UInt]
A term is an identifier, number, string, or (<EXPRESSION>)
- New types are marked with
specimin <NAME>
- Type aliases with inheritance are marked with
specimin(<INHERITING TYPES>) <NAME>
- Typing a variable or function return type is optional.
- Types that are an
Array
have a[]
after it
specimin(Flags) Week = Mon | Tue | Wed | Thu | Fri | Sat | Sun
<TYPE>[]
- For classes, just hit school
school <IDENT> {
# These have `bar` by default, no need to specify
callmeonmycellphone snoRt() {
# Destructor
}
callmeonmycellphone cooK() {
# Constructor
}
}
The constructors and destructors must have these names.
Fields are placed at the top of the class, they are by default private.
- Comments are
#
and#*
+*#
for multi line.
- Boolean type but very foolish
specimin(Enum) Foolean =
Yup | // True
Nope | // Cap
Dunno | // `wat`
Huh | // IO Failure
Yeet // Why the hell not
- Flags be bussin', ya know. You can add 'em up or subtract 'em. They're just like those
bitflags
swag in Rust (they could legit be implemented with that).
specimin(Flag) OldProductTypes ∑ Type1 | Type2 | Type3
specimin(Flag) CurrentProductTypes ∑ OldProductTypes | Type4 // Add
specimin(Flag) SupportedTypes ∑ CurrentProductTypes - Type3 // Subtract
specimin(Flag) NonSupportedTypes ∑ CurrentProductTypes - SupportedTypes // Diff
Strings be poppin' off, with an array of characters (dont tell anyone, i added my idea where a character is an array of booleans, comment e if you notice)
A number can store any flipping integer from A-Z, 0-9, Monday to Sunday. They're bussin'!
- Ever wanted to use your rad numbers, with your cool decimals? Well, now you can! Like a float with more bussiness.
<UNARY_OPERATOR><VALUE>.<VALUE>
- This can store whole numbers
- The way the number is stored internally should be going up to the moon y'all! Ex, start small, if cant fit, go up a bit and go back!. ( Sizes: u8 u16 u32 u64 u128 i8 i16 i32 i64 i128 ). Decimals should be float(32, 64, 128) which should also be expanding.
<UNARY_OPERATOR><VALUE>
- This is nothing!
- Array index starts with
-1
like a cool dude!
array_value[<UInt>] # Index is inside of the brackets
- Equality: ⅀
- Add: ⨋
- Subtract: -
- Multiply: *
- XOR: ⊕
- Divide: ⎲
- Positive: ⨋
- Negative: -
- Assignment: ∑
- Amongus: ඞ Amongus is still cool right?
The standard library is already at the party! No need to invite it! If you for some reason feel the need too, weneed "std/[module]"
- io
- time
coitusinterruptus
print dat' string! Signaturecall coitusinterruptus(text damn String)
pulloutnt
Read that line! Signaturecall String pulloutnt()
Reads a line from stdio and returns it with no newline at the end
zzz
makes your code as boring as you! Signaturecall zzz(timeMs damn Number)
Stops the current thread fortimeMs
seconds