string ancora un po' rustiche

This commit is contained in:
uan
2026-02-05 22:30:50 +01:00
parent 078a300c1f
commit 1581ca4928
3 changed files with 35 additions and 11 deletions

View File

@@ -115,7 +115,7 @@ fn (mut s SymbolTable) is_in_global_scope() bool {
// ------------------------------------------- Expressions
type Expr = VoidExpr | UnaryExpr | BinaryExpr | IntegerLiteral | RealLiteral | BoolLiteral | Variable | TypeExpr | Function | TypeCast | ParenExpr | PrintExpr | FnCall | ClassMember | ClassInstantiation | MemberAccess
type Expr = VoidExpr | UnaryExpr | BinaryExpr | IntegerLiteral | RealLiteral | BoolLiteral | StringLiteral | Variable | TypeExpr | Function | TypeCast | ParenExpr | PrintExpr | FnCall | ClassMember | ClassInstantiation | MemberAccess
struct VoidExpr {}
@@ -142,6 +142,10 @@ struct BoolLiteral {
val bool
}
struct StringLiteral {
val string
}
struct Variable {
name string
}
@@ -295,6 +299,7 @@ fn (mut p Parser) parse_primary() Expr {
.integer {IntegerLiteral{token.text.int()}}
.real {RealLiteral{token.text.f32()}}
.boolean {BoolLiteral{token.text == 'true'}}
.string {StringLiteral{token.text}}
.kw_fn {Function{token.text}}
.identifier {p.parse_ident(token.text)}
.type {p.parse_type(token.text)}
@@ -461,6 +466,7 @@ fn (mut p Parser) get_expr_type(expr Expr) string {
IntegerLiteral {'int'}
RealLiteral {'real'}
BoolLiteral {'bool'}
StringLiteral {'string'}
VoidExpr {'void'}
TypeExpr {expr.name}
BinaryExpr {