help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parsing user-defined types


From: EML
Subject: Parsing user-defined types
Date: Wed, 8 May 2019 18:48:31 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

I'm having trouble seeing how to handle user-defined types without lots of feedback from the parser to the lexer. For example, consider a C-like language with a struct declaration:

foo() {
  struct a {...};  // type defn
  struct a b;      // declare object 'b' of user-defined type 'a'
}

this is easy to parse, but if you add a typedef, or go to C++, you can have code that looks like this:

foo() {
  struct a {...};
  a b;
}

With a simple flex/bison setup this is likely to lead to a lot of conflicts. So how do you handle this? Do you just work through the conflicts, if possible, or is this a job for a hand-coded lexer, which can be told about new types at runtime?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]