Skip to content

Instantly share code, notes, and snippets.

@DeadlySurgeon
Last active March 9, 2022 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeadlySurgeon/f3e90f1110149d35d96db83d64c1cc1a to your computer and use it in GitHub Desktop.
Save DeadlySurgeon/f3e90f1110149d35d96db83d64c1cc1a to your computer and use it in GitHub Desktop.
POC language syntax

C

Verbal/VerbalScript (.vrbl)

This example bit of syntax can only be described as annoying. I've taken various aspects of different languages and picked out things I hate, and shoved them in. It is unlikely that I'll go far with this language, however I think that if I plan on learning LLVM and need a toy to hook up to it, this will be the syntax for that.

Fun Key Features:

  • Instead of functions being declared with parentheses, brackets, and whatnot, functions are declared by verbosely specifying the input, output, and call section. I find it interesting, as it is more annoying to write, but, if it weren't for the lack of brackets, potentially faster to read. I both love and hate it.
  • No return keyword. As the return variable is already specified in the declaration, there is no need to return. Maybe an exit type of keyword, eventually, but if you need to not continue forward then well you better learn how to construct your logic around that. Maybe if/else blocks for more pain.
  • Tabs over spaces. Various reasonings for this, but the main one is for accessability reasons. Tabs allow you to change the visual space, whereas 4 spaces will always be 4 spaces wide. Some spaces will be used, such as when allignment of various things after tabs needs to be done.
  • And more, probably going to be added later

WIP (Work In Progress)

This language is in fact a work in progress. The syntax is missing a lot, including but not limited to: Arrays, Error Handling, Most Operators, Streams, potentially Channels, Threading/Concurrency, and whatever else I'm missing.

Namespace/Packaging

The namespace/package is based off of the folder the code is in. If your code is in example/users/user.vrbl, it'll be imported as example/users, and potentially called as users.Stuff.

Attributes

I was thinking about public and private and whatever else, and I was thinking of Go, which it does it's wonderfully nuanced Public/private casing, which also does a wonderful job at keeping standards, we could throw public/private into the attributes section of things to ensure maximum bloat. Otherwise, I do like the casing for visibility.

// more comments
/* woah */
// calls this verbal.vbrl
// Author: AWildTyphlosion
/*
Things to think about:
- Instead of 4 letter words for each top level command, we could just have it
be the full word. This language is supposed to be verbose, so having the full
word would be in the spirit of the language, however another spirit of this
language is that it is annoying so maybe it could stay. If we really hate
people we could have both c:
*/
// Imports, importing in order.
// IDK if we'll have an init function.
pkgs
importName domain.com/repo/folder
// @Start: Example Object Definition
defn user
fields
username string
email string
defn person
inherits
user
fields
name string
age int
enabled bool
methods
decl string
takes
returns
name string
calls
name = "person:" + person.name // aids, but we can fix it later.
//
// Implementation acts like how go interfaces work
// Essencially, as long as the function provided matches, it can be used.
// ie:
// void print(stringer)
// p person
// print(p)
//
impl stringer
methods
decl string
takes
returns
name string
// @End: Example Object Definition
extn c:rand
takes
returns
i int
decl printPerson
takes
p person
returns
calls
print(p.string()) // I feel like we can make this more crazy
decl exampleLocalDecl
takes
returns
calls
// With the current scope, values defined here will be allociated in the scope,
// and will be deleted when the scope is over.
a int // Basic decl
b int = 4 // Basic decl and assignment
c = 8 // Potentially, without type assignment. However I dislike it how it isn't verbal enough.
d, e = example() // Types don't have to be declared when returning from a function.
decl add
annotate
key: value
takes
a int
b int
returns
r int
calls
r = a + b
// This wouldn't be valid, as we don't plan on overloading.
decl add
takes
a int
b int
c int
returns
r int
calls
r = a + b + c
decl exampleConditions
takes
a int
b int
returns
r int
calls
// Anonymous functions are allowed, but honestly not recommended.
// The amount of bloat it adds is bad, but hey, it's supposed to be a bad syntax.
decl sub
takes
a int
b int
returns
r int
calls
r = a - b
if a < b
// One way of calling sub
r = sub(a, b)
// Another way of calling sub
r = sub(
a,
b,
)
// Unlikely way of calling sub, might not be in the language
r = sub(
a: a
b: b
)
else if a == b
r = a
else
r = a + b
// Entrypoint function
// As we see, it doesn't really take anything, but it does return the status
// code. The equivlant of `int main()` in C. Arguments can be taken elsewhere.
decl main
takes
returns
status int
calls
@DeadlySurgeon
Copy link
Author

Comments:

-- This is a comment
->

This is a block

<-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment