Skip to content

MichaelReza/Speare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1 | Introduction to Speare

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!


2 | Features

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.


3 | Example Code

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.

Hello World:

JavaScriptSpeare

console.log("hello, world")

speaketh("hello, world")

Functions:

  • Declared with 'enter`
  • Comma separated parameters
  • Parameters must have their type
JavaScriptSpeare
function foo(bar, baz) {
  let x = 0
  return x
}
enter Numeral foo(Numeral bar, Numeral baz) {
  alloweth Numeral x be 0
  returneth x
}

Variable Declaration and Assignment

  • 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
JavaScriptSpeare
var a
var b = 0
var c = "hello"
var d = [6, 4, 3]
var e = { 6: 12, 3: 7 }
alloweth Numeral b be 0
alloweth Lexicographical c be "hello"
alloweth Liste of Numeral d be [6, 4, 3]
alloweth Concordance of Numeral and Numeral e be {6 : 12, 3 : 7}

Conditionals

JavaScriptSpeare
let x = 10
if (x == 10) {
  console.log(x)
} else if (x > 10) {
  console.log("greater")
} else {
  console.log("less")
}
alloweth Numeral x be 10
whether (x tis 10) {
  speaketh(x)
}
subsequently (x nobler 10) {
  speaketh("greater")
}
otherwise {
  speaketh("less")
}

For, For-in Loops

  • For loops in Speare must have two or three statements within them
JavaScriptSpeare
for (int x = 0; x < 10; x++) {
  for (int y = 0; y < 20; y++) {
    y += 5;
  }
}
in regards to(alloweth x be 0, x lesser 10, x increment) {
  in regards to (alloweth y be 0, y lesser 20, y increment) {
    y incrementby 5
  }
}

While, Do-While loops

JavaScriptSpeare
while (x) {
  console.log("doing!")
}
whilst(x) {
  speaketh("doing!")
}

3.1 | Printing

Printing in Speare is easy if you're a lexicographer:

speaketh("quite superior, i must say")

3.2 | Numbers and Arithmetic

Arithmetic is quite fancy! Here are some examples:

Addition

x with 6 adds 6 to the variable x.

Subtraction

x without 6 subtracts 6 from the variable x.

Multiplication

x accumulate 6 gets the product of 6 and x.

Division

x sunder 6 gets the quotient of 6 and x.

Modulus

x residue 6 gets the remainder of x divided by 6.

Exponents

x exponentiate 6 raises x to the 6th power.

Absolute value

absolutization(x) is the absolute value of x.

Square root

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.

3.3 | Variables & Types

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)

3.3.1 | Numeral

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


3.3.2 | Lexicographical

Lexicographicals are strings, easy enough.

alloweth Lexicographical myopinion be "I am so sophisticated"

3.3.3 | ToBeOrNotToBe

That is the question, is it not? These are true/false values of faithful and fallacious.

alloweth ToBeOrNotToBe flatearththeory be fallacious


3.4 | Compositions

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 {...}

3.5 | Reserved Words

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

3.6 | Semantic Errors

  • 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

4.0 | Installation

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

About

'Tis the dopest script thy shall lay thine eyes upon

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published