cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Coccinelle vs Firefox
Date: Mon, 18 Jul 2016 07:11:40 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1607180700380.3156@hadrien> (raw)
In-Reply-To: <46E0A0AB-6D78-485E-8CEA-2F7639BF12AC@mac.com>



On Sun, 17 Jul 2016, Perry Wagle wrote:

> If you took coccinelle and somehow retargeted it to ocaml, which I believe
> it?s implemented in, could you then turn around and use that version to
> automate excising/abstracting the AST out, and maybe automating the addition
> of a new/different AST? ?In principle, I mean. ?In practice, I can think of
> a few possible problems, but bootstrapping it might help.

I guess.  I would imagine that reimplementing the whole thing in a more
generic way would be easier.  But neither is a priority for us.

> This is the sort of transformation I?m looking to do, and, in any case, I
> want to do things to ocaml itself (and hence coq).

This person:

Th?ophane Hufschmitt <theophane.hufschmitt@polytechnique.org>

worked on something like Coccinelle for OCaml. It was just a summer
project, but he may have come up with something usable.

> PS. ?John Viega convinced me in 2001 (personal conversation) that trying to
> write your own C++ grammar was a PITA, and mostly futile to get perfect.

The nice part of Coccinele is that we have no need for the grammar to be
perfect.  Our goal is to convert the source code to an AST, not to be sure
that the source code is correctly formed.

> ?Since then, I?ve had the stance that using the compiler itself to do the
> parse was the way to go, but found that GCC was purposely designed not to
> allow you to do this. ?The then new LLVM seemed the way to go, and now its
> finally matured. ?What?s your take on using the compiler?s AST?

If you use someone else's AST, then you have to live with the information
that they thought was useful.  Coccinelle needs information about the
whitespace and commas around each token so that it is able to perform
transformation, ie rebuild the code exactly as it was outside of the
transformed parts.  Coccinelle also has the goal of parsing individual
source code files without expanding macros, to limit the code size, to
avoid the need to interpret make files, and so that the user can express
transformations in terms of the code that he sees, ie macro uses.  I don't
know if LLVM would support that.

>?I did see a
> paper recently fly by about using approximation methods instead of full
> parsing with a compiler, but I can?t find it in my notes right now. ?Anyone
> recognize what I?m talking about?

The concept of island grammars comes to mind:

https://en.wikipedia.org/wiki/Island_grammar

There was also recently a paper from the group of Dawson Engler about
doing program analysis for lots of languages using approximate parsing.
I'm not sure if either is connected to a compiler though.

Fraser Brown, Andres N?tzli, Dawson R. Engler:
How to Build Static Checking Systems Using Orders of Magnitude Less Code.
ASPLOS 2016: 143-157

julia

  parent reply	other threads:[~2016-07-18  5:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17  2:12 [Cocci] Coccinelle vs Firefox Perry Wagle
2016-07-17  5:47 ` Julia Lawall
2016-07-17 22:44   ` Perry Wagle
2016-07-18  2:05     ` Perry Wagle
2016-07-18  5:11     ` Julia Lawall [this message]
2016-07-18 11:34       ` Perry Wagle
2016-07-18 15:39         ` Julia Lawall
2016-07-18 23:17           ` Perry Wagle
2016-07-18 15:57         ` SF Markus Elfring
2016-07-18 23:26           ` Perry Wagle
2016-07-18 16:19         ` [Cocci] Object-orientation with SmPL? SF Markus Elfring
2016-07-18 23:31           ` Perry Wagle
2016-07-17  6:48 ` [Cocci] Support for more programming languages? SF Markus Elfring
2016-07-18  0:43   ` Perry Wagle
2016-07-18 15:20     ` SF Markus Elfring
2016-07-18 23:39       ` Perry Wagle
2016-07-19  7:57         ` SF Markus Elfring
2016-07-17  7:14 ` [Cocci] Transformations for Firefox source files SF Markus Elfring
2016-07-18  0:50   ` Perry Wagle
2016-07-18 15:27     ` SF Markus Elfring

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

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

  git send-email \
    --in-reply-to=alpine.DEB.2.10.1607180700380.3156@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    /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 NNTP newsgroup(s).