%{ /* Copyright (c) 2016 Continuum Analytics. BSD 2-Clause License */ %} /* keywords */ %token PAD /* "x" */ %token BOOL /* "?" */ %token CHAR /* "c" */ %token SCHAR /* "b" */ %token UCHAR /* "B" */ %token SHORT /* "h" */ %token USHORT /* "H" */ %token INT /* "i" */ %token UINT /* "I" */ %token LONG /* "l" */ %token ULONG /* "L" */ %token LONGLONG /* "q" */ %token ULONGLONG /* "Q" */ %token SSIZE /* "n" */ %token SIZE /* "N" */ %token FLOAT /* "f" */ %token DOUBLE /* "d" */ %token BYTES /* "s" */ %token COMPLEX /* "Z" */ %token STRUCT /* "T" */ /* punctuation */ %token AT /* "@" */ %token EQUAL /* "=" */ %token LT /* "<" */ %token GT /* ">" */ %token BANG /* "!" */ %token COMMA /* "," */ %token LPAREN /* "(" */ %token RPAREN /* ")" */ %token LBRACE /* "{" */ %token RBRACE /* "}" */ /* values */ %token NAME %token INTEGER /* eof */ %token EOF %start input %type input %% input: datatype EOF { } ; modifier_opt: /* empty */ { } | AT { } | EQUAL { } | LT { } | GT { } | BANG { } ; repeat_opt: /* empty */ { } | INTEGER { } padding: /* empty */ { } | PAD padding { } datatype: modifier_opt LPAREN dimensions RPAREN dtype_or_tuple { } | dtype_or_tuple { } ; dimensions: /* empty */ { } | INTEGER { } | INTEGER COMMA dimensions { } ; /* A tuple is of course also a dtype, the naming scheme breaks down here. */ dtype_or_tuple: dtype { } | tuple_type { } ; tuple_type: dtype dtype { } | dtype tuple_type { } ; dtype: modifier_opt scalar_seq padding { } | modifier_opt struct_type padding { } ; struct_type: STRUCT LBRACE struct_field_list RBRACE { } ; struct_field_list: struct_field { } | struct_field struct_field_list { } ; struct_field: datatype NAME padding { } ; scalar_seq: repeat_opt BOOL { } | repeat_opt CHAR { } | repeat_opt SCHAR { } | repeat_opt UCHAR { } | repeat_opt SHORT { } | repeat_opt USHORT { } | repeat_opt INT { } | repeat_opt UINT { } | repeat_opt LONG { } | repeat_opt ULONG { } | repeat_opt LONGLONG { } | repeat_opt ULONGLONG { } | repeat_opt SSIZE { } | repeat_opt SIZE { } | repeat_opt FLOAT { } | repeat_opt DOUBLE { } | repeat_opt BYTES { } | repeat_opt COMPLEX FLOAT { } | repeat_opt COMPLEX DOUBLE { } ;