Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions compiler/src/parsing/parser.messages
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,32 @@ program: EXPORT TYPEID AS WHILE
## The known suffix of the stack is as follows:
## AS
##
program: LET NUMBER_INT AS WHILE
##
## Ends in an error in state: 367.
##
## pattern -> pattern AS . id_str [ WHEN THICKARROW RPAREN RBRACK RBRACE PIPE EQUAL EOL COMMA COLON AS ]
## pattern -> pattern AS . eols id_str [ WHEN THICKARROW RPAREN RBRACK RBRACE PIPE EQUAL EOL COMMA COLON AS ]
##
## The known suffix of the stack is as follows:
## pattern AS
##
program: LET NUMBER_INT AS EOL WHILE
##
## Ends in an error in state: 369.
##
## pattern -> pattern AS eols . id_str [ WHEN THICKARROW RPAREN RBRACK RBRACE PIPE EQUAL EOL COMMA COLON AS ]
##
## The known suffix of the stack is as follows:
## pattern AS eols
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
##

Expected an identifier to use as an alias.

Expand Down
4 changes: 3 additions & 1 deletion compiler/src/parsing/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module Grain_parsing = struct end

%nonassoc _below_infix

%left AS
%left PIPEPIPE
%left AMPAMP
%left PIPE
Expand Down Expand Up @@ -250,7 +251,8 @@ pattern:
| type_id { Pat.construct ~loc:(to_loc $loc) $1 [] }
| lbrack rbrack { Pat.list ~loc:(to_loc $loc) [] }
| lbrack lseparated_nonempty_list(comma, list_item_pat) comma? rbrack { Pat.list ~loc:(to_loc $loc) $2 }
| pattern pipe_op opt_eols pattern { Pat.or_ ~loc:(to_loc $loc) $1 $4 }
| pattern pipe_op opt_eols pattern %prec PIPE { Pat.or_ ~loc:(to_loc $loc) $1 $4 }
| pattern AS opt_eols id_str { Pat.alias ~loc:(to_loc $loc) $1 $4 }

list_item_pat:
| ELLIPSIS pattern { ListSpread ($2, to_loc $loc) }
Expand Down
Loading