Added dumb parsing of metadata.

master
Rohan Jacob-Rao 9 years ago
parent 44dfcf4a4d
commit 950b6f4aa4

@ -162,6 +162,10 @@ 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 }
| '!' (id as str) { NAMED_METADATA str }
| '!' (nonneg_int as i) { NUMBERED_METADATA (int_of_string i) }
| '!' '{' [^ '\n']* '}' { METADATA_NODE }
(* attribute groups *) (* attribute groups *)
| '#' (nonneg_int as i) { ATTRIBUTE_GROUP (int_of_string i) } | '#' (nonneg_int as i) { ATTRIBUTE_GROUP (int_of_string i) }
| attribute_junk { token lexbuf } | attribute_junk { token lexbuf }

@ -131,6 +131,10 @@
%token <int> NUMBERED_LOCAL %token <int> NUMBERED_LOCAL
%token <string> IDENT %token <string> IDENT
%token <string> NAMED_METADATA
%token <int> NUMBERED_METADATA
%token METADATA_NODE
%token <int> ATTRIBUTE_GROUP %token <int> ATTRIBUTE_GROUP
%token EOF %token EOF
@ -144,7 +148,14 @@
%% %%
prog: 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: func_def:
| DEFINE ret_tp = ret_typ name = variable LPAREN params = | DEFINE ret_tp = ret_typ name = variable LPAREN params =

Loading…
Cancel
Save