1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 16:33:03 +03:00

Parse PHP in a precise manner now that its assignment is disabled.

This commit is contained in:
Patrick Thomson 2020-02-14 12:54:23 -05:00
parent 75bbed48f5
commit 26d3f221ee

View File

@ -41,6 +41,7 @@ module Parsing.Parser
) where
import Assigning.Assignment
import AST.Unmarshal
import qualified CMarkGFM
import Data.AST
import Data.Functor.Classes
@ -52,25 +53,25 @@ import Data.Term
import Foreign.Ptr
import qualified Language.Go as GoPrecise
import qualified Language.Go.Assignment as GoALaCarte
import Language.Go.Grammar
import qualified Language.Java as Java
import qualified Language.JSON as JSON
import qualified Language.Markdown.Assignment as Markdown
import qualified Language.PHP as PHPPrecise
import qualified Language.Python as PythonPrecise
import qualified Language.Python.Assignment as PythonALaCarte
import Language.Python.Grammar
import qualified Language.Ruby as RubyPrecise
import qualified Language.Ruby.Assignment as RubyALaCarte
import Language.Ruby.Grammar (tree_sitter_ruby)
import qualified Language.TSX as TSXPrecise
import qualified Language.TSX.Assignment as TSXALaCarte
import qualified Language.TypeScript as TypeScriptPrecise
import qualified Language.TypeScript.Assignment as TypeScriptALaCarte
import Prelude hiding (fail)
import Language.Go.Grammar
import qualified TreeSitter.Language as TS (Language, Symbol)
import Language.Python.Grammar
import Language.Ruby.Grammar (tree_sitter_ruby)
import TreeSitter.TSX
import Language.TypeScript.Grammar
import AST.Unmarshal
import Prelude hiding (fail)
import qualified TreeSitter.Language as TS (Language, Symbol)
import TreeSitter.TSX
-- | A parser from 'Source' onto some term type.
data Parser term where
@ -160,6 +161,9 @@ jsxParser modes = case jsxMode modes of
markdownParser :: c Markdown.Term => (Language, SomeParser c Loc)
markdownParser = (Markdown, SomeParser (AssignmentParser MarkdownParser Markdown.assignment))
phpParserPrecise :: c PHPPrecise.Term => (Language, SomeParser c Loc)
phpParserPrecise = (PHP, SomeParser (UnmarshalParser @PHPPrecise.Term PHPPrecise.tree_sitter_php))
pythonParserALaCarte :: c PythonALaCarte.Term => (Language, SomeParser c Loc)
pythonParserALaCarte = (Python, SomeParser (AssignmentParser (ASTParser tree_sitter_python) PythonALaCarte.assignment))
@ -210,6 +214,7 @@ type family TermMode term where
TermMode GoPrecise.Term = 'Precise
TermMode Java.Term = 'Precise
TermMode JSON.Term = 'Precise
TermMode PHPPrecise.Term = 'Precise
TermMode PythonPrecise.Term = 'Precise
TermMode RubyPrecise.Term = 'Precise
TermMode TypeScriptPrecise.Term = 'Precise
@ -244,6 +249,7 @@ preciseParsers
, c PythonPrecise.Term
, c RubyPrecise.Term
, c GoPrecise.Term
, c PHPPrecise.Term
, c TypeScriptPrecise.Term
, c TSXPrecise.Term
)
@ -254,6 +260,7 @@ preciseParsers = Map.fromList
, jsonParser
, jsxParserPrecise
, pythonParserPrecise
, phpParserPrecise
, rubyParserPrecise
, tsxParserPrecise
, typescriptParserPrecise