mirror of
https://github.com/github/semantic.git
synced 2024-12-28 09:21:35 +03:00
Stub out JavaScript prelude
This commit is contained in:
parent
7137c057b4
commit
72917bc3e7
2
preludes/javascript.js
Normal file
2
preludes/javascript.js
Normal file
@ -0,0 +1,2 @@
|
||||
// can't quite define console.log in a way we can evaluate yet, but...
|
||||
function log(x) { return __semantic_print(x) }
|
@ -7,6 +7,7 @@ module Language.Preluded
|
||||
import GHC.TypeLits
|
||||
import qualified Language.Python.Assignment as Python
|
||||
import qualified Language.Ruby.Assignment as Ruby
|
||||
import qualified Language.TypeScript.Assignment as TypeScript
|
||||
|
||||
class Preluded syntax where
|
||||
type PreludePath syntax :: Symbol
|
||||
@ -16,3 +17,6 @@ instance Preluded Ruby.Term where
|
||||
|
||||
instance Preluded Python.Term where
|
||||
type PreludePath Python.Term = "preludes/python.py"
|
||||
|
||||
instance Preluded TypeScript.Term where
|
||||
type PreludePath TypeScript.Term = "preludes/javascript.js"
|
||||
|
@ -73,7 +73,7 @@ someAnalysisParser :: ( ApplyAll' typeclasses Go.Syntax
|
||||
-> Language -- ^ The 'Language' to select.
|
||||
-> SomeAnalysisParser typeclasses (Record Location) -- ^ A 'SomeAnalysisParser abstracting the syntax type to be produced.
|
||||
someAnalysisParser _ Go = SomeAnalysisParser goParser Nothing
|
||||
someAnalysisParser _ JavaScript = SomeAnalysisParser typescriptParser Nothing
|
||||
someAnalysisParser _ JavaScript = SomeAnalysisParser typescriptParser $ Just (File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath TypeScript.Term))) (Just JavaScript))
|
||||
someAnalysisParser _ PHP = SomeAnalysisParser phpParser Nothing
|
||||
someAnalysisParser _ Python = SomeAnalysisParser pythonParser $ Just (File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Python.Term))) (Just Python))
|
||||
someAnalysisParser _ Ruby = SomeAnalysisParser rubyParser $ Just (File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Ruby.Term))) (Just Ruby))
|
||||
|
@ -24,6 +24,7 @@ import Semantic.Task
|
||||
|
||||
import qualified Language.Python.Assignment as Python
|
||||
import qualified Language.Ruby.Assignment as Ruby
|
||||
import qualified Language.TypeScript.Assignment as TypeScript
|
||||
|
||||
justEvaluating
|
||||
= runM
|
||||
@ -79,7 +80,7 @@ evalGoProject path = justEvaluating =<< evaluateProject goParser Language.Go Not
|
||||
evalRubyProject path = justEvaluating =<< evaluateProject rubyParser Language.Ruby rubyPrelude path
|
||||
evalPHPProject path = justEvaluating =<< evaluateProject phpParser Language.PHP Nothing path
|
||||
evalPythonProject path = justEvaluating =<< evaluateProject pythonParser Language.Python pythonPrelude path
|
||||
evalJavaScriptProject path = justEvaluating =<< evaluateProject typescriptParser Language.JavaScript Nothing path
|
||||
evalJavaScriptProject path = justEvaluating =<< evaluateProject typescriptParser Language.JavaScript javaScriptPrelude path
|
||||
evalTypeScriptProjectQuietly path = evaluatingWithHoles =<< evaluateProject typescriptParser Language.TypeScript Nothing path
|
||||
evalTypeScriptProject path = justEvaluating =<< evaluateProject typescriptParser Language.TypeScript Nothing path
|
||||
|
||||
@ -87,6 +88,7 @@ typecheckGoFile path = checking =<< evaluateProjectWithCaching goParser Language
|
||||
|
||||
rubyPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Ruby.Term))) (Just Language.Ruby)
|
||||
pythonPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Python.Term))) (Just Language.Python)
|
||||
javaScriptPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath TypeScript.Term))) (Just Language.JavaScript)
|
||||
|
||||
-- Evaluate a project, starting at a single entrypoint.
|
||||
evaluateProject parser lang prelude path = evaluatePackageWith id withTermSpans <$> runTask (readProject Nothing path lang [] >>= parsePackage parser prelude)
|
||||
|
Loading…
Reference in New Issue
Block a user