Skip to content

Commit

Permalink
Merge pull request #123 from nekketsuuu/nekketsuuu-fixed-length-list-…
Browse files Browse the repository at this point in the history
…pattern

Support fixed-length list pattern
  • Loading branch information
gfngfn committed Nov 5, 2018
2 parents ccbe682 + 68c9966 commit d3b03e1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/frontend/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -1006,12 +1006,18 @@ patbot: /* -> Types_.untyped_pattern_tree */
| LPAREN patas RPAREN { make_standard (Tok $1) (Tok $3) (extract_main $2) }
| LPAREN patas COMMA pattuple RPAREN { make_standard (Tok $1) (Tok $5) (UTPTupleCons($2, $4)) }
| BLIST ELIST { make_standard (Tok $1) (Tok $2) UTPEndOfList }
| BLIST patlist ELIST { make_standard (Tok $1) (Tok $3) (extract_main $2) }
| tok=LITERAL { let (rng, str, pre, post) = tok in make_standard (Tok rng) (Tok rng) (UTPStringConstant(rng, omit_spaces pre post str)) }
;
pattuple: /* -> untyped_pattern_tree */
| patas { make_standard (Ranged $1) (Ranged $1) (UTPTupleCons($1, (Range.dummy "end-of-tuple-pattern", UTPEndOfTuple))) }
| patas COMMA pattuple { make_standard (Ranged $1) (Ranged $3) (UTPTupleCons($1, $3)) }
;
patlist: /* -> untyped_pattern_tree */
| patas { make_standard (Ranged $1) (Ranged $1) (UTPListCons($1, (Range.dummy "end-of-list-pattern", UTPEndOfList))) }
| patas LISTPUNCT { make_standard (Ranged $1) (Tok $2) (UTPListCons($1, (Range.dummy "end-of-list-pattern", UTPEndOfList))) }
| patas LISTPUNCT patlist { make_standard (Ranged $1) (Ranged $3) (UTPListCons($1, $3)) }
;
binop:
| UNOP_EXCLAM
| BINOP_TIMES
Expand Down

0 comments on commit d3b03e1

Please sign in to comment.