diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-04 18:58:28 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-04 21:05:18 -0800 |
| commit | eaa183b7dfc841df75d42ace7a90ada1e40ff282 (patch) | |
| tree | 1d627b8088d5996a7bbf7c0a7439360e31de3dc3 /Parser.sml | |
| parent | c48a992a6ed6ebd79c344b37364a680ddd948dea (diff) | |
| download | sml-eaa183b7dfc841df75d42ace7a90ada1e40ff282.tar.zst | |
Diffstat (limited to 'Parser.sml')
| -rw-r--r-- | Parser.sml | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -28,8 +28,18 @@ struct , "signature", "struct", "structure", "where", ":>" ] - val emptyInfixOperators : infixTable = - Vector.tabulate (10, fn _ => ([], [])) + val defaultInfixOperators : infixTable = Vector.fromList + [ ([], []) + , ([], []) + , ([], []) + , ([], []) + , ([], []) + , ([], ["::"]) + , ([], []) + , ([], []) + , ([], []) + , ([], []) + ] fun printSourceLoc ({file, row, column} : sourceLoc) : string = file ^ ":" ^ Int.toString row ^ "." ^ Int.toString column @@ -69,7 +79,7 @@ struct fun newState (fileName : string) (fileStream : TextIO.instream) : state = { stream = TextIO.getInstream fileStream, loc = newLoc fileName, - userState = {infixTable = emptyInfixOperators} + userState = {infixTable = defaultInfixOperators} } fun updateUserState (f : userState -> userState) : userState parser = @@ -414,6 +424,10 @@ struct val rec atpat : Syntax.pat parser = fn st => (Syntax.PWild <$ reserved "_" <|> Syntax.PInt <$> integer + <|> (symbol "[" >> + bind (sepBy pat (symbol ",")) (fn pats => + symbol "]" >> + const (Syntax.PList pats))) <|> bind (between (symbol "(") (symbol ")") (sepBy pat (symbol ","))) (fn pats => const (case pats of @@ -476,6 +490,10 @@ struct bind expr (fn e => reserved "end" >> const (Syntax.ELet (List.mapPartial (fn x => x) decs, e))))) + <|> (symbol "[" >> + bind (sepBy expr (symbol ",")) (fn exprs => + symbol "]" >> + const (Syntax.EList exprs))) <|> (symbol "(" >> bind (sepBy expr (symbol ",")) (fn exprs => symbol ")" >> |
