Friends, Romans, countrymen, lend me your ears...
Welcome to the realm of sophisticated programming. No more are the days of writing simplistic "for" loops, "if-else" statements, and "classes". Speare brings sophistication to the computer science industry, with terms that only Shakespeare himself might take interest in. With Speare, your code will be quite the superiority complex stamp on your GitHub account. Try Speare today!
Speare has a number of different features:
- Static typing
- Complex Nesting
- Sophistication
- JS-like numeric types
Make sure to utilize them all to get the best out of Speare.
Below, you will find a comprehensive set of examples of code in Speare. Hopefully this will allow you to see just how bland and homespun other languages are, compared to Speare.
JavaScript | Speare |
---|---|
|
|
- Declared with 'enter`
- Comma separated parameters
- Parameters must have their type
JavaScript | Speare |
---|---|
function foo(bar, baz) {
let x = 0
return x
} |
|
- Speare allows for only assignment of variables. You may not create variables with no value
- Speare requires that you state the type of the variable you are creating
JavaScript | Speare |
---|---|
var a
var b = 0
var c = "hello"
var d = [6, 4, 3]
var e = { 6: 12, 3: 7 } |
|
JavaScript | Speare |
---|---|
let x = 10
if (x == 10) {
console.log(x)
} else if (x > 10) {
console.log("greater")
} else {
console.log("less")
} |
|
- For loops in Speare must have two or three statements within them
JavaScript | Speare |
---|---|
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 20; y++) {
y += 5;
}
} |
|
JavaScript | Speare |
---|---|
while (x) {
console.log("doing!")
} |
|
Printing in Speare is easy if you're a lexicographer:
speaketh("quite superior, i must say")
Arithmetic is quite fancy! Here are some examples:
x with 6
adds 6 to the variable x
.
x without 6
subtracts 6 from the variable x
.
x accumulate 6
gets the product of 6 and x
.
x sunder 6
gets the quotient of 6 and x
.
x residue 6
gets the remainder of x
divided by 6.
x exponentiate 6
raises x
to the 6th power.
absolutization(x)
is the absolute value of x
.
quadrangle(x)
gets the square root of x
.
So you don't have to worry about your lackluster English skills in this part of the Speare language.
Similar to Java, declaring or initializing a variable requires that you explicitly provide its type:
alloweth Numeral x be 0
Speare types include:
- Numeral (integer, float, etc.)
- Lexicographical (strings)
- ToBeOrNotToBe (boolean)
- Indistinguishable (None)
- Ideogram (symbol)
- Enter (function)
- IllUsed (null)
- Accommodation (object)
- Liste (list)
- Concordance (dictionary)
The numeral type contains what other languages might consider both "integers" and "floats" (or in some cases, doubles).
alloweth Numeral x be 6 with 7 without 8 exponentiate 9
Lexicographicals are strings, easy enough.
alloweth Lexicographical myopinion be "I am so sophisticated"
That is the question, is it not? These are true/false values of faithful
and fallacious
.
alloweth ToBeOrNotToBe flatearththeory be fallacious
Compositions... or as the casuals call them, "classes," are very simple to create in Speare, yet so snazzy. These are not currently supported in Speare.
Composition Foo {...}
Here is a list of all reserved words in the language:
- alloweth
- enter
- ToBeOrNotToBe
- Numeral
- Lexicographical
- IllUsed
- Ideogram
- Corollary
- indistinguishable
- fallacious
- faithful
- null
- with
- without
- accumulate
- sunder
- residue
- exponentiate
- absolutization
- quadrangle
- Composition
- tis nobler
- tis not
- tis lesser
- tis
- nobler
- lesser
- furthermore
- alternatively
- nay
- be
- increment
- incrementby
- decrement
- decrementby
- whether
- subsequently
- otherwise
- trigger
- condition
- exit
- whilst
- execute
- in regards to
- within
- Variable assignment with incompatible types
- Non-distinct keys for Concordances
- Variable reassignment with incompatible types
- Listes have inconsistent types
- Exit outside of loop
- Attempts to call a non-function or constructor
- Function with no return
- Returning a value where no value should be returned
- Wrong return type
- mismatching parameter types
- Creating a variable with an id that has already been used
- Referencing an unused identifier
- Compositions will raise a semantic error. They are not yet implemented
To run Spear, fork and pull this repo. Run npm install
, cd to the speare project folder.
You can run several different commands with the Speare compiler:
node ./src/speare.js <your/directory/code.speare ast
will output the ast for your speare program.
node ./src/speare.js <your/directory/code.speare analyzed
will output the analyzed speare file.
node ./src/speare.js <your/directory/code.speare generated
will output the JavaScript code version.
node ./src/speare.js <your/directory/code.speare optimized
will output the optimized semantically analyzed representation.
node ./src/speare.js <your/directory/code.speare js
will output the translation to JavaScript