[LLVMdev] LLVM grammar for ANTLR
Peter Housel
housel at acm.org
Mon Jan 24 12:25:09 PST 2011
On Mon, 2011-01-24 at 15:35 +1100, Surinder wrote:
> 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?
http://www.opendylan.org/cgi-bin/viewvc.cgi/trunk/fundev/sources/lib/llvm/llvm-asm-parser.dylgram
is a grammar for LLVM assembly language written for a YACC-like LALR(1)
parser generator. (The actual grammar rules start at the "define parser
llvm-parser" line and continue to the end of the file.) This was
constructed by starting from the original YACC-based parser for llvm-as
(using a script that extracted raw grammar rules from the output of
bison -v), and then augmenting it to disambiguate several shift/reduce
conflicts and to handle changes to LLVM assembly language after the
lib/AsmParser parser was re-implemented as a recursive-descent parser.
Note that as usual with LR grammars, it contains a fair amount of
left-recursion and would not be directly suitable for ANTLR, which
implements LL(k).
-Peter-
More information about the llvm-dev
mailing list