diff --git a/compiler/frontend.go b/compiler/frontend.go index a656e6d..03323c4 100644 --- a/compiler/frontend.go +++ b/compiler/frontend.go @@ -347,16 +347,16 @@ func newVariable(token Token, offset int) (Variable, int) { vt := parser.previous switch vt.typ { - case TOKEN_DTYPE_BOOL: + case TOKEN_BOOL: newVar.dtype = DATA_BOOL newOffset += SIZE_64b - case TOKEN_DTYPE_INT: + case TOKEN_INT: newVar.dtype = DATA_INT newOffset += SIZE_64b - case TOKEN_DTYPE_PTR: + case TOKEN_PTR: newVar.dtype = DATA_PTR newOffset += SIZE_64b - case TOKEN_DTYPE_CHAR: + case TOKEN_CHAR: newVar.dtype = DATA_CHAR newOffset += SIZE_8b default: @@ -595,19 +595,19 @@ func parseToken(token Token) { } // TYPE CASTING - case TOKEN_DTYPE_BOOL: + case TOKEN_BOOL: code.op = OP_CAST code.value = DATA_BOOL emit(code) - case TOKEN_DTYPE_CHAR: + case TOKEN_CHAR: code.op = OP_CAST code.value = DATA_CHAR emit(code) - case TOKEN_DTYPE_INT: + case TOKEN_INT: code.op = OP_CAST code.value = DATA_INT emit(code) - case TOKEN_DTYPE_PTR: + case TOKEN_PTR: code.op = OP_CAST code.value = DATA_PTR emit(code) @@ -813,13 +813,13 @@ func parseArityInAssembly(token Token, args *Arity) { var newArg Argument switch token.typ { - case TOKEN_DTYPE_BOOL: + case TOKEN_BOOL: newArg.typ = DATA_BOOL - case TOKEN_DTYPE_CHAR: + case TOKEN_CHAR: newArg.typ = DATA_CHAR - case TOKEN_DTYPE_INT: + case TOKEN_INT: newArg.typ = DATA_INT - case TOKEN_DTYPE_PTR: + case TOKEN_PTR: newArg.typ = DATA_PTR default: msg := fmt.Sprintf(MsgParseTypeUnknown, token.value.(string)) @@ -834,22 +834,22 @@ func parseArityInFunction(token Token, function *Function, parsingArguments bool var newArg Argument switch token.typ { - case TOKEN_DTYPE_ANY: + case TOKEN_ANY: if !parser.internal { errorAt(&token, MsgParseArityArgumentAnyOnlyInternal) ExitWithError(CodeParseError) } newArg.typ = DATA_ANY - case TOKEN_DTYPE_BOOL: + case TOKEN_BOOL: newArg.typ = DATA_BOOL - case TOKEN_DTYPE_CHAR: + case TOKEN_CHAR: newArg.typ = DATA_CHAR - case TOKEN_DTYPE_INT: + case TOKEN_INT: newArg.typ = DATA_INT - case TOKEN_DTYPE_PTR: + case TOKEN_PTR: newArg.typ = DATA_PTR - case TOKEN_DTYPE_PARAPOLY: + case TOKEN_PARAPOLY: if !parsingArguments { errorAt(&token, MsgParseArityReturnParapolyNotAllowed) ExitWithError(CodeParseError) diff --git a/compiler/scanner.go b/compiler/scanner.go index 5b868e3..cbddfcd 100644 --- a/compiler/scanner.go +++ b/compiler/scanner.go @@ -17,12 +17,12 @@ const ( TOKEN_CONSTANT_TRUE // Types - TOKEN_DTYPE_ANY - TOKEN_DTYPE_BOOL - TOKEN_DTYPE_CHAR - TOKEN_DTYPE_INT - TOKEN_DTYPE_PARAPOLY - TOKEN_DTYPE_PTR + TOKEN_ANY + TOKEN_BOOL + TOKEN_CHAR + TOKEN_INT + TOKEN_PARAPOLY + TOKEN_PTR // Flow Control TOKEN_CASE @@ -88,18 +88,19 @@ type reserved struct { } var reservedWords = []reserved{ + // DATA TYPES + reserved{typ: TOKEN_ANY, word: "any" }, + reserved{typ: TOKEN_BOOL, word: "bool" }, + reserved{typ: TOKEN_CHAR, word: "char" }, + reserved{typ: TOKEN_INT, word: "int" }, + reserved{typ: TOKEN_PTR, word: "ptr" }, + reserved{typ: TOKEN_DASH_DASH_DASH, word: "---" }, reserved{typ: TOKEN_LET, word: "let" }, reserved{typ: TOKEN_LETSTAR, word: "let*" }, reserved{typ: TOKEN_IN, word: "in" }, reserved{typ: TOKEN_DONE, word: "done" }, - reserved{typ: TOKEN_DTYPE_ANY, word: "any" }, - reserved{typ: TOKEN_DTYPE_BOOL, word: "bool" }, - reserved{typ: TOKEN_DTYPE_CHAR, word: "char" }, - reserved{typ: TOKEN_DTYPE_INT, word: "int" }, - reserved{typ: TOKEN_DTYPE_PTR, word: "ptr" }, - reserved{typ: TOKEN_BANG, word: "!" }, reserved{typ: TOKEN_AT, word: "@" }, reserved{typ: TOKEN_C_BANG, word: "c!" }, @@ -295,7 +296,7 @@ func makeParapolyToken(c byte, line string, index *int) { word += string(c) } - makeToken(TOKEN_DTYPE_PARAPOLY, word) + makeToken(TOKEN_PARAPOLY, word) } func TokenizeFile(f string, s string) []Token {