Re: Parsing user-defined types

EML <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
I've just found the problem described on Wikipedia 
(https://en.wikipedia.org/wiki/The_lexer_hack), but not much practical 
information on actually handling it.

On 08/05/2019 18:48, EML wrote:
> 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?
> 
> _______________________________________________
> [email protected] https://lists.gnu.org/mailman/listinfo/help-bison


_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.