diff --git a/languages/ruby/vendor/tree-sitter-ruby b/languages/ruby/vendor/tree-sitter-ruby index fc17fcfa9..0d42e1f0b 160000 --- a/languages/ruby/vendor/tree-sitter-ruby +++ b/languages/ruby/vendor/tree-sitter-ruby @@ -1 +1 @@ -Subproject commit fc17fcfa9387d1e8cc387c269067be90f9462028 +Subproject commit 0d42e1f0bd3bb8aa97432c9a17337d69a48e8ab6 diff --git a/src/Language/Ruby/Grammar.hs b/src/Language/Ruby/Grammar.hs index 81da956c0..fa7671539 100644 --- a/src/Language/Ruby/Grammar.hs +++ b/src/Language/Ruby/Grammar.hs @@ -5,6 +5,6 @@ import Language.Haskell.TH import Text.Parser.TreeSitter.Language import Text.Parser.TreeSitter.Ruby --- v4 - Bump to get file to change to force template haskell to regenerate. +-- v5 - Bump to get file to change to force template haskell to regenerate. -- | Statically-known rules corresponding to symbols in the grammar. mkSymbolDatatype (mkName "Grammar") tree_sitter_ruby diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index 7eac2d20c..9230152b2 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -19,7 +19,6 @@ import Data.Union import GHC.Stack import Language.Ruby.Grammar as Grammar import Prologue hiding (for, get, Location, state, unless) -import Prelude (reverse) import qualified Term -- | The type of Ruby syntax. @@ -271,16 +270,9 @@ until' = makeTerm <$> symbol Until <*> children (Statement.While <$> invert expression <*> expressions) <|> makeTerm <$> symbol UntilModifier <*> children (flip Statement.While <$> expression <*> invert expression) --- (for --- (in --- (one or more binding expressions) --- (one and only one subject expression)) --- (body - zero or more expressions)) for :: Assignment -for = makeTerm <$> symbol For <*> children (forStatement <*> expressions) - where - forStatement = (reverse <$> (symbol In *> children (many expression))) >>= \ (x:rest) -> - Statement.ForEach <$> (flip makeTerm (reverse rest) <$> location) <*> (pure x) +for = makeTerm <$> symbol For <*> children (Statement.ForEach <$> expressions <*> inClause <*> expressions) + where inClause = symbol In *> children (expression) case' :: Assignment case' = makeTerm <$> symbol Case <*> children (Statement.Match <$> (expression <|> emptyTerm) <*> whens) diff --git a/src/Semantic.hs b/src/Semantic.hs index 69e5fd0c3..98096169b 100644 --- a/src/Semantic.hs +++ b/src/Semantic.hs @@ -52,7 +52,6 @@ parseBlob renderer blob@Blob{..} = case (renderer, blobLanguage) of (JSONTermRenderer, _) -> parse syntaxParser blob >>= decorate identifierAlgebra >>= render (renderJSONTerm blob) (SExpressionTermRenderer, Just Language.Markdown) -> parse markdownParser blob >>= decorate constructorLabel >>= render renderSExpressionTerm . fmap keepConstructorLabel (SExpressionTermRenderer, Just Language.Python) -> parse pythonParser blob >>= decorate constructorLabel >>= render renderSExpressionTerm . fmap keepConstructorLabel - (SExpressionTermRenderer, Just Language.Ruby) -> parse rubyParser blob >>= decorate constructorLabel >>= render renderSExpressionTerm . fmap keepConstructorLabel (SExpressionTermRenderer, Just Language.JSON) -> parse jsonParser blob >>= decorate constructorLabel >>= render renderSExpressionTerm . fmap keepConstructorLabel (SExpressionTermRenderer, _) -> parse syntaxParser blob >>= render renderSExpressionTerm . fmap keepCategory (IdentityTermRenderer, Just Language.Markdown) -> pure Nothing