Skip to content

adamhirata/uwuScript

Repository files navigation

uwuScript ( ́ ◕◞ε◟◕`)

uwuScript logo

Introduction (づ。◕‿‿◕。)づ

uwuScript is a cute scripting language that is designed to be fun (and possibly cringey) to use. Because of the use of adorable emoticons and keywords, you will not only feel cuter, but look cuter by the end of developing your program!❀ This language compiles to Javascript and pulls inspiration from other sugoi すごい languages such as Java's static typing and Swift's for-in loops. uwuScipt also allowed for the programmer to use comments to effectively convey their emotions through various comment emoticons.

uwuScript Website: https://adamhirata.github.io/uwuScript/ grammar: https://github.com/adamhirata/uwuScript/blob/master/syntax/uwuScript.ohm Presentation Slides: Presentation Slides

Features

  • Cuteness
  • Scripting Language
  • Statically Typed
  • For-in/While Loops

Optimizations

  • Constant Folding - to compute simple expressions at compiler time
  • Strength Reduction - optimizations to reduce cost of more expensive Unary and Binary Operations

Types

  • Boowean/Boow
  • Stwing
  • Numbwer
  • Awway/Aww
  • Dictionawy/Dict

Unary and Binary Operators

  • add +
  • subtract -
  • multiply *
  • divide /
  • modulo %
  • not !
  • negative -
  • equality == or !=
  • less than <
  • less than or equal to <=
  • greater than >
  • greater than or equal to >=

Declarations


Numbwer a = 1
Boowean b = a != 1
Boow c = twue;
Stwing d = "this wetter iz c"
Awway<Stwing> e = ["this", "iz", "an", "awway"]
Dictionawy<Numbwer to Stwing> f = {1 to "one", 2 to "two", 3 to "three"}

Comments

 
Stwing a = "cute"         (*≧ω≦*) uwu
Stwing b = "give" 	  (づ ◕‿◕ )づ here take this
Stwing c = "happy"        (ノ゚▽゚)ノ yay it finally works

(╯°益°)╯彡┻━┻ I hate this table
Where did that table go?      ┻━┻
Nevermind that table was pretty cool ┬─┬ノ( º _ ºノ)

Code Examples

  • Top is uwuScript
  • Bottom is JavaScript

Max Number


Numbwer max(Numbwer n, Numbwer m) uwu
	if (n > m) uwu
    	retuwn n
    owo ewse uwu
    	retuwn m
    owo
owo

function max(n, m) {
  if (n > m) {
    return n;
  } else {
    return m;
  }
}

Factorial


Numbwer factorial (Numbwer n) uwu
  if (n == 1)  uwu 
    retuwn 1
  owo ewse uwu
    retuwn n * factorial(n - 1)
  owo
 owo

function factorial(n) {
    if(n == 0) {
        return 1
    } else {
        return n * factorial(n - 1);
    }
}

Bubble Sort


Aww<Numbwer> bubbleSort(Aww<Numbwer> arr) uwu 
  Numbwer len = length(arr)
  fow i in 0...len uwu 
    fow j in 0...len uwu
      if (arr[j] > arr[j+1]) uwu
        [arr[j], arr[j+1]] = [arr[j+1], arr[j]]
      owo
    owo
  owo
  retuwn arr
owo

function bubbleSort(arr) {
  let len = arr.length;
  for (let i = 0; i < len; i++) {
      for (let j = 0; j < len; j++) {
        if (arr[j] > arr[j + 1]) {
 	  [arr[j], arr[j+1]] = [arr[j+1], arr[j]];
        }
      }
  }
  return arr;
};

Nested for-in loop


fow i in 0...10 uwu
  fow j in 0...10 uwu
    pwint(i + j)
  owo
  if (i % 2 == 0) uwu
    aww[i-1] = stwing(i)
  owo
owo

for(int i = 0; i <= 10; i++) {
  for(int j = 0; i <= 10; j++) {
    console.log(i + j);
  }
  if (i % 2 == 0) {
    aww[i-1] = i.toString()
  }
}

Semantic Errors

  • Cannot chain relation operators

    a < b < c

  • Using relation operators on non-numbers

    "a" < "b"

  • Using mathematical operators on non-numbers

    "a" + "b"

  • Using "and" or "or" operators on non booleans

    1 && 2

  • Using equality operators on expressions of different types

    "1" == 1

  • Assigning a variable to a differently typed expression

    Numbwer a = 1 a = "one"
  • Declaring a variable with 2 different types

    Numbwer a = "one"
  • Cannot return a different type than specified

    Aww<Numbwer> a() uwu retuwn 1 owo
  • Arrays/Dictionaries must be of specified type

    Aww<Numbwer> a = ["1"] Dict<Numbwer to Stwing> b = {1 to "two", "1" to "two"}
  • Using break outside of a loop

    Numbwer a = 2 bweak
  • Incorrect amount or type of function parameters

    Numbwer a (Stwing str) uwu retuwn 2 owo a(2) a(2, "two")
  • Expression in if statement, while loop, or ternary statement is not a boolean

    Stwing a = "twue" while (a) uwu pwint(a) owo if (a) uwu pwint(a) owo a ? a = "twue" ewse a = "fawse"

About

Language implementation project for CMSI 488

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •