Posts

Showing posts with the label semantics

Compiling Pascal function return value assignment

Image
Clash Royale CLAN TAG #URR8PPP Compiling Pascal function return value assignment I'm writing a toy Pascal compiler in Haskell. I can produce a Type-annotated AST. I've been ignoring function return value assignments: function foo : integer; begin foo := 12 end; How do I handle those, given that the grammar doesn't distinguish between them and any other regular assignment statement? Should the AST be modified to specifically highlight a return value assignment? And how to deal with them in the type checking phase (An environment Symbol table consisting of function signatures and a stack of contexts was enough so far)? I think the type checking question is probably too broad, and the reason for the close vote. I think the AST question would be good if this question included things like the current AST data structure. – Carl 28 mins ago ...