unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: Jan Nieuwenhuizen <janneke@gnu.org>
Cc: guile-user@gnu.org
Subject: Re: nyacc 0.73.0 released
Date: Sat, 31 Dec 2016 16:04:24 -0800	[thread overview]
Message-ID: <57B2C5AB-DDE6-4B0E-9D9F-A45C6B34ED51@gmail.com> (raw)
In-Reply-To: <87r34ob2wc.fsf@gnu.org>


> On Dec 31, 2016, at 6:15 AM, Jan Nieuwenhuizen <janneke@gnu.org> wrote:
> 
> Matt Wette writes:
> 
>> I believe C99 parser is complete.  There may be errors, but I think
>> all the elements are there.

> 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"

Jan,

So this is a bug.  And I am not sure how to proceed yet.  The parser was designed to return a AST with code from includes under a subtree.  This allows a file to be processed with respect to code only in that file.  The way it works is to parse the included file as a new parse.  That only works at the top level.  This breaks for files included inside functions etc.  

How are you processing the file?  Do you want to be able to discriminate between a file and the included files, and only if included files are at the decl level (e.g., #include <stdio.h>) but code inside functions gets included as is (i.e., the AST looks as if the code was in the parent file)?

This will take some sort of parser-lexer hook I think.  I want to think about a clean architecture for all the use cases.

Matt




  parent reply	other threads:[~2017-01-01  0:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-26  4:05 nyacc 0.73.0 released Matt Wette
2016-12-26  7:29 ` Jan Nieuwenhuizen
2016-12-26 14:53   ` Matt Wette
2016-12-31 14:15     ` Jan Nieuwenhuizen
2016-12-31 15:57       ` Matt Wette
2016-12-31 16:08         ` Matt Wette
2017-01-01 12:22           ` Jan Nieuwenhuizen
2017-01-01  0:04       ` Matt Wette [this message]
2017-01-01 12:32         ` Jan Nieuwenhuizen
2017-01-07 11:14 ` Jan Nieuwenhuizen
2017-01-07 14:19   ` Matt Wette
2017-01-07 20:02     ` Jan Nieuwenhuizen
2017-01-11  2:33 ` Chaos Eternal
2017-01-11  2:58   ` Matt Wette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57B2C5AB-DDE6-4B0E-9D9F-A45C6B34ED51@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=janneke@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).