Parse metadata nodes.

master
Rohan Jacob-Rao 10 years ago
parent ef01c485da
commit f20236fcac

@ -166,10 +166,12 @@ rule token = parse
| '%' (nonneg_int as i) { NUMBERED_LOCAL (int_of_string i) } | '%' (nonneg_int as i) { NUMBERED_LOCAL (int_of_string i) }
| id as str { IDENT str } | id as str { IDENT str }
(* METADATA *)
| "!dbg" { DEBUG_ANNOTATION } | "!dbg" { DEBUG_ANNOTATION }
| '!' (id as str) { NAMED_METADATA str } | '!' (id as str) { NAMED_METADATA str }
| '!' (nonneg_int as i) { NUMBERED_METADATA (int_of_string i) } | '!' (nonneg_int as i) { NUMBERED_METADATA (int_of_string i) }
| '!' '{' [^ '\n']* '}' { METADATA_NODE } | '!' '"' ([^ '"']* as str) '"' { METADATA_STRING str }
| "!{" { METADATA_NODE_BEGIN }
(* attribute groups *) (* attribute groups *)
| '#' (nonneg_int as i) { ATTRIBUTE_GROUP (int_of_string i) } | '#' (nonneg_int as i) { ATTRIBUTE_GROUP (int_of_string i) }

@ -138,7 +138,8 @@
%token DEBUG_ANNOTATION %token DEBUG_ANNOTATION
%token <string> NAMED_METADATA %token <string> NAMED_METADATA
%token <int> NUMBERED_METADATA %token <int> NUMBERED_METADATA
%token METADATA_NODE %token <string> METADATA_STRING
%token METADATA_NODE_BEGIN
%token <int> ATTRIBUTE_GROUP %token <int> ATTRIBUTE_GROUP
@ -169,12 +170,23 @@ target_triple:
| TARGET TRIPLE EQUALS str = CONSTANT_STRING { str } | TARGET TRIPLE EQUALS str = CONSTANT_STRING { str }
metadata_def: metadata_def:
| metadata_var EQUALS METADATA? METADATA_NODE { () } | metadata_var EQUALS metadata_node { () }
metadata_var: metadata_var:
| NAMED_METADATA { () } | NAMED_METADATA { () }
| NUMBERED_METADATA { () } | NUMBERED_METADATA { () }
metadata_node:
| METADATA? METADATA_NODE_BEGIN separated_list(COMMA, metadata_component) RBRACE { () }
metadata_component:
| tp = typ? op = operand { () }
| METADATA? metadata_value { () }
metadata_value:
| metadata_var { () }
| METADATA_STRING { () }
func_def: func_def:
| DEFINE ret_tp = ret_typ name = variable LPAREN | DEFINE ret_tp = ret_typ name = variable LPAREN
params = separated_list(COMMA, pair(typ, IDENT)) RPAREN attribute_group* params = separated_list(COMMA, pair(typ, IDENT)) RPAREN attribute_group*

Loading…
Cancel
Save