Allow for attribute groups in function definitions.

master
Rohan Jacob-Rao 9 years ago
parent 8fbe358b34
commit 66aecca31f

@ -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 }

@ -132,6 +132,8 @@
%token <int> NUMBERED_LOCAL
%token <string> IDENT
%token <int> 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 }

Loading…
Cancel
Save