diff --git a/lib/lexer.mll b/lib/lexer.mll index 2477985..6f7eab5 100644 --- a/lib/lexer.mll +++ b/lib/lexer.mll @@ -104,12 +104,6 @@ let white = [' ' '\t']+ let newline = '\r' | '\n' | "\r\n" let backslash_escapes = ['\\' '\'' '"' 'n' 't' 'b' 'r' ' '] -let hashnum = '#' int -let hashnumbrack = hashnum '[' -let sized_id = lowercase_alpha+ hashnum -let hashquest = '#' '?' -let unknown_sized_id = lowercase_alpha+ hashquest - let plus_ops = '+' | '-' let mult_ops = '*' | '/' let cmp_ops = '<' | '>' @@ -182,10 +176,8 @@ rule read = | '}' { Rcurly } | '[' { Lbrack } | ']' { Rbrack } - | "#[" { Hashtag_brack } - | hashnumbrack { Hashnum_brack (int_of_hashnum (Lexing.lexeme lexbuf)) } - | sized_id { Sized_ident (Lexing.lexeme lexbuf) } - | unknown_sized_id { Unknown_sized_ident (Lexing.lexeme lexbuf) } + | "#?" { Hash_quest } + | '#' { Hash } | "->" { Right_arrow } | "--" { line_comment lexbuf } | eq_op { Eq_op (Lexing.lexeme lexbuf) } diff --git a/lib/parser.mly b/lib/parser.mly index 571ee16..a26cbbc 100644 --- a/lib/parser.mly +++ b/lib/parser.mly @@ -39,8 +39,8 @@ %token String_lit %token True %token False -%token Hashtag_brack -%token Hashnum_brack +%token Hash +%token Hash_quest %token Semicolon %token Right_arrow %token With @@ -56,8 +56,6 @@ %token Builtin_id %token Val %token Rec -%token Sized_ident -%token Unknown_sized_ident /* ops */ @@ -84,7 +82,7 @@ %left Lcurly %left Lbrack %left Lpar -%left Path Hashtag_brack +%left Path Hash %start prog @@ -373,7 +371,7 @@ special_builtins: {App ($loc, Var ($loc, "__array_get"), [{apass = Dnorm; aloc = $loc(e); aexpr = e}; {apass = Dnorm; aloc = $loc(i); aexpr = i}])} - | e = expr; Hashtag_brack; i = expr; Rbrack + | e = expr; Hash; Lbrack; i = expr; Rbrack {App ($loc, Var ($loc, "__fixed_array_get"), [{apass = Dnorm; aloc = $loc(e); aexpr = e}; {apass = Dnorm; aloc = $loc(i); aexpr = i}])} @@ -420,8 +418,8 @@ separated_trailing_list(sep, item, terminator): | lst = separated_nonempty_trailing_list(sep, item, terminator) { lst } fixed_array_lit: - | Hashtag_brack; items = separated_nonempty_trailing_list(Comma, expr, Rbrack) { Fixed_array items } - | num = Hashnum_brack; item = expr; Rbrack { Fixed_array_num (num, item) } + | Hash; Lbrack; items = separated_nonempty_trailing_list(Comma, expr, Rbrack) { Fixed_array items } + | Hash; num = Int; Lbrack; item = expr; Rbrack { Fixed_array_num (num, item) } call_arg: | aexpr = expr { {apass = Dnorm; aexpr; aloc = $loc} } @@ -468,8 +466,8 @@ parens(x): type_spec: | id = Ident { Ty_id id } | id = poly_id { Ty_var id } - | id = Sized_ident { Ty_id id } - | id = Unknown_sized_ident { Ty_id id } + | id = Ident; Hash; i = Int { Ty_id (id ^ "#" ^ string_of_int i) } + | id = Ident; Hash_quest { Ty_id (id ^ "#?") } | path = type_path { Ty_use_id ($loc, path) } | head = type_spec; Lbrack; tail = separated_nonempty_list(Comma, type_spec); Rbrack { Ty_applied (head :: tail) } diff --git a/lib/syntax_errors.messages b/lib/syntax_errors.messages index 49ec602..5ab9626 100644 --- a/lib/syntax_errors.messages +++ b/lib/syntax_errors.messages @@ -62,7 +62,15 @@ prog: External Ident Colon Lpar Rpar Right_arrow With -prog: External Ident Colon Lpar Rpar Right_arrow Ident With +prog: External Ident Colon Ident With + + + +prog: External Ident Colon Ident Hash With + + + +prog: External Ident Colon Lpar Rpar Right_arrow Quote Ident With @@ -94,7 +102,7 @@ prog: External Ident Colon Lpar Ident Rpar Right_arrow With -prog: External Ident Colon Lpar Ident Rpar Right_arrow Ident With +prog: External Ident Colon Lpar Ident Rpar Right_arrow Quote Ident With @@ -110,7 +118,7 @@ prog: External Ident Colon Lpar Ident Ampersand Rpar Right_arrow With -prog: External Ident Colon Lpar Ident Ampersand Rpar Right_arrow Ident With +prog: External Ident Colon Lpar Ident Ampersand Rpar Right_arrow Quote Ident With @@ -142,7 +150,7 @@ prog: External Ident Colon Lpar Ident Comma Ident Rpar Right_arrow With -prog: External Ident Colon Lpar Ident Comma Ident Rpar Right_arrow Ident With +prog: External Ident Colon Lpar Ident Comma Ident Rpar Right_arrow Quote Ident With @@ -466,11 +474,11 @@ prog: If With -prog: Hashtag_brack With +prog: Hash With -prog: Hashnum_brack With +prog: Hash Lbrack With @@ -650,11 +658,15 @@ prog: False Mult_op False Wildcard -prog: False Hashtag_brack With +prog: False Hash With -prog: False Hashtag_brack False Wildcard +prog: False Hash Lbrack With + + + +prog: False Hash Lbrack False Wildcard @@ -858,15 +870,23 @@ prog: Fun Lpar Rpar Colon False Wildcard -prog: Hashnum_brack False Wildcard +prog: Lbrack False Wildcard + + + +prog: Lbrack False Comma With + + + +prog: Hash Int With -prog: Hashtag_brack False Wildcard +prog: Hash Int Lbrack With -prog: Hashtag_brack False Comma With +prog: Hash Int Lbrack False Wildcard @@ -1062,11 +1082,11 @@ prog: Functor Ident Lpar With -prog: Functor Ident Lpar Ident Colon Ident Rpar With +prog: Functor Ident Lpar Rpar With -prog: Functor Ident Lpar Ident Colon Ident Rpar Lcurly With +prog: Functor Ident Lpar Rpar Lcurly With @@ -1098,7 +1118,7 @@ prog: Ident Semicolon With -prog: Functor Ident Lpar Ident Colon Ident Rpar Lcurly Ident Eof +prog: Functor Ident Lpar Rpar Lcurly Ident Eof diff --git a/test/modules.t/run.t b/test/modules.t/run.t index 72a894d..8c23f30 100644 --- a/test/modules.t/run.t +++ b/test/modules.t/run.t @@ -1087,3 +1087,8 @@ Fix handling of parameterized abstract types Fix external declarations in inner modules $ schmu inner_module_externals.smu + +Make applied functors hidden behind signatures usable. Does this apply to local module too? + $ schmu -m hidden_functor_app.smu + $ schmu use_hidden_functor_app.smu + $ valgrind -q --leak-check=yes --show-reachable=yes ./use_hidden_functor_app