string ancora un po' rustiche
This commit is contained in:
8
parser.v
8
parser.v
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user