1
1
mirror of https://github.com/github/semantic.git synced 2024-12-28 17:32:05 +03:00

Merge remote-tracking branch 'origin/master' into ruby-assignment-fixes

This commit is contained in:
Timothy Clem 2017-08-15 07:59:24 -07:00
commit 9dda6bf725
715 changed files with 7083 additions and 3517 deletions

5
.gitattributes vendored
View File

@ -1,6 +1,3 @@
test/diffs linguist-vendored
test/diffs-todo linguist-vendored
test/crashers linguist-vendored
test/crashers-todo linguist-vendored
test/fixtures linguist-vendored
test/repos linguist-vendored
vendor linguist-vendored

15
.gitmodules vendored
View File

@ -13,30 +13,15 @@
[submodule "vendor/effects"]
path = vendor/effects
url = https://github.com/joshvera/effects.git
[submodule "languages/ruby/vendor/tree-sitter-ruby"]
path = languages/ruby/vendor/tree-sitter-ruby
url = https://github.com/tree-sitter/tree-sitter-ruby.git
[submodule "languages/c/vendor/tree-sitter-c"]
path = languages/c/vendor/tree-sitter-c
url = https://github.com/tree-sitter/tree-sitter-c.git
[submodule "languages/go/vendor/tree-sitter-go"]
path = languages/go/vendor/tree-sitter-go
url = https://github.com/tree-sitter/tree-sitter-go.git
[submodule "languages/javascript/vendor/tree-sitter-javascript"]
path = languages/javascript/vendor/tree-sitter-javascript
url = https://github.com/tree-sitter/tree-sitter-javascript.git
[submodule "vendor/haskell-tree-sitter"]
path = vendor/haskell-tree-sitter
url = https://github.com/tree-sitter/haskell-tree-sitter.git
[submodule "languages/typescript/vendor/tree-sitter-typescript"]
path = languages/typescript/vendor/tree-sitter-typescript
url = https://github.com/tree-sitter/tree-sitter-typescript/
[submodule "languages/python/vendor/tree-sitter-python"]
path = languages/python/vendor/tree-sitter-python
url = https://github.com/tree-sitter/tree-sitter-python.git
[submodule "languages/json/vendor/tree-sitter-json"]
path = languages/json/vendor/tree-sitter-json
url = https://github.com/tree-sitter/tree-sitter-json
[submodule "vendor/freer-cofreer"]
path = vendor/freer-cofreer
url = https://github.com/robrix/freer-cofreer.git

View File

@ -1,4 +1,3 @@
packages: ./ languages/*/ tools/*/
optional-packages: vendor/*/
packages: ./ vendor/*/ vendor/haskell-tree-sitter/languages/*/
jobs: $ncpus

View File

@ -1,2 +0,0 @@
import Distribution.Simple
main = defaultMain

View File

@ -1,25 +0,0 @@
name: go
version: 0.1.0
synopsis: tree-sitter go language bindings
description: Please see README.md
homepage: https://github.com/github/semantic-diff#readme
author: semantic-code
maintainer: tclem@github.com
copyright: 2017 GitHub
category: Web
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Text.Parser.TreeSitter.Go
build-depends: base >= 4.7 && < 5
, haskell-tree-sitter
default-language: Haskell2010
default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards
c-sources: vendor/tree-sitter-go/src/parser.c
source-repository head
type: git
location: https://github.com/github/semantic-diff

View File

@ -1,6 +0,0 @@
module Text.Parser.TreeSitter.Go where
import Text.Parser.TreeSitter
import Foreign.Ptr
foreign import ccall unsafe "vendor/tree-sitter-go/src/parser.c tree_sitter_go" tree_sitter_go :: Ptr Language

@ -1 +0,0 @@
Subproject commit 025ece6ddcdf3e3cbc6c865e2d2c010217fbf90f

View File

@ -1,2 +0,0 @@
import Distribution.Simple
main = defaultMain

View File

@ -1,27 +0,0 @@
name: json
version: 0.1.0
synopsis: tree-sitter json language bindings
description: Please see README.md
homepage: https://github.com/github/semantic-diff#readme
author: semantic-code
maintainer: vera@github.com
copyright: 2017 GitHub
category: Web
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Text.Parser.TreeSitter.JSON
build-depends: base >= 4.7 && < 5
, haskell-tree-sitter
default-language: Haskell2010
default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards
c-sources: vendor/tree-sitter-json/src/parser.c
cc-options: -std=c99 -Os
source-repository head
type: git
location: https://github.com/github/semantic-diff

View File

@ -1,6 +0,0 @@
module Text.Parser.TreeSitter.JSON where
import Foreign.Ptr
import Text.Parser.TreeSitter
foreign import ccall unsafe "vendor/tree-sitter-json/src/parser.c tree_sitter_json" tree_sitter_json :: Ptr Language

@ -1 +0,0 @@
Subproject commit 81b519e6ad7aa87c61851f1f6925b59fcc34d347

View File

@ -1,2 +0,0 @@
import Distribution.Simple
main = defaultMain

View File

@ -1,27 +0,0 @@
name: python
version: 0.1.0
synopsis: tree-sitter python language bindings
homepage: https://github.com/github/semantic-diff#readme
description: Please see README.md
author: semantic-code
maintainer: tclem@github.com
copyright: 2017 GitHub
category: Web
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Text.Parser.TreeSitter.Python
build-depends: base >= 4.7 && < 5
, haskell-tree-sitter
default-language: Haskell2010
default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards
c-sources: vendor/tree-sitter-python/src/parser.c
, vendor/tree-sitter-python/src/scanner.cc
extra-libraries: stdc++
source-repository head
type: git
location: https://github.com/github/semantic-diff

View File

@ -1,8 +0,0 @@
module Text.Parser.TreeSitter.Python
( tree_sitter_python
) where
import Foreign.Ptr
import Text.Parser.TreeSitter
foreign import ccall unsafe "vendor/tree-sitter-python/src/parser.c tree_sitter_python" tree_sitter_python :: Ptr Language

@ -1 +0,0 @@
Subproject commit 24220e066fd65ccfa5dba65c0095705d559e97cb

View File

@ -1,2 +0,0 @@
import Distribution.Simple
main = defaultMain

View File

@ -1,27 +0,0 @@
name: ruby
version: 0.1.0
synopsis: tree-sitter ruby language bindings
description: Please see README.md
homepage: https://github.com/github/semantic-diff#readme
author: semantic-code
maintainer: tclem@github.com
copyright: 2017 GitHub
category: Web
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Text.Parser.TreeSitter.Ruby
build-depends: base >= 4.7 && < 5
, haskell-tree-sitter
default-language: Haskell2010
default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards
c-sources: vendor/tree-sitter-ruby/src/parser.c
, vendor/tree-sitter-ruby/src/scanner.cc
extra-libraries: stdc++
source-repository head
type: git
location: https://github.com/github/semantic-diff

View File

@ -1,8 +0,0 @@
module Text.Parser.TreeSitter.Ruby
( tree_sitter_ruby
) where
import Foreign.Ptr
import Text.Parser.TreeSitter
foreign import ccall unsafe "vendor/tree-sitter-ruby/src/parser.c tree_sitter_ruby" tree_sitter_ruby :: Ptr Language

@ -1 +0,0 @@
Subproject commit 6681b4c8d255ca0aec09c29777271736186b6c7d

View File

@ -1,2 +0,0 @@
import Distribution.Simple
main = defaultMain

View File

@ -1,6 +0,0 @@
module Text.Parser.TreeSitter.TypeScript where
import Foreign.Ptr
import Text.Parser.TreeSitter
foreign import ccall unsafe "vendor/tree-sitter-typescript/src/parser.c tree_sitter_typescript" tree_sitter_typescript :: Ptr Language

View File

@ -1,28 +0,0 @@
name: typescript
version: 0.1.0
synopsis: tree-sitter typescript language bindings
description: Please see README.md
homepage: https://github.com/github/semantic-diff#readme
author: semantic-code
maintainer: vera@github.com
copyright: 2017 GitHub
category: Web
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Text.Parser.TreeSitter.TypeScript
build-depends: base >= 4.7 && < 5
, haskell-tree-sitter
default-language: Haskell2010
default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards
c-sources: vendor/tree-sitter-typescript/src/parser.c
, vendor/tree-sitter-typescript/src/scanner.c
cc-options: -std=c99 -Os
source-repository head
type: git
location: https://github.com/github/semantic-diff

@ -1 +0,0 @@
Subproject commit 6d44526e059ebf456c9059ee1717126d69e41018

View File

@ -32,10 +32,6 @@ generate_example () {
fileB="$2"
parseFileA="${fileA%%.*}.parseA.txt"
parseFileB="${fileB%%.*}.parseB.txt"
diffFileAddA="${fileA%%.*}.diff+A.txt"
diffFileRemoveA="${fileA%%.*}.diff-A.txt"
diffFileAddB="${fileB%%.*}.diff+B.txt"
diffFileRemoveB="${fileB%%.*}.diff-B.txt"
diffFileAB="${fileA%%.*}.diffA-B.txt"
diffFileBA="${fileB%%.*}.diffB-A.txt"
@ -45,18 +41,6 @@ generate_example () {
status $parseFileB
"$(dirname "$0")/run" semantic parse --sexpression $fileB > $parseFileB
status $diffFileAddA
"$(dirname "$0")/run" semantic diff --sexpression /dev/null $fileA > $diffFileAddA
status $diffFileRemoveA
"$(dirname "$0")/run" semantic diff --sexpression $fileA /dev/null > $diffFileRemoveA
status $diffFileAddB
"$(dirname "$0")/run" semantic diff --sexpression /dev/null $fileB > $diffFileAddB
status $diffFileRemoveB
"$(dirname "$0")/run" semantic diff --sexpression $fileB /dev/null > $diffFileRemoveB
status $diffFileAB
"$(dirname "$0")/run" semantic diff --sexpression $fileA $fileB > $diffFileAB

View File

@ -116,11 +116,11 @@ library
, time
, unix
, haskell-tree-sitter
, go
, ruby
, typescript
, python
, json
, tree-sitter-go
, tree-sitter-json
, tree-sitter-python
, tree-sitter-ruby
, tree-sitter-typescript
default-language: Haskell2010
default-extensions: DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric, FlexibleContexts, FlexibleInstances, OverloadedStrings, RecordWildCards, StrictData
ghc-options: -Wall -fno-warn-name-shadowing -O -j

View File

@ -115,7 +115,7 @@ import GHC.Stack
import qualified Info
import Prelude hiding (head, until)
import Text.Parser.Combinators as Parsers
import Text.Parser.TreeSitter.Language
import TreeSitter.Language
-- | Assignment from an AST with some set of 'symbol's onto some other value.
--

View File

@ -29,6 +29,7 @@ import Text.Read
-- | Read a utf8-encoded file to a 'Blob'.
readFile :: forall m. MonadIO m => FilePath -> Maybe Language -> m Blob.Blob
readFile path@"/dev/null" _ = pure (Blob.emptyBlob path)
readFile path language = do
raw <- liftIO $ (Just <$> B.readFile path) `catch` (const (pure Nothing) :: IOException -> IO (Maybe B.ByteString))
pure $ fromMaybe (Blob.emptyBlob path) (Blob.sourceBlob path language . fromBytes <$> raw)

View File

@ -2,8 +2,8 @@
module Language.Go.Syntax where
import Language.Haskell.TH
import Text.Parser.TreeSitter.Go
import Text.Parser.TreeSitter.Language
import TreeSitter.Go
import TreeSitter.Language
-- | Statically-known rules corresponding to symbols in the grammar.
mkSymbolDatatype (mkName "Grammar") tree_sitter_go

View File

@ -2,8 +2,8 @@
module Language.JSON.Grammar where
import Language.Haskell.TH
import Text.Parser.TreeSitter.Language
import Text.Parser.TreeSitter.JSON
import TreeSitter.Language
import TreeSitter.JSON
-- | Statically-known rules corresponding to symbols in the grammar.
-- v2 - bump this to regenerate

View File

@ -11,7 +11,7 @@ import Data.Ix
import Data.Source
import qualified Data.Syntax.Assignment as A (AST, Node(..))
import Info
import Text.Parser.TreeSitter.Language (Symbol(..), SymbolType(..))
import TreeSitter.Language (Symbol(..), SymbolType(..))
data Grammar
= Document

View File

@ -2,8 +2,8 @@
module Language.Python.Grammar where
import Language.Haskell.TH
import Text.Parser.TreeSitter.Language
import Text.Parser.TreeSitter.Python
import TreeSitter.Language
import TreeSitter.Python
-- | Statically-known rules corresponding to symbols in the grammar.
-- v3 - bump this to regenerate

View File

@ -2,11 +2,11 @@
module Language.Ruby.Grammar where
import Language.Haskell.TH
import Text.Parser.TreeSitter.Language
import Text.Parser.TreeSitter.Ruby
import TreeSitter.Language
import TreeSitter.Ruby
-- Regenerate template haskell code when these files change:
addDependentFileRelative "../../../languages/ruby/vendor/tree-sitter-ruby/src/parser.c"
addDependentFileRelative "../../../vendor/haskell-tree-sitter/languages/ruby/vendor/tree-sitter-ruby/src/parser.c"
-- | Statically-known rules corresponding to symbols in the grammar.
mkSymbolDatatype (mkName "Grammar") tree_sitter_ruby

View File

@ -69,7 +69,7 @@ termAssignment _ category children =
| S.Indexed _ <- unwrap statements
-> Just $ S.Export Nothing (toList (unwrap statements))
| otherwise -> Just $ S.Export (Just statements) []
(For, _:_) -> Just $ S.For (init children) [last children]
(For, _:_) -> Just $ S.For (init children >>= flattenExpressionStatements) [last children]
(Function, children) -> case break ((== ExpressionStatements) . Info.category . extract) children of
(inits, [body]) -> case inits of
[id, callSignature] -> Just $ S.Function id (toList (unwrap callSignature)) (toList (unwrap body))
@ -79,6 +79,9 @@ termAssignment _ category children =
(Ty, children) -> Just $ S.Ty children
(Interface, children) -> toInterface children
_ -> Nothing
where flattenExpressionStatements term
| Info.category (extract term) `elem` [ExpressionStatements, CommaOperator] = toList (unwrap term) >>= flattenExpressionStatements
| otherwise = [term]
categoryForTypeScriptName :: Text -> Category
categoryForTypeScriptName category = case category of
@ -95,8 +98,10 @@ categoryForTypeScriptName category = case category of
"arrow_function" -> Function
"generator_function" -> Function
"math_op" -> MathOperator -- math operator, e.g. +, -, *, /.
"update_expression" -> MathOperator -- math operator, e.g. ++, --
"bool_op" -> BooleanOperator -- boolean operator, e.g. ||, &&.
"comma_op" -> CommaOperator -- comma operator, e.g. expr1, expr2.
"sequence_expression" -> CommaOperator -- comma operator, e.g. expr1, expr2.
"delete_op" -> Operator -- delete operator, e.g. delete x[2].
"type_op" -> Operator -- type operator, e.g. typeof Object.
"void_op" -> Operator -- void operator, e.g. void 2.
@ -109,12 +114,15 @@ categoryForTypeScriptName category = case category of
"new_expression" -> Constructor
"class" -> Class
"catch" -> Catch
"catch_clause" -> Catch
"finally" -> Finally
"finally_clause" -> Finally
"if_statement" -> If
"trailing_if_statement" -> If
"empty_statement" -> Empty
"program" -> Program
"function_call" -> FunctionCall
"call_expression" -> FunctionCall
"pair" -> Pair
"string" -> StringLiteral
"integer" -> IntegerLiteral
@ -128,17 +136,23 @@ categoryForTypeScriptName category = case category of
"arguments" -> Args
"statement_block" -> ExpressionStatements
"assignment" -> Assignment
"assignment_expression" -> Assignment
"member_access" -> MemberAccess
"member_expression" -> MemberAccess
"op" -> Operator
"subscript_access" -> SubscriptAccess
"subscript_expression" -> SubscriptAccess
"regex" -> Regex
"template_string" -> TemplateString
"switch_statement" -> Switch
"math_assignment" -> MathAssignment
"augmented_assignment_expression" -> MathAssignment
"case" -> Case
"switch_case" -> Case
"true" -> Boolean
"false" -> Boolean
"ternary" -> Ternary
"ternary_expression" -> Ternary
"while_statement" -> While
"trailing_while_statement" -> While
"do_statement" -> DoWhile
@ -164,4 +178,5 @@ categoryForTypeScriptName category = case category of
"module" -> Module
"internal_module" -> Namespace
"interface_declaration" -> Interface
"parenthesized_expression" -> ParenthesizedExpression
name -> Other name

View File

@ -2,8 +2,8 @@
module Language.TypeScript.Syntax where
import Language.Haskell.TH
import Text.Parser.TreeSitter.Language
import Text.Parser.TreeSitter.TypeScript
import TreeSitter.Language
import TreeSitter.TypeScript
-- | Statically-known rules corresponding to symbols in the grammar.
mkSymbolDatatype (mkName "Grammar") tree_sitter_typescript

View File

@ -30,20 +30,19 @@ import qualified Language.Python.Syntax as Python
import qualified Language.Ruby.Syntax as Ruby
import Syntax hiding (Go)
import Term
import qualified Text.Parser.TreeSitter as TS
import Text.Parser.TreeSitter.Language (Symbol)
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 qualified TreeSitter.Language as TS (Language, Symbol)
import TreeSitter.Go
import TreeSitter.Python
import TreeSitter.Ruby
import TreeSitter.TypeScript
import TreeSitter.JSON
-- | A parser from 'Source' onto some term type.
data Parser term where
-- | A parser producing 'AST' using a 'TS.Language'.
ASTParser :: (Bounded grammar, Enum grammar) => Ptr TS.Language -> Parser (AST grammar)
-- | A parser producing an à la carte term given an 'AST'-producing parser and an 'Assignment' onto 'Term's in some syntax type.
AssignmentParser :: (Bounded grammar, Ix grammar, Show grammar, Symbol grammar, Syntax.Error :< fs, Apply1 Foldable fs, Apply1 Functor fs, Eq ast, Recursive ast, Foldable (Base ast))
AssignmentParser :: (Bounded grammar, Ix grammar, Show grammar, TS.Symbol grammar, Syntax.Error :< fs, Apply1 Foldable fs, Apply1 Functor fs, Eq ast, Recursive ast, Foldable (Base ast))
=> Parser ast -- ^ A parser producing AST.
-> (forall x. Base ast x -> Node grammar) -- ^ A function extracting the symbol and location.
-> Assignment ast grammar (Term (Union fs) (Record Location)) -- ^ An assignment from AST onto 'Term's.

View File

@ -2,15 +2,16 @@
module TreeSitter
( treeSitterParser
, parseToAST
, defaultTermAssignment
) where
import Category
import Control.Comonad (extract)
import Control.Comonad.Cofree (unwrap)
import Control.Exception
import Control.Monad ((<=<))
import Data.Blob
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
import Data.Foldable (toList)
import Data.Functor.Foldable hiding (Nil)
import Data.Range
import Data.Record
@ -27,42 +28,43 @@ import Foreign.C.String (peekCString)
import Foreign.Marshal.Array (allocaArray)
import qualified Syntax as S
import Term
import Text.Parser.TreeSitter hiding (Language(..))
import qualified Text.Parser.TreeSitter as TS
import qualified Text.Parser.TreeSitter.Go as TS
import qualified Text.Parser.TreeSitter.Ruby as TS
import qualified Text.Parser.TreeSitter.TypeScript as TS
import qualified TreeSitter.Document as TS
import qualified TreeSitter.Node as TS
import qualified TreeSitter.Language as TS
import qualified TreeSitter.Go as TS
import qualified TreeSitter.Ruby as TS
import qualified TreeSitter.TypeScript as TS
import Info
-- | Returns a TreeSitter parser for the given language and TreeSitter grammar.
treeSitterParser :: Ptr TS.Language -> Blob -> IO (SyntaxTerm DefaultFields)
treeSitterParser language blob = bracket ts_document_new ts_document_free $ \ document -> do
ts_document_set_language document language
treeSitterParser language blob = bracket TS.ts_document_new TS.ts_document_free $ \ document -> do
TS.ts_document_set_language document language
unsafeUseAsCStringLen (sourceBytes (blobSource blob)) $ \ (sourceBytes, len) -> do
ts_document_set_input_string_with_length document sourceBytes len
ts_document_parse_halt_on_error document
TS.ts_document_set_input_string_with_length document sourceBytes len
TS.ts_document_parse_halt_on_error document
term <- documentToTerm language document blob
pure term
-- | Parse 'Source' with the given 'TS.Language' and return its AST.
parseToAST :: (Bounded grammar, Enum grammar) => Ptr TS.Language -> Blob -> IO (A.AST grammar)
parseToAST language Blob{..} = bracket ts_document_new ts_document_free $ \ document -> do
ts_document_set_language document language
parseToAST language Blob{..} = bracket TS.ts_document_new TS.ts_document_free $ \ document -> do
TS.ts_document_set_language document language
root <- unsafeUseAsCStringLen (sourceBytes blobSource) $ \ (source, len) -> do
ts_document_set_input_string_with_length document source len
ts_document_parse_halt_on_error document
TS.ts_document_set_input_string_with_length document source len
TS.ts_document_parse_halt_on_error document
alloca (\ rootPtr -> do
ts_document_root_node_p document rootPtr
TS.ts_document_root_node_p document rootPtr
peek rootPtr)
anaM toAST root
toAST :: forall grammar . (Bounded grammar, Enum grammar) => Node -> IO (Base (A.AST grammar) Node)
toAST node@Node{..} = do
toAST :: forall grammar . (Bounded grammar, Enum grammar) => TS.Node -> IO (Base (A.AST grammar) TS.Node)
toAST node@TS.Node{..} = do
let count = fromIntegral nodeChildCount
children <- allocaArray count $ \ childNodesPtr -> do
_ <- with nodeTSNode (\ nodePtr -> ts_node_copy_child_nodes nullPtr nodePtr childNodesPtr (fromIntegral count))
_ <- with nodeTSNode (\ nodePtr -> TS.ts_node_copy_child_nodes nullPtr nodePtr childNodesPtr (fromIntegral count))
peekArray count childNodesPtr
pure $! A.Node (toEnum (min (fromIntegral nodeSymbol) (fromEnum (maxBound :: grammar)))) (nodeRange node) (nodeSpan node) :< children
@ -71,46 +73,46 @@ anaM g = a where a = pure . embed <=< traverse a <=< g
-- | Return a parser for a tree sitter language & document.
documentToTerm :: Ptr TS.Language -> Ptr Document -> Blob -> IO (SyntaxTerm DefaultFields)
documentToTerm :: Ptr TS.Language -> Ptr TS.Document -> Blob -> IO (SyntaxTerm DefaultFields)
documentToTerm language document Blob{..} = do
root <- alloca (\ rootPtr -> do
ts_document_root_node_p document rootPtr
TS.ts_document_root_node_p document rootPtr
peek rootPtr)
toTerm root
where toTerm :: Node -> IO (SyntaxTerm DefaultFields)
toTerm node = do
name <- peekCString (nodeType node)
where toTerm :: TS.Node -> IO (SyntaxTerm DefaultFields)
toTerm node@TS.Node{..} = do
name <- peekCString nodeType
children <- getChildren (fromIntegral (nodeNamedChildCount node)) copyNamed
let allChildren = getChildren (fromIntegral (nodeChildCount node)) copyAll
children <- getChildren (fromIntegral nodeNamedChildCount) copyNamed
let allChildren = getChildren (fromIntegral nodeChildCount) copyAll
let source = slice (nodeRange node) blobSource
assignTerm language source (range :. categoryForLanguageProductionName language (pack name) :. nodeSpan node :. Nil) children allChildren
where getChildren count copy = do
nodes <- allocaArray count $ \ childNodesPtr -> do
_ <- with (nodeTSNode node) (\ nodePtr -> copy nodePtr childNodesPtr (fromIntegral count))
_ <- with nodeTSNode (\ nodePtr -> copy nodePtr childNodesPtr (fromIntegral count))
peekArray count childNodesPtr
children <- traverse toTerm nodes
return $! filter isNonEmpty children
range = nodeRange node
copyNamed = ts_node_copy_named_child_nodes document
copyAll = ts_node_copy_child_nodes document
copyNamed = TS.ts_node_copy_named_child_nodes document
copyAll = TS.ts_node_copy_child_nodes document
isNonEmpty :: HasField fields Category => SyntaxTerm fields -> Bool
isNonEmpty = (/= Empty) . category . extract
nodeRange :: Node -> Range
nodeRange Node{..} = Range (fromIntegral nodeStartByte) (fromIntegral nodeEndByte)
nodeRange :: TS.Node -> Range
nodeRange TS.Node{..} = Range (fromIntegral nodeStartByte) (fromIntegral nodeEndByte)
nodeSpan :: Node -> Span
nodeSpan Node{..} = nodeStartPoint `seq` nodeEndPoint `seq` Span (pointPos nodeStartPoint) (pointPos nodeEndPoint)
where pointPos TSPoint{..} = pointRow `seq` pointColumn `seq` Pos (1 + fromIntegral pointRow) (1 + fromIntegral pointColumn)
nodeSpan :: TS.Node -> Span
nodeSpan TS.Node{..} = nodeStartPoint `seq` nodeEndPoint `seq` Span (pointPos nodeStartPoint) (pointPos nodeEndPoint)
where pointPos TS.TSPoint{..} = pointRow `seq` pointColumn `seq` Pos (1 + fromIntegral pointRow) (1 + fromIntegral pointColumn)
assignTerm :: Ptr TS.Language -> Source -> Record DefaultFields -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (SyntaxTerm DefaultFields)
assignTerm language source annotation children allChildren =
cofree . (annotation :<) <$> case assignTermByLanguage source (category annotation) children of
Just a -> pure a
_ -> defaultTermAssignment source (category annotation) children allChildren
case assignTermByLanguage source (category annotation) children of
Just a -> pure (cofree (annotation :< a))
_ -> defaultTermAssignment source annotation children allChildren
where assignTermByLanguage :: Source -> Category -> [ SyntaxTerm DefaultFields ] -> Maybe (S.Syntax (SyntaxTerm DefaultFields))
assignTermByLanguage = case languageForTSLanguage language of
Just Language.Go -> Go.termAssignment
@ -118,33 +120,58 @@ assignTerm language source annotation children allChildren =
Just TypeScript -> TS.termAssignment
_ -> \ _ _ _ -> Nothing
defaultTermAssignment :: Source -> Category -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (S.Syntax (SyntaxTerm DefaultFields))
defaultTermAssignment source category children allChildren
| category `elem` operatorCategories = S.Operator <$> allChildren
| otherwise = pure $! case (category, children) of
(ParseError, children) -> S.ParseError children
defaultTermAssignment :: Source -> Record DefaultFields -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (SyntaxTerm DefaultFields)
defaultTermAssignment source annotation children allChildren
| category annotation `elem` operatorCategories = cofree . (annotation :<) . S.Operator <$> allChildren
| otherwise = case (category annotation, children) of
(ParseError, children) -> toTerm $ S.ParseError children
(Comment, _) -> S.Comment (toText source)
(Comment, _) -> toTerm $ S.Comment (toText source)
(Pair, [key, value]) -> S.Pair key value
(Pair, [key, value]) -> toTerm $ S.Pair key value
-- Control flow statements
(If, condition : body) -> S.If condition body
(Switch, _) -> uncurry S.Switch (break ((== Case) . Info.category . extract) children)
(Case, expr : body) -> S.Case expr body
(While, expr : rest) -> S.While expr rest
(If, condition : body) -> toTerm $ S.If condition body
(Switch, _) -> let (subject, body) = break ((== Other "switch_body") . Info.category . extract) children in toTerm $ S.Switch subject (body >>= toList . unwrap)
(Case, expr : body) -> toTerm $ S.Case expr body
(While, expr : rest) -> toTerm $ S.While expr rest
-- Statements
(Return, _) -> S.Return children
(Yield, _) -> S.Yield children
(Throw, [expr]) -> S.Throw expr
(Break, [label]) -> S.Break (Just label)
(Break, []) -> S.Break Nothing
(Continue, [label]) -> S.Continue (Just label)
(Continue, []) -> S.Continue Nothing
(Return, _) -> toTerm $ S.Return children
(Yield, _) -> toTerm $ S.Yield children
(Throw, [expr]) -> toTerm $ S.Throw expr
(Break, [label]) -> toTerm $ S.Break (Just label)
(Break, []) -> toTerm $ S.Break Nothing
(Continue, [label]) -> toTerm $ S.Continue (Just label)
(Continue, []) -> toTerm $ S.Continue Nothing
(_, []) -> S.Leaf (toText source)
(_, children) -> S.Indexed children
(ParenthesizedExpression, [child]) -> pure child
(Other "unary_expression", _) -> do
cs <- allChildren
let c = case category . extract <$> cs of
[Other s, _]
| s `elem` ["-", "+", "++", "--"] -> MathOperator
| s == "~" -> BitwiseOperator
| s == "!" -> BooleanOperator
[_, Other t]
| t `elem` ["--", "++"] -> MathOperator
_ -> Operator
pure (cofree ((setCategory annotation c) :< S.Operator cs))
(Other "binary_expression", _) -> do
cs <- allChildren
let c = case category . extract <$> cs of
[_, Other s, _]
| s `elem` ["<=", "<", ">=", ">", "==", "===", "!=", "!=="] -> RelationalOperator
| s `elem` ["*", "+", "-", "/", "%"] -> MathOperator
| s `elem` ["&&", "||"] -> BooleanOperator
| s `elem` [">>", ">>=", ">>>", ">>>=", "<<", "<<=", "&", "^", "|"] -> BitwiseOperator
_ -> Operator
pure (cofree ((setCategory annotation c) :< S.Operator cs))
(_, []) -> toTerm $ S.Leaf (toText source)
(_, children) -> toTerm $ S.Indexed children
where operatorCategories =
[ Operator
, Binary
@ -156,6 +183,7 @@ defaultTermAssignment source category children allChildren
, RelationalOperator
, BitwiseOperator
]
toTerm = pure . cofree . (annotation :<)
categoryForLanguageProductionName :: Ptr TS.Language -> Text -> Category

View File

@ -14,7 +14,7 @@ import Data.Syntax.Assignment
import GHC.Stack (getCallStack)
import Prelude hiding (words)
import Test.Hspec
import Text.Parser.TreeSitter.Language (Symbol(..), SymbolType(..))
import TreeSitter.Language (Symbol(..), SymbolType(..))
spec :: Spec
spec = do

View File

@ -58,25 +58,15 @@ examples directory = do
bs <- globFor "*.B.*"
sExpAs <- globFor "*.parseA.txt"
sExpBs <- globFor "*.parseB.txt"
sExpDiffsAddA <- globFor "*.diff+A.txt"
sExpDiffsRemoveA <- globFor "*.diff-A.txt"
sExpDiffsAddB <- globFor "*.diff+B.txt"
sExpDiffsRemoveB <- globFor "*.diff-B.txt"
sExpDiffsAB <- globFor "*.diffA-B.txt"
sExpDiffsBA <- globFor "*.diffB-A.txt"
let exampleDiff lefts rights out name = DiffExample (lookupNormalized name lefts) (lookupNormalized name rights) out
let exampleAddDiff files out name = DiffExample "" (lookupNormalized name files) out
let exampleRemoveDiff files out name = DiffExample (lookupNormalized name files) "" out
let exampleParse files out name = ParseExample (lookupNormalized name files) out
let keys = (normalizeName <$> as) `union` (normalizeName <$> bs)
pure $ merge [ getExamples (exampleParse as) sExpAs keys
, getExamples (exampleParse bs) sExpBs keys
, getExamples (exampleAddDiff as) sExpDiffsAddA keys
, getExamples (exampleRemoveDiff as) sExpDiffsRemoveA keys
, getExamples (exampleAddDiff bs) sExpDiffsAddB keys
, getExamples (exampleRemoveDiff bs) sExpDiffsRemoveB keys
, getExamples (exampleDiff as bs) sExpDiffsAB keys
, getExamples (exampleDiff bs as) sExpDiffsBA keys ]
where

View File

@ -1,14 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ArrayTy
(RelationalOperator
(NumberLiteral)
(NumberLiteral))
(Identifier))))))+}

View File

@ -1,16 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(ArrayTy
(Identifier))
(NumberLiteral)
(NumberLiteral)
(NumberLiteral)))))))+}

View File

@ -1,28 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier)
(Identifier))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))))+}

View File

@ -1,18 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))))+}

View File

@ -1,13 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Switch
(Case
(Case
(Other "expression_list"
(Identifier)))
(FunctionCall
(Identifier))))))+}

View File

@ -1,22 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(Identifier))))
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(StructTy))))
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(Identifier)))))))+}

View File

@ -1,7 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Comment)))+}

View File

@ -1,14 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Identifier)
(Identifier)
(Other "expression_list"
(NumberLiteral)
(NumberLiteral))))))+}

View File

@ -1,13 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Identifier)
(Other "expression_list"
(NumberLiteral)
(NumberLiteral))))))+}

View File

@ -1,15 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Identifier)))
(VarAssignment
(Identifier))
(VarAssignment
(Identifier)))))+}

View File

@ -12,10 +12,9 @@
(Identifier)
(ChannelTy
(Identifier))
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy

View File

@ -1,29 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(FunctionCall
(Identifier)
(ChannelTy
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier))
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier))
(NumberLiteral)
(NumberLiteral))
(FunctionCall
(Identifier)
(DictionaryTy
(Identifier)
(Identifier)))))+}

View File

@ -12,10 +12,9 @@
(Identifier)
(ChannelTy
(Identifier))
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy

View File

@ -12,10 +12,9 @@
(Identifier)
(ChannelTy
(Identifier))
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy

View File

@ -14,10 +14,9 @@
(ChannelTy
{ (Identifier)
->(Identifier) })
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy

View File

@ -14,10 +14,9 @@
(ChannelTy
{ (Identifier)
->(Identifier) })
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy

View File

@ -12,10 +12,9 @@
(Identifier)
(ChannelTy
(Identifier))
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy

View File

@ -12,10 +12,9 @@
(Identifier)
(ChannelTy
(Identifier))
(ParenthesizedExpression
(RelationalOperator
(Identifier)
(Identifier))))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy

View File

@ -1,31 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))))+}

View File

@ -1,38 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(For
(FunctionCall
(Identifier))
(Other "goto_statement"
(Identifier)))
(For
(Other "expression_list"
(Identifier))
(Identifier)
(FunctionCall
(Identifier))
(Break
(Identifier)))
(For
(FunctionCall
(Identifier))
(Continue
(Identifier)))
(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue))
(For
(ExpressionStatements
(FunctionCall
(Identifier)
(Identifier))
(Break)))))+}

View File

@ -1,37 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args))
(Function
(Identifier)
(Args))
(Function
(Identifier)
(Args
(ParameterDecl
(Identifier)
(Identifier))
(Identifier)
(Identifier)
(ParameterDecl
(Identifier)
(Identifier)))
(Identifier))
(Function
(Identifier)
(Args)
(Args
(Identifier)
(Identifier)))
(Function
(Identifier)
(Args)
(Args
(ParameterDecl
(Identifier)
(Identifier))
(ParameterDecl
(Identifier)
(Identifier)))))+}

View File

@ -1,17 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(AnonymousFunction
(Identifier)
(Identifier)
(Return
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))))))))+}

View File

@ -1,15 +0,0 @@
{+(ParseError
(Module
(Identifier))
(Identifier)
(Args)
(TypeDecl
(Identifier)
(FunctionTy
(Args
(Identifier))
(Identifier)))
(Identifier)
(Args
(Identifier)
(Identifier)))+}

View File

@ -1,16 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Defer
(FunctionCall
(SubscriptAccess
(Identifier)
(Identifier))))
(Go
(FunctionCall
(SubscriptAccess
(Identifier)
(Identifier))))))+}

View File

@ -1,8 +0,0 @@
{+(ParseError
(Module
(Identifier))
(Identifier)
(Args)
(Identifier)
(StringLiteral)
(StringLiteral))+}

View File

@ -1,15 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "var_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(NumberLiteral)))
(VarAssignment
(Identifier)
(Other "expression_list"
(NumberLiteral))))))+}

View File

@ -1,32 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(If
(FunctionCall
(Identifier))
(ExpressionStatements
(FunctionCall
(Identifier))))
(If
(VarDecl
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FunctionCall
(Identifier))))
(Identifier)
(ExpressionStatements
(FunctionCall
(Identifier))))
(If
(FunctionCall
(Identifier))
(ExpressionStatements
(FunctionCall
(Identifier)))
(ExpressionStatements
(FunctionCall
(Identifier))))))+}

View File

@ -1,15 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "imaginary_literal")))
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "imaginary_literal"))))))+}

View File

@ -1,8 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(IncrementStatement)
(IncrementStatement)))+}

View File

@ -1,28 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Slice
(Identifier)
(NumberLiteral))
(Slice
(Identifier)
(NumberLiteral))
(Slice
(Identifier)
(NumberLiteral))
(Slice
(Identifier)
(NumberLiteral)
(NumberLiteral))
(Slice
(Identifier)
(NumberLiteral)
(NumberLiteral))
(Slice
(Identifier)
(NumberLiteral)
(NumberLiteral)
(NumberLiteral))))+}

View File

@ -1,10 +0,0 @@
{+(ParseError
(Module
(Identifier))
(Identifier)
(Args)
(VarAssignment
(Identifier)
(Other "expression_list"
(NumberLiteral)
(Identifier))))+}

View File

@ -1,28 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(Other "interface_type")))
(Other "type_declaration"
(TypeDecl
(Identifier)
(Other "interface_type"
(QualifiedType))))
(Other "type_declaration"
(TypeDecl
(Identifier)
(Other "interface_type"
(Identifier)
(QualifiedType)
(Other "method_spec"
(Identifier)
(Args
(ParameterDecl
(Identifier)
(Identifier)))
(Identifier)))))))+}

View File

@ -1,9 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(ExpressionStatements
(Other "label_statement"
(Identifier)))))+}

View File

@ -1,20 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(DictionaryTy
(Identifier)
(Identifier))
(Pair
(StringLiteral)
(StringLiteral))
(Pair
(StringLiteral)
(StringLiteral))))))))+}

View File

@ -1,12 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(DictionaryTy
(Identifier)
(Identifier))))))+}

View File

@ -1,17 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args))
(Method
(Identifier)
(Args
(ParameterDecl
(Identifier)
(Identifier)))
(Args
(ParameterDecl
(Identifier)
(Identifier)))
(Identifier)))+}

View File

@ -1,18 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(VarDecl
(Other "expression_list"
(Identifier))
(Other "expression_list"
(Operator
(Other "composite_literal"
(Identifier)
(Pair
(Identifier)
(FunctionCall
(Identifier)
(QualifiedType)))))))))+}

View File

@ -1,15 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args))
(Function
(Identifier)
(Args
(ParameterDecl
(Identifier)
(Identifier))
(ParameterDecl
(Identifier)
(Identifier)))))+}

View File

@ -1,16 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(PointerTy
(Identifier)))
(TypeDecl
(Identifier)
(PointerTy
(PointerTy
(Identifier)))))))+}

View File

@ -1,10 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(QualifiedType)))))+}

View File

@ -1,28 +0,0 @@
{+(Program
(Module
(Identifier))
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(RuneLiteral)))
(VarAssignment
(Identifier)
(Other "expression_list"
(RuneLiteral)))
(VarAssignment
(Identifier)
(Other "expression_list"
(RuneLiteral)))
(VarAssignment
(Identifier)
(Other "expression_list"
(RuneLiteral)))
(VarAssignment
(Identifier)
(Other "expression_list"
(RuneLiteral)))
(VarAssignment
(Identifier)
(Other "expression_list"
(RuneLiteral)))))+}

View File

@ -1,36 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Select
(Case
(Other "receive_statement"
(Other "expression_list"
(Identifier))
(Operator
(Identifier))))
(FunctionCall
(Identifier)
(Identifier))
(Case
(Send
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(NumberLiteral))
(Case
(Other "receive_statement"
(Operator
(FunctionCall
(SubscriptAccess
(Identifier)
(Identifier))
(NumberLiteral)))))
(FunctionCall
(Identifier)
(NumberLiteral))
(Case)
(Return))))+}

View File

@ -1,12 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(FunctionCall
(SubscriptAccess
(SubscriptAccess
(Identifier)
(Identifier))
(Identifier)))))+}

View File

@ -1,9 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Send
(Identifier)
(NumberLiteral))))+}

View File

@ -1,13 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(VarDecl
(Other "expression_list"
(Identifier)
(Identifier))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))))+}

View File

@ -1,7 +0,0 @@
{+(ParseError
(Module
(Identifier))
(Identifier)
(Args)
(Identifier)
(StringLiteral))+}

View File

@ -1,25 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args))
(Function
(Identifier)
(Args)
(FunctionCall
(Identifier)))
(Function
(Identifier)
(Args)
(FunctionCall
(Identifier))
(FunctionCall
(Identifier)))
(Function
(Identifier)
(Args)
(FunctionCall
(Identifier))
(FunctionCall
(Identifier))))+}

View File

@ -1,34 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(SliceTy
(Identifier))
(Literal
(StringLiteral))))))
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(SliceTy
(Identifier))
(Literal
(StringLiteral))))))
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(SliceTy
(Identifier))
(Literal
(StringLiteral)
(StringLiteral))))))))+}

View File

@ -1,17 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(SliceTy
(SliceTy
(Identifier)))))
(Other "type_declaration"
(TypeDecl
(Identifier)
(SliceTy
(Identifier))))))+}

View File

@ -1,15 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(StringLiteral)))
(VarAssignment
(Identifier)
(Other "expression_list"
(StringLiteral))))))+}

View File

@ -1,14 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(StructTy
(FieldDecl
(Identifier)
(Identifier)
(Identifier)))))))+}

View File

@ -1,36 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(Identifier)
(Pair
(Identifier)
(StringLiteral))
(Pair
(Identifier)
(StringLiteral))))))
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(StructTy
(FieldDecl
(Identifier)
(Identifier)))
(Pair
(Identifier)
(NumberLiteral))))))
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(Other "composite_literal"
(QualifiedType)))))))+}

View File

@ -1,34 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(StructTy)))
(Other "type_declaration"
(TypeDecl
(Identifier)
(StructTy
(FieldDecl
(Identifier)))))
(Other "type_declaration"
(TypeDecl
(Identifier)
(StructTy
(FieldDecl
(Identifier)
(Identifier)
(Identifier)))))
(Other "type_declaration"
(TypeDecl
(Identifier)
(StructTy
(FieldDecl
(QualifiedType))
(FieldDecl
(Identifier)
(Identifier)
(StringLiteral)))))))+}

View File

@ -1,31 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Switch
(Case
(Case
(Other "expression_list"
(RelationalOperator
(Identifier)
(Identifier))))
(FunctionCall
(Identifier)))
(Case
(Case
(Other "expression_list"
(RelationalOperator
(Identifier)
(Identifier))))
(FunctionCall
(Identifier)))
(Case
(Case
(Other "expression_list"
(RelationalOperator
(Identifier)
(NumberLiteral))))
(FunctionCall
(Identifier))))))+}

View File

@ -1,9 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(TypeAssertion
(Identifier)
(QualifiedType))))+}

View File

@ -23,8 +23,7 @@
(Identifier))
(Identifier))
(FunctionCall
(ParenthesizedExpression
(SubscriptAccess
(Identifier)
(Identifier)))
(SubscriptAccess
(Identifier)
(Identifier))
(Identifier))))+}

View File

@ -1,30 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(TypeConversion
(SliceTy
(QualifiedType))
(SubscriptAccess
(Identifier)
(Identifier)))
(TypeConversion
(ParenthesizedType
(SliceTy
(QualifiedType)))
(SubscriptAccess
(Identifier)
(Identifier)))
(FunctionCall
(SubscriptAccess
(Identifier)
(Identifier))
(Identifier))
(FunctionCall
(ParenthesizedExpression
(SubscriptAccess
(Identifier)
(Identifier)))
(Identifier))))+}

View File

@ -23,8 +23,7 @@
(Identifier))
(Identifier))
(FunctionCall
(ParenthesizedExpression
(SubscriptAccess
(Identifier)
(Identifier)))
(SubscriptAccess
(Identifier)
(Identifier))
(Identifier))))-}

View File

@ -23,8 +23,7 @@
(Identifier))
(Identifier))
(FunctionCall
(ParenthesizedExpression
(SubscriptAccess
(Identifier)
(Identifier)))
(SubscriptAccess
(Identifier)
(Identifier))
(Identifier))))-}

View File

@ -32,11 +32,10 @@
{ (Identifier)
->(Identifier) })
(FunctionCall
(ParenthesizedExpression
(SubscriptAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }))
(SubscriptAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })
{ (Identifier)
->(Identifier) })))

View File

@ -32,11 +32,10 @@
{ (Identifier)
->(Identifier) })
(FunctionCall
(ParenthesizedExpression
(SubscriptAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }))
(SubscriptAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })
{ (Identifier)
->(Identifier) })))

View File

@ -23,8 +23,7 @@
(Identifier))
(Identifier))
(FunctionCall
(ParenthesizedExpression
(SubscriptAccess
(Identifier)
(Identifier)))
(SubscriptAccess
(Identifier)
(Identifier))
(Identifier))))

Some files were not shown because too many files have changed in this diff Show More