[LLVMdev] LLVM grammar for ANTLR
Samuel Crow
samuraileumas at yahoo.com
Tue Jan 25 10:19:35 PST 2011
Hello Surinder,
I understand now what you are trying to do. Unfortunately what I was going to
suggest takes things in exactly the opposite direction of what you need.
I have a parsing expression grammar-based parser generator that generates LLVM
bitcode by using the LLVM assembly parser to generate all rules. I was
considering adding an LLVM assembly parser to it to simplify the parsing of
actions. This would be exactly the opposite of what you need since you
essentially need an LLVM backend to generate code in your nondeterministic
language.
Also, I'm unfamiliar with ANTLR since the unusual platforms I support oftentimes
don't have a Java VM to run ANTLR on. The PEG parser generator I use generates
C rather than Haskell. I'm not interested in making another parser generator to
generate Haskell parsing code. If you need a parser in C I might be able to get
something set up for you using PEG.
I'm sorry I wasn't able to help you more,
--Sam
----- Original Message ----
> From: Surinder <surifilms at gmail.com>
> To: Samuel Crow <samuraileumas at yahoo.com>
> Cc: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu>
> Sent: Tue, January 25, 2011 12:00:42 AM
> Subject: Re: [LLVMdev] LLVM grammar for ANTLR
>
> Hi Sam,
>
> Thanks for your reply.
>
> I am implementing my research
> (http://www.it.usyd.edu.au/~suri/Detecting%20Buffer%20Over.pdf), a
> translation of LLVM to a simple non-deterministic language to detect
> buffer overflows. It involves
>
> (1) printing a control flow graph of basic blocks of a function (easily done)
> (2) translating each llvm statement to a corresponding data flow
> language (needs ASTs to traverse)
> (3) translating control flow graph to a regular expression
> (4) translating data flow language statements to non-deterministic language
> (5) translating non-deterministic language to CLP (Prolog like solver)
> (6) finding a Prolog solution as proof of or absence of buffer overflows
>
> I have implemented Step (1) & (2) above by writing a transform pass.
> Remaining steps (3) to (6) have been written in Haskell. Step (2),
> translation from llvm to dfl language has been done by implementing an
> AnnotationWriter and it emits dfl format of each llvm statement. This
> is rather crude and causes crashes between llvm/haskell interface. I
> am considering to dump llvm as it is into Haskell program and then use
> a parser tool to do llvm statement translation to dfl. The
> translation is a set of simple rewrite tools.
>
> You can get further details from my website
> http://it.usyd.edu.au/~suri or you can ask me.
>
> Thank you for your interest.
>
> Surinder
>
> On Tue, Jan 25, 2011 at 3:22 AM, Samuel Crow <samuraileumas at yahoo.com>
wrote:
> > Hello Surinder,
> >
> > The existing hand-written parser is callable from almost anywhere so the
>only
> > reason you'd need to have a parser for it would be to extend it. Originally
>it
> > was written using Flex and Bison but Chris Lattner rewrote it from scratch
>to
> > catch more errors at the parsing stage.
> >
> > The only feature I've found to be missing from the existing LLVM-AS utility
>was
> > an include function with automatic unique detection. This would allow the
>use
> > of headers instead of having to manually copy and paste them into the
>source.
> > What were you planning on doing with your LLVM parser, if I may ask?
> >
> > --Sam
> >
> >
> > ----- Original Message ----
> >> From: Surinder <surifilms at gmail.com>
> >> To: llvmdev at cs.uiuc.edu
> >> Sent: Sun, January 23, 2011 10:35:38 PM
> >> Subject: [LLVMdev] LLVM grammar for ANTLR
> >>
> >> Has anyone written a grammar for LLVM for ANTLR. I mean an ANTLR
> >> grammar that parses LLVM instructions. Is an LLVM grammar available
> >> for any other parsing tool?
> >>
> >> Surinder
> >
> >
> >
> >
>
More information about the llvm-dev
mailing list