1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 01:42:43 +03:00

Merge remote-tracking branch 'origin/master' into typescript-assignment

This commit is contained in:
joshvera 2017-08-25 12:18:09 -04:00
commit b99309bcc5
963 changed files with 333 additions and 12272 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ tags
cabal.project.local
dist
dist-newstyle
.ghc.environment.*
tmp/

View File

@ -1,4 +1,4 @@
{-# LANGUAGE DataKinds, GADTs, InstanceSigs, MultiParamTypeClasses, RankNTypes, ScopedTypeVariables, TypeFamilies, TypeOperators #-}
{-# LANGUAGE DataKinds, GADTs, InstanceSigs, MultiParamTypeClasses, RankNTypes, ScopedTypeVariables, StandaloneDeriving, TypeFamilies, TypeOperators, UndecidableInstances #-}
-- | Assignment of AST onto some other structure (typically terms).
--
-- Parsing yields an AST represented as a Rose tree labelled with symbols in the languages grammar and source locations (byte Range and Span). An Assignment represents a (partial) map from AST nodes onto some other structure; in essence, its a parser that operates over trees. (For our purposes, this structure is typically Terms annotated with source locations.) Assignments are able to match based on symbol, sequence, and hierarchy; thus, in @x = y@, both @x@ and @y@ might have the same symbol, @Identifier@, the left can be assigned to a variable declaration, while the right can be assigned to a variable reference.
@ -70,7 +70,7 @@ module Data.Syntax.Assignment
, Alternative(..)
, MonadError(..)
, location
, project
, currentNode
, symbol
, source
, children
@ -85,7 +85,7 @@ module Data.Syntax.Assignment
, nodeError
, firstSet
-- Running
, assignBy
, assign
, runAssignment
-- Implementation details (for testing)
, State(..)
@ -95,8 +95,9 @@ module Data.Syntax.Assignment
import Control.Arrow ((&&&))
import Control.Applicative
import Control.Comonad.Cofree
import Control.Monad ((<=<), guard)
import Control.Comonad.Cofree as Cofree
import qualified Control.Comonad.Trans.Cofree as CofreeF (CofreeF(..), headF)
import Control.Monad (guard)
import Control.Monad.Error.Class hiding (Error)
import Control.Monad.Free.Freer
import Data.Bifunctor
@ -105,69 +106,77 @@ import Data.Error
import Data.Foldable
import Data.Function
import Data.Functor.Classes
import qualified Data.Functor.Foldable as F hiding (Nil)
import qualified Data.IntMap.Lazy as IntMap
import Data.Ix (Ix(..))
import Data.List (union)
import Data.List.NonEmpty ((<|), NonEmpty(..))
import Data.List.NonEmpty (NonEmpty(..))
import Data.Maybe
import Data.Record
import Data.Semigroup
import qualified Data.Source as Source (Source, slice, sourceBytes)
import GHC.Stack
import qualified Info
import Prelude hiding (head, until)
import Prelude hiding (until)
import Term (runCofree)
import Text.Parser.Combinators as Parsers
import TreeSitter.Language
-- | Assignment from an AST with some set of 'symbol's onto some other value.
--
-- This is essentially a parser.
type Assignment ast grammar = Freer (AssignmentF ast grammar)
type Assignment ast grammar = Freer (Tracing (AssignmentF ast grammar))
data AssignmentF ast grammar a where
End :: HasCallStack => AssignmentF ast grammar ()
Location :: HasCallStack => AssignmentF ast grammar (Record Location)
Project :: HasCallStack => (forall x. F.Base ast x -> a) -> AssignmentF ast grammar a
Source :: HasCallStack => AssignmentF ast grammar ByteString
Children :: HasCallStack => Assignment ast grammar a -> AssignmentF ast grammar a
Advance :: HasCallStack => AssignmentF ast grammar ()
Choose :: HasCallStack => [grammar] -> IntMap.IntMap a -> AssignmentF ast grammar a
Many :: HasCallStack => Assignment ast grammar a -> AssignmentF ast grammar [a]
Alt :: HasCallStack => NonEmpty a -> AssignmentF ast grammar a
Throw :: HasCallStack => Maybe (Error (Either String grammar)) -> AssignmentF ast grammar a
Catch :: HasCallStack => Assignment ast grammar a -> (Error (Either String grammar) -> Assignment ast grammar a) -> AssignmentF ast grammar a
Label :: HasCallStack => Assignment ast grammar a -> String -> AssignmentF ast grammar a
End :: AssignmentF ast grammar ()
Location :: AssignmentF ast grammar (Record Location)
CurrentNode :: AssignmentF ast grammar (CofreeF.CofreeF ast (Node grammar) ())
Source :: AssignmentF ast grammar ByteString
Children :: Assignment ast grammar a -> AssignmentF ast grammar a
Advance :: AssignmentF ast grammar ()
Choose :: [grammar] -> IntMap.IntMap a -> Maybe a -> AssignmentF ast grammar a
Many :: Assignment ast grammar a -> AssignmentF ast grammar [a]
Alt :: [a] -> AssignmentF ast grammar a
Throw :: Error (Either String grammar) -> AssignmentF ast grammar a
Catch :: Assignment ast grammar a -> (Error (Either String grammar) -> Assignment ast grammar a) -> AssignmentF ast grammar a
Label :: Assignment ast grammar a -> String -> AssignmentF ast grammar a
data Tracing f a where
Tracing :: { tracingCallSite :: Maybe (String, SrcLoc), runTracing :: f a } -> Tracing f a
assignmentCallSite :: Assignment ast grammar a -> Maybe (String, SrcLoc)
assignmentCallSite (Tracing site _ `Then` _) = site
assignmentCallSite _ = Nothing
tracing :: HasCallStack => f a -> Tracing f a
tracing f = case getCallStack callStack of
(_ : site : _) -> Tracing (Just site) f
_ -> Tracing Nothing f
-- | Zero-width production of the current location.
--
-- If assigning at the end of input or at the end of a list of children, the loccation will be returned as an empty Range and Span at the current offset. Otherwise, it will be the Range and Span of the current node.
location :: HasCallStack => Assignment ast grammar (Record Location)
location = withFrozenCallStack $ Location `Then` return
location = tracing Location `Then` return
-- | Zero-width projection of the current node.
--
-- Since this is zero-width, care must be taken not to repeat it without chaining on other rules. I.e. @many (project f *> b)@ is fine, but @many (project f)@ is not.
project :: HasCallStack => (forall x. F.Base ast x -> a) -> Assignment ast grammar a
project projection = withFrozenCallStack $ Project projection `Then` return
-- | Zero-width production of the current node.
currentNode :: HasCallStack => Assignment ast grammar (CofreeF.CofreeF ast (Node grammar) ())
currentNode = tracing CurrentNode `Then` return
-- | Zero-width match of a node with the given symbol, producing the current nodes location.
--
-- Since this is zero-width, care must be taken not to repeat it without chaining on other rules. I.e. @many (symbol A *> b)@ is fine, but @many (symbol A)@ is not.
symbol :: (Bounded grammar, Ix grammar, HasCallStack) => grammar -> Assignment ast grammar (Record Location)
symbol s = withFrozenCallStack $ Choose [s] (IntMap.singleton (toIndex s) location) `Then` id
symbol s = tracing (Choose [s] (IntMap.singleton (toIndex s) location) Nothing) `Then` id
-- | A rule to produce a nodes source as a ByteString.
source :: HasCallStack => Assignment ast grammar ByteString
source = withFrozenCallStack $ Source `Then` return
source = tracing Source `Then` return
-- | Match a node by applying an assignment to its children.
children :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar a
children forEach = withFrozenCallStack $ Children forEach `Then` return
children child = tracing (Children child) `Then` return
-- | Advance past the current node.
advance :: HasCallStack => Assignment ast grammar ()
advance = withFrozenCallStack $ Advance `Then` return
advance = tracing Advance `Then` return
-- | Match and advance past a node with the given symbol.
token :: (Bounded grammar, Ix grammar, HasCallStack) => grammar -> Assignment ast grammar (Record Location)
@ -199,7 +208,7 @@ toIndex = index (minBound, maxBound)
type Location = '[Info.Range, Info.Span]
-- | An AST node labelled with symbols and source location.
type AST grammar = Cofree [] (Node grammar)
type AST f grammar = Cofree f (Node grammar)
data Node grammar = Node
{ nodeSymbol :: !grammar
@ -212,177 +221,195 @@ nodeLocation :: Node grammar -> Record Location
nodeLocation Node{..} = nodeByteRange :. nodeSpan :. Nil
nodeError :: HasCallStack => [Either String grammar] -> Node grammar -> Error (Either String grammar)
nodeError expected (Node actual _ span) = Error span expected (Just (Right actual))
nodeError expected Node{..} = Error nodeSpan expected (Just (Right nodeSymbol))
firstSet :: Assignment ast grammar a -> [grammar]
firstSet = iterFreer (\ assignment _ -> case assignment of
Choose symbols _ -> symbols
firstSet = iterFreer (\ (Tracing _ assignment) _ -> case assignment of
Choose symbols _ _ -> symbols
Catch during _ -> firstSet during
Label child _ -> firstSet child
_ -> []) . ([] <$)
-- | Run an assignment over an AST exhaustively.
assignBy :: (Bounded grammar, Ix grammar, Symbol grammar, Show grammar, Eq ast, F.Recursive ast, Foldable (F.Base ast))
=> (forall x. F.Base ast x -> Node grammar) -- ^ A function to project a 'Node' from the ast.
-> Source.Source -- ^ The source for the parse tree.
-> Assignment ast grammar a -- ^ The 'Assignment to run.
-> ast -- ^ The root of the ast.
-> Either (Error String) a -- ^ 'Either' an 'Error' or an assigned value.
assignBy toNode source assignment ast = bimap (fmap (either id show)) fst (runAssignment toNode source assignment (makeState [ast]))
{-# INLINE assignBy #-}
assign :: (Bounded grammar, Ix grammar, Symbol grammar, Show grammar, Eq (ast (AST ast grammar)), Foldable ast, Functor ast)
=> Source.Source -- ^ The source for the parse tree.
-> Assignment ast grammar a -- ^ The 'Assignment to run.
-> AST ast grammar -- ^ The root of the ast.
-> Either (Error String) a -- ^ 'Either' an 'Error' or an assigned value.
assign source assignment ast = bimap (fmap (either id show)) fst (runAssignment source assignment (makeState [ast]))
{-# INLINE assign #-}
-- | Run an assignment of nodes in a grammar onto terms in a syntax over an AST exhaustively.
runAssignment :: forall grammar a ast. (Bounded grammar, Ix grammar, Symbol grammar, Eq ast, F.Recursive ast, Foldable (F.Base ast))
=> (forall x. F.Base ast x -> Node grammar) -- ^ A function to project a 'Node' from the ast.
-> Source.Source -- ^ The source for the parse tree.
-> Assignment ast grammar a -- ^ The 'Assignment' to run.
-> State ast -- ^ The current state.
-> Either (Error (Either String grammar)) (a, State ast) -- ^ 'Either' an 'Error' or an assigned value & updated state.
runAssignment toNode source = \ assignment state -> go assignment state >>= requireExhaustive
-- Note: We explicitly bind toNode & source above in order to ensure that the where clause can close over them; they dont change through the course of the run, so holding one reference is sufficient. On the other hand, we dont want to accidentally capture the assignment and state in the where clause, since they change at every step—and capturing when you meant to shadow is an easy mistake to make, & results in hard-to-debug errors. Binding them in a lambda avoids that problem while also being easier to follow than a pointfree definition.
where go :: Assignment ast grammar result -> State ast -> Either (Error (Either String grammar)) (result, State ast)
runAssignment :: forall grammar a ast. (Bounded grammar, Ix grammar, Symbol grammar, Eq (ast (AST ast grammar)), Foldable ast, Functor ast)
=> Source.Source -- ^ The source for the parse tree.
-> Assignment ast grammar a -- ^ The 'Assignment' to run.
-> State ast grammar -- ^ The current state.
-> Either (Error (Either String grammar)) (a, State ast grammar) -- ^ 'Either' an 'Error' or an assigned value & updated state.
runAssignment source = \ assignment state -> go assignment state >>= requireExhaustive (assignmentCallSite assignment)
-- Note: We explicitly bind source above in order to ensure that the where clause can close over them; they dont change through the course of the run, so holding one reference is sufficient. On the other hand, we dont want to accidentally capture the assignment and state in the where clause, since they change at every step—and capturing when you meant to shadow is an easy mistake to make, & results in hard-to-debug errors. Binding them in a lambda avoids that problem while also being easier to follow than a pointfree definition.
where go :: Assignment ast grammar result -> State ast grammar -> Either (Error (Either String grammar)) (result, State ast grammar)
go assignment = iterFreer run ((pure .) . (,) <$> assignment)
{-# INLINE go #-}
run :: AssignmentF ast grammar x
-> (x -> State ast -> Either (Error (Either String grammar)) (result, State ast))
-> State ast
-> Either (Error (Either String grammar)) (result, State ast)
run assignment yield initialState = assignment `seq` expectedSymbols `seq` state `seq` maybe (anywhere Nothing) (atNode . F.project) (listToMaybe stateNodes)
where atNode node = case assignment of
Location -> yield (nodeLocation (toNode node)) state
Project projection -> yield (projection node) state
Source -> yield (Source.sourceBytes (Source.slice (nodeByteRange (toNode node)) source)) (advance state)
run :: Tracing (AssignmentF ast grammar) x
-> (x -> State ast grammar -> Either (Error (Either String grammar)) (result, State ast grammar))
-> State ast grammar
-> Either (Error (Either String grammar)) (result, State ast grammar)
run t yield initialState = expectedSymbols `seq` state `seq` maybe (anywhere Nothing) atNode (listToMaybe stateNodes)
where atNode (node :< f) = case runTracing t of
Location -> yield (nodeLocation node) state
CurrentNode -> yield (node CofreeF.:< (() <$ f)) state
Source -> yield (Source.sourceBytes (Source.slice (nodeByteRange node) source)) (advanceState state)
Children child -> do
(a, state') <- go child state { stateNodes = toList node } >>= requireExhaustive
yield a (advance state' { stateNodes = stateNodes })
Advance -> yield () (advance state)
Choose _ choices | Just choice <- IntMap.lookup (toIndex (nodeSymbol (toNode node))) choices -> yield choice state
(a, state') <- go child state { stateNodes = toList f, stateCallSites = maybe id (:) (tracingCallSite t) stateCallSites } >>= requireExhaustive (tracingCallSite t)
yield a (advanceState state' { stateNodes = stateNodes, stateCallSites = stateCallSites })
Advance -> yield () (advanceState state)
Choose _ choices _ | Just choice <- IntMap.lookup (toIndex (nodeSymbol node)) choices -> yield choice state
Catch during handler -> go during state `catchError` (flip go state . handler) >>= uncurry yield
_ -> anywhere (Just node)
anywhere node = case assignment of
End -> requireExhaustive ((), state) >>= uncurry yield
anywhere node = case runTracing t of
End -> requireExhaustive (tracingCallSite t) ((), state) >>= uncurry yield
Location -> yield (Info.Range stateOffset stateOffset :. Info.Span statePos statePos :. Nil) state
Many rule -> fix (\ recur state -> (go rule state >>= \ (a, state') -> first (a:) <$> if state == state' then pure ([], state') else recur state') `catchError` const (pure ([], state))) state >>= uncurry yield
Alt as -> sconcat (flip yield state <$> as)
Throw e -> Left (fromMaybe (makeError node) e)
Alt (a:as) -> sconcat (flip yield state <$> a:|as)
Throw e -> Left e
Catch during _ -> go during state >>= uncurry yield
Choose{} -> Left (makeError node)
Project{} -> Left (makeError node)
Children{} -> Left (makeError node)
Source -> Left (makeError node)
Advance{} -> Left (makeError node)
Label child label -> go child state `catchError` (\ err -> throwError err { errorExpected = [Left label] }) >>= uncurry yield
Choose _ _ (Just atEnd) | Nothing <- node -> yield atEnd state
_ -> Left (makeError node)
state@State{..} = if not (null expectedSymbols) && all ((== Regular) . symbolType) expectedSymbols then dropAnonymous initialState else initialState
expectedSymbols = firstSet (assignment `Then` return)
makeError :: HasCallStack => Maybe (F.Base ast ast) -> Error (Either String grammar)
makeError = maybe (Error (Info.Span statePos statePos) (fmap Right expectedSymbols) Nothing) (nodeError (fmap Right expectedSymbols) . toNode)
state@State{..} = if not (null expectedSymbols) && all ((== Regular) . symbolType) expectedSymbols then skipTokens initialState else initialState
expectedSymbols = firstSet (t `Then` return)
makeError = withStateCallStack (tracingCallSite t) state $ maybe (Error (Info.Span statePos statePos) (fmap Right expectedSymbols) Nothing) (nodeError (fmap Right expectedSymbols))
requireExhaustive :: HasCallStack => (result, State ast) -> Either (Error (Either String grammar)) (result, State ast)
requireExhaustive (a, state) = let state' = dropAnonymous state in case stateNodes state' of
[] -> Right (a, state')
node : _ -> Left (nodeError [] (toNode (F.project node)))
requireExhaustive :: Symbol grammar => Maybe (String, SrcLoc) -> (result, State ast grammar) -> Either (Error (Either String grammar)) (result, State ast grammar)
requireExhaustive callSite (a, state) = let state' = skipTokens state in case stateNodes state' of
[] -> Right (a, state')
(node :< _) : _ -> Left (withStateCallStack callSite state (nodeError [] node))
dropAnonymous state = state { stateNodes = dropWhile ((/= Regular) . symbolType . nodeSymbol . toNode . F.project) (stateNodes state) }
withStateCallStack :: Maybe (String, SrcLoc) -> State ast grammar -> (HasCallStack => a) -> a
withStateCallStack callSite state action = withCallStack (freezeCallStack (fromCallSiteList (maybe id (:) callSite (stateCallSites state)))) action
-- Advances the state past the current (head) node (if any), dropping it off stateNodes, and updating stateOffset & statePos to its end; or else returns the state unchanged.
advance state@State{..}
| node : rest <- stateNodes
, Node{..} <- toNode (F.project node) = State (Info.end nodeByteRange) (Info.spanEnd nodeSpan) rest
| otherwise = state
skipTokens :: Symbol grammar => State ast grammar -> State ast grammar
skipTokens state = state { stateNodes = dropWhile ((/= Regular) . symbolType . nodeSymbol . CofreeF.headF . runCofree) (stateNodes state) }
-- | Advances the state past the current (head) node (if any), dropping it off stateNodes, and updating stateOffset & statePos to its end; or else returns the state unchanged.
advanceState :: State ast grammar -> State ast grammar
advanceState state@State{..}
| (Node{..} Cofree.:< _) : rest <- stateNodes = State (Info.end nodeByteRange) (Info.spanEnd nodeSpan) stateCallSites rest
| otherwise = state
-- | State kept while running 'Assignment's.
data State ast = State
{ stateOffset :: {-# UNPACK #-} !Int -- ^ The offset into the Source thus far reached, measured in bytes.
, statePos :: {-# UNPACK #-} !Info.Pos -- ^ The (1-indexed) line/column position in the Source thus far reached.
, stateNodes :: ![ast] -- ^ The remaining nodes to assign. Note that 'children' rules recur into subterms, and thus this does not necessarily reflect all of the terms remaining to be assigned in the overall algorithm, only those “in scope.”
data State ast grammar = State
{ stateOffset :: {-# UNPACK #-} !Int -- ^ The offset into the Source thus far reached, measured in bytes.
, statePos :: {-# UNPACK #-} !Info.Pos -- ^ The (1-indexed) line/column position in the Source thus far reached.
, stateCallSites :: ![(String, SrcLoc)] -- ^ The symbols & source locations of the calls thus far.
, stateNodes :: ![AST ast grammar] -- ^ The remaining nodes to assign. Note that 'children' rules recur into subterms, and thus this does not necessarily reflect all of the terms remaining to be assigned in the overall algorithm, only those “in scope.”
}
deriving (Eq, Show)
makeState :: [ast] -> State ast
makeState = State 0 (Info.Pos 1 1)
deriving instance (Eq grammar, Eq (ast (AST ast grammar))) => Eq (State ast grammar)
deriving instance (Show grammar, Show (ast (AST ast grammar))) => Show (State ast grammar)
makeState :: [AST ast grammar] -> State ast grammar
makeState = State 0 (Info.Pos 1 1) []
-- Instances
instance Eq grammar => Alternative (Assignment ast grammar) where
instance (Eq grammar, Eq (ast (AST ast grammar))) => Alternative (Assignment ast grammar) where
empty :: HasCallStack => Assignment ast grammar a
empty = Throw Nothing `Then` return
empty = tracing (Alt []) `Then` return
(<|>) :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar a -> Assignment ast grammar a
(<|>) :: forall a. HasCallStack => Assignment ast grammar a -> Assignment ast grammar a -> Assignment ast grammar a
Return a <|> _ = Return a
(Throw Nothing `Then` _) <|> r = r
l <|> (Throw Nothing `Then` _) = l
(Throw err `Then` continue) <|> _ = Throw err `Then` continue
(Children l `Then` continueL) <|> (Children r `Then` continueR) = Children (Left <$> l <|> Right <$> r) `Then` either continueL continueR
(Location `Then` continueL) <|> (Location `Then` continueR) = Location `Then` uncurry (<|>) . (continueL &&& continueR)
(Source `Then` continueL) <|> (Source `Then` continueR) = Source `Then` uncurry (<|>) . (continueL &&& continueR)
(Alt ls `Then` continueL) <|> (Alt rs `Then` continueR) = Alt ((Left <$> ls) <> (Right <$> rs)) `Then` either continueL continueR
(Alt ls `Then` continueL) <|> r = Alt ((continueL <$> ls) <> pure r) `Then` id
l <|> (Alt rs `Then` continueR) = Alt (l <| (continueR <$> rs)) `Then` id
l <|> r | Just (sl, cl) <- choices l, Just (sr, cr) <- choices r = fromMaybe id (rewrapFor r) . fromMaybe id (rewrapFor l) $
withBestCallStack (Choose (sl `union` sr) (IntMap.unionWith (<|>) cl cr) `Then` id)
| otherwise = withBestCallStack (Alt (l :| [r]) `Then` id)
where choices :: Assignment ast grammar a -> Maybe ([grammar], IntMap.IntMap (Assignment ast grammar a))
choices (Choose symbols choices `Then` continue) = Just (symbols, continue <$> choices)
choices (Many rule `Then` continue) = second ((Many rule `Then` continue) <$) <$> choices rule
choices (Catch during _ `Then` continue) = second (fmap (>>= continue)) <$> choices during
choices (Label rule label `Then` continue) = second ((Label rule label `Then` continue) <$) <$> choices rule
l@(Tracing cs _ `Then` _) <|> r@Return{} = Tracing cs (Alt [l, r]) `Then` id
l@(Tracing callSiteL la `Then` continueL) <|> r@(Tracing callSiteR ra `Then` continueR) = go callSiteL la continueL callSiteR ra continueR
where go :: forall l r . Maybe (String, SrcLoc) -> AssignmentF ast grammar l -> (l -> Assignment ast grammar a) -> Maybe (String, SrcLoc) -> AssignmentF ast grammar r -> (r -> Assignment ast grammar a) -> Assignment ast grammar a
go callSiteL la continueL callSiteR ra continueR = case (la, ra) of
(Alt [], _) -> r
(_, Alt []) -> l
(Throw _, _) -> l
(Children cl, Children cr) -> alternate (Children (Left <$> cl <|> Right <$> cr))
(Location, Location) -> distribute Location
(CurrentNode, CurrentNode) -> distribute CurrentNode
(Advance, Advance) -> distribute Advance
(End, End) -> distribute End
(Source, Source) -> distribute Source
(Alt ls, Alt rs) -> alternate (Alt ((Left <$> ls) <> (Right <$> rs)))
(Alt ls, _) -> rebuild (Alt ((continueL <$> ls) <> pure r)) id
(_, Alt rs) -> rebuild (Alt (pure l <> (continueR <$> rs))) id
_ | Just (sl, cl) <- choices l
, Just (sr, cr) <- choices r
-> rebuild (Choose (sl `union` sr) (IntMap.unionWith (<|>) cl cr) (merge <$> atEnd l <*> atEnd r)) id
| otherwise -> rebuild (Alt [l, r]) id
where distribute :: (l ~ lr, r ~ lr) => AssignmentF ast grammar lr -> Assignment ast grammar a
distribute a = rebuild a (uncurry (<|>) . (continueL &&& continueR))
alternate :: AssignmentF ast grammar (Either l r) -> Assignment ast grammar a
alternate a = rebuild a (either continueL continueR)
rebuild :: AssignmentF ast grammar x -> (x -> Assignment ast grammar a) -> Assignment ast grammar a
rebuild a c = Tracing (callSiteL <|> callSiteR) a `Then` c
merge l r = rebuild (Alt [l, r]) id
choices :: Assignment ast grammar z -> Maybe ([grammar], IntMap.IntMap (Assignment ast grammar z))
choices (Tracing _ (Choose symbols choices _) `Then` continue) = Just (symbols, continue <$> choices)
choices (Tracing cs (Many rule) `Then` continue) = second ((Tracing cs (Many rule) `Then` continue) <$) <$> choices rule
choices (Tracing _ (Catch during _) `Then` continue) = second (fmap (>>= continue)) <$> choices during
choices (Tracing cs (Label rule label) `Then` continue) = second ((Tracing cs (Label rule label) `Then` continue) <$) <$> choices rule
choices _ = Nothing
rewrapFor :: Assignment ast grammar a -> Maybe (Assignment ast grammar a -> Assignment ast grammar a)
rewrapFor (Many _ `Then` continue) = Just (<|> continue [])
rewrapFor (Catch _ handler `Then` continue) = Just (`catchError` (continue <=< handler))
rewrapFor _ = Nothing
assignmentCallStack (Choose{} `Then` _) = Just callStack
assignmentCallStack (Many{} `Then` _) = Just callStack
assignmentCallStack (Catch{} `Then` _) = Just callStack
assignmentCallStack (Label{} `Then` _) = Just callStack
assignmentCallStack _ = Nothing
withBestCallStack = withCallStack (freezeCallStack (fromMaybe callStack (((<|>) `on` assignmentCallStack) r l)))
atEnd :: Assignment ast grammar z -> Maybe (Assignment ast grammar z)
atEnd (Tracing _ (Choose _ _ atEnd) `Then` continue) = continue <$> atEnd
atEnd rule@(Tracing _ (Many _) `Then` _) = Just rule
atEnd rule@(Tracing _ (Catch _ _) `Then` _) = Just rule
atEnd rule@(Tracing _ (Label inner _) `Then` _) = rule <$ atEnd inner
atEnd _ = Nothing
many :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar [a]
many a = Many a `Then` return
many a = tracing (Many a) `Then` return
instance (Eq grammar, Show grammar) => Parsing (Assignment ast grammar) where
instance (Eq grammar, Eq (ast (AST ast grammar)), Show grammar, Show (ast (AST ast grammar))) => Parsing (Assignment ast grammar) where
try :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar a
try = id
(<?>) :: HasCallStack => Assignment ast grammar a -> String -> Assignment ast grammar a
a <?> s = Label a s `Then` return
a <?> s = tracing (Label a s) `Then` return
unexpected :: HasCallStack => String -> Assignment ast grammar a
unexpected s = location >>= \ loc -> throwError (Error (Info.sourceSpan loc) [] (Just (Left s)))
eof :: HasCallStack => Assignment ast grammar ()
eof = withFrozenCallStack $ End `Then` return
eof = tracing End `Then` return
notFollowedBy :: (HasCallStack, Show a) => Assignment ast grammar a -> Assignment ast grammar ()
notFollowedBy a = a *> unexpected (show a) <|> pure ()
instance MonadError (Error (Either String grammar)) (Assignment ast grammar) where
throwError :: HasCallStack => Error (Either String grammar) -> Assignment ast grammar a
throwError error = withFrozenCallStack $ Throw (Just error) `Then` return
throwError error = tracing (Throw error) `Then` return
catchError :: HasCallStack => Assignment ast grammar a -> (Error (Either String grammar) -> Assignment ast grammar a) -> Assignment ast grammar a
catchError during handler = Catch during handler `Then` return
catchError during handler = tracing (Catch during handler) `Then` return
instance Show grammar => Show1 (AssignmentF ast grammar) where
instance Show1 f => Show1 (Tracing f) where
liftShowsPrec sp sl d = liftShowsPrec sp sl d . runTracing
instance (Show grammar, Show (ast (AST ast grammar))) => Show1 (AssignmentF ast grammar) where
liftShowsPrec sp sl d a = case a of
End -> showString "End" . showChar ' ' . sp d ()
Advance -> showString "Advance" . showChar ' ' . sp d ()
Location -> showString "Location" . sp d (Info.Range 0 0 :. Info.Span (Info.Pos 1 1) (Info.Pos 1 1) :. Nil)
Project projection -> showsUnaryWith (const (const (showChar '_'))) "Project" d projection
CurrentNode -> showString "CurrentNode"
Source -> showString "Source" . showChar ' ' . sp d ""
Children a -> showsUnaryWith (liftShowsPrec sp sl) "Children" d a
Choose symbols choices -> showsBinaryWith showsPrec (const (liftShowList sp sl)) "Choose" d symbols (IntMap.toList choices)
Choose symbols choices atEnd -> showsTernaryWith showsPrec (const (liftShowList sp sl)) (liftShowsPrec sp sl) "Choose" d symbols (IntMap.toList choices) atEnd
Many a -> showsUnaryWith (liftShowsPrec (\ d a -> sp d [a]) (sl . pure)) "Many" d a
Alt as -> showsUnaryWith (const sl) "Alt" d (toList as)
Throw e -> showsUnaryWith showsPrec "Throw" d e
Catch during handler -> showsBinaryWith (liftShowsPrec sp sl) (const (const (showChar '_'))) "Catch" d during handler
Label child string -> showsBinaryWith (liftShowsPrec sp sl) showsPrec "Label" d child string
where showsTernaryWith :: (Int -> a -> ShowS) -> (Int -> b -> ShowS) -> (Int -> c -> ShowS) -> String -> Int -> a -> b -> c -> ShowS
showsTernaryWith sp1 sp2 sp3 name d x y z = showParen (d > 10) $ showString name . showChar ' ' . sp1 11 x . showChar ' ' . sp2 11 y . showChar ' ' . sp3 11 z

View File

@ -31,7 +31,7 @@ type Syntax =
]
type Term = Term.Term (Union Syntax) (Record Location)
type Assignment = HasCallStack => Assignment.Assignment (AST Grammar) Grammar Term
type Assignment = HasCallStack => Assignment.Assignment [] Grammar Term
assignment :: Assignment

View File

@ -5,7 +5,8 @@ module Language.Markdown
, toGrammar
) where
import Control.Comonad.Cofree
import Control.Comonad.Cofree as Cofree
import Control.Comonad.Trans.Cofree as CofreeF (CofreeF(..))
import CMarkGFM
import Data.Ix
import Data.Source
@ -48,13 +49,13 @@ exts = [
, extTagfilter
]
cmarkParser :: Source -> A.AST NodeType
cmarkParser :: Source -> A.AST (CofreeF [] NodeType) Grammar
cmarkParser source = toTerm (totalRange source) (totalSpan source) $ commonmarkToNode [ optSourcePos, optSafe ] exts (toText source)
where toTerm :: Range -> Span -> Node -> A.AST NodeType
where toTerm :: Range -> Span -> Node -> A.AST (CofreeF [] NodeType) Grammar
toTerm within withinSpan (Node position t children) =
let range = maybe within (spanToRangeInLineRanges lineRanges . toSpan) position
span = maybe withinSpan toSpan position
in (A.Node t range span) :< (toTerm range span <$> children)
in (A.Node (toGrammar t) range span) Cofree.:< (t CofreeF.:< (toTerm range span <$> children))
toSpan PosInfo{..} = Span (Pos startLine startColumn) (Pos (max startLine endLine) (succ (if endLine <= startLine then max startColumn endColumn else endColumn)))

View File

@ -7,6 +7,7 @@ module Language.Markdown.Syntax
) where
import Control.Comonad.Cofree (Cofree(..), unwrap)
import Control.Comonad.Trans.Cofree (CofreeF, headF, tailF)
import qualified CMarkGFM
import Data.ByteString (ByteString)
import Data.Function (on)
@ -52,7 +53,7 @@ type Syntax =
]
type Term = Term.Term (Union Syntax) (Record Location)
type Assignment = HasCallStack => Assignment.Assignment (AST CMarkGFM.NodeType) Grammar Term
type Assignment = HasCallStack => Assignment.Assignment (CofreeF [] CMarkGFM.NodeType) Grammar Term
assignment :: Assignment
@ -68,16 +69,16 @@ paragraph :: Assignment
paragraph = makeTerm <$> symbol Paragraph <*> children (Markup.Paragraph <$> many inlineElement)
list :: Assignment
list = (:<) <$> symbol List <*> (project (\ (Node (CMarkGFM.LIST CMarkGFM.ListAttributes{..}) _ _ Term.:< _) -> case listType of
list = (:<) <$> symbol List <*> ((\ (CMarkGFM.LIST CMarkGFM.ListAttributes{..}) -> case listType of
CMarkGFM.BULLET_LIST -> inj . Markup.UnorderedList
CMarkGFM.ORDERED_LIST -> inj . Markup.OrderedList) <*> children (many item))
CMarkGFM.ORDERED_LIST -> inj . Markup.OrderedList) . headF . tailF <$> currentNode <*> children (many item))
item :: Assignment
item = makeTerm <$> symbol Item <*> children (many blockElement)
section :: Assignment
section = makeTerm <$> symbol Heading <*> (heading >>= \ headingTerm -> Markup.Section (level headingTerm) headingTerm <$> while (((<) `on` level) headingTerm) blockElement)
where heading = makeTerm <$> symbol Heading <*> (project (\ (Node (CMarkGFM.HEADING level) _ _ Term.:< _) -> Markup.Heading level) <*> children (many inlineElement))
where heading = makeTerm <$> symbol Heading <*> ((\ (CMarkGFM.HEADING level) -> Markup.Heading level) . headF . tailF <$> currentNode <*> children (many inlineElement))
level term = case term of
_ | Just section <- prj (unwrap term) -> level (Markup.sectionHeading section)
_ | Just heading <- prj (unwrap term) -> Markup.headingLevel heading
@ -87,10 +88,10 @@ blockQuote :: Assignment
blockQuote = makeTerm <$> symbol BlockQuote <*> children (Markup.BlockQuote <$> many blockElement)
codeBlock :: Assignment
codeBlock = makeTerm <$> symbol CodeBlock <*> (project (\ (Node (CMarkGFM.CODE_BLOCK language _) _ _ Term.:< _) -> Markup.Code (nullText language)) <*> source)
codeBlock = makeTerm <$> symbol CodeBlock <*> ((\ (CMarkGFM.CODE_BLOCK language _) -> Markup.Code (nullText language)) . headF . tailF <$> currentNode <*> source)
thematicBreak :: Assignment
thematicBreak = makeTerm <$> symbol ThematicBreak <*> pure Markup.ThematicBreak <* source
thematicBreak = makeTerm <$> token ThematicBreak <*> pure Markup.ThematicBreak
htmlBlock :: Assignment
htmlBlock = makeTerm <$> symbol HTMLBlock <*> (Markup.HTMLBlock <$> source)
@ -125,19 +126,19 @@ htmlInline :: Assignment
htmlInline = makeTerm <$> symbol HTMLInline <*> (Markup.HTMLBlock <$> source)
link :: Assignment
link = makeTerm <$> symbol Link <*> project (\ (Node (CMarkGFM.LINK url title) _ _ Term.:< _) -> Markup.Link (encodeUtf8 url) (nullText title)) <* source
link = makeTerm <$> symbol Link <*> ((\ (CMarkGFM.LINK url title) -> Markup.Link (encodeUtf8 url) (nullText title)) . headF . tailF <$> currentNode) <* advance
image :: Assignment
image = makeTerm <$> symbol Image <*> project (\ (Node (CMarkGFM.IMAGE url title) _ _ Term.:< _) -> Markup.Image (encodeUtf8 url) (nullText title)) <* source
image = makeTerm <$> symbol Image <*> ((\ (CMarkGFM.IMAGE url title) -> Markup.Image (encodeUtf8 url) (nullText title)) . headF . tailF <$> currentNode) <* advance
code :: Assignment
code = makeTerm <$> symbol Code <*> (Markup.Code Nothing <$> source)
lineBreak :: Assignment
lineBreak = makeTerm <$> symbol LineBreak <*> pure Markup.LineBreak <* source
lineBreak = makeTerm <$> token LineBreak <*> pure Markup.LineBreak
softBreak :: Assignment
softBreak = makeTerm <$> symbol SoftBreak <*> pure Markup.LineBreak <* source
softBreak = makeTerm <$> token SoftBreak <*> pure Markup.LineBreak
-- Implementation details

View File

@ -11,7 +11,7 @@ import Data.Align.Generic
import Data.Functor (void)
import Data.Functor.Classes.Eq.Generic
import Data.Functor.Classes.Show.Generic
import Data.List.NonEmpty (some1)
import Data.List.NonEmpty (NonEmpty(..))
import Data.Maybe (fromMaybe)
import Data.Record
import Data.Syntax (contextualize, emptyTerm, handleError, infixContext, makeTerm, makeTerm', makeTerm1, postContextualize)
@ -85,7 +85,7 @@ type Syntax =
]
type Term = Term.Term (Union Syntax) (Record Location)
type Assignment = HasCallStack => Assignment.Assignment (AST Grammar) Grammar Term
type Assignment = HasCallStack => Assignment.Assignment [] Grammar Term
-- | Ellipsis (used in splice expressions and alternatively can be used as a fill in expression, like `undefined` in Haskell)
data Ellipsis a = Ellipsis
@ -106,74 +106,80 @@ assignment :: Assignment
assignment = handleError $ makeTerm <$> symbol Module <*> children (Syntax.Program <$> many expression)
expression :: Assignment
expression = handleError . term $
argument
<|> argumentList
<|> assertStatement
<|> assignment'
<|> await
<|> binaryOperator
<|> booleanOperator
<|> breakStatement
<|> call
<|> classDefinition
<|> comparisonOperator
<|> conditionalExpression
<|> continueStatement
<|> decoratedDefinition
<|> deleteStatement
<|> dottedName
<|> ellipsis
<|> exceptClause
<|> execStatement
<|> expressionList
<|> expressionStatement
<|> finallyClause
<|> forInClause
<|> forStatement
<|> functionDefinition
<|> globalStatement
<|> identifier
<|> ifClause
<|> ifStatement
<|> import'
<|> identifier
<|> literal
<|> memberAccess
<|> nonlocalStatement
<|> notOperator
<|> parameter
<|> passStatement
<|> printStatement
<|> raiseStatement
<|> returnStatement
<|> slice
<|> subscript
<|> tryStatement
<|> tuple
<|> type'
<|> unaryOperator
<|> variables
<|> whileStatement
<|> withStatement
<|> yield
expression = handleError (term everything)
where -- Alright, so.
-- Its *much* more efficient to merge IntMaps of similar size than it is to left-associatively keep merging single-element IntMaps into a single large one. Were talking ~5% productivity. Chunking it manually like this brings that up to a whopping 20% user (albeit a rosier ~45% elapsed) in my test case, and speeds up the construction of the assignment by a large margin.
-- We may at some point wish to write something to perform this chunking for us.
-- Medium-term, we should consider the construction of choices from first principles; maybe theres a better API for us to construct these tables.
-- Long-term, can we de/serialize assignments and avoid paying the cost of construction altogether?
everything = abcd <|> efil <|> pstv
abcd = a <|> b <|> c <|> d
efil = e <|> f <|> i <|> l
pstv = p <|> s <|> t <|> v
a = argument
<|> argumentList
<|> assertStatement
<|> assignment'
<|> await
b = binaryOperator
<|> boolean
<|> booleanOperator
<|> breakStatement
<|> call
<|> classDefinition
c = comparisonOperator
<|> comprehension
<|> concatenatedString
<|> conditionalExpression
<|> continueStatement
d = decoratedDefinition
<|> deleteStatement
<|> dictionary
<|> dottedName
e = ellipsis
<|> exceptClause
<|> execStatement
<|> expressionList
<|> expressionStatement
f = finallyClause
<|> float
<|> forInClause
<|> forStatement
<|> functionDefinition
<|> globalStatement
i = identifier
<|> ifClause
<|> ifStatement
<|> import'
<|> identifier
<|> integer
l = list'
<|> memberAccess
<|> none
<|> nonlocalStatement
<|> notOperator
p = pair
<|> parameter
<|> passStatement
<|> printStatement
<|> raiseStatement
<|> returnStatement
s = set
<|> slice
<|> string
<|> subscript
t = tryStatement
<|> tuple
<|> type'
<|> unaryOperator
v = variables
<|> whileStatement
<|> withStatement
<|> yield
expressions :: Assignment
expressions = makeTerm <$> location <*> many expression
literal :: Assignment
literal = boolean
<|> comprehension
<|> concatenatedString
<|> dictionary
<|> float
<|> integer
<|> list'
<|> none
<|> pair
<|> set
<|> string
expressionStatement :: Assignment
expressionStatement = mk <$> symbol ExpressionStatement <*> children (some expression)
where mk _ [child] = child
@ -200,11 +206,9 @@ parameter = makeTerm <$> symbol DefaultParameter <*> children (Statement.Assign
makeAssignment loc identifier' value' = makeTerm loc (Statement.Assignment identifier' value')
decoratedDefinition :: Assignment
decoratedDefinition = symbol DecoratedDefinition *> children (makeDecorator <$> partialDecorator <*> (flip (foldr makeDecorator) <$> many partialDecorator <*> term (functionDefinition <|> classDefinition)))
decoratedDefinition = symbol DecoratedDefinition *> children (term decorator)
where
makeDecorator (loc, partialDecorator') next = makeTerm loc (partialDecorator' next)
partialDecorator = (,) <$> symbol Decorator <*> children decorator'
decorator' = Declaration.Decorator <$> expression <*> many expression
decorator = makeTerm <$> symbol Decorator <*> (children (Declaration.Decorator <$> expression <*> many expression) <*> term (decorator <|> functionDefinition <|> classDefinition))
argumentList :: Assignment
argumentList = symbol ArgumentList *> children expressions
@ -472,20 +476,20 @@ conditionalExpression = makeTerm <$> symbol ConditionalExpression <*> children (
-- | Match a term optionally preceded by comment(s), or a sequence of comments if the term is not present.
term :: Assignment -> Assignment
term term = contextualize comment term <|> makeTerm1 <$> (Syntax.Context <$> some1 comment <*> emptyTerm)
term term = contextualize comment term <|> makeTerm1 <$> (Syntax.Context . (\ (a:as) -> a:|as) <$> some comment <*> emptyTerm)
-- | Match a left-associated infix chain of terms, optionally followed by comments. Like 'chainl1' but assigning comment nodes automatically.
chainl1Term :: Assignment -> Assignment.Assignment (AST Grammar) Grammar (Term -> Term -> Term) -> Assignment
chainl1Term :: Assignment -> Assignment.Assignment [] Grammar (Term -> Term -> Term) -> Assignment
chainl1Term expr op = postContextualize (comment <|> symbol AnonLambda *> empty) expr `chainl1` op
-- | Match a series of terms or comments until a delimiter is matched.
manyTermsTill :: Show b => Assignment.Assignment (AST Grammar) Grammar Term -> Assignment.Assignment (AST Grammar) Grammar b -> Assignment.Assignment (AST Grammar) Grammar [Term]
manyTermsTill :: Show b => Assignment.Assignment [] Grammar Term -> Assignment.Assignment [] Grammar b -> Assignment.Assignment [] Grammar [Term]
manyTermsTill step end = manyTill (step <|> comment) end
-- | Match infix terms separated by any of a list of operators, assigning any comments following each operand.
infixTerm :: HasCallStack
=> Assignment
-> Assignment
-> [Assignment.Assignment (AST Grammar) Grammar (Term -> Term -> Union Syntax Term)]
-> Assignment.Assignment (AST Grammar) Grammar (Union Syntax Term)
-> [Assignment.Assignment [] Grammar (Term -> Term -> Union Syntax Term)]
-> Assignment.Assignment [] Grammar (Union Syntax Term)
infixTerm = infixContext comment

View File

@ -78,7 +78,7 @@ type Syntax = '[
]
type Term = Term.Term (Union Syntax) (Record Location)
type Assignment = HasCallStack => Assignment.Assignment (AST Grammar) Grammar Term
type Assignment = HasCallStack => Assignment.Assignment [] Grammar Term
-- | Assignment from AST in Rubys grammar onto a program in Rubys syntax.
assignment :: Assignment
@ -398,6 +398,6 @@ term term = contextualize comment term <|> makeTerm1 <$> (Syntax.Context <$> som
infixTerm :: HasCallStack
=> Assignment
-> Assignment
-> [Assignment.Assignment (AST Grammar) Grammar (Term -> Term -> Union Syntax Term)]
-> Assignment.Assignment (AST Grammar) Grammar (Union Syntax Term)
-> [Assignment.Assignment [] Grammar (Term -> Term -> Union Syntax Term)]
-> Assignment.Assignment [] Grammar (Union Syntax Term)
infixTerm = infixContext comment

View File

@ -12,9 +12,9 @@ module Parser
, typescriptParser
) where
import Control.Comonad.Trans.Cofree (headF)
import Control.Comonad.Cofree (Cofree)
import Control.Comonad.Trans.Cofree (CofreeF)
import qualified CMarkGFM
import Data.Functor.Foldable hiding (fold, Nil)
import Data.Ix
import Data.Record
import Data.Source as Source
@ -24,7 +24,6 @@ import Data.Union
import Foreign.Ptr
import Info hiding (Empty, Go)
import Language
import Language.Markdown
import qualified Language.JSON.Syntax as JSON
import qualified Language.Markdown.Syntax as Markdown
import qualified Language.Python.Syntax as Python
@ -42,17 +41,16 @@ 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)
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, 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.
AssignmentParser :: (Bounded grammar, Ix grammar, Show grammar, TS.Symbol grammar, Syntax.Error :< fs, Eq (ast (Cofree ast (Node grammar))), Apply1 Foldable fs, Apply1 Functor fs, Foldable ast, Functor ast)
=> Parser (Cofree ast (Node grammar)) -- ^ A parser producing AST.
-> Assignment ast grammar (Term (Union fs) (Record Location)) -- ^ An assignment from AST onto 'Term's.
-> Parser (Term (Union fs) (Record Location)) -- ^ A parser producing 'Term's.
-- | A tree-sitter parser.
TreeSitterParser :: Ptr TS.Language -> Parser (SyntaxTerm DefaultFields)
-- | A parser for 'Markdown' using cmark.
MarkdownParser :: Parser (AST CMarkGFM.NodeType)
MarkdownParser :: Parser (Cofree (CofreeF [] CMarkGFM.NodeType) (Node Markdown.Grammar))
-- | A parser which will parse any input 'Source' into a top-level 'Term' whose children are leaves consisting of the 'Source's lines.
LineByLineParser :: Parser (SyntaxTerm DefaultFields)
@ -69,19 +67,19 @@ parserForLanguage (Just language) = case language of
_ -> LineByLineParser
rubyParser :: Parser Ruby.Term
rubyParser = AssignmentParser (ASTParser tree_sitter_ruby) headF Ruby.assignment
rubyParser = AssignmentParser (ASTParser tree_sitter_ruby) Ruby.assignment
pythonParser :: Parser Python.Term
pythonParser = AssignmentParser (ASTParser tree_sitter_python) headF Python.assignment
pythonParser = AssignmentParser (ASTParser tree_sitter_python) Python.assignment
jsonParser :: Parser JSON.Term
jsonParser = AssignmentParser (ASTParser tree_sitter_json) headF JSON.assignment
jsonParser = AssignmentParser (ASTParser tree_sitter_json) JSON.assignment
typescriptParser :: Parser TypeScript.Term
typescriptParser = AssignmentParser (ASTParser tree_sitter_typescript) headF TypeScript.assignment
markdownParser :: Parser Markdown.Term
markdownParser = AssignmentParser MarkdownParser (\ (node@Node{..} :< _) -> node { nodeSymbol = toGrammar nodeSymbol }) Markdown.assignment
markdownParser = AssignmentParser MarkdownParser Markdown.assignment
-- | A fallback parser that treats a file simply as rows of strings.

View File

@ -193,11 +193,11 @@ runParser Options{..} blob@Blob{..} = go
ASTParser language ->
logTiming "ts ast parse" $
liftIO $ (Right <$> parseToAST language blob) `catchError` (pure . Left. displayException)
AssignmentParser parser by assignment -> do
AssignmentParser parser assignment -> do
res <- go parser
case res of
Left err -> writeLog Error "failed parsing" blobFields >> pure (Left err)
Right ast -> logTiming "assign" $ case Assignment.assignBy by blobSource assignment ast of
Right ast -> logTiming "assign" $ case Assignment.assign blobSource assignment ast of
Left err -> do
let formatted = Error.formatError optionsPrintSource (optionsIsTerminal && optionsEnableColour) blob err
writeLog Error formatted blobFields

View File

@ -48,7 +48,7 @@ treeSitterParser language blob = bracket TS.ts_document_new TS.ts_document_free
-- | 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 :: (Bounded grammar, Enum grammar) => Ptr TS.Language -> Blob -> IO (A.AST [] grammar)
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
@ -60,7 +60,7 @@ parseToAST language Blob{..} = bracket TS.ts_document_new TS.ts_document_free $
anaM toAST root
toAST :: forall grammar . (Bounded grammar, Enum grammar) => TS.Node -> IO (Base (A.AST grammar) TS.Node)
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

View File

@ -2,7 +2,6 @@
module Data.Syntax.Assignment.Spec where
import Control.Comonad.Cofree (Cofree(..))
import Control.Comonad.Trans.Cofree (headF)
import Data.Bifunctor (first)
import Data.ByteString.Char8 as B (ByteString, length, words)
import Data.Ix
@ -20,13 +19,13 @@ spec :: Spec
spec = do
describe "Applicative" $
it "matches in sequence" $
fst <$> runAssignment headF "helloworld" ((,) <$> red <*> red) (makeState [node Red 0 5 [], node Red 5 10 []])
fst <$> runAssignment "helloworld" ((,) <$> red <*> red) (makeState [node Red 0 5 [], node Red 5 10 []])
`shouldBe`
Right (Out "hello", Out "world")
describe "Alternative" $ do
it "attempts multiple alternatives" $
fst <$> runAssignment headF "hello" (green <|> red) (makeState [node Red 0 5 []])
fst <$> runAssignment "hello" (green <|> red) (makeState [node Red 0 5 []])
`shouldBe`
Right (Out "hello")
@ -34,107 +33,107 @@ spec = do
let s = "colourless green ideas sleep furiously"
w = words s
(_, nodes) = foldl (\ (i, prev) word -> (i + B.length word + 1, prev <> [node Red i (i + B.length word) []])) (0, []) w in
fst <$> runAssignment headF (fromBytes s) (many red) (makeState nodes)
fst <$> runAssignment (fromBytes s) (many red) (makeState nodes)
`shouldBe`
Right (Out <$> w)
it "matches one-or-more repetitions against one or more input nodes" $
fst <$> runAssignment headF "hello" (some red) (makeState [node Red 0 5 []])
fst <$> runAssignment "hello" (some red) (makeState [node Red 0 5 []])
`shouldBe`
Right [Out "hello"]
it "distributes through overlapping committed choices, matching the left alternative" $
fst <$> runAssignment headF "(red (green))" (symbol Red *> children green <|> symbol Red *> children blue) (makeState [node Red 0 13 [node Green 5 12 []]])
fst <$> runAssignment "(red (green))" (symbol Red *> children green <|> symbol Red *> children blue) (makeState [node Red 0 13 [node Green 5 12 []]])
`shouldBe`
Right (Out "(green)")
it "distributes through overlapping committed choices, matching the right alternative" $
fst <$> runAssignment headF "(red (blue))" (symbol Red *> children green <|> symbol Red *> children blue) (makeState [node Red 0 12 [node Blue 5 11 []]])
fst <$> runAssignment "(red (blue))" (symbol Red *> children green <|> symbol Red *> children blue) (makeState [node Red 0 12 [node Blue 5 11 []]])
`shouldBe`
Right (Out "(blue)")
it "distributes through overlapping committed choices, matching the left alternatives" $
fst <$> runAssignment headF "magenta green green" (symbol Magenta *> many green <|> symbol Magenta *> many blue) (makeState [node Magenta 0 7 [], node Green 8 13 [], node Green 14 19 []])
fst <$> runAssignment "magenta green green" (symbol Magenta *> many green <|> symbol Magenta *> many blue) (makeState [node Magenta 0 7 [], node Green 8 13 [], node Green 14 19 []])
`shouldBe`
Right [Out "green", Out "green"]
it "distributes through overlapping committed choices, matching the right alternatives" $
fst <$> runAssignment headF "magenta blue blue" (symbol Magenta *> many green <|> symbol Magenta *> many blue) (makeState [node Magenta 0 7 [], node Blue 8 12 [], node Blue 13 17 []])
fst <$> runAssignment "magenta blue blue" (symbol Magenta *> many green <|> symbol Magenta *> many blue) (makeState [node Magenta 0 7 [], node Blue 8 12 [], node Blue 13 17 []])
`shouldBe`
Right [Out "blue", Out "blue"]
it "distributes through overlapping committed choices, matching the empty list" $
fst <$> runAssignment headF "magenta" (symbol Magenta *> (Left <$> many green) <|> symbol Magenta *> (Right <$> many blue)) (makeState [node Magenta 0 7 []])
fst <$> runAssignment "magenta" (symbol Magenta *> (Left <$> many green) <|> symbol Magenta *> (Right <$> many blue)) (makeState [node Magenta 0 7 []])
`shouldBe`
Right (Left [])
it "distributes through overlapping committed choices, dropping anonymous nodes & matching the left alternative" $
fst <$> runAssignment headF "magenta green" (symbol Magenta *> green <|> symbol Magenta *> blue) (makeState [node Magenta 0 7 [], node Green 8 13 []])
fst <$> runAssignment "magenta green" (symbol Magenta *> green <|> symbol Magenta *> blue) (makeState [node Magenta 0 7 [], node Green 8 13 []])
`shouldBe`
Right (Out "green")
it "distributes through overlapping committed choices, dropping anonymous nodes & matching the right alternative" $
fst <$> runAssignment headF "magenta blue" (symbol Magenta *> green <|> symbol Magenta *> blue) (makeState [node Magenta 0 7 [], node Blue 8 12 []])
fst <$> runAssignment "magenta blue" (symbol Magenta *> green <|> symbol Magenta *> blue) (makeState [node Magenta 0 7 [], node Blue 8 12 []])
`shouldBe`
Right (Out "blue")
it "alternates repetitions, matching the left alternative" $
fst <$> runAssignment headF "green green" (many green <|> many blue) (makeState [node Green 0 5 [], node Green 6 11 []])
fst <$> runAssignment "green green" (many green <|> many blue) (makeState [node Green 0 5 [], node Green 6 11 []])
`shouldBe`
Right [Out "green", Out "green"]
it "alternates repetitions, matching the right alternative" $
fst <$> runAssignment headF "blue blue" (many green <|> many blue) (makeState [node Blue 0 4 [], node Blue 5 9 []])
fst <$> runAssignment "blue blue" (many green <|> many blue) (makeState [node Blue 0 4 [], node Blue 5 9 []])
`shouldBe`
Right [Out "blue", Out "blue"]
it "alternates repetitions, matching at the end of input" $
fst <$> runAssignment headF "" (many green <|> many blue) (makeState [])
fst <$> runAssignment "" (many green <|> many blue) (makeState [])
`shouldBe`
Right []
it "distributes through children rules" $
fst <$> runAssignment headF "(red (blue))" (children (many green) <|> children (many blue)) (makeState [node Red 0 12 [node Blue 5 11 []]])
fst <$> runAssignment "(red (blue))" (children (many green) <|> children (many blue)) (makeState [node Red 0 12 [node Blue 5 11 []]])
`shouldBe`
Right [Out "(blue)"]
it "matches rules to the left of pure" $
fst <$> runAssignment headF "green" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [node Green 0 5 []])
fst <$> runAssignment "green" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [node Green 0 5 []])
`shouldBe`
Right (Out "green")
it "matches pure instead of rules to its right" $
fst <$> runAssignment headF "blue" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [node Blue 0 4 []])
fst <$> runAssignment "blue" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [node Blue 0 4 []])
`shouldBe`
Right (Out "other")
it "matches other nodes with pure" $
fst <$> runAssignment headF "red" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [node Red 0 3 []])
fst <$> runAssignment "red" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [node Red 0 3 []])
`shouldBe`
Right (Out "other")
it "matches at end with pure" $
fst <$> runAssignment headF "red" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [])
fst <$> runAssignment "red" ((green <|> pure (Out "other") <|> blue) <* many source) (makeState [])
`shouldBe`
Right (Out "other")
describe "symbol" $ do
it "matches nodes with the same symbol" $
fst <$> runAssignment headF "hello" red (makeState [node Red 0 5 []]) `shouldBe` Right (Out "hello")
fst <$> runAssignment "hello" red (makeState [node Red 0 5 []]) `shouldBe` Right (Out "hello")
it "does not advance past the current node" $
runAssignment headF "hi" (symbol Red) (makeState [ node Red 0 2 [] ]) `shouldBe` Left (Error (Span (Pos 1 1) (Pos 1 3)) [] (Just (Right Red)))
runAssignment "hi" (symbol Red) (makeState [ node Red 0 2 [] ]) `shouldBe` Left (Error (Span (Pos 1 1) (Pos 1 3)) [] (Just (Right Red)))
describe "without catchError" $ do
it "assignment returns unexpected symbol error" $
runAssignment headF "A"
runAssignment "A"
red
(makeState [node Green 0 1 []])
`shouldBe`
Left (Error (Span (Pos 1 1) (Pos 1 2)) [Right Red] (Just (Right Green)))
it "assignment returns unexpected end of input" $
runAssignment headF "A"
runAssignment "A"
(symbol Green *> children (some red))
(makeState [node Green 0 1 []])
`shouldBe`
@ -142,28 +141,28 @@ spec = do
describe "eof" $ do
it "matches at the end of branches" $
fst <$> runAssignment headF "" eof (makeState [] :: State (AST Grammar)) `shouldBe` Right ()
fst <$> runAssignment "" eof (makeState [] :: State [] Grammar) `shouldBe` Right ()
it "matches before anonymous nodes at the end of branches" $
fst <$> runAssignment headF "magenta" eof (makeState [ node Magenta 0 7 [] ] :: State (AST Grammar)) `shouldBe` Right ()
fst <$> runAssignment "magenta" eof (makeState [ node Magenta 0 7 [] ] :: State [] Grammar) `shouldBe` Right ()
describe "catchError" $ do
it "handler that always matches" $
fst <$> runAssignment headF "A"
fst <$> runAssignment "A"
(red `catchError` (\ _ -> OutError <$ location <*> source))
(makeState [node Green 0 1 []])
`shouldBe`
Right (OutError "A")
it "handler that matches" $
fst <$> runAssignment headF "A"
fst <$> runAssignment "A"
(red `catchError` const green)
(makeState [node Green 0 1 []])
`shouldBe`
Right (Out "A")
it "handler that doesn't match produces error" $
runAssignment headF "A"
runAssignment "A"
(red `catchError` const blue)
(makeState [node Green 0 1 []])
`shouldBe`
@ -171,7 +170,7 @@ spec = do
describe "in many" $ do
it "handler that always matches" $
fst <$> runAssignment headF "PG"
fst <$> runAssignment "PG"
(symbol Palette *> children (
many (red `catchError` (\ _ -> OutError <$ location <*> source))
))
@ -180,21 +179,21 @@ spec = do
Right [OutError "G"]
it "handler that matches" $
fst <$> runAssignment headF "PG"
fst <$> runAssignment "PG"
(symbol Palette *> children ( many (red `catchError` const green) ))
(makeState [node Palette 0 1 [node Green 1 2 []]])
`shouldBe`
Right [Out "G"]
it "handler that doesn't match produces error" $
runAssignment headF "PG"
runAssignment "PG"
(symbol Palette *> children ( many (red `catchError` const blue) ))
(makeState [node Palette 0 1 [node Green 1 2 []]])
`shouldBe`
Left (Error (Span (Pos 1 2) (Pos 1 3)) [] (Just (Right Green)))
it "handlers are greedy" $
runAssignment headF "PG"
runAssignment "PG"
(symbol Palette *> children (
(,) <$> many (red `catchError` (\ _ -> OutError <$ location <*> source)) <*> green
))
@ -203,7 +202,7 @@ spec = do
Left (Error (Span (Pos 1 3) (Pos 1 3)) [Right Green] Nothing)
it "handler that doesn't match with apply" $
fst <$> runAssignment headF "PG"
fst <$> runAssignment "PG"
(symbol Palette *> children (
(,) <$> many (red `catchError` const blue) <*> green
))
@ -213,7 +212,7 @@ spec = do
describe "many" $ do
it "takes ones and only one zero width repetition" $
fst <$> runAssignment headF "PGG"
fst <$> runAssignment "PGG"
(symbol Palette *> children ( many (green <|> pure (Out "always")) ))
(makeState [node Palette 0 1 [node Green 1 2 [], node Green 2 3 []]])
`shouldBe`
@ -221,38 +220,38 @@ spec = do
describe "source" $ do
it "produces the nodes source" $
assignBy headF "hi" source (node Red 0 2 []) `shouldBe` Right ("hi")
assign "hi" source (node Red 0 2 []) `shouldBe` Right ("hi")
it "advances past the current node" $
snd <$> runAssignment headF "hi" source (makeState [ node Red 0 2 [] ])
snd <$> runAssignment "hi" source (makeState [ node Red 0 2 [] ])
`shouldBe`
Right (State 2 (Pos 1 3) [])
Right (State 2 (Pos 1 3) [] [])
describe "children" $ do
it "advances past the current node" $
snd <$> runAssignment headF "a" (children (pure (Out ""))) (makeState [node Red 0 1 []])
snd <$> runAssignment "a" (children (pure (Out ""))) (makeState [node Red 0 1 []])
`shouldBe`
Right (State 1 (Pos 1 2) [])
Right (State 1 (Pos 1 2) [] [])
it "matches if its subrule matches" $
() <$ runAssignment headF "a" (children red) (makeState [node Blue 0 1 [node Red 0 1 []]])
() <$ runAssignment "a" (children red) (makeState [node Blue 0 1 [node Red 0 1 []]])
`shouldBe`
Right ()
it "does not match if its subrule does not match" $
runAssignment headF "a" (children red) (makeState [node Blue 0 1 [node Green 0 1 []]])
runAssignment "a" (children red) (makeState [node Blue 0 1 [node Green 0 1 []]])
`shouldBe`
Left (Error (Span (Pos 1 1) (Pos 1 2)) [Right Red] (Just (Right Green)))
it "matches nested children" $
fst <$> runAssignment headF "1"
fst <$> runAssignment "1"
(symbol Red *> children (symbol Green *> children (symbol Blue *> source)))
(makeState [ node Red 0 1 [ node Green 0 1 [ node Blue 0 1 [] ] ] ])
`shouldBe`
Right "1"
it "continues after children" $
fst <$> runAssignment headF "BC"
fst <$> runAssignment "BC"
(many (symbol Red *> children (symbol Green *> source)
<|> symbol Blue *> source))
(makeState [ node Red 0 1 [ node Green 0 1 [] ]
@ -261,7 +260,7 @@ spec = do
Right ["B", "C"]
it "matches multiple nested children" $
fst <$> runAssignment headF "12"
fst <$> runAssignment "12"
(symbol Red *> children (many (symbol Green *> children (symbol Blue *> source))))
(makeState [ node Red 0 2 [ node Green 0 1 [ node Blue 0 1 [] ]
, node Green 1 2 [ node Blue 1 2 [] ] ] ])
@ -270,26 +269,26 @@ spec = do
describe "runAssignment" $ do
it "drops anonymous nodes before matching symbols" $
fst <$> runAssignment headF "magenta red" red (makeState [node Magenta 0 7 [], node Red 8 11 []])
fst <$> runAssignment "magenta red" red (makeState [node Magenta 0 7 [], node Red 8 11 []])
`shouldBe`
Right (Out "red")
it "drops anonymous nodes after matching to ensure exhaustiveness" $
stateNodes . snd <$> runAssignment headF "red magenta" red (makeState [node Red 0 3 [], node Magenta 4 11 []])
stateNodes . snd <$> runAssignment "red magenta" red (makeState [node Red 0 3 [], node Magenta 4 11 []])
`shouldBe`
Right []
it "does not drop anonymous nodes when requested" $
fst <$> runAssignment headF "magenta red" ((,) <$> magenta <*> red) (makeState [node Magenta 0 7 [], node Red 8 11 []])
fst <$> runAssignment "magenta red" ((,) <$> magenta <*> red) (makeState [node Magenta 0 7 [], node Red 8 11 []])
`shouldBe`
Right (Out "magenta", Out "red")
it "produces errors with callstacks pointing at the failing assignment" $
first (fmap fst . getCallStack . errorCallStack) (runAssignment headF "blue" red (makeState [node Blue 0 4 []]))
first (fmap fst . getCallStack . errorCallStack) (runAssignment "blue" red (makeState [node Blue 0 4 []]))
`shouldBe`
Left [ "symbol", "red" ]
Left [ "symbol" ]
node :: symbol -> Int -> Int -> [AST symbol] -> AST symbol
node :: symbol -> Int -> Int -> [AST [] symbol] -> AST [] symbol
node symbol start end children = Node symbol (Range start end) (Span (Pos 1 (succ start)) (Pos 1 (succ end))) :< children
data Grammar = Palette | Red | Green | Blue | Magenta
@ -302,14 +301,14 @@ instance Symbol Grammar where
data Out = Out B.ByteString | OutError B.ByteString
deriving (Eq, Show)
red :: HasCallStack => Assignment (AST Grammar) Grammar Out
red :: HasCallStack => Assignment [] Grammar Out
red = Out <$ symbol Red <*> source
green :: HasCallStack => Assignment (AST Grammar) Grammar Out
green :: HasCallStack => Assignment [] Grammar Out
green = Out <$ symbol Green <*> source
blue :: HasCallStack => Assignment (AST Grammar) Grammar Out
blue :: HasCallStack => Assignment [] Grammar Out
blue = Out <$ symbol Blue <*> source
magenta :: HasCallStack => Assignment (AST Grammar) Grammar Out
magenta :: HasCallStack => Assignment [] Grammar Out
magenta = Out <$ symbol Magenta <*> source

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,14 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ArrayTy
(RelationalOperator
(NumberLiteral)
(NumberLiteral))
(Identifier))))))-}

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,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,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,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,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,18 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))))-}

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,7 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Switch)))+}

View File

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

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,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,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,7 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Comment)))-}

View File

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

View File

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

View File

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

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,11 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(NumberLiteral))))))+}

View File

@ -1,11 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "const_declaration"
(VarAssignment
(Identifier)
(Other "expression_list"
(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

@ -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

@ -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

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

View File

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

View File

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

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,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,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,47 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(For
(ExpressionStatements
(FunctionCall
(Identifier))
(Other "goto_statement"
(Identifier))))
(For
(VarDecl
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Break
(Identifier)))
(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue
(Identifier)))
(For
(FunctionCall
(Identifier))
(Continue))
(For
(Other "expression_list"
(Identifier))
(Identifier)
(FunctionCall
(Identifier)
(Identifier))
(Break))))+}

View File

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

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,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,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,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,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,22 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(FunctionTy
(Args
(Identifier))
(Identifier)))
(TypeDecl
(Identifier)
(FunctionTy
(Args
(Identifier)
(Identifier))
(Args
(Identifier)
(Identifier)))))))+}

View File

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

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,16 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Defer
(FunctionCall
(SubscriptAccess
(Identifier)
(Identifier))))
(Go
(FunctionCall
(SubscriptAccess
(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,8 +0,0 @@
{-(ParseError
(Module
(Identifier))
(Identifier)
(Args)
(Identifier)
(StringLiteral)
(StringLiteral))-}

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,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,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,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,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,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,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)
(DecrementStatement)))+}

View File

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

View File

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

View File

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

View File

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

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,10 +0,0 @@
{-(ParseError
(Module
(Identifier))
(Identifier)
(Args)
(VarAssignment
(Identifier)
(Other "expression_list"
(NumberLiteral)
(Identifier))))-}

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,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,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,9 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(ExpressionStatements
(Other "label_statement"
(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,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,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,12 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(Other "type_declaration"
(TypeDecl
(Identifier)
(DictionaryTy
(Identifier)
(Identifier))))))-}

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,17 +0,0 @@
{-(Program
(Module
(Identifier))
(Function
(Identifier)
(Args))
(Method
(Identifier)
(Args
(ParameterDecl
(Identifier)
(Identifier)))
(Args
(ParameterDecl
(Identifier)
(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,16 +0,0 @@
{+(Program
(Module
(Identifier))
(Function
(Identifier)
(Args)
(VarDecl
(Other "expression_list"
(Identifier))
(Other "expression_list"
(Operator
(Other "composite_literal"
(Identifier)
(Pair
(Identifier)
(Identifier))))))))+}

View File

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

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