mirror of
https://github.com/github/semantic.git
synced 2024-12-27 00:44:57 +03:00
Merge pull request #2118 from github/evaluate-ruby
add eval instances for unspecialized Ruby syntax
This commit is contained in:
commit
c3e5622e06
@ -69,6 +69,9 @@ class Show value => AbstractIntro value where
|
||||
-- TODO: Should these be interned in some table to provide stronger uniqueness guarantees?
|
||||
symbol :: Text -> value
|
||||
|
||||
-- | Construct an abstract regex value.
|
||||
regex :: Text -> value
|
||||
|
||||
-- | Construct an abstract integral value.
|
||||
integer :: Integer -> value
|
||||
|
||||
@ -87,7 +90,6 @@ class Show value => AbstractIntro value where
|
||||
-- | Construct the nil/null datatype.
|
||||
null :: value
|
||||
|
||||
|
||||
-- | A 'Monad' abstracting the evaluation of (and under) binding constructs (functions, methods, etc).
|
||||
--
|
||||
-- This allows us to abstract the choice of whether to evaluate under binders for different value types.
|
||||
|
@ -47,6 +47,7 @@ instance AbstractIntro Abstract where
|
||||
string _ = Abstract
|
||||
float _ = Abstract
|
||||
symbol _ = Abstract
|
||||
regex _ = Abstract
|
||||
rational _ = Abstract
|
||||
hash _ = Abstract
|
||||
kvPair _ _ = Abstract
|
||||
|
@ -32,6 +32,7 @@ data Value address body
|
||||
| Float (Number.Number Scientific)
|
||||
| String Text
|
||||
| Symbol Text
|
||||
| Regex Text
|
||||
| Tuple [address]
|
||||
| Array [address]
|
||||
| Class Name [address] (Bindings address)
|
||||
@ -102,6 +103,7 @@ instance Show address => AbstractIntro (Value address body) where
|
||||
float = Float . Number.Decimal
|
||||
symbol = Symbol
|
||||
rational = Rational . Number.Ratio
|
||||
regex = Regex
|
||||
|
||||
kvPair = KVPair
|
||||
hash = Hash . map (uncurry KVPair)
|
||||
|
@ -25,6 +25,7 @@ data Type
|
||||
| Bool -- ^ Primitive boolean type.
|
||||
| String -- ^ Primitive string type.
|
||||
| Symbol -- ^ Type of unique symbols.
|
||||
| Regex -- ^ Primitive regex type.
|
||||
| Unit -- ^ The unit type.
|
||||
| Float -- ^ Floating-point type.
|
||||
| Rational -- ^ Rational type.
|
||||
@ -153,6 +154,7 @@ occur id = prune >=> \case
|
||||
Bool -> pure False
|
||||
String -> pure False
|
||||
Symbol -> pure False
|
||||
Regex -> pure False
|
||||
Unit -> pure False
|
||||
Float -> pure False
|
||||
Rational -> pure False
|
||||
@ -256,6 +258,7 @@ instance AbstractIntro Type where
|
||||
string _ = String
|
||||
float _ = Float
|
||||
symbol _ = Symbol
|
||||
regex _ = Regex
|
||||
rational _ = Rational
|
||||
hash = Hash
|
||||
kvPair k v = k :* v
|
||||
|
@ -169,7 +169,8 @@ instance Show1 Regex where liftShowsPrec = genericLiftShowsPrec
|
||||
-- TODO: Heredoc-style string literals?
|
||||
|
||||
-- TODO: Implement Eval instance for Regex
|
||||
instance Evaluatable Regex
|
||||
instance Evaluatable Regex where
|
||||
eval (Regex x) = rvalBox (regex x)
|
||||
|
||||
-- Collections
|
||||
|
||||
|
@ -102,6 +102,7 @@ evalJavaScriptProject = justEvaluating <=< evaluateProject (Proxy :: Proxy 'Lang
|
||||
evalTypeScriptProject = justEvaluating <=< evaluateProject (Proxy :: Proxy 'Language.TypeScript) typescriptParser
|
||||
|
||||
typecheckGoFile = checking <=< evaluateProjectWithCaching (Proxy :: Proxy 'Language.Go) goParser
|
||||
typecheckRubyFile = checking <=< evaluateProjectWithCaching (Proxy :: Proxy 'Language.Ruby) rubyParser
|
||||
|
||||
callGraphProject parser proxy opts paths = runTaskWithOptions opts $ do
|
||||
blobs <- catMaybes <$> traverse readFile (flip File (Language.reflect proxy) <$> paths)
|
||||
|
Loading…
Reference in New Issue
Block a user