Basic type system working

This commit is contained in:
Neemek 2025-03-16 22:46:49 +01:00
parent 3f260e7ffd
commit 84cc845748
Signed by: neemek
GPG key ID: 28360A8951CD0E9B
19 changed files with 900 additions and 131 deletions

View file

@ -53,6 +53,7 @@ const (
TokenComma
TokenDot
TokenColon
TokenAssign
TokenDeclare
@ -153,6 +154,8 @@ func (t TokenType) String() string {
return "close bracket"
case TokenImport:
return "import"
case TokenColon:
return "colon"
}
return "UNDEFINED TOKENTYPE STRING CONVERSION"
@ -234,11 +237,11 @@ func (l *Lexer) NextToken() (Token, error) {
case '.':
return l.makeToken(TokenDot), nil
case ':':
if !l.accept('=') {
return l.makeToken(TokenError), errors.New("malformed token (got ':', expected '=' to follow)")
if l.accept('=') {
return l.makeToken(TokenDeclare), nil
}
return l.makeToken(TokenDeclare), nil
return l.makeToken(TokenColon), nil
case '!':
if l.accept('=') {
return l.makeToken(TokenBangEquals), nil