1
1
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:
Timothy Clem 2017-08-02 10:24:57 -07:00
parent 7efb8e4db4
commit 5bb90ff93d
4 changed files with 4 additions and 13 deletions

@ -1 +1 @@
Subproject commit fc17fcfa9387d1e8cc387c269067be90f9462028
Subproject commit 0d42e1f0bd3bb8aa97432c9a17337d69a48e8ab6

View File

@ -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

View File

@ -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)

View File

@ -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