-
Notifications
You must be signed in to change notification settings - Fork 459
Bump the parsers #95
Bump the parsers #95
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, there are still some tagging test failures which @patrickt is giving me a hand with but this is otherwise ready for review.
Fixed! Ready for review.
| block = symbol Block *> children (makeTerm'' <$> location <*> manyTerm expression) | ||
|
|
||
| block' :: Assignment Term | ||
| block' = symbol Block *> children (makeTerm <$> location <*> manyTerm expression) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defined these to incur as few changes to the fixtures as possibly; basically I only changed the fixtures where the assignments themselves were outright wrong.
| withItem = symbol WithItem *> children (flip Statement.Let <$> term expression <*> term (expression <|> emptyTerm)) | ||
| <|> flip Statement.Let <$> term expression <*> emptyTerm | ||
| make (val, name) = makeTerm1 . Statement.Let name val | ||
| withItem = symbol WithItem *> children ((,) <$> term expression <*> term (expression <|> emptyTerm)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had been incorrectly building a sequence of separate Lets instead of a right-nested chain of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
children (flip (foldr make) — that's the Good Shit. that's the Shit I Like. Hell yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes parsing is Good, Actually.
| tryStatement :: Assignment Term | ||
| tryStatement = makeTerm <$> symbol TryStatement <*> children (Statement.Try <$> term expression <*> manyTerm (expression <|> elseClause)) | ||
| where elseClause = makeTerm <$> symbol ElseClause <*> children (Statement.Else <$> emptyTerm <*> expressions) | ||
| tryStatement = makeTerm <$> symbol TryStatement <*> children (Statement.Try <$> term block <*> manyTerm (expression <|> elseClause)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try statements with multiple statements in the body were shoving all but the first into the list of catches. Whoops!
| , (inject .) . Expression.Minus <$ (symbol AnonMinus <|> symbol AnonMinus' <|> symbol AnonMinus'') | ||
| , (inject .) . Expression.Times <$ (symbol AnonStar <|> symbol AnonStar') | ||
| , (inject .) . Expression.Power <$ symbol AnonStarStar | ||
| , (inject .) . Expression.DividedBy <$ (symbol AnonSlash <|> symbol AnonSlash' <|> symbol AnonSlash'') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty trivial; just removing some symbols that don’t exist any more.
| result <- if compatible then | ||
| liftIO $ runParser parser blobSource | ||
| else | ||
| Failed <$ trace "tree-sitter: incompatible versions" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we should do something smarter than this (because we still report this as a parser timeout exception), but for now at least it’s distinguishable by the trace.
| actual `shouldBe` expected | ||
| actual <- fmap verbatim <$> parseFilePath session path | ||
| case actual of | ||
| Left err -> throw err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lets us see the actual exception instead of just ExitFailure or w/e.
| {+(Catch | ||
| {+(Identifier)+} | ||
| {+(Statements)+})+} | ||
| {-(Identifier)-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you doing here (Identifier)? You belong in the body!
| {-(Assignment | ||
| {-(Identifier)-} | ||
| {-(Boolean)-})-})-})-})) | ||
| {+(Statements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just un-nested a single layer of [].
| , Language.JSON.Assignment | ||
| , Language.JSON.PrettyPrint | ||
| , Language.MiniRuby.Assignment | ||
| , Language.MiniPython.Assignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were pretty much just dead weight. 🔥 with much 🔥ing.
patrickt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bravo, @robrix. Bravo.
| withItem = symbol WithItem *> children (flip Statement.Let <$> term expression <*> term (expression <|> emptyTerm)) | ||
| <|> flip Statement.Let <$> term expression <*> emptyTerm | ||
| make (val, name) = makeTerm1 . Statement.Let name val | ||
| withItem = symbol WithItem *> children ((,) <$> term expression <*> term (expression <|> emptyTerm)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
children (flip (foldr make) — that's the Good Shit. that's the Shit I Like. Hell yeah.
This PR bumps the parsers to
master, except fortree-sitter-python, which is on thenode-fieldsbranch, andtree-sitter-typescriptwhich is reset back to what we had it at before tree-sitter/haskell-tree-sitter#86 accidentally changed it. That means we’re now using a recenthaskell-tree-sitterand can work at migrating it & the language packages to hackage!