[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nyacc 0.73.0 released
From: |
Matt Wette |
Subject: |
Re: nyacc 0.73.0 released |
Date: |
Sat, 31 Dec 2016 07:57:01 -0800 |
> On Dec 31, 2016, at 6:15 AM, Jan Nieuwenhuizen <address@hidden> wrote:
>
> Matt Wette writes:
>
>> I believe C99 parser is complete. There may be errors, but I think
>> all the elements are there.
>
> Great! As it turns out, I was using some GNU extensions (anonymous
> unions inside structs.
>
> I have now picked-up my work on Mes's simple C compiler backend, using
> Nyacc. I have already replaced my LALR parser with Nyacc's AST[0].
>
> How far is the Nyacc's C99 preprocessor? I have two problems with it.
>
> It would be very helpful if it would disregard anything inside a false
> conditional directive. It seems I cannot conditionally comment things
> out that Nyacc does not parse, like
>
> --8<---------------cut here---------------start------------->8---
> #if __GNUC__
> void
> _start ()
> {
> puts ("Hello micro-mes!\n");
>
> ///int r = main (0,0);
> int r;
> asm (
> "push $0\n\t"
> "push $0\n\t"
> "call main\n\t"
> "movl %%eax,%0\n\t"
> : "=r" (r)
> : //no inputs "" (&main)
> );
> #endif // GNUC
> --8<---------------cut here---------------end--------------->8---
>
> ==> micro-mes.c:199: parse failed at state 379, on input “:"
I need to document better. There is an argument to handle this. I think this
may accomplish what you want:
(define (my-xdef? name mode) (if (equal? name “__GNUC__”) #f (env? mode ‘code))
(parse-c99 #:xdef? my-xdef? …)
> headers that Nyacc does not parse, like <assert.h>, which is
> a bit of a pain.
(define my-td-dict ‘((“assert.h”)))
(parse-c99 #:td-dict my-td-dict …)
See std-dict in nyacc/lang/c99/body.scm. This is added by default, but should
probably not be.
td-dict is an a-list of include files with typedefs in those files.
>
> Also, it seems like it doesn't like it if an #includ'ed file is meant to
> go inside a function, like (simplified example)
>
> --8<---------------cut here---------------start------------->8---
> // main.i
> r = 3;
> --8<---------------cut here---------------end--------------->8---
>
> --8<---------------cut here---------------start------------->8---
> // main.c
> int
> main ()
> {
> int r;
> #include "main.i"
> return r;
> }
> --8<---------------cut here---------------end--------------->8---
>
>
> ==> ./main.i:2: parse failed at state 43, on input “r"
This seems like a bug to me. I will check it out.