[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nyacc 0.73.0 released
From: |
Jan Nieuwenhuizen |
Subject: |
Re: nyacc 0.73.0 released |
Date: |
Sat, 31 Dec 2016 15:15:47 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
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 ":"
or like GCC headers that Nyacc does not parse, like <assert.h>, which is
a bit of a pain.
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"
Greetings,
Jan
[0] https://gitlab.com/janneke/mes/tree/wip-mescc
--
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.nl