summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.c20
-rw-r--r--test.toc13
-rw-r--r--tokenizer.c2
-rw-r--r--types.h1
4 files changed, 14 insertions, 22 deletions
diff --git a/parse.c b/parse.c
index 38447d0..f33131e 100644
--- a/parse.c
+++ b/parse.c
@@ -1139,15 +1139,15 @@ static bool parse_expr(Parser *p, Expression *e, Token *end) {
}
}
}
- if (token_is_kw(t->token, KW_COLONCOLON)) {
- tokr_err(t, "The variable(s) in a for loop cannot be constant.");
- return false;
- }
if (!token_is_kw(t->token, KW_COLON)) {
tokr_err(t, "Expected : following identifiers in for statement.");
return false;
}
++t->token;
+ if (token_is_kw(t->token, KW_COLON)) {
+ tokr_err(t, "The variable(s) in a for loop cannot be constant.");
+ return false;
+ }
if (!token_is_kw(t->token, KW_EQ)) {
ea->flags |= EACH_ANNOTATED_TYPE;
if (!parse_type(p, &ea->type))
@@ -1752,9 +1752,12 @@ static bool parse_decl(Parser *p, Declaration *d, DeclEndKind ends_with, U16 fla
}
if (token_is_kw(t->token, KW_COLON)) {
++t->token;
- break;
+ } else {
+
+ tokr_err(t, "Expected ',' to continue listing variables or ':' / '::' to indicate type.");
+ goto ret_false;
}
- if (token_is_kw(t->token, KW_COLONCOLON)) {
+ if (token_is_kw(t->token, KW_COLON)) {
++t->token;
if (token_is_kw(t->token, KW_COLON) && (flags & PARSE_DECL_ALLOW_SEMI_CONST)) {
++t->token;
@@ -1764,8 +1767,7 @@ static bool parse_decl(Parser *p, Declaration *d, DeclEndKind ends_with, U16 fla
}
break;
}
- tokr_err(t, "Expected ',' to continue listing variables or ':' / '::' to indicate type.");
- goto ret_false;
+ break;
}
if (token_is_kw(t->token, KW_SEMICOLON) || token_is_kw(t->token, KW_RPAREN)) {
@@ -1860,7 +1862,7 @@ static bool is_decl(Tokenizer *t) {
if (token->kind != TOKEN_IDENT) return false;
++token;
if (token->kind != TOKEN_KW) return false;
- if (token->kw == KW_COLON || token->kw == KW_COLONCOLON)
+ if (token->kw == KW_COLON)
return true;
if (token->kw != KW_COMMA) return false;
++token;
diff --git a/test.toc b/test.toc
index 55c20e6..c53a160 100644
--- a/test.toc
+++ b/test.toc
@@ -6,16 +6,7 @@ putf ::= fn(x: float) {
#C("printf(\"%f\\n\", (double)x);
");
};
-f ::= fn(x : int) Type {
- if x == 0 { int } else { float }
-};
-
-r ::= fn(n::=, a :f(n)) int {
-n
-};
-
main ::= fn() {
- x :: = 3;
- y : f(x);
- puti(r(y));
+ x : : = 3;
+ puti(x);
}; \ No newline at end of file
diff --git a/tokenizer.c b/tokenizer.c
index 90b37d3..ae17a4d 100644
--- a/tokenizer.c
+++ b/tokenizer.c
@@ -4,7 +4,7 @@
You should have received a copy of the GNU General Public License along with toc. If not, see <https://www.gnu.org/licenses/>.
*/
static const char *keywords[KW_COUNT] =
- {";", "::", ":", ",", "(", ")", "{", "}", "[", "]", "==",
+ {";", ":", ",", "(", ")", "{", "}", "[", "]", "==",
"+=", "-=", "*=", "/=",
"!=", "<=", "<", ">=", ">",
"+", "-", "*", "!", "&", "/", "..", ".",
diff --git a/types.h b/types.h
index 54ffbda..fef7492 100644
--- a/types.h
+++ b/types.h
@@ -205,7 +205,6 @@ typedef enum {
typedef enum {
KW_SEMICOLON,
- KW_COLONCOLON,
KW_COLON,
KW_COMMA,
KW_LPAREN,