LangProc / langproc-2021-cw

5 stars 4 forks source link

When to use pointers in the yacc file #25

Closed ptar124 closed 2 years ago

ptar124 commented 2 years ago

In lab 2, pointers are used to make new variables. what other situations are there in the coursework might we need to do the same? image

petraratkai commented 2 years ago

You don't need to use pointers in the parser. You can either return a dynamically allocated variable (so using new), or you need to copy the objects. Copying the objects is just much less efficient, but it should be fine to use either, as long as all your types are correct. (If your AST consists of pointers, then your parser should also return pointers)