Skip to content
Snippets Groups Projects
Commit e3602c80 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Allow function definition for compound types

For instance, following constructions are syntactically correct
``
let f : R*R -> R*R, (x,y) -> (y, x);
let g : R*R -> R,   (x,y) -> x+y;
let h : R   -> R*R,  x    -> (x, x*x);
``
Semantic remains to be defined.

Also,
``
let f : R*R -> R*R, x -> x;
``
is a correct construction, but one will require `x[0]` and `x[1]` to be defined
to make this syntax useful.
parent 5d3e5b3d
No related branches found
No related tags found
1 merge request!37Feature/language
...@@ -209,6 +209,8 @@ using selector = ...@@ -209,6 +209,8 @@ using selector =
real, real,
literal, literal,
name, name,
name_list,
expression_list,
B_set, B_set,
N_set, N_set,
Z_set, Z_set,
......
...@@ -206,7 +206,11 @@ struct declaration : if_must< TYPESPECIFIER, NAME, opt< if_must< seq< one< '=' > ...@@ -206,7 +206,11 @@ struct declaration : if_must< TYPESPECIFIER, NAME, opt< if_must< seq< one< '=' >
struct type_expression : list_must< TYPESPECIFIER, one< '*' > >{}; struct type_expression : list_must< TYPESPECIFIER, one< '*' > >{};
struct type_mapping : seq< type_expression, RIGHT_ARROW, type_expression >{}; struct type_mapping : seq< type_expression, RIGHT_ARROW, type_expression >{};
struct function_definition : seq< NAME, RIGHT_ARROW, expression >{};
struct name_list : seq< open_parent, list_must< NAME, COMMA >, close_parent >{};
struct expression_list : seq< open_parent, list_must< expression, COMMA >, close_parent >{};
struct function_definition : seq< sor< name_list, NAME >, RIGHT_ARROW, sor< expression_list, expression > >{};
struct let_declaration : if_must< LET, NAME, COLUMN, type_mapping, COMMA, function_definition >{}; struct let_declaration : if_must< LET, NAME, COLUMN, type_mapping, COMMA, function_definition >{};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment