1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Add json grammar module

This commit is contained in:
joshvera 2017-07-17 12:52:50 -04:00
parent 7078fb84f8
commit 3f6c71b3a4
5 changed files with 15 additions and 1 deletions

View File

@ -19,7 +19,6 @@ library
default-language: Haskell2010
default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards
c-sources: vendor/tree-sitter-json/src/parser.c
, vendor/tree-sitter-json/src/scanner.c
cc-options: -std=c99 -Os

View File

@ -51,6 +51,7 @@ library
, Language.Markdown.Syntax
, Language.Go
, Language.Go.Syntax
, Language.JSON.Grammar
, Language.Ruby
, Language.Ruby.Grammar
, Language.Ruby.Syntax

View File

@ -14,6 +14,7 @@ data Language =
C
| Go
| JavaScript
| JSON
| Markdown
| Python
| Ruby
@ -25,6 +26,7 @@ languageForType :: String -> Maybe Language
languageForType mediaType = case mediaType of
".h" -> Just C
".c" -> Just C
".json" -> Just JSON
".md" -> Just Markdown
".rb" -> Just Ruby
".go" -> Just Language.Go

View File

@ -0,0 +1,10 @@
{-# LANGUAGE TemplateHaskell #-}
module Language.JSON.Grammar where
import Language.Haskell.TH
import Text.Parser.TreeSitter.Language
import Text.Parser.TreeSitter.JSON
-- | Statically-known rules corresponding to symbols in the grammar.
-- v1 - bump this to regenerate
mkSymbolDatatype (mkName "Grammar") tree_sitter_json

View File

@ -33,6 +33,7 @@ import Text.Parser.TreeSitter.Go
import Text.Parser.TreeSitter.Python
import Text.Parser.TreeSitter.Ruby
import Text.Parser.TreeSitter.TypeScript
import Text.Parser.TreeSitter.JSON
import TreeSitter
-- | A parser from 'Source' onto some term type.
@ -58,6 +59,7 @@ parserForLanguage Nothing = LineByLineParser
parserForLanguage (Just language) = case language of
C -> TreeSitterParser C tree_sitter_c
Go -> TreeSitterParser Go tree_sitter_go
JSON -> TreeSitterParser JSON tree_sitter_json
JavaScript -> TreeSitterParser TypeScript tree_sitter_typescript
Ruby -> TreeSitterParser Ruby tree_sitter_ruby
TypeScript -> TreeSitterParser TypeScript tree_sitter_typescript