mirror of
https://github.com/github/semantic.git
synced 2025-01-02 20:41:38 +03:00
Simplier for in assignment with updated tree-sitter
This commit is contained in:
parent
7efb8e4db4
commit
5bb90ff93d
2
languages/ruby/vendor/tree-sitter-ruby
vendored
2
languages/ruby/vendor/tree-sitter-ruby
vendored
@ -1 +1 @@
|
|||||||
Subproject commit fc17fcfa9387d1e8cc387c269067be90f9462028
|
Subproject commit 0d42e1f0bd3bb8aa97432c9a17337d69a48e8ab6
|
@ -5,6 +5,6 @@ import Language.Haskell.TH
|
|||||||
import Text.Parser.TreeSitter.Language
|
import Text.Parser.TreeSitter.Language
|
||||||
import Text.Parser.TreeSitter.Ruby
|
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.
|
-- | Statically-known rules corresponding to symbols in the grammar.
|
||||||
mkSymbolDatatype (mkName "Grammar") tree_sitter_ruby
|
mkSymbolDatatype (mkName "Grammar") tree_sitter_ruby
|
||||||
|
@ -19,7 +19,6 @@ import Data.Union
|
|||||||
import GHC.Stack
|
import GHC.Stack
|
||||||
import Language.Ruby.Grammar as Grammar
|
import Language.Ruby.Grammar as Grammar
|
||||||
import Prologue hiding (for, get, Location, state, unless)
|
import Prologue hiding (for, get, Location, state, unless)
|
||||||
import Prelude (reverse)
|
|
||||||
import qualified Term
|
import qualified Term
|
||||||
|
|
||||||
-- | The type of Ruby syntax.
|
-- | The type of Ruby syntax.
|
||||||
@ -271,16 +270,9 @@ until' =
|
|||||||
makeTerm <$> symbol Until <*> children (Statement.While <$> invert expression <*> expressions)
|
makeTerm <$> symbol Until <*> children (Statement.While <$> invert expression <*> expressions)
|
||||||
<|> makeTerm <$> symbol UntilModifier <*> children (flip Statement.While <$> expression <*> invert expression)
|
<|> 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 :: Assignment
|
||||||
for = makeTerm <$> symbol For <*> children (forStatement <*> expressions)
|
for = makeTerm <$> symbol For <*> children (Statement.ForEach <$> expressions <*> inClause <*> expressions)
|
||||||
where
|
where inClause = symbol In *> children (expression)
|
||||||
forStatement = (reverse <$> (symbol In *> children (many expression))) >>= \ (x:rest) ->
|
|
||||||
Statement.ForEach <$> (flip makeTerm (reverse rest) <$> location) <*> (pure x)
|
|
||||||
|
|
||||||
case' :: Assignment
|
case' :: Assignment
|
||||||
case' = makeTerm <$> symbol Case <*> children (Statement.Match <$> (expression <|> emptyTerm) <*> whens)
|
case' = makeTerm <$> symbol Case <*> children (Statement.Match <$> (expression <|> emptyTerm) <*> whens)
|
||||||
|
@ -52,7 +52,6 @@ parseBlob renderer blob@Blob{..} = case (renderer, blobLanguage) of
|
|||||||
(JSONTermRenderer, _) -> parse syntaxParser blob >>= decorate identifierAlgebra >>= render (renderJSONTerm blob)
|
(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.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.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, Just Language.JSON) -> parse jsonParser blob >>= decorate constructorLabel >>= render renderSExpressionTerm . fmap keepConstructorLabel
|
||||||
(SExpressionTermRenderer, _) -> parse syntaxParser blob >>= render renderSExpressionTerm . fmap keepCategory
|
(SExpressionTermRenderer, _) -> parse syntaxParser blob >>= render renderSExpressionTerm . fmap keepCategory
|
||||||
(IdentityTermRenderer, Just Language.Markdown) -> pure Nothing
|
(IdentityTermRenderer, Just Language.Markdown) -> pure Nothing
|
||||||
|
Loading…
Reference in New Issue
Block a user