diff --git a/docs/TODO.txt b/docs/TODO.txt index f58d02a..ec13803 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -31,7 +31,7 @@ DONE: are compounds shallow or deep copies? Deep copies DONE: third output stream, for lexer/parser/compiler/interpreter errors DONE: Assertion-based test scripts DONE: Import/export keywords -DONE: A way to check the type of a variable (oftype keyword) +DONE: A way to check the type of a variable (typeOf keyword) DONE: slice and dot notation around the builtin _index and _dot functions diff --git a/docs/spec.md b/docs/spec.md index 82a116e..a4f156c 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -45,12 +45,12 @@ The following list of keywords cannot be used as names, due to their significanc * int * null * of -* oftype * print * return * string * true * type +* typeof * var * while diff --git a/scripts/small.toy b/scripts/small.toy index b5921ba..89062fc 100644 --- a/scripts/small.toy +++ b/scripts/small.toy @@ -11,5 +11,5 @@ t = astype [float]; //redefnition var b: u; -print oftype a; //<[]> -print oftype b; //<[]> \ No newline at end of file +print typeof a; //<[]> +print typeof b; //<[]> \ No newline at end of file diff --git a/scripts/test/imports-and-exports.toy b/scripts/test/imports-and-exports.toy index f759d10..e05bf03 100644 --- a/scripts/test/imports-and-exports.toy +++ b/scripts/test/imports-and-exports.toy @@ -32,7 +32,7 @@ assert func() == 69, "import/export of functions failed"; } -//test that variables retain their types with the oftype keyword +//test that variables retain their types with the typeof keyword { var t: type = int; @@ -42,7 +42,7 @@ { import t; - assert oftype t == type, "type retention failed"; + assert typeof t == type, "type retention failed"; } print "All good"; diff --git a/source/keyword_types.c b/source/keyword_types.c index e047487..cd4d1a7 100644 --- a/source/keyword_types.c +++ b/source/keyword_types.c @@ -34,7 +34,7 @@ KeywordType keywordTypes[] = { {TOKEN_RETURN, "return"}, {TOKEN_TYPE, "type"}, {TOKEN_ASTYPE, "astype"}, - {TOKEN_OFTYPE, "oftype"}, + {TOKEN_TYPEOF, "typeof"}, {TOKEN_VAR, "var"}, {TOKEN_WHILE, "while"}, diff --git a/source/parser.c b/source/parser.c index 225d8d8..2262dd4 100644 --- a/source/parser.c +++ b/source/parser.c @@ -136,7 +136,7 @@ static Opcode asType(Parser* parser, Node** nodeHandle) { return OP_EOF; } -static Opcode ofType(Parser* parser, Node** nodeHandle) { +static Opcode typeOf(Parser* parser, Node** nodeHandle) { Node* rhs = NULL; parsePrecedence(parser, &rhs, PREC_TERNARY); emitNodeUnary(nodeHandle, OP_TYPE_OF, rhs); @@ -821,7 +821,7 @@ ParseRule parseRules[] = { //must match the token types {NULL, NULL, PREC_NONE},// TOKEN_RETURN, {atomic, NULL, PREC_NONE},// TOKEN_TYPE, {asType, NULL, PREC_PRIMARY},// TOKEN_ASTYPE, - {ofType, NULL, PREC_CALL},// TOKEN_OFTYPE, + {typeOf, NULL, PREC_CALL},// TOKEN_TYPEOF, {NULL, NULL, PREC_NONE},// TOKEN_VAR, {NULL, NULL, PREC_NONE},// TOKEN_WHILE, diff --git a/source/token_types.h b/source/token_types.h index 2249a55..24c5090 100644 --- a/source/token_types.h +++ b/source/token_types.h @@ -32,7 +32,7 @@ typedef enum TokenType { TOKEN_RETURN, TOKEN_TYPE, TOKEN_ASTYPE, - TOKEN_OFTYPE, + TOKEN_TYPEOF, TOKEN_VAR, TOKEN_WHILE,