aboutsummaryrefslogtreecommitdiff
path: root/compilador/ast/decl.py
blob: 1c1216221940a0b4536ef4002ef7ba74a7801840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import Optional

from type import Type
from ident import Ident
from expr import Expr

# A global declaration.
#
#     entero a = 0;
@dataclass
class DeclGlobal:
    ident: Ident
    _type: Type
    init: Optional[Expr]

# A function declaration.
#
#     vacio main() { ... }
@dataclass
class DeclFunc:
    ident: Ident
    prototype: Type
    body: Optional[Expr]

# A Javañol declaration
Decl = DeclGlobal | DeclFunc