Skip to content
LabRicecat edited this page Dec 8, 2022 · 6 revisions

Welcome to MeowScript! This wiki will teach you how to write MeowScript but be careful, this wiki is written for people who have already programmed before.
If you haven't consider reading the book instead! (Link coming later)

Paradigms

MeowScript is

  • interpreted
  • dynamic typed
  • lexical scoped
  • object oriented
  • procedural
  • structured
  • half context free
  • lazy
  • unbiased

Comments

A line comment is started´ with a # and a multi line comment begins and ends with a ##

Types and their literals

Number

A basic number. Can hold negative as well as floating point numbers

12
42.001
(-54.13)

String

A list of characters that can also handle escape sequences. (has nothing to do with type List)

"Hello, "
"World!\n"
" \rsomething something\t\t "

List of escape sequences:

  • \n -> Newline
  • \r -> Carry return
  • \t -> Vertical tab
  • \\ -> Normal backslash

List

A dynamic list that can hold any amount of elements of the VariableType subset.

[1,2,3]
["This"," is ","a list!"]
[[1,2],[3,4],[5,6]]
[1,"2",[3]]

Dictionary

A map of keys and values of any type.

{
	"key" = 12,
	key2 = "woo",
	"shopping list" = ["salad","bread","cookies"],
	subdic = {
		1 = 2,
		"a" = b
	},
}

Function

Any name that has been used previously to define a function.

Command

A built in command name.

Compound

A code snippet that has been put into curly braces. ({})

{code that does stuff; ...}

Name

Any set of characters that follows these rules:

  • First character is not a number
  • Rest is either A-Z, a-z, 0-9 or _
a_Name
am2cool4u
sTufF

Expression

A sequence of mathematical terms following the rule of: (left operator right).

(1 + 2 * 3 == 9)
(42.2 / (3 - 2.2))

Argumentlist

A list or values, compounds and expressions that is inbetween two braces (()).

(12.3,"hi",[1,2,3])
({...},(12*23),(-44.6))
()

Parameterlist

Similar to an Argumentlist but with more restrictions. Used as parameter lists for functions.

(a :: Number, b, c :: String)
(a,b,c)
()

Operator

A combination of only special characters that is in the list of known operators.

==
+
-
^

Module

A loaded module that can be used to call methods on or to be enabled. In the standard library are three:

os
filesystem
math

But others can be added at runtime by the user.

Struct

An already defined structure in either the current or in a scope below the current.

Object

A object is an instance of a struct. It has no literal.

Event

An defined event by the event command. No literal.

Keyword

Some reserved words used by MeowScript to ensure that some names don't get used as function names.

public
private
occur_only

Type Subsets

There are some subsets of the main set of types.

VariableType

Any type that a variable can hold. This includes:

  • Number
  • String
  • List
  • Dictionary
  • Object

MethodSet

Any type that can be methods be called on. This includes:

  • List
  • Dictionary
  • Object
  • Module

Execution process

MeowScript executes line by line, but things that are in braces counts still as one line.

command argument1 argument2 {
 ....
} () ...

An argument can be type.

There are also commands that use an unspecified amount of arguments.

Returning

Everything in MeowScript returns something, even if it's just void. If something gets returned that is not void some rules are to be considered:

  • If we are in the main scope, the return value will be printed to the console.
  • If we are not the in main scope and there are more lines with commands still to come, we ignore it.
  • If we are not in the main scope and there are no more lines with commands left, we return down the current return.

Compounds, if they aren't used as body of something (a function for example), run their context and return the their result down, may it even be void.

>>> Next Article