Hi,

I'm writing a DLang parser and got confused of this.
What is a good way to distinguish lambda functions and structure initialization blocks.

Both of them are {} blocks.

I'm thinking of something like this:

1. checking inside (on the first hierarchy level inside {})
   ,   => must be a struct initializer
   ;   => must be a lambda
   no , and no ;  => check it from the outside


2. checking outside (on the same hierarchy level as the {}):
   () before {}   ->  lambda
   => before {}   ->  lambda
   () after {}    ->  lambda  //this check feels wrong to me.
   otherwise      ->  struct initializer

But I think it's logically loose.
I have only the syntax tree, I have no access to semantics. I don't know if an identifier is a struct for example.

Is there a better way to do this?

Thank You in advance!

Reply via email to