From 66aecca31f3461452f02c61c866df11fcba7efb9 Mon Sep 17 00:00:00 2001 From: Rohan Jacob-Rao Date: Tue, 4 Aug 2015 17:09:08 -0700 Subject: [PATCH] Allow for attribute groups in function definitions. --- infer/src/llvm/lLexer.mll | 7 +++++++ infer/src/llvm/lParser.mly | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/infer/src/llvm/lLexer.mll b/infer/src/llvm/lLexer.mll index 4ea44ec69..2ad880d0e 100644 --- a/infer/src/llvm/lLexer.mll +++ b/infer/src/llvm/lLexer.mll @@ -29,6 +29,9 @@ let id_special_char = ['-' '$' '.' '_'] let id_char = lower | upper | id_special_char let id = id_char (id_char | digit)* +(* definition of attribute group - not used for now *) +let attribute_junk = "attributes" [^ '\n']* + rule token = parse | space | comment { token lexbuf } | newline { token lexbuf } @@ -158,4 +161,8 @@ rule token = parse | '%' (nonneg_int as i) { NUMBERED_LOCAL (int_of_string i) } | id as str { IDENT str } + (* attribute groups *) + | '#' (nonneg_int as i) { ATTRIBUTE_GROUP (int_of_string i) } + | attribute_junk { token lexbuf } + | eof { EOF } diff --git a/infer/src/llvm/lParser.mly b/infer/src/llvm/lParser.mly index 6362f9446..bb09ac13c 100644 --- a/infer/src/llvm/lParser.mly +++ b/infer/src/llvm/lParser.mly @@ -132,6 +132,8 @@ %token NUMBERED_LOCAL %token IDENT +%token ATTRIBUTE_GROUP + %token EOF %start prog @@ -146,8 +148,11 @@ prog: | defs = list(func_def) EOF { Prog defs } func_def: - | DEFINE ret_tp = ret_typ name = variable LPAREN params = separated_list(COMMA, pair(typ, IDENT)) RPAREN instrs = block { - FuncDef (name, ret_tp, params, instrs) } + | DEFINE ret_tp = ret_typ name = variable LPAREN params = + separated_list(COMMA, pair(typ, IDENT)) RPAREN list(attribute_group) instrs = block { FuncDef (name, ret_tp, params, instrs) } + +attribute_group: + | i = ATTRIBUTE_GROUP { i } ret_typ: | VOID { None }