From 950b6f4aa45ca9f052eed5199f38bbef8c66fb13 Mon Sep 17 00:00:00 2001 From: Rohan Jacob-Rao Date: Thu, 6 Aug 2015 09:14:16 -0700 Subject: [PATCH] Added dumb parsing of metadata. --- infer/src/llvm/lLexer.mll | 4 ++++ infer/src/llvm/lParser.mly | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/infer/src/llvm/lLexer.mll b/infer/src/llvm/lLexer.mll index ee0cab94c..8e675d03c 100644 --- a/infer/src/llvm/lLexer.mll +++ b/infer/src/llvm/lLexer.mll @@ -162,6 +162,10 @@ rule token = parse | '%' (nonneg_int as i) { NUMBERED_LOCAL (int_of_string i) } | id as str { IDENT str } + | '!' (id as str) { NAMED_METADATA str } + | '!' (nonneg_int as i) { NUMBERED_METADATA (int_of_string i) } + | '!' '{' [^ '\n']* '}' { METADATA_NODE } + (* attribute groups *) | '#' (nonneg_int as i) { ATTRIBUTE_GROUP (int_of_string i) } | attribute_junk { token lexbuf } diff --git a/infer/src/llvm/lParser.mly b/infer/src/llvm/lParser.mly index 08e7aa928..a048f0669 100644 --- a/infer/src/llvm/lParser.mly +++ b/infer/src/llvm/lParser.mly @@ -131,6 +131,10 @@ %token NUMBERED_LOCAL %token IDENT +%token NAMED_METADATA +%token NUMBERED_METADATA +%token METADATA_NODE + %token ATTRIBUTE_GROUP %token EOF @@ -144,7 +148,14 @@ %% prog: - | defs = list(func_def) EOF { Prog defs } + | defs = list(func_def) metadata_def* EOF { Prog defs } + +metadata_def: + | metadata_var EQUALS METADATA? METADATA_NODE { () } + +metadata_var: + | NAMED_METADATA { () } + | NUMBERED_METADATA { () } func_def: | DEFINE ret_tp = ret_typ name = variable LPAREN params =