mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-05 00:00:10 +00:00
changed class -> proto
This commit is contained in:
parent
e0d51c191f
commit
9ca67c8408
@ -1,8 +1,8 @@
|
||||
# Cosmo
|
||||
Cosmo is a portable scripting language loosely based off of Lua. Cosmo easily allows the user to extend the language through the use of Proto objects, which describe the behavior of Objects. For example the following is a simple Vector class which describes behavior for a Vector-like object.
|
||||
Cosmo is a portable scripting language loosely based off of Lua. Cosmo easily allows the user to extend the language through the use of Proto objects, which describe the behavior of Objects. For example the following is a simple Vector Proto which describes behavior for a Vector-like object.
|
||||
|
||||
```
|
||||
class Vector
|
||||
proto Vector
|
||||
function __init(self)
|
||||
self.vector = {}
|
||||
self.x = 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
class Vector
|
||||
proto Vector
|
||||
function __init(self)
|
||||
self.vector = {}
|
||||
self.x = 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
class test
|
||||
proto test
|
||||
function __init(self, x)
|
||||
self.setArg(x)
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
class Test
|
||||
proto Test
|
||||
function __init(self, x)
|
||||
self.x = x
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
// crafts a dummy class
|
||||
class test end
|
||||
// crafts a dummy proto
|
||||
proto test end
|
||||
|
||||
// instance of test
|
||||
var obj = test()
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
CReservedWord reservedWords[] = {
|
||||
{TOKEN_AND, "and", 3},
|
||||
{TOKEN_CLASS, "class", 5},
|
||||
{TOKEN_DO, "do", 2},
|
||||
{TOKEN_ELSE, "else", 4},
|
||||
{TOKEN_ELSEIF, "elseif", 6},
|
||||
@ -18,6 +17,7 @@ CReservedWord reservedWords[] = {
|
||||
{TOKEN_NIL, "nil", 3},
|
||||
{TOKEN_NOT, "not", 3},
|
||||
{TOKEN_OR, "or", 2},
|
||||
{TOKEN_PROTO, "proto", 5},
|
||||
{TOKEN_RETURN, "return", 6},
|
||||
{TOKEN_THEN, "then", 4},
|
||||
{TOKEN_TRUE, "true", 4},
|
||||
|
@ -49,7 +49,7 @@ typedef enum {
|
||||
TOKEN_END,
|
||||
TOKEN_FOR,
|
||||
TOKEN_FUNCTION,
|
||||
TOKEN_CLASS,
|
||||
TOKEN_PROTO,
|
||||
TOKEN_IF,
|
||||
TOKEN_LOCAL,
|
||||
TOKEN_NOT,
|
||||
|
@ -742,7 +742,7 @@ ParseRule ruleTable[] = {
|
||||
[TOKEN_END] = {NULL, NULL, PREC_NONE},
|
||||
[TOKEN_FOR] = {NULL, NULL, PREC_NONE},
|
||||
[TOKEN_FUNCTION] = {anonFunction, NULL, PREC_NONE},
|
||||
[TOKEN_CLASS] = {NULL, NULL, PREC_NONE},
|
||||
[TOKEN_PROTO] = {NULL, NULL, PREC_NONE},
|
||||
[TOKEN_IF] = {NULL, NULL, PREC_NONE},
|
||||
[TOKEN_LOCAL] = {NULL, NULL, PREC_NONE},
|
||||
[TOKEN_NOT] = {NULL, NULL, PREC_NONE},
|
||||
@ -828,7 +828,7 @@ static void defineVariable(CParseState *pstate, uint16_t global, bool forceLocal
|
||||
valuePopped(pstate, 1);
|
||||
}
|
||||
|
||||
static void _class(CParseState *pstate) {
|
||||
static void _proto(CParseState *pstate) {
|
||||
uint16_t var = parseVariable(pstate, "Expected identifer!", false);
|
||||
int entries = 0;
|
||||
|
||||
@ -1156,8 +1156,8 @@ static void expressionStatement(CParseState *pstate) {
|
||||
forLoop(pstate);
|
||||
} else if (match(pstate, TOKEN_FUNCTION)) {
|
||||
functionDeclaration(pstate);
|
||||
} else if (match(pstate, TOKEN_CLASS)) {
|
||||
_class(pstate);
|
||||
} else if (match(pstate, TOKEN_PROTO)) {
|
||||
_proto(pstate);
|
||||
} else if (match(pstate, TOKEN_RETURN)) {
|
||||
returnStatement(pstate);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user