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

Merge remote-tracking branch 'origin/go-assignment' into 🔥-monolithic-syntax

This commit is contained in:
Rob Rix 2017-11-15 10:57:25 -05:00
commit 2ddd0fafdc
267 changed files with 6844 additions and 3720 deletions

View File

@ -50,6 +50,7 @@ library
, Language.Markdown.Assignment , Language.Markdown.Assignment
, Language.Markdown.Syntax , Language.Markdown.Syntax
, Language.Go.Grammar , Language.Go.Grammar
, Language.Go.Assignment
, Language.Go.Syntax , Language.Go.Syntax
, Language.JSON.Grammar , Language.JSON.Grammar
, Language.JSON.Assignment , Language.JSON.Assignment

View File

@ -152,7 +152,7 @@ tracing f = case getCallStack callStack of
-- | Zero-width production of the current location. -- | 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. -- If assigning at the end of input or at the end of a list of children, the location 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 :: HasCallStack => Assignment ast grammar (Record Location)
location = tracing Location `Then` return location = tracing Location `Then` return

View File

@ -99,12 +99,6 @@ instance Eq1 Module where liftEq = genericLiftEq
instance Ord1 Module where liftCompare = genericLiftCompare instance Ord1 Module where liftCompare = genericLiftCompare
instance Show1 Module where liftShowsPrec = genericLiftShowsPrec instance Show1 Module where liftShowsPrec = genericLiftShowsPrec
data Interface a = Interface { interfaceIdentifier :: !a, interfaceBody :: ![a] }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
instance Eq1 Interface where liftEq = genericLiftEq
instance Show1 Interface where liftShowsPrec = genericLiftShowsPrec
-- | A decorator in Python -- | A decorator in Python
data Decorator a = Decorator { decoratorIdentifier :: !a, decoratorParamaters :: ![a], decoratorBody :: !a } data Decorator a = Decorator { decoratorIdentifier :: !a, decoratorParamaters :: ![a], decoratorBody :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)

View File

@ -180,17 +180,3 @@ data Cast a = Cast { castSubject :: !a, castType :: !a }
instance Eq1 Cast where liftEq = genericLiftEq instance Eq1 Cast where liftEq = genericLiftEq
instance Ord1 Cast where liftCompare = genericLiftCompare instance Ord1 Cast where liftCompare = genericLiftCompare
instance Show1 Cast where liftShowsPrec = genericLiftShowsPrec instance Show1 Cast where liftShowsPrec = genericLiftShowsPrec
-- | Increment (e.g. 1++ in C or Go).
newtype Increment a = Increment a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable)
instance Eq1 Increment where liftEq = genericLiftEq
instance Show1 Increment where liftShowsPrec = genericLiftShowsPrec
-- | Decrement (e.g. 1-- in C or Go).
newtype Decrement a = Decrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable)
instance Eq1 Decrement where liftEq = genericLiftEq
instance Show1 Decrement where liftShowsPrec = genericLiftShowsPrec

View File

@ -159,20 +159,42 @@ instance Eq1 Set where liftEq = genericLiftEq
instance Ord1 Set where liftCompare = genericLiftCompare instance Ord1 Set where liftCompare = genericLiftCompare
instance Show1 Set where liftShowsPrec = genericLiftShowsPrec instance Show1 Set where liftShowsPrec = genericLiftShowsPrec
-- Pointers
-- | A declared pointer (e.g. var pointer *int in Go)
newtype Pointer a = Pointer a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Pointer where liftEq = genericLiftEq
instance Ord1 Pointer where liftCompare = genericLiftCompare
instance Show1 Pointer where liftShowsPrec = genericLiftShowsPrec
-- | A reference to a pointer's address (e.g. &pointer in Go)
newtype Reference a = Reference a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Reference where liftEq = genericLiftEq
instance Ord1 Reference where liftCompare = genericLiftCompare
instance Show1 Reference where liftShowsPrec = genericLiftShowsPrec
-- Misc -- Misc
-- A channel literal in Go -- A channel literal in Go
newtype Channel a = Channel { channelContent :: a } newtype Channel a = Channel { channelContent :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Channel where liftEq = genericLiftEq instance Eq1 Channel where liftEq = genericLiftEq
instance Ord1 Channel where liftCompare = genericLiftCompare
instance Show1 Channel where liftShowsPrec = genericLiftShowsPrec instance Show1 Channel where liftShowsPrec = genericLiftShowsPrec
-- A composite literal in Go -- A composite literal in Go
data Composite a = Composite { compositeType :: !a, compositeElement :: !a } data Composite a = Composite { compositeType :: !a, compositeElement :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Composite where liftEq = genericLiftEq instance Eq1 Composite where liftEq = genericLiftEq
instance Ord1 Composite where liftCompare = genericLiftCompare
instance Show1 Composite where liftShowsPrec = genericLiftShowsPrec instance Show1 Composite where liftShowsPrec = genericLiftShowsPrec
-- TODO: Object literals as distinct from hash literals? Or coalesce object/hash literals into “key-value literals”? -- TODO: Object literals as distinct from hash literals? Or coalesce object/hash literals into “key-value literals”?

View File

@ -26,9 +26,10 @@ instance Ord1 Else where liftCompare = genericLiftCompare
instance Show1 Else where liftShowsPrec = genericLiftShowsPrec instance Show1 Else where liftShowsPrec = genericLiftShowsPrec
newtype Goto a = Goto { gotoLocation :: a } newtype Goto a = Goto { gotoLocation :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Goto where liftEq = genericLiftEq instance Eq1 Goto where liftEq = genericLiftEq
instance Ord1 Goto where liftCompare = genericLiftCompare
instance Show1 Goto where liftShowsPrec = genericLiftShowsPrec instance Show1 Goto where liftShowsPrec = genericLiftShowsPrec
-- TODO: Alternative definition would flatten if/else if/else chains: data If a = If ![(a, a)] !(Maybe a) -- TODO: Alternative definition would flatten if/else if/else chains: data If a = If ![(a, a)] !(Maybe a)
@ -194,3 +195,19 @@ newtype ScopeExit a = ScopeExit [a]
instance Eq1 ScopeExit where liftEq = genericLiftEq instance Eq1 ScopeExit where liftEq = genericLiftEq
instance Ord1 ScopeExit where liftCompare = genericLiftCompare instance Ord1 ScopeExit where liftCompare = genericLiftCompare
instance Show1 ScopeExit where liftShowsPrec = genericLiftShowsPrec instance Show1 ScopeExit where liftShowsPrec = genericLiftShowsPrec
-- | Post increment operator (e.g. 1++ in Go, or i++ in C).
newtype PostIncrement a = PostIncrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 PostIncrement where liftEq = genericLiftEq
instance Ord1 PostIncrement where liftCompare = genericLiftCompare
instance Show1 PostIncrement where liftShowsPrec = genericLiftShowsPrec
-- | Post decrement operator (e.g. 1-- in Go, or i-- in C).
newtype PostDecrement a = PostDecrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 PostDecrement where liftEq = genericLiftEq
instance Ord1 PostDecrement where liftCompare = genericLiftCompare
instance Show1 PostDecrement where liftShowsPrec = genericLiftShowsPrec

View File

@ -16,10 +16,18 @@ instance Eq1 Annotation where liftEq = genericLiftEq
instance Ord1 Annotation where liftCompare = genericLiftCompare instance Ord1 Annotation where liftCompare = genericLiftCompare
instance Show1 Annotation where liftShowsPrec = genericLiftShowsPrec instance Show1 Annotation where liftShowsPrec = genericLiftShowsPrec
data Alias a = Alias { aliasSubject :: !a, aliasType :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Alias where liftEq = genericLiftEq
instance Ord1 Alias where liftCompare = genericLiftCompare
instance Show1 Alias where liftShowsPrec = genericLiftShowsPrec
data Function a = Function { functionParameters :: [a], functionReturn :: a } data Function a = Function { functionParameters :: [a], functionReturn :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Function where liftEq = genericLiftEq instance Eq1 Function where liftEq = genericLiftEq
instance Ord1 Function where liftCompare = genericLiftCompare
instance Show1 Function where liftShowsPrec = genericLiftShowsPrec instance Show1 Function where liftShowsPrec = genericLiftShowsPrec
newtype Product a = Product { productElements :: [a] } newtype Product a = Product { productElements :: [a] }
@ -30,51 +38,59 @@ instance Ord1 Product where liftCompare = genericLiftCompare
instance Show1 Product where liftShowsPrec = genericLiftShowsPrec instance Show1 Product where liftShowsPrec = genericLiftShowsPrec
data Array a = Array { arraySize :: Maybe a, arrayElementType :: a } data Array a = Array { arraySize :: Maybe a, arrayElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Array where liftEq = genericLiftEq instance Eq1 Array where liftEq = genericLiftEq
instance Ord1 Array where liftCompare = genericLiftCompare
instance Show1 Array where liftShowsPrec = genericLiftShowsPrec instance Show1 Array where liftShowsPrec = genericLiftShowsPrec
newtype BiDirectionalChannel a = BiDirectionalChannel { biDirectionalChannelElementType :: a } newtype BiDirectionalChannel a = BiDirectionalChannel { biDirectionalChannelElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 BiDirectionalChannel where liftEq = genericLiftEq instance Eq1 BiDirectionalChannel where liftEq = genericLiftEq
instance Ord1 BiDirectionalChannel where liftCompare = genericLiftCompare
instance Show1 BiDirectionalChannel where liftShowsPrec = genericLiftShowsPrec instance Show1 BiDirectionalChannel where liftShowsPrec = genericLiftShowsPrec
newtype Interface a = Interface { interfaceElements :: [a] } newtype Interface a = Interface { interfaceElements :: [a] }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Interface where liftEq = genericLiftEq instance Eq1 Interface where liftEq = genericLiftEq
instance Ord1 Interface where liftCompare = genericLiftCompare
instance Show1 Interface where liftShowsPrec = genericLiftShowsPrec instance Show1 Interface where liftShowsPrec = genericLiftShowsPrec
data Map a = Map { mapKeyType :: a, mapElementType :: a } data Map a = Map { mapKeyType :: a, mapElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Map where liftEq = genericLiftEq instance Eq1 Map where liftEq = genericLiftEq
instance Ord1 Map where liftCompare = genericLiftCompare
instance Show1 Map where liftShowsPrec = genericLiftShowsPrec instance Show1 Map where liftShowsPrec = genericLiftShowsPrec
newtype Pointer a = Pointer { pointerType :: a } newtype Pointer a = Pointer { pointerType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Pointer where liftEq = genericLiftEq instance Eq1 Pointer where liftEq = genericLiftEq
instance Ord1 Pointer where liftCompare = genericLiftCompare
instance Show1 Pointer where liftShowsPrec = genericLiftShowsPrec instance Show1 Pointer where liftShowsPrec = genericLiftShowsPrec
newtype ReceiveChannel a = ReceiveChannel { receiveChannelElementType :: a } newtype ReceiveChannel a = ReceiveChannel { receiveChannelElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 ReceiveChannel where liftEq = genericLiftEq instance Eq1 ReceiveChannel where liftEq = genericLiftEq
instance Ord1 ReceiveChannel where liftCompare = genericLiftCompare
instance Show1 ReceiveChannel where liftShowsPrec = genericLiftShowsPrec instance Show1 ReceiveChannel where liftShowsPrec = genericLiftShowsPrec
newtype SendChannel a = SendChannel { sendChannelElementType :: a } newtype SendChannel a = SendChannel { sendChannelElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 SendChannel where liftEq = genericLiftEq instance Eq1 SendChannel where liftEq = genericLiftEq
instance Ord1 SendChannel where liftCompare = genericLiftCompare
instance Show1 SendChannel where liftShowsPrec = genericLiftShowsPrec instance Show1 SendChannel where liftShowsPrec = genericLiftShowsPrec
newtype Slice a = Slice { sliceElementType :: a } newtype Slice a = Slice { sliceElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Slice where liftEq = genericLiftEq instance Eq1 Slice where liftEq = genericLiftEq
instance Ord1 Slice where liftCompare = genericLiftCompare
instance Show1 Slice where liftShowsPrec = genericLiftShowsPrec instance Show1 Slice where liftShowsPrec = genericLiftShowsPrec
data TypeParameters a = TypeParameters { typeParameters :: ![a] } data TypeParameters a = TypeParameters { typeParameters :: ![a] }

View File

@ -0,0 +1,649 @@
{-# LANGUAGE DataKinds, DeriveAnyClass, RankNTypes, TupleSections, TypeOperators #-}
module Language.Go.Assignment
( assignment
, Syntax
, Grammar
, Term
) where
import Data.Functor (void)
import Data.List.NonEmpty (some1)
import Data.Record
import Data.Syntax (contextualize, emptyTerm, parseError, handleError, infixContext, makeTerm, makeTerm', makeTerm1)
import qualified Data.Syntax as Syntax
import Data.Syntax.Assignment hiding (Assignment, Error)
import qualified Data.Syntax.Assignment as Assignment
import qualified Data.Syntax.Comment as Comment
import qualified Data.Syntax.Declaration as Declaration
import qualified Data.Syntax.Expression as Expression
import qualified Data.Syntax.Literal as Literal
import qualified Data.Syntax.Statement as Statement
import qualified Data.Syntax.Type as Type
import qualified Data.Term as Term
import Data.Union
import GHC.Stack
import Language.Go.Grammar as Grammar
import Language.Go.Syntax as Go.Syntax
type Syntax =
'[ Comment.Comment
, Declaration.Constructor
, Declaration.Function
, Declaration.Import
, Declaration.Method
, Declaration.Module
, Expression.Arithmetic
, Expression.Bitwise
, Expression.Boolean
, Expression.Call
, Expression.Comparison
, Expression.Subscript
, Statement.PostDecrement
, Statement.PostIncrement
, Expression.MemberAccess
, Go.Syntax.DefaultPattern
, Go.Syntax.Defer
, Go.Syntax.Field
, Go.Syntax.Go
, Go.Syntax.Label
, Go.Syntax.ParenthesizedType
, Go.Syntax.Receive
, Go.Syntax.RuneLiteral
, Go.Syntax.Select
, Go.Syntax.Send
, Go.Syntax.Slice
, Go.Syntax.TypeAssertion
, Go.Syntax.TypeConversion
, Go.Syntax.TypeSwitch
, Go.Syntax.TypeSwitchGuard
, Go.Syntax.Variadic
, Literal.Array
, Literal.Channel
, Literal.Complex
, Literal.Composite
, Literal.Float
, Literal.Hash
, Literal.Integer
, Literal.KeyValue
, Literal.Pointer
, Literal.Reference
, Literal.TextElement
, Statement.Assignment
, Statement.Break
, Statement.Continue
, Statement.For
, Statement.ForEach
, Statement.Goto
, Statement.If
, Statement.Match
, Statement.NoOp
, Statement.Pattern
, Statement.Return
, Syntax.Context
, Syntax.Error
, Syntax.Empty
, Syntax.Identifier
, Syntax.Program
, Type.Alias
, Type.Annotation
, Type.Array
, Type.BiDirectionalChannel
, Type.Function
, Type.Interface
, Type.Map
, Type.Pointer
, Type.ReceiveChannel
, Type.SendChannel
, Type.Slice
, []
]
type Term = Term.Term (Union Syntax) (Record Location)
type Assignment = HasCallStack => Assignment.Assignment [] Grammar Term
-- | Assignment from AST in Go's grammar onto a program in Go's syntax.
assignment :: Assignment
assignment = handleError $ makeTerm <$> symbol SourceFile <*> children (Syntax.Program <$> many expression) <|> parseError
expression :: Assignment
expression = term (handleError (choice expressionChoices))
expressionChoices :: [Assignment.Assignment [] Grammar Term]
expressionChoices =
[ assignment'
, arrayType
, binaryExpression
, block
, breakStatement
, callExpression
, channelType
, comment
, communicationClause
, compositeLiteral
, continueStatement
, varDeclaration
, varSpecification
, decStatement
, defaultCase
, deferStatement
, element
, elseClause
, emptyStatement
, expressionCaseClause
, expressionList
, expressionSwitchStatement
, fallThroughStatement
, fieldDeclaration
, fieldIdentifier
, floatLiteral
, forStatement
, functionDeclaration
, functionType
, goStatement
, gotoStatement
, ifInitializer
, ifStatement
, imaginaryLiteral
, incStatement
, identifier
, implicitLengthArrayType
, importDeclaration
, importSpec
, indexExpression
, interfaceType
, interpretedStringLiteral
, intLiteral
, keyedElement
, labelName'
, labelStatement'
, literalValue
, mapType
, methodDeclaration
, methodSpec
, packageClause
, packageIdentifier
, parameterDeclaration
, parameters
, parenthesizedExpression
, parenthesizedType
, pointerType
, qualifiedType
, rawStringLiteral
, receiveStatement
, returnStatement
, runeLiteral
, selectStatement
, selectorExpression
, sendStatement
, shortVarDeclaration
, sliceExpression
, sliceType
, structType
, typeAssertion
, typeConversion
, typeDeclaration
, typeIdentifier
, typeSwitchStatement
, typeSwitchGuard
, typeCase
, typeCaseClause
, unaryExpression
, variadicArgument
, variadicParameterDeclaration
]
identifiers :: Assignment
identifiers = mk <$> location <*> many identifier
where
mk _ [a] = a
mk loc children = makeTerm loc children
expressions :: Assignment
expressions = mk <$> location <*> many expression
where
mk _ [a] = a
mk loc children = makeTerm loc children
types :: Assignment
types = arrayType
<|> channelType
<|> functionType
<|> implicitLengthArrayType
<|> interfaceType
<|> mapType
<|> parenthesizedType
<|> pointerType
<|> qualifiedType
<|> sliceType
<|> structType
<|> typeAssertion
<|> typeConversion
<|> typeDeclaration
<|> typeIdentifier
<|> typeCase
<|> typeCaseClause
<|> typeSwitchGuard
<|> typeSwitchStatement
-- Literals
element :: Assignment
element = symbol Element *> children expression
imaginaryLiteral :: Assignment
imaginaryLiteral = makeTerm <$> symbol ImaginaryLiteral <*> (Literal.Complex <$> source)
literalValue :: Assignment
literalValue = makeTerm <$> symbol LiteralValue <*> children (many expression)
compositeLiteral :: Assignment
compositeLiteral = makeTerm <$> symbol CompositeLiteral <*> children (Literal.Composite <$> expression <*> expression)
intLiteral :: Assignment
intLiteral = makeTerm <$> symbol IntLiteral <*> (Literal.Integer <$> source)
floatLiteral :: Assignment
floatLiteral = makeTerm <$> symbol FloatLiteral <*> (Literal.Float <$> source)
rawStringLiteral :: Assignment
rawStringLiteral = makeTerm <$> symbol RawStringLiteral <*> (Literal.TextElement <$> source)
typeIdentifier :: Assignment
typeIdentifier = makeTerm <$> symbol TypeIdentifier <*> (Syntax.Identifier <$> source)
identifier :: Assignment
identifier = makeTerm <$> (symbol Identifier <|> symbol Identifier') <*> (Syntax.Identifier <$> source)
fieldIdentifier :: Assignment
fieldIdentifier = makeTerm <$> symbol FieldIdentifier <*> (Syntax.Identifier <$> source)
packageIdentifier :: Assignment
packageIdentifier = makeTerm <$> symbol PackageIdentifier <*> (Syntax.Identifier <$> source)
parenthesizedType :: Assignment
parenthesizedType = makeTerm <$> symbol Grammar.ParenthesizedType <*> children (Go.Syntax.ParenthesizedType <$> expression)
interpretedStringLiteral :: Assignment
interpretedStringLiteral = makeTerm <$> symbol InterpretedStringLiteral <*> (Literal.TextElement <$> source)
comment :: Assignment
comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)
runeLiteral :: Assignment
runeLiteral = makeTerm <$> symbol Grammar.RuneLiteral <*> (Go.Syntax.RuneLiteral <$> source)
-- Primitive Types
qualifiedType :: Assignment
qualifiedType = makeTerm <$> symbol QualifiedType <*> children (Expression.MemberAccess <$> expression <*> expression)
arrayType :: Assignment
arrayType = makeTerm <$> symbol ArrayType <*> children (Type.Array . Just <$> expression <*> (expression <|> arrayType))
implicitLengthArrayType :: Assignment
implicitLengthArrayType = makeTerm <$> symbol ImplicitLengthArrayType <*> children (Type.Array Nothing <$> expression)
functionType :: Assignment
functionType = makeTerm <$> symbol FunctionType <*> children (Type.Function <$> many parameters <*> returnType)
where
returnType = symbol Parameters *> children expressions <|> expression <|> emptyTerm
sliceType :: Assignment
sliceType = makeTerm <$> symbol SliceType <*> children (Type.Slice <$> expression)
channelType :: Assignment
channelType = (makeTerm <$> symbol ChannelType <*> children (token AnonLAngleMinus *> token AnonChan *> (Type.ReceiveChannel <$> expression)))
<|> (makeTerm <$> symbol ChannelType <*> children (token AnonChan *> token AnonLAngleMinus *> (Type.SendChannel <$> expression)))
<|> (makeTerm <$> symbol ChannelType <*> children (token AnonChan *> (Type.BiDirectionalChannel <$> expression)))
structType :: Assignment
structType = handleError $ makeTerm <$> symbol StructType <*> children (Declaration.Constructor <$> emptyTerm <*> many expression)
interfaceType :: Assignment
interfaceType = handleError $ makeTerm <$> symbol InterfaceType <*> children (Type.Interface <$> many expression)
mapType :: Assignment
mapType = handleError $ makeTerm <$> symbol MapType <*> children (Type.Map <$> expression <*> expression)
pointerType :: Assignment
pointerType = handleError $ makeTerm <$> symbol PointerType <*> children (Type.Pointer <$> expression)
fieldDeclaration :: Assignment
fieldDeclaration = mkFieldDeclarationWithTag <$> symbol FieldDeclaration <*> children ((,,) <$> (manyTermsTill expression (void (symbol TypeIdentifier)) <|> (many expression)) <*> optional expression <*> optional expression)
where
mkFieldDeclarationWithTag loc (fields, (Just type'), (Just tag)) = makeTerm loc $ Go.Syntax.Field [type', tag] (makeTerm loc fields) --Type.Annotation (makeTerm loc (Type.Annotation (makeTerm loc fields) type')) tag
mkFieldDeclarationWithTag loc (fields, (Just type'), Nothing) = makeTerm loc $ Go.Syntax.Field [type'] (makeTerm loc fields)
mkFieldDeclarationWithTag loc (fields, Nothing, (Just tag)) = makeTerm loc $ Go.Syntax.Field [tag] (makeTerm loc fields)
mkFieldDeclarationWithTag loc (fields, Nothing, Nothing) = makeTerm loc $ Go.Syntax.Field [] (makeTerm loc fields)
-- Type Declarations
channelTypeDeclaration :: Assignment
channelTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> channelType)
functionTypeDeclaration :: Assignment
functionTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> functionType)
interfaceTypeDeclaration :: Assignment
interfaceTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> interfaceType)
mapTypeDeclaration :: Assignment
mapTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> mapType)
structTypeDeclaration :: Assignment
structTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> structType)
qualifiedTypeDeclaration :: Assignment
qualifiedTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> qualifiedType)
arrayTypeDeclaration :: Assignment
arrayTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> arrayType)
sliceTypeDeclaration :: Assignment
sliceTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> sliceType)
pointerTypeDeclaration :: Assignment
pointerTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> pointerType)
typeAlias :: Assignment
typeAlias = makeTerm <$> symbol TypeAlias <*> children (Type.Alias <$> expression <*> expression)
typeIdentifierDeclaration :: Assignment
typeIdentifierDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> expression)
typeDeclaration :: Assignment
typeDeclaration = handleError $ makeTerm <$> symbol TypeDeclaration <*> children (many ( arrayTypeDeclaration
<|> channelTypeDeclaration
<|> functionTypeDeclaration
<|> interfaceTypeDeclaration
<|> qualifiedTypeDeclaration
<|> pointerTypeDeclaration
<|> sliceTypeDeclaration
<|> structTypeDeclaration
<|> mapTypeDeclaration
<|> typeAlias
<|> typeIdentifierDeclaration ))
-- Expressions
indexExpression :: Assignment
indexExpression = makeTerm <$> symbol IndexExpression <*> children (Expression.Subscript <$> expression <*> many expression)
sliceExpression :: Assignment
sliceExpression = makeTerm <$> symbol SliceExpression <*> children ( (Go.Syntax.Slice <$> expression <*> expression <*> expression <*> expression)
<|> (Go.Syntax.Slice <$> expression <*> emptyTerm <* symbol AnonColon <*> expression <* symbol AnonColon <*> expression)
<|> (Go.Syntax.Slice <$> expression <*> emptyTerm <* symbol AnonColon <*> expression <*> emptyTerm)
<|> (Go.Syntax.Slice <$> expression <*> expression <*> expression <*> emptyTerm)
<|> (Go.Syntax.Slice <$> expression <*> expression <*> emptyTerm <*> emptyTerm)
<|> (Go.Syntax.Slice <$> expression <*> emptyTerm <*> emptyTerm <*> emptyTerm))
parenthesizedExpression :: Assignment
parenthesizedExpression = symbol ParenthesizedExpression *> children expressions
selectorExpression :: Assignment
selectorExpression = makeTerm <$> symbol SelectorExpression <*> children (Expression.MemberAccess <$> expression <*> expression)
typeAssertion :: Assignment
typeAssertion = makeTerm <$> symbol TypeAssertionExpression <*> children (Go.Syntax.TypeAssertion <$> expression <*> expression)
typeConversion :: Assignment
typeConversion = makeTerm <$> symbol TypeConversionExpression <*> children (Go.Syntax.TypeConversion <$> expression <*> expression)
unaryExpression :: Assignment
unaryExpression = symbol UnaryExpression >>= \ location -> (notExpression location) <|> (unaryMinus location) <|> unaryPlus <|> unaryAmpersand <|> unaryReceive <|> unaryPointer <|> unaryComplement
where
notExpression location = makeTerm location . Expression.Not <$> children (symbol AnonBang *> expression)
unaryMinus location = makeTerm location . Expression.Negate <$> children (symbol AnonMinus *> expression)
unaryPlus = children (symbol AnonPlus *> expression)
unaryAmpersand = children (makeTerm <$> symbol AnonAmpersand <*> (Literal.Reference <$> expression))
unaryReceive = children (makeTerm <$> symbol AnonLAngleMinus <*> (Go.Syntax.Receive <$> emptyTerm <*> expression))
unaryPointer = children (makeTerm <$> symbol AnonStar <*> (Literal.Pointer <$> expression))
unaryComplement = children (makeTerm <$> symbol AnonCaret <*> (Expression.Complement <$> expression))
binaryExpression :: Assignment
binaryExpression = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expression expression
[ (inj .) . Expression.Plus <$ symbol AnonPlus
, (inj .) . Expression.Minus <$ symbol AnonMinus
, (inj .) . Expression.Times <$ symbol AnonStar
, (inj .) . Expression.DividedBy <$ symbol AnonSlash
, (inj .) . Expression.Modulo <$ symbol AnonPercent
, (inj .) . Expression.Or <$ symbol AnonPipePipe
, (inj .) . Expression.And <$ symbol AnonAmpersandAmpersand
, (inj .) . Expression.LessThan <$ symbol AnonLAngle
, (inj .) . Expression.LessThanEqual <$ symbol AnonLAngleEqual
, (inj .) . Expression.GreaterThan <$ symbol AnonRAngle
, (inj .) . Expression.GreaterThanEqual <$ symbol AnonRAngleEqual
, (inj .) . invert Expression.Equal <$ symbol AnonBangEqual
, (inj .) . Expression.Equal <$ symbol AnonEqualEqual
, (inj .) . Expression.BOr <$ symbol AnonPipe
, (inj .) . Expression.BAnd <$ symbol AnonAmpersand
, (inj .) . Expression.BAnd <$ symbol AnonAmpersandCaret
, (inj .) . Expression.BXOr <$ symbol AnonCaret
, (inj .) . Expression.LShift <$ symbol AnonLAngleLAngle
, (inj .) . Expression.RShift <$ symbol AnonRAngleRAngle
])
where
invert cons a b = Expression.Not (makeTerm1 (cons a b))
block :: Assignment
block = symbol Block *> children expressions
expressionCase :: Assignment
expressionCase = makeTerm <$> symbol ExpressionCase <*> (Statement.Pattern <$> children expressions <*> expressions)
defaultCase :: Assignment
defaultCase = makeTerm <$> symbol DefaultCase <*> children (Go.Syntax.DefaultPattern <$> (expressions <|> emptyTerm))
defaultExpressionCase :: Assignment
defaultExpressionCase = makeTerm <$> symbol DefaultCase <*> (Go.Syntax.DefaultPattern <$ source <*> (expressions <|> emptyTerm))
expressionCaseClause :: Assignment
expressionCaseClause = symbol ExpressionCaseClause *> children (expressionCase <|> defaultExpressionCase)
expressionSwitchStatement :: Assignment
expressionSwitchStatement = makeTerm <$> symbol ExpressionSwitchStatement <*> children (Statement.Match <$> (expression <|> emptyTerm) <*> (expressionCaseClauses <|> emptyTerm))
where
expressionCaseClauses = makeTerm <$> location <*> many expressionCaseClause
typeSwitchStatement :: Assignment
typeSwitchStatement = makeTerm <$> symbol TypeSwitchStatement <*> children (Go.Syntax.TypeSwitch <$> _typeSwitchSubject <*> expressions)
where
_typeSwitchSubject = makeTerm <$> location <*> manyTermsTill expression (void (symbol TypeCaseClause))
typeSwitchGuard :: Assignment
typeSwitchGuard = makeTerm <$> symbol Grammar.TypeSwitchGuard <*> children (Go.Syntax.TypeSwitchGuard <$> expressions)
typeCaseClause :: Assignment
typeCaseClause = makeTerm <$> symbol TypeCaseClause <*> children (Statement.Pattern <$> expression <*> expressions)
typeCase :: Assignment
typeCase = symbol TypeCase *> children expression
fallThroughStatement :: Assignment
fallThroughStatement = makeTerm <$> symbol FallthroughStatement <*> (Statement.Pattern <$> (makeTerm <$> location <*> (Syntax.Identifier <$> source)) <*> emptyTerm)
variadicArgument :: Assignment
variadicArgument = makeTerm <$> symbol VariadicArgument <*> children (Go.Syntax.Variadic <$> pure [] <*> expression)
callExpression :: Assignment
callExpression = makeTerm <$> symbol CallExpression <*> children (Expression.Call <$> pure [] <*> expression <*> many expression <*> emptyTerm)
varDeclaration :: Assignment
varDeclaration = (symbol ConstDeclaration <|> symbol VarDeclaration) *> children expressions
varSpecification :: Assignment
varSpecification = makeTerm <$> (symbol ConstSpec <|> symbol VarSpec) <*> children (Statement.Assignment <$> pure [] <*> (annotatedLHS <|> identifiers) <*> expressions)
where
annotatedLHS = makeTerm <$> location <*> (Type.Annotation <$> (makeTerm <$> location <*> (manyTermsTill identifier (void (symbol TypeIdentifier)))) <*> expression)
expressionList :: Assignment
expressionList = symbol ExpressionList *> children expressions
functionDeclaration :: Assignment
functionDeclaration = mkTypedFunctionDeclaration <$> symbol FunctionDeclaration <*> children ((,,,) <$> expression <*> many parameters <*> optional (types <|> identifier <|> returnParameters) <*> optional block)
<|> mkTypedFunctionLiteral <$> symbol FuncLiteral <*> children ((,,,) <$> emptyTerm <*> many parameters <*> optional (types <|> identifier <|> returnParameters) <*> block)
where
mkTypedFunctionDeclaration loc (name', params', types', block') = makeTerm loc (Declaration.Function [(maybe (makeTerm loc Syntax.Empty) id types')] name' params' (maybe (makeTerm loc Syntax.Empty) id block'))
mkTypedFunctionLiteral loc (name', params', types', block') = makeTerm loc (Declaration.Function [(maybe (makeTerm loc Syntax.Empty) id types')] name' params' block')
returnParameters = makeTerm <$> symbol Parameters <*> children (many expression)
variadicParameterDeclaration :: Assignment
variadicParameterDeclaration = mkVariadic <$> symbol VariadicParameterDeclaration <*> children ((,) <$> emptyTerm <*> expression)
<|> mkVariadic <$> symbol VariadicParameterDeclaration <*> children ((,) <$> expression <*> expression)
where
mkVariadic loc (identifier', typeIdentifier') = makeTerm loc (Go.Syntax.Variadic [typeIdentifier'] identifier')
importDeclaration :: Assignment
importDeclaration = makeTerm <$> symbol ImportDeclaration <*> children (Declaration.Import <$> many expression)
importSpec :: Assignment
importSpec = symbol ImportSpec *> children expressions
parameters :: Assignment
parameters = makeTerm <$> symbol Parameters <*> children (many expression)
parameterDeclaration :: Assignment
parameterDeclaration = makeTerm <$> symbol ParameterDeclaration <*> children (many expression)
methodDeclaration :: Assignment
methodDeclaration = mkTypedMethodDeclaration <$> symbol MethodDeclaration <*> children ((,,,,) <$> receiver <*> fieldIdentifier <*> many parameters <*> (expression <|> emptyTerm) <*> block)
where
receiver = symbol Parameters *> children ((symbol ParameterDeclaration *> children expressions) <|> expressions)
mkTypedMethodDeclaration loc (receiver', name', parameters', type'', body') = makeTerm loc (Declaration.Method [type''] receiver' name' parameters' body')
methodSpec :: Assignment
methodSpec = mkMethodSpec <$> symbol MethodSpec <*> children ((,,,,) <$> empty <*> expression <*> parameters <*> (expression <|> parameters <|> emptyTerm) <*> empty)
where
empty = makeTerm <$> location <*> pure Syntax.Empty
mkMethodSpec loc (receiver', name', params, optionaltypeLiteral, body') = makeTerm loc $ Type.Annotation (mkMethod loc receiver' name' params body') optionaltypeLiteral
mkMethod loc empty' name' params empty'' = makeTerm loc $ Declaration.Method [] empty' name' (pure params) empty''
packageClause :: Assignment
packageClause = makeTerm <$> symbol PackageClause <*> children (Declaration.Module <$> expression <*> pure [])
-- Statements
assignment' :: Assignment
assignment' = makeTerm' <$> symbol AssignmentStatement <*> children (infixTerm expressionList expressionList
[ assign <$ symbol AnonEqual
, augmentedAssign Expression.Plus <$ symbol AnonPlusEqual
, augmentedAssign Expression.Minus <$ symbol AnonMinusEqual
, augmentedAssign Expression.Times <$ symbol AnonStarEqual
, augmentedAssign Expression.DividedBy <$ symbol AnonSlashEqual
, augmentedAssign Expression.BOr <$ symbol AnonPipeEqual
, augmentedAssign Expression.BAnd <$ symbol AnonAmpersandEqual
, augmentedAssign Expression.Modulo <$ symbol AnonPercentEqual
, augmentedAssign Expression.RShift <$ symbol AnonRAngleRAngleEqual
, augmentedAssign Expression.LShift <$ symbol AnonLAngleLAngleEqual
, augmentedAssign Expression.BXOr <$ symbol AnonCaretEqual
, augmentedAssign (invert Expression.BAnd) <$ symbol AnonAmpersandCaretEqual
])
where
assign :: Term -> Term -> Union Syntax Term
assign l r = inj (Statement.Assignment [] l r)
augmentedAssign :: f :< Syntax => (Term -> Term -> f Term) -> Term -> Term -> Union Syntax Term
augmentedAssign c l r = assign l (makeTerm1 (c l r))
invert cons a b = Expression.Not (makeTerm1 (cons a b))
emptyStatement :: Assignment
emptyStatement = makeTerm <$> token EmptyStatement <*> (Statement.NoOp <$> emptyTerm)
shortVarDeclaration :: Assignment
shortVarDeclaration = makeTerm <$> symbol ShortVarDeclaration <*> children (Statement.Assignment <$> pure [] <*> expression <*> expression)
sendStatement :: Assignment
sendStatement = makeTerm <$> symbol SendStatement <*> children (Go.Syntax.Send <$> expression <*> expression)
breakStatement :: Assignment
breakStatement = makeTerm <$> symbol BreakStatement <*> children (Statement.Break <$> (labelName' <|> emptyTerm))
continueStatement :: Assignment
continueStatement = makeTerm <$> symbol ContinueStatement <*> children (Statement.Continue <$> (labelName' <|> emptyTerm))
decStatement :: Assignment
decStatement = makeTerm <$> symbol DecStatement <*> children (Statement.PostDecrement <$> expression)
deferStatement :: Assignment
deferStatement = makeTerm <$> symbol DeferStatement <*> children (Go.Syntax.Defer <$> expression)
goStatement :: Assignment
goStatement = makeTerm <$> symbol GoStatement <*> children (Go.Syntax.Go <$> expression)
gotoStatement :: Assignment
gotoStatement = makeTerm <$> symbol GotoStatement <*> children (Statement.Goto <$> expression)
ifStatement :: Assignment
ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> (makeTerm <$> location <*> manyTermsTill expression (void (symbol Block))) <*> expression <*> (expression <|> emptyTerm))
ifInitializer :: Assignment
ifInitializer = symbol IfInitializer *> children expression
elseClause :: Assignment
elseClause = symbol ElseClause *> children expression
forStatement :: Assignment
forStatement = mkForStatement <$> symbol ForStatement <*> children ((,) <$> (forClause <|> rangeClause <|> for <|> emptyClause) <*> expression)
where
mkForStatement loc ((constructor, a, b, c), block') = case (constructor :: [Char]) of
"forEach" -> makeTerm loc $ (Statement.ForEach a b block')
_ -> makeTerm loc $ (Statement.For a b c block')
emptyClause = children (("for",,,) <$> emptyTerm <*> emptyTerm <*> emptyTerm)
rangeClause = symbol RangeClause *> children ( (("forEach",,,) <$> expression <*> expression <*> emptyTerm)
<|> (("forEach",,,) <$> emptyTerm <*> expression <*> emptyTerm))
forClause = symbol ForClause *> children ( (("for",,,) <$> expression <*> expression <*> expression)
<|> (("for",,,) <$> expression <*> expression <*> emptyTerm)
<|> (("for",,,) <$> expression <*> emptyTerm <*> emptyTerm)
<|> (("for",,,) <$> emptyTerm <*> emptyTerm <*> emptyTerm))
for = ("for",,,) <$> emptyTerm <*> expression <*> emptyTerm
incStatement :: Assignment
incStatement = makeTerm <$> symbol IncStatement <*> children (Statement.PostIncrement <$> expression)
keyedElement :: Assignment
keyedElement = makeTerm <$> symbol KeyedElement <*> children (Literal.KeyValue <$> expression <*> expression)
labelName' :: Assignment
labelName' = makeTerm <$> symbol LabelName <*> (Syntax.Identifier <$> source)
labelStatement' :: Assignment
labelStatement' = makeTerm <$> symbol LabelStatement <*> children (Go.Syntax.Label <$> expression <*> (expression <|> emptyTerm))
returnStatement :: Assignment
returnStatement = makeTerm <$> symbol ReturnStatement <*> children (Statement.Return <$> (expression <|> emptyTerm))
receiveStatement :: Assignment
receiveStatement = makeTerm <$> symbol ReceiveStatement <*> children ( (Go.Syntax.Receive <$> expression <*> expression)
<|> (Go.Syntax.Receive <$> emptyTerm <*> expression))
selectStatement :: Assignment
selectStatement = makeTerm <$> symbol SelectStatement <*> children (Go.Syntax.Select <$> expressions)
communicationClause :: Assignment
communicationClause = makeTerm <$> symbol CommunicationClause <*> children (Statement.Pattern <$> (communicationCase <|> defaultCase) <*> (expression <|> emptyTerm))
where
communicationCase = symbol CommunicationCase *> children expression
-- Helpers
-- | Match infix terms separated by any of a list of operators, assigning any comments following each operand.
infixTerm :: HasCallStack
=> Assignment
-> Assignment
-> [Assignment.Assignment [] Grammar (Term -> Term -> Union Syntax Term)]
-> Assignment.Assignment [] Grammar (Union Syntax Term)
infixTerm = infixContext comment
-- | 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)
-- | Match a series of terms or comments until a delimiter is matched
manyTermsTill :: Show b => Assignment.Assignment [] Grammar Term -> Assignment.Assignment [] Grammar b -> Assignment.Assignment [] Grammar [Term]
manyTermsTill step end = manyTill (step <|> comment) end

View File

@ -1,420 +1,137 @@
{-# LANGUAGE DataKinds, DeriveAnyClass, RankNTypes, TypeOperators #-} {-# LANGUAGE DeriveAnyClass #-}
module Language.Go.Syntax module Language.Go.Syntax where
( assignment
, Syntax import Algorithm
, Grammar import Data.Align.Generic
, Term import Data.ByteString (ByteString)
) where import Data.Functor.Classes.Eq.Generic
import Data.Functor.Classes.Ord.Generic
import Data.Functor (void) import Data.Functor.Classes.Show.Generic
import Data.List.NonEmpty (some1) import Data.Mergeable
import Data.Record import GHC.Generics
import Data.Syntax (contextualize, postContextualize, emptyTerm, parseError, handleError, infixContext, makeTerm, makeTerm', makeTerm1)
import qualified Data.Syntax as Syntax -- | Variadic arguments and parameters in Go (e.g. parameter: `param ...Type`, argument: `Type...`).
import Data.Syntax.Assignment hiding (Assignment, Error) data Variadic a = Variadic { variadicContext :: [a], variadicIdentifier :: a }
import qualified Data.Syntax.Assignment as Assignment deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
import qualified Data.Syntax.Comment as Comment
import qualified Data.Syntax.Declaration as Declaration instance Eq1 Variadic where liftEq = genericLiftEq
import qualified Data.Syntax.Expression as Expression instance Ord1 Variadic where liftCompare = genericLiftCompare
import qualified Data.Syntax.Literal as Literal instance Show1 Variadic where liftShowsPrec = genericLiftShowsPrec
import qualified Data.Syntax.Statement as Statement
import qualified Data.Syntax.Type as Type -- | A default pattern in a Go select or switch statement (e.g. `switch { default: s() }`).
import qualified Data.Term as Term newtype DefaultPattern a = DefaultPattern { defaultPatternBody :: a }
import Data.Union deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
import GHC.Stack
import Language.Go.Grammar as Grammar instance Eq1 DefaultPattern where liftEq = genericLiftEq
instance Ord1 DefaultPattern where liftCompare = genericLiftCompare
type Syntax = instance Show1 DefaultPattern where liftShowsPrec = genericLiftShowsPrec
'[ Comment.Comment
, Declaration.Constructor -- | A rune literal in Go (e.g. `'⌘'`).
, Declaration.Function newtype RuneLiteral a = RuneLiteral { runeLiteralContent :: ByteString }
, Declaration.Import deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, Declaration.Interface
, Declaration.Method instance Eq1 RuneLiteral where liftEq = genericLiftEq
, Declaration.Module instance Ord1 RuneLiteral where liftCompare = genericLiftCompare
, Expression.Arithmetic instance Show1 RuneLiteral where liftShowsPrec = genericLiftShowsPrec
, Expression.Bitwise
, Expression.Boolean -- | A label statement in Go (e.g. `label:continue`).
, Expression.Call data Label a = Label { labelName :: !a, labelStatement :: !a }
, Expression.Comparison deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, Expression.Decrement
, Expression.Increment instance Eq1 Label where liftEq = genericLiftEq
, Expression.MemberAccess instance Ord1 Label where liftCompare = genericLiftCompare
, Literal.Array instance Show1 Label where liftShowsPrec = genericLiftShowsPrec
, Literal.Channel
, Literal.Composite -- | A send statement in Go (e.g. `channel <- value`).
, Literal.Hash data Send a = Send { sendReceiver :: !a, sendValue :: !a }
, Literal.Integer deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, Literal.KeyValue
, Literal.TextElement instance Eq1 Send where liftEq = genericLiftEq
, Statement.Assignment instance Ord1 Send where liftCompare = genericLiftCompare
, Statement.Break instance Show1 Send where liftShowsPrec = genericLiftShowsPrec
, Statement.Goto
, Statement.If -- | A defer statement in Go (e.g. `defer x()`).
, Statement.Return newtype Defer a = Defer { deferBody :: a }
, Syntax.Context deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, Syntax.Error
, Syntax.Empty instance Eq1 Defer where liftEq = genericLiftEq
, Syntax.Identifier instance Ord1 Defer where liftCompare = genericLiftCompare
, Syntax.Program instance Show1 Defer where liftShowsPrec = genericLiftShowsPrec
, Type.Annotation
, Type.Array -- | A go statement (i.e. go routine) in Go (e.g. `go x()`).
, Type.BiDirectionalChannel newtype Go a = Go { goBody :: a }
, Type.Function deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, Type.Interface
, Type.Map instance Eq1 Go where liftEq = genericLiftEq
, Type.Pointer instance Ord1 Go where liftCompare = genericLiftCompare
, Type.ReceiveChannel instance Show1 Go where liftShowsPrec = genericLiftShowsPrec
, Type.SendChannel
, Type.Slice -- | A slice expression in Go (e.g. `a[1:4:3]` where a is a list, 1 is the low bound, 4 is the high bound, and 3 is the max capacity).
, [] data Slice a = Slice { sliceName :: !a, sliceLow :: !a, sliceHigh :: !a, sliceCapacity :: !a }
] deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
type Term = Term.Term (Union Syntax) (Record Location) instance Eq1 Slice where liftEq = genericLiftEq
type Assignment = HasCallStack => Assignment.Assignment [] Grammar Term instance Ord1 Slice where liftCompare = genericLiftCompare
instance Show1 Slice where liftShowsPrec = genericLiftShowsPrec
-- | Assignment from AST in Go's grammar onto a program in Go's syntax.
assignment :: Assignment -- | A select statement in Go (e.g. `select { case x := <-c: x() }` where each case is a send or receive operation on channels).
assignment = handleError $ makeTerm <$> symbol SourceFile <*> children (Syntax.Program <$> many expression) <|> parseError data Select a = Select { selectCases :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
expression :: Assignment
expression = term (handleError (choice expressionChoices)) instance Eq1 Select where liftEq = genericLiftEq
instance Ord1 Select where liftCompare = genericLiftCompare
expressionChoices :: [Assignment.Assignment [] Grammar Term] instance Show1 Select where liftShowsPrec = genericLiftShowsPrec
expressionChoices =
[ assignment' -- | A type switch statement in Go (e.g. `switch x.(type) { // cases }`).
, binaryExpression data TypeSwitch a = TypeSwitch { typeSwitchSubject :: !a, typeSwitchCases :: !a }
, block deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, breakStatement
, callExpression instance Eq1 TypeSwitch where liftEq = genericLiftEq
, channelType instance Ord1 TypeSwitch where liftCompare = genericLiftCompare
, comment instance Show1 TypeSwitch where liftShowsPrec = genericLiftShowsPrec
, compositeLiteral
, constVarDeclaration -- | A type switch guard statement in a Go type switch statement (e.g. `switch i := x.(type) { // cases}`).
, constVarSpecification newtype TypeSwitchGuard a = TypeSwitchGuard { typeSwitchGuardSubject :: a }
, decStatement deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, element
, expressionList instance Eq1 TypeSwitchGuard where liftEq = genericLiftEq
, fieldDeclaration instance Ord1 TypeSwitchGuard where liftCompare = genericLiftCompare
, fieldIdentifier instance Show1 TypeSwitchGuard where liftShowsPrec = genericLiftShowsPrec
, functionDeclaration
, functionType -- | A receive statement in Go (e.g. `value = <-channel` )
, gotoStatement data Receive a = Receive { receiveSubject :: !a, receiveExpression :: !a }
, ifStatement deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
, incStatement
, identifier instance Eq1 Receive where liftEq = genericLiftEq
, implicitLengthArrayType instance Ord1 Receive where liftCompare = genericLiftCompare
, importDeclaration instance Show1 Receive where liftShowsPrec = genericLiftShowsPrec
, importSpec
, interfaceType
, interpretedStringLiteral
, intLiteral
, labelName
, literalValue
, mapType
, methodDeclaration
, methodSpec
, packageClause
, packageIdentifier
, parameterDeclaration
, parenthesizedExpression
, parenthesizedType
, pointerType
, rawStringLiteral
, returnStatement
, shortVarDeclaration
, sliceType
, structType
, typeDeclaration
, typeIdentifier
, unaryExpression
]
identifiers :: Assignment
identifiers = mk <$> location <*> many identifier
where mk _ [a] = a
mk loc children = makeTerm loc children
expressions :: Assignment
expressions = mk <$> location <*> many expression
where mk _ [a] = a
mk loc children = makeTerm loc children
-- Literals
element :: Assignment
element = symbol Element *> children expression
literalValue :: Assignment
literalValue = makeTerm <$> symbol LiteralValue <*> children (many expression)
compositeLiteral :: Assignment
compositeLiteral = makeTerm <$> symbol CompositeLiteral <*> children (Literal.Composite <$> expression <*> expression)
intLiteral :: Assignment
intLiteral = makeTerm <$> symbol IntLiteral <*> (Literal.Integer <$> source)
rawStringLiteral :: Assignment
rawStringLiteral = makeTerm <$> symbol RawStringLiteral <*> (Literal.TextElement <$> source)
typeIdentifier :: Assignment
typeIdentifier = makeTerm <$> symbol TypeIdentifier <*> (Syntax.Identifier <$> source)
identifier :: Assignment
identifier = makeTerm <$> symbol Identifier <*> (Syntax.Identifier <$> source)
fieldIdentifier :: Assignment
fieldIdentifier = makeTerm <$> symbol FieldIdentifier <*> (Syntax.Identifier <$> source)
packageIdentifier :: Assignment
packageIdentifier = makeTerm <$> symbol PackageIdentifier <*> (Syntax.Identifier <$> source)
parenthesizedType :: Assignment
parenthesizedType = makeTerm <$> symbol ParenthesizedType <*> (Syntax.Identifier <$> source)
interpretedStringLiteral :: Assignment
interpretedStringLiteral = makeTerm <$> symbol InterpretedStringLiteral <*> (Literal.TextElement <$> source)
comment :: Assignment
comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)
-- Primitive Types
qualifiedType :: Assignment
qualifiedType = makeTerm <$> symbol QualifiedType <*> children (Expression.MemberAccess <$> expression <*> expression)
arrayType :: Assignment
arrayType = makeTerm <$> symbol ArrayType <*> children (Type.Array . Just <$> expression <*> expression)
implicitLengthArrayType :: Assignment
implicitLengthArrayType = makeTerm <$> symbol ImplicitLengthArrayType <*> children (Type.Array Nothing <$> expression)
functionType :: Assignment
functionType = makeTerm <$> symbol FunctionType <*> children (Type.Function <$> parameters <*> returnType)
where parameters = symbol Parameters *> children (many expression)
returnType = symbol Parameters *> children expressions <|> expression <|> emptyTerm
sliceType :: Assignment
sliceType = makeTerm <$> symbol SliceType <*> children (Type.Slice <$> expression)
channelType :: Assignment
channelType = handleError
$ (makeTerm <$> symbol ChannelType <*> (children (token AnonLAngleMinus *> token AnonChan *> (Type.ReceiveChannel <$> expression))))
<|> (makeTerm <$> symbol ChannelType <*> (children (token AnonChan *> token AnonLAngleMinus *> (Type.SendChannel <$> expression))))
<|> (makeTerm <$> symbol ChannelType <*> (children (token AnonChan *> (Type.BiDirectionalChannel <$> expression))))
structType :: Assignment
structType = handleError $ makeTerm <$> symbol StructType <*> children (Declaration.Constructor <$> emptyTerm <*> many expression)
interfaceType :: Assignment
interfaceType = handleError $ makeTerm <$> symbol InterfaceType <*> children (Type.Interface <$> many expression)
mapType :: Assignment
mapType = handleError $ makeTerm <$> symbol MapType <*> children (Type.Map <$> expression <*> expression)
pointerType :: Assignment
pointerType = handleError $ makeTerm <$> symbol PointerType <*> children (Type.Pointer <$> expression)
fieldDeclaration :: Assignment
fieldDeclaration = mkFieldDeclarationWithTag <$> symbol FieldDeclaration <*> children ((,,) <$> many identifier <*> expression <*> optional expression)
where
mkFieldDeclarationWithTag loc (fields, type', (Just tag)) = makeTerm loc $ Type.Annotation (makeTerm loc (Type.Annotation (makeTerm loc fields) type')) tag
mkFieldDeclarationWithTag loc (fields, type', Nothing) = makeTerm loc $ Type.Annotation (makeTerm loc fields) type'
-- Type Declarations -- | A field declaration in a Go struct type declaration.
data Field a = Field { fieldContext :: ![a], fieldName :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
channelTypeDeclaration :: Assignment instance Eq1 Field where liftEq = genericLiftEq
channelTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> channelType) instance Ord1 Field where liftCompare = genericLiftCompare
instance Show1 Field where liftShowsPrec = genericLiftShowsPrec
functionTypeDeclaration :: Assignment -- | A type assertion in Go (e.g. x.(T) where the value of x is not nil and is of type T).
functionTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> functionType) data TypeAssertion a = TypeAssertion { typeAssertionSubject :: !a, typeAssertionType :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
interfaceTypeDeclaration :: Assignment instance Eq1 TypeAssertion where liftEq = genericLiftEq
interfaceTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> interfaceType) instance Ord1 TypeAssertion where liftCompare = genericLiftCompare
instance Show1 TypeAssertion where liftShowsPrec = genericLiftShowsPrec
mapTypeDeclaration :: Assignment data TypeConversion a = TypeConversion { typeConversionType :: !a, typeConversionSubject :: !a }
mapTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> mapType) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
structTypeDeclaration :: Assignment instance Eq1 TypeConversion where liftEq = genericLiftEq
structTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> structType) instance Ord1 TypeConversion where liftCompare = genericLiftCompare
instance Show1 TypeConversion where liftShowsPrec = genericLiftShowsPrec
qualifiedTypeDeclaration :: Assignment newtype ParenthesizedType a = ParenthesizedType a
qualifiedTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> qualifiedType) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
arrayTypeDeclaration :: Assignment instance Eq1 ParenthesizedType where liftEq = genericLiftEq
arrayTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> arrayType) instance Ord1 ParenthesizedType where liftCompare = genericLiftCompare
instance Show1 ParenthesizedType where liftShowsPrec = genericLiftShowsPrec
sliceTypeDeclaration :: Assignment
sliceTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> sliceType)
pointerTypeDeclaration :: Assignment
pointerTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> pointerType)
typeDeclaration :: Assignment
typeDeclaration = handleError $ makeTerm <$> symbol TypeDeclaration <*> children (many ( arrayTypeDeclaration
<|> channelTypeDeclaration
<|> functionTypeDeclaration
<|> interfaceTypeDeclaration
<|> qualifiedTypeDeclaration
<|> pointerTypeDeclaration
<|> sliceTypeDeclaration
<|> structTypeDeclaration
<|> mapTypeDeclaration ))
-- Expressions
parenthesizedExpression :: Assignment
parenthesizedExpression = symbol ParenthesizedExpression *> children expressions
unaryExpression :: Assignment
unaryExpression = symbol UnaryExpression >>= \ location -> (notExpression location) <|> (unaryMinus location) <|> unaryPlus
where notExpression location = makeTerm location . Expression.Not <$> children (symbol AnonBang *> expression)
unaryMinus location = makeTerm location . Expression.Negate <$> children (symbol AnonMinus *> expression)
unaryPlus = children (symbol AnonPlus *> expression)
binaryExpression :: Assignment
binaryExpression = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expression expression
[ (inj .) . Expression.Plus <$ symbol AnonPlus
, (inj .) . Expression.Minus <$ symbol AnonMinus
, (inj .) . Expression.Times <$ symbol AnonStar
, (inj .) . Expression.DividedBy <$ symbol AnonSlash
, (inj .) . Expression.Modulo <$ symbol AnonPercent
, (inj .) . Expression.Or <$ symbol AnonPipePipe
, (inj .) . Expression.And <$ symbol AnonAmpersandAmpersand
, (inj .) . Expression.LessThan <$ symbol AnonLAngle
, (inj .) . Expression.LessThanEqual <$ symbol AnonLAngleEqual
, (inj .) . Expression.GreaterThan <$ symbol AnonRAngle
, (inj .) . Expression.GreaterThanEqual <$ symbol AnonRAngleEqual
, (inj .) . invert Expression.Equal <$ symbol AnonBangEqual
, (inj .) . Expression.Equal <$ symbol AnonEqualEqual
, (inj .) . Expression.BOr <$ symbol AnonPipe
, (inj .) . Expression.BAnd <$ symbol AnonAmpersand
, (inj .) . Expression.BAnd <$ symbol AnonAmpersandCaret
, (inj .) . Expression.BXOr <$ symbol AnonCaret
, (inj .) . Expression.LShift <$ symbol AnonLAngleLAngle
, (inj .) . Expression.RShift <$ symbol AnonRAngleRAngle
])
where invert cons a b = Expression.Not (makeTerm1 (cons a b))
block :: Assignment
block = symbol Block *> children expressions
callExpression :: Assignment
callExpression = makeTerm <$> symbol CallExpression <*> children (Expression.Call <$> pure [] <*> identifier <*> pure [] <*> emptyTerm)
constVarDeclaration :: Assignment
constVarDeclaration = (symbol ConstDeclaration <|> symbol VarDeclaration) *> children expressions
constVarSpecification :: Assignment
constVarSpecification = makeTerm <$> (symbol ConstSpec <|> symbol VarSpec) <*> children (Statement.Assignment
<$> pure []
<*> (annotatedLHS <|> identifiers)
<*> expressions)
where
annotatedLHS = makeTerm <$> location <*> (Type.Annotation
<$> (makeTerm <$> location <*> (manyTermsTill identifier (void (symbol TypeIdentifier))))
<*> expression)
expressionList :: Assignment
expressionList = symbol ExpressionList *> children expressions
functionDeclaration :: Assignment
functionDeclaration = mkTypedFunctionDeclaration <$> symbol FunctionDeclaration <*> children ((,,,) <$> expression <*> parameters <*> (expression <|> emptyTerm) <*> block)
where mkTypedFunctionDeclaration loc (name', params', types', block') = makeTerm loc (Declaration.Function [types'] name' params' block')
parameters = symbol Parameters *> children (many expression)
importDeclaration :: Assignment
importDeclaration = makeTerm <$> symbol ImportDeclaration <*> children (Declaration.Import <$> many expression)
importSpec :: Assignment
importSpec = symbol ImportSpec *> children expressions
methodDeclaration :: Assignment
methodDeclaration = mkTypedMethodDeclaration <$> symbol MethodDeclaration <*> children ((,,,,) <$> receiver <*> fieldIdentifier <*> parameters <*> typeIdentifier <*> block)
where parameters = symbol Parameters *> children (symbol ParameterDeclaration *> children (many expression))
receiver = symbol Parameters *> children (symbol ParameterDeclaration *> children expressions)
mkTypedMethodDeclaration loc (receiver', name', parameters', type'', body') = makeTerm loc (Declaration.Method [type''] receiver' name' parameters' body')
methodSpec :: Assignment
methodSpec = mkMethodSpec <$> symbol MethodSpec <*> children ((,,,,) <$> empty <*> identifier <*> parameters <*> (expression <|> parameters <|> emptyTerm) <*> empty)
where parameters = makeTerm <$> symbol Parameters <*> children (many expression)
empty = makeTerm <$> location <*> pure Syntax.Empty
mkMethodSpec loc (receiver', name', params, optionaltypeLiteral, body') = makeTerm loc $ Type.Annotation (mkMethod loc receiver' name' params body') optionaltypeLiteral
mkMethod loc empty' name' params empty'' = makeTerm loc $ Declaration.Method [] empty' name' (pure params) empty''
packageClause :: Assignment
packageClause = makeTerm <$> symbol PackageClause <*> children (Declaration.Module <$> expression <*> pure [])
parameterDeclaration :: Assignment
parameterDeclaration = symbol ParameterDeclaration *> children expressions
-- Statements
assignment' :: Assignment
assignment' = makeTerm' <$> symbol AssignmentStatement <*> children (infixTerm expressionList expressionList
[ assign <$ symbol AnonEqual
, augmentedAssign Expression.Plus <$ symbol AnonPlusEqual
, augmentedAssign Expression.Minus <$ symbol AnonMinusEqual
, augmentedAssign Expression.Times <$ symbol AnonStarEqual
, augmentedAssign Expression.DividedBy <$ symbol AnonSlashEqual
, augmentedAssign Expression.BOr <$ symbol AnonPipeEqual
, augmentedAssign Expression.BAnd <$ symbol AnonAmpersandEqual
, augmentedAssign Expression.Modulo <$ symbol AnonPercentEqual
, augmentedAssign Expression.RShift <$ symbol AnonRAngleRAngleEqual
, augmentedAssign Expression.LShift <$ symbol AnonLAngleLAngleEqual
, augmentedAssign Expression.BXOr <$ symbol AnonCaretEqual
, augmentedAssign (invert Expression.BAnd) <$ symbol AnonAmpersandCaretEqual
])
where
assign :: Term -> Term -> Union Syntax Term
assign l r = inj (Statement.Assignment [] l r)
augmentedAssign :: f :< Syntax => (Term -> Term -> f Term) -> Term -> Term -> Union Syntax Term
augmentedAssign c l r = assign l (makeTerm1 (c l r))
invert cons a b = Expression.Not (makeTerm1 (cons a b))
shortVarDeclaration :: Assignment
shortVarDeclaration = makeTerm <$> symbol ShortVarDeclaration <*> children (Statement.Assignment <$> pure [] <*> expression <*> expression)
breakStatement :: Assignment
breakStatement = makeTerm <$> symbol BreakStatement <*> children (Statement.Break <$> labelName)
decStatement :: Assignment
decStatement = makeTerm <$> symbol DecStatement <*> children (Expression.Decrement <$> expression)
gotoStatement :: Assignment
gotoStatement = makeTerm <$> symbol GotoStatement <*> children (Statement.Goto <$> expression)
ifStatement :: Assignment
ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> expression <*> expression <*> (expression <|> emptyTerm))
incStatement :: Assignment
incStatement = makeTerm <$> symbol IncStatement <*> children (Expression.Increment <$> expression)
labelName :: Assignment
labelName = makeTerm <$> symbol LabelName <*> (Syntax.Identifier <$> source)
returnStatement :: Assignment
returnStatement = makeTerm <$> symbol ReturnStatement <*> children (Statement.Return <$> (expression <|> emptyTerm))
-- Helpers
-- | Match infix terms separated by any of a list of operators, assigning any comments following each operand.
infixTerm :: HasCallStack
=> Assignment
-> Assignment
-> [Assignment.Assignment [] Grammar (Term -> Term -> Union Syntax Term)]
-> Assignment.Assignment [] Grammar (Union Syntax Term)
infixTerm = infixContext comment
-- | 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)
-- | Match a series of terms or comments until a delimiter is matched
manyTermsTill :: Show b => Assignment.Assignment [] Grammar Term -> Assignment.Assignment [] Grammar b -> Assignment.Assignment [] Grammar [Term]
manyTermsTill step end = manyTill (step <|> comment) end

View File

@ -22,7 +22,7 @@ import Data.Term
import Data.Union import Data.Union
import Foreign.Ptr import Foreign.Ptr
import Language import Language
import qualified Language.Go.Syntax as Go import qualified Language.Go.Assignment as Go
import qualified Language.JSON.Assignment as JSON import qualified Language.JSON.Assignment as JSON
import qualified Language.Markdown.Assignment as Markdown import qualified Language.Markdown.Assignment as Markdown
import qualified Language.Python.Assignment as Python import qualified Language.Python.Assignment as Python

View File

@ -2,4 +2,6 @@ package main
func main() { func main() {
type a [2+2]x type a [2+2]x
type b [3][5]int
type c [2][2][2]float64
} }

View File

@ -2,4 +2,6 @@ package main
func main() { func main() {
type a [1+1]y type a [1+1]y
type d [6][9]int
type e [1][2][3]float64
} }

View File

@ -2,17 +2,42 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (
(Annotation
(Identifier) (Identifier)
(ArrayTy (Array
(RelationalOperator (Plus
{ (NumberLiteral) { (Integer)
->(NumberLiteral) } ->(Integer) }
(Other "+") { (Integer)
{ (NumberLiteral) ->(Integer) })
->(NumberLiteral) })
{ (Identifier) { (Identifier)
->(Identifier) }))))) ->(Identifier) })))
(
(Annotation
{ (Identifier)
->(Identifier) }
(Array
{ (Integer)
->(Integer) }
(Array
{ (Integer)
->(Integer) }
(Identifier)))))
(
(Annotation
{ (Identifier)
->(Identifier) }
(Array
{ (Integer)
->(Integer) }
(Array
(Integer)
(Array
{ (Integer)
->(Integer) }
(Identifier)))))))))

View File

@ -2,17 +2,42 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (
(Annotation
(Identifier) (Identifier)
(ArrayTy (Array
(RelationalOperator (Plus
{ (NumberLiteral) { (Integer)
->(NumberLiteral) } ->(Integer) }
(Other "+") { (Integer)
{ (NumberLiteral) ->(Integer) })
->(NumberLiteral) })
{ (Identifier) { (Identifier)
->(Identifier) }))))) ->(Identifier) })))
(
(Annotation
{ (Identifier)
->(Identifier) }
(Array
{ (Integer)
->(Integer) }
(Array
{ (Integer)
->(Integer) }
(Identifier)))))
(
(Annotation
{ (Identifier)
->(Identifier) }
(Array
{ (Integer)
->(Integer) }
(Array
(Integer)
(Array
{ (Integer)
->(Integer) }
(Identifier)))))))))

View File

@ -2,14 +2,33 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (
(Annotation
(Identifier) (Identifier)
(ArrayTy (Array
(RelationalOperator (Plus
(NumberLiteral) (Integer)
(Other "+") (Integer))
(NumberLiteral)) (Identifier))))
(Identifier)))))) (
(Annotation
(Identifier)
(Array
(Integer)
(Array
(Integer)
(Identifier)))))
(
(Annotation
(Identifier)
(Array
(Integer)
(Array
(Integer)
(Array
(Integer)
(Identifier)))))))))

View File

@ -2,14 +2,33 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (
(Annotation
(Identifier) (Identifier)
(ArrayTy (Array
(RelationalOperator (Plus
(NumberLiteral) (Integer)
(Other "+") (Integer))
(NumberLiteral)) (Identifier))))
(Identifier)))))) (
(Annotation
(Identifier)
(Array
(Integer)
(Array
(Integer)
(Identifier)))))
(
(Annotation
(Identifier)
(Array
(Integer)
(Array
(Integer)
(Array
(Integer)
(Identifier)))))))))

View File

@ -2,18 +2,18 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Composite
(Other "composite_literal" (Array
(ArrayTy
(Identifier)) (Identifier))
{ (NumberLiteral) (
->(NumberLiteral) } { (Integer)
{ (NumberLiteral) ->(Integer) }
->(NumberLiteral) } { (Integer)
{ (NumberLiteral) ->(Integer) }
->(NumberLiteral) })))))) { (Integer)
->(Integer) })))))

View File

@ -2,18 +2,18 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Composite
(Other "composite_literal" (Array
(ArrayTy
(Identifier)) (Identifier))
{ (NumberLiteral) (
->(NumberLiteral) } { (Integer)
{ (NumberLiteral) ->(Integer) }
->(NumberLiteral) } { (Integer)
{ (NumberLiteral) ->(Integer) }
->(NumberLiteral) })))))) { (Integer)
->(Integer) })))))

View File

@ -2,15 +2,15 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Composite
(Other "composite_literal" (Array
(ArrayTy
(Identifier)) (Identifier))
(NumberLiteral) (
(NumberLiteral) (Integer)
(NumberLiteral))))))) (Integer)
(Integer))))))

View File

@ -2,15 +2,15 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Composite
(Other "composite_literal" (Array
(ArrayTy
(Identifier)) (Identifier))
(NumberLiteral) (
(NumberLiteral) (Integer)
(NumberLiteral))))))) (Integer)
(Integer))))))

View File

@ -5,4 +5,12 @@ a = 1
b, c += 2, 3 b, c += 2, 3
d *= 3 d *= 3
e += 1 e += 1
f <<= 1
g >>= 2
h /= 2
i ^= 2
j %= 2
k &^= 2
var pointer *Point3D = &Point3D{y: 1000}
} }

View File

@ -1,8 +1,16 @@
package main package main
func main() { func main() {
x = 1 h = 1
y, c += 2, 3 f, g += 2, 3
z *= 3 e *= 3
h += 1 d += 1
c <<= 1
b >>= 2
a /= 2
z ^= 2
y %= 2
x &^= 2
var pointer *Point2D = &Point2D{x: 1000}
} }

View File

@ -2,31 +2,132 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Identifier)) (Integer))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))
(Assignment (Assignment
(Other "expression_list" (
{ (Identifier)
->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
(Other "expression_list" (Plus
(NumberLiteral))) (
(Assignment { (Identifier)
(Other "expression_list" ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
(Other "expression_list" (
(NumberLiteral))))) (Integer)
(Integer))))
{+(Assignment
{+(Identifier)+}
{+(Times
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(Plus
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(LShift
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(RShift
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(DividedBy
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(BXOr
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(Modulo
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(Not
{+(BAnd
{+(Identifier)+}
{+(Integer)+})+})+})+}
{+(Assignment
{+(Identifier)+}
{+(
{+(Pointer
{+(Identifier)+})+}
{+(Reference
{+(Composite
{+(Identifier)+}
{+(
{+(KeyValue
{+(Identifier)+}
{+(Integer)+})+})+})+})+})+})+}
{-(Assignment
{-(Identifier)-}
{-(Times
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(Plus
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(LShift
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(RShift
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(DividedBy
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(BXOr
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(Modulo
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(Not
{-(BAnd
{-(Identifier)-}
{-(Integer)-})-})-})-}
{-(Assignment
{-(Identifier)-}
{-(
{-(Pointer
{-(Identifier)-})-}
{-(Reference
{-(Composite
{-(Identifier)-}
{-(
{-(KeyValue
{-(Identifier)-}
{-(Integer)-})-})-})-})-})-})-})))

View File

@ -2,31 +2,130 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Identifier)) (Integer))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))
(Assignment (Assignment
(Other "expression_list" (
{ (Identifier)
->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
(Other "expression_list" (Plus
(NumberLiteral))) (
(Assignment { (Identifier)
(Other "expression_list" ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
(Other "expression_list" (
(NumberLiteral))))) (Integer)
(Integer))))
{+(Assignment
{+(Identifier)+}
{+(Times
{+(Identifier)+}
{+(Integer)+})+})+}
(Assignment
(Identifier)
{ (Times
{-(Identifier)-}
{-(Integer)-})
->(Plus
{+(Identifier)+}
{+(Integer)+}) })
{+(Assignment
{+(Identifier)+}
{+(LShift
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(RShift
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(DividedBy
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(BXOr
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(Modulo
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(Not
{+(BAnd
{+(Identifier)+}
{+(Integer)+})+})+})+}
{+(Assignment
{+(Identifier)+}
{+(
{+(Pointer
{+(Identifier)+})+}
{+(Reference
{+(Composite
{+(Identifier)+}
{+(
{+(KeyValue
{+(Identifier)+}
{+(Integer)+})+})+})+})+})+})+}
{-(Assignment
{-(Identifier)-}
{-(Plus
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(LShift
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(RShift
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(DividedBy
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(BXOr
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(Modulo
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(Not
{-(BAnd
{-(Identifier)-}
{-(Integer)-})-})-})-}
{-(Assignment
{-(Identifier)-}
{-(
{-(Pointer
{-(Identifier)-})-}
{-(Reference
{-(Composite
{-(Identifier)-}
{-(
{-(KeyValue
{-(Identifier)-}
{-(Integer)-})-})-})-})-})-})-})))

View File

@ -2,27 +2,74 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Integer))
(Other "expression_list"
(NumberLiteral)))
(Assignment (Assignment
(Other "expression_list" (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Other "expression_list" (Plus
(NumberLiteral) (
(NumberLiteral))) (Identifier)
(Assignment
(Other "expression_list"
(Identifier)) (Identifier))
(Other "expression_list" (
(NumberLiteral))) (Integer)
(Integer))))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Times
(Identifier)
(Integer)))
(Assignment
(Identifier)
(Plus
(Identifier)
(Integer)))
(Assignment
(Identifier)
(LShift
(Identifier)
(Integer)))
(Assignment
(Identifier)
(RShift
(Identifier)
(Integer)))
(Assignment
(Identifier)
(DividedBy
(Identifier)
(Integer)))
(Assignment
(Identifier)
(BXOr
(Identifier)
(Integer)))
(Assignment
(Identifier)
(Modulo
(Identifier)
(Integer)))
(Assignment
(Identifier)
(Not
(BAnd
(Identifier)
(Integer))))
(Assignment
(Identifier)
(
(Pointer
(Identifier)) (Identifier))
(Other "expression_list" (Reference
(NumberLiteral))))) (Composite
(Identifier)
(
(KeyValue
(Identifier)
(Integer))))))))))

View File

@ -2,27 +2,74 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Integer))
(Other "expression_list"
(NumberLiteral)))
(Assignment (Assignment
(Other "expression_list" (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Other "expression_list" (Plus
(NumberLiteral) (
(NumberLiteral))) (Identifier)
(Assignment
(Other "expression_list"
(Identifier)) (Identifier))
(Other "expression_list" (
(NumberLiteral))) (Integer)
(Integer))))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Times
(Identifier)
(Integer)))
(Assignment
(Identifier)
(Plus
(Identifier)
(Integer)))
(Assignment
(Identifier)
(LShift
(Identifier)
(Integer)))
(Assignment
(Identifier)
(RShift
(Identifier)
(Integer)))
(Assignment
(Identifier)
(DividedBy
(Identifier)
(Integer)))
(Assignment
(Identifier)
(BXOr
(Identifier)
(Integer)))
(Assignment
(Identifier)
(Modulo
(Identifier)
(Integer)))
(Assignment
(Identifier)
(Not
(BAnd
(Identifier)
(Integer))))
(Assignment
(Identifier)
(
(Pointer
(Identifier)) (Identifier))
(Other "expression_list" (Reference
(NumberLiteral))))) (Composite
(Identifier)
(
(KeyValue
(Identifier)
(Integer))))))))))

View File

@ -2,22 +2,27 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
{ (Identifier) (Call
->(Identifier) }
(Identifier)
(Other "variadic_argument"
(Identifier)))
(FunctionCall
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Identifier) (Identifier)
(Variadic
(Identifier)) (Identifier))
(FunctionCall (Empty))
(Call
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Identifier) (Identifier)
(Other "variadic_argument" (Identifier)
(Identifier))))) (Empty))
(Call
{ (Identifier)
->(Identifier) }
(Identifier)
(Variadic
(Identifier))
(Empty)))))

View File

@ -2,22 +2,27 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
{ (Identifier) (Call
->(Identifier) }
(Identifier)
(Other "variadic_argument"
(Identifier)))
(FunctionCall
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Identifier) (Identifier)
(Variadic
(Identifier)) (Identifier))
(FunctionCall (Empty))
(Call
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Identifier) (Identifier)
(Other "variadic_argument" (Identifier)
(Identifier))))) (Empty))
(Call
{ (Identifier)
->(Identifier) }
(Identifier)
(Variadic
(Identifier))
(Empty)))))

View File

@ -2,19 +2,24 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
(Identifier) (Call
(Identifier)
(Other "variadic_argument"
(Identifier)))
(FunctionCall
(Identifier) (Identifier)
(Identifier) (Identifier)
(Variadic
(Identifier)) (Identifier))
(FunctionCall (Empty))
(Call
(Identifier) (Identifier)
(Identifier) (Identifier)
(Other "variadic_argument" (Identifier)
(Identifier))))) (Empty))
(Call
(Identifier)
(Identifier)
(Variadic
(Identifier))
(Empty)))))

View File

@ -2,19 +2,24 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
(Identifier) (Call
(Identifier)
(Other "variadic_argument"
(Identifier)))
(FunctionCall
(Identifier) (Identifier)
(Identifier) (Identifier)
(Variadic
(Identifier)) (Identifier))
(FunctionCall (Empty))
(Call
(Identifier) (Identifier)
(Identifier) (Identifier)
(Other "variadic_argument" (Identifier)
(Identifier))))) (Empty))
(Call
(Identifier)
(Identifier)
(Variadic
(Identifier))
(Empty)))))

View File

@ -2,4 +2,13 @@ package main
func main() { func main() {
switch { case foo: f1() } switch { case foo: f1() }
switch e {
case 1, 2:
a()
b()
fallthrough
default:
c()
break
}
} }

View File

@ -2,12 +2,41 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Switch { (Match
{+(Case {-(Empty)-}
{+(Case {-([])-})
{+(Other "expression_list" ->(
{+(Identifier)+})+})+} {+(Match
{+(FunctionCall {+(Pattern
{+(Identifier)+})+})+}))) {+(Identifier)+}
{+(Call
{+(Identifier)+}
{+(Empty)+})+})+}
{+([])+})+}
{+(Match
{+(Identifier)+}
{+(
{+(Pattern
{+(
{+(Integer)+}
{+(Integer)+})+}
{+(
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Pattern
{+(Identifier)+}
{+(Empty)+})+})+})+}
{+(DefaultPattern
{+(
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Break
{+(Empty)+})+})+})+})+})+}) }))

View File

@ -2,12 +2,41 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Switch { (
{-(Case {-(Match
{-(Case {-(Pattern
{-(Other "expression_list" {-(Identifier)-}
{-(Identifier)-})-})-} {-(Call
{-(FunctionCall {-(Identifier)-}
{-(Identifier)-})-})-}))) {-(Empty)-})-})-}
{-([])-})-}
{-(Match
{-(Identifier)-}
{-(
{-(Pattern
{-(
{-(Integer)-}
{-(Integer)-})-}
{-(
{-(Call
{-(Identifier)-}
{-(Empty)-})-}
{-(Call
{-(Identifier)-}
{-(Empty)-})-}
{-(Pattern
{-(Identifier)-}
{-(Empty)-})-})-})-}
{-(DefaultPattern
{-(
{-(Call
{-(Identifier)-}
{-(Empty)-})-}
{-(Break
{-(Empty)-})-})-})-})-})-})
->(Match
{+(Empty)+}
{+([])+}) }))

View File

@ -2,6 +2,9 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Switch))) (Match
(Empty)
([]))))

View File

@ -2,12 +2,38 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Switch (
(Case (Match
(Case (Pattern
(Other "expression_list" (Identifier)
(Identifier))) (Call
(FunctionCall (Identifier)
(Identifier)))))) (Empty)))
([]))
(Match
(Identifier)
(
(Pattern
(
(Integer)
(Integer))
(
(Call
(Identifier)
(Empty))
(Call
(Identifier)
(Empty))
(Pattern
(Identifier)
(Empty))))
(DefaultPattern
(
(Call
(Identifier)
(Empty))
(Break
(Empty)))))))))

View File

@ -5,5 +5,7 @@ type (
c1 chan<- chan int c1 chan<- chan int
c2 chan<- chan<- struct{} c2 chan<- chan<- struct{}
c3 chan<- <-chan int c3 chan<- <-chan int
c4 <-chan <-chan int
c5 chan (<-chan int)
) )
} }

View File

@ -5,5 +5,7 @@ type (
c2 chan<- chan string c2 chan<- chan string
c3 chan<- chan<- struct{} c3 chan<- chan<- struct{}
c4 chan<- <-chan string c4 chan<- <-chan string
c4 <-chan <-chan string
c5 chan (<-chan string)
) )
} }

View File

@ -2,26 +2,52 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(ChannelTy (BiDirectionalChannel
(ChannelTy (ReceiveChannel
{ (Identifier) { (Identifier)
->(Identifier) }))) ->(Identifier) })))
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(ChannelTy (SendChannel
(ChannelTy (BiDirectionalChannel
(StructTy)))) (Constructor
(TypeDecl (Empty)))))
{+(Annotation
{+(Identifier)+}
{+(SendChannel
{+(ReceiveChannel
{+(Identifier)+})+})+})+}
(Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(ChannelTy { (SendChannel
(ChannelTy {-(ReceiveChannel
{ (Identifier) {-(Identifier)-})-})
->(Identifier) })))))) ->(ReceiveChannel
{+(ReceiveChannel
{+(Identifier)+})+}) })
{+(Annotation
{+(Identifier)+}
{+(BiDirectionalChannel
{+(ParenthesizedType
{+(ReceiveChannel
{+(Identifier)+})+})+})+})+}
{-(Annotation
{-(Identifier)-}
{-(ReceiveChannel
{-(ReceiveChannel
{-(Identifier)-})-})-})-}
{-(Annotation
{-(Identifier)-}
{-(BiDirectionalChannel
{-(ParenthesizedType
{-(ReceiveChannel
{-(Identifier)-})-})-})-})-})))

View File

@ -2,26 +2,53 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(ChannelTy (BiDirectionalChannel
(ChannelTy (ReceiveChannel
{ (Identifier) { (Identifier)
->(Identifier) }))) ->(Identifier) })))
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(ChannelTy (SendChannel
(ChannelTy (BiDirectionalChannel
(StructTy)))) (Constructor
(TypeDecl (Empty)))))
{ (Identifier) {+(Annotation
->(Identifier) } {+(Identifier)+}
(ChannelTy {+(SendChannel
(ChannelTy {+(ReceiveChannel
{ (Identifier) {+(Identifier)+})+})+})+}
->(Identifier) })))))) {+(Annotation
{+(Identifier)+}
{+(ReceiveChannel
{+(ReceiveChannel
{+(Identifier)+})+})+})+}
{+(Annotation
{+(Identifier)+}
{+(BiDirectionalChannel
{+(ParenthesizedType
{+(ReceiveChannel
{+(Identifier)+})+})+})+})+}
{-(Annotation
{-(Identifier)-}
{-(SendChannel
{-(ReceiveChannel
{-(Identifier)-})-})-})-}
{-(Annotation
{-(Identifier)-}
{-(ReceiveChannel
{-(ReceiveChannel
{-(Identifier)-})-})-})-}
{-(Annotation
{-(Identifier)-}
{-(BiDirectionalChannel
{-(ParenthesizedType
{-(ReceiveChannel
{-(Identifier)-})-})-})-})-})))

View File

@ -2,21 +2,34 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
(Identifier) (Identifier)
(ChannelTy (BiDirectionalChannel
(ChannelTy (ReceiveChannel
(Identifier)))) (Identifier))))
(TypeDecl (Annotation
(Identifier) (Identifier)
(ChannelTy (SendChannel
(ChannelTy (BiDirectionalChannel
(StructTy)))) (Constructor
(TypeDecl (Empty)))))
(Annotation
(Identifier) (Identifier)
(ChannelTy (SendChannel
(ChannelTy (ReceiveChannel
(Identifier))))))) (Identifier))))
(Annotation
(Identifier)
(ReceiveChannel
(ReceiveChannel
(Identifier))))
(Annotation
(Identifier)
(BiDirectionalChannel
(ParenthesizedType
(ReceiveChannel
(Identifier))))))))

View File

@ -2,21 +2,34 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
(Identifier) (Identifier)
(ChannelTy (BiDirectionalChannel
(ChannelTy (ReceiveChannel
(Identifier)))) (Identifier))))
(TypeDecl (Annotation
(Identifier) (Identifier)
(ChannelTy (SendChannel
(ChannelTy (BiDirectionalChannel
(StructTy)))) (Constructor
(TypeDecl (Empty)))))
(Annotation
(Identifier) (Identifier)
(ChannelTy (SendChannel
(ChannelTy (ReceiveChannel
(Identifier))))))) (Identifier))))
(Annotation
(Identifier)
(ReceiveChannel
(ReceiveChannel
(Identifier))))
(Annotation
(Identifier)
(BiDirectionalChannel
(ParenthesizedType
(ReceiveChannel
(Identifier))))))))

View File

@ -2,7 +2,8 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
{ (Comment) { (Comment)
->(Comment) })) ->(Comment) }))

View File

@ -2,7 +2,8 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
{ (Comment) { (Comment)
->(Comment) })) ->(Comment) }))

View File

@ -2,6 +2,7 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Comment))) (Comment)))

View File

@ -2,6 +2,7 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Comment))) (Comment)))

View File

@ -2,16 +2,18 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment (Annotation
{+(Identifier)+} (
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{+(Identifier)+})
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) })
(Other "expression_list" { (Integer)
{ (NumberLiteral) ->(
->(NumberLiteral) } {+(Integer)+}
{+(NumberLiteral)+}))))) {+(Integer)+}) })))

View File

@ -2,17 +2,18 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment (Annotation
{+(Identifier)+} (
{+(Identifier)+} { (Identifier)
{+(Other "expression_list" ->(Identifier) }
{+(NumberLiteral)+})+} {-(Identifier)-})
{-(Identifier)-} { (Identifier)
{-(Identifier)-} ->(Identifier) })
{-(Identifier)-} { (
{-(Other "expression_list" {-(Integer)-}
{-(NumberLiteral)-} {-(Integer)-})
{-(NumberLiteral)-})-})))) ->(Integer) })))

View File

@ -2,11 +2,12 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment (Annotation
(Identifier) (
(Identifier) (Identifier))
(Other "expression_list" (Identifier))
(NumberLiteral)))))) (Integer))))

View File

@ -2,13 +2,15 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment (Annotation
(
(Identifier) (Identifier)
(Identifier) (Identifier))
(Identifier) (Identifier))
(Other "expression_list" (
(NumberLiteral) (Integer)
(NumberLiteral)))))) (Integer)))))

View File

@ -2,16 +2,15 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
{ (VarAssignment { (Identifier)
{-(Identifier)-} ->(
{-(Other "expression_list"
{-(NumberLiteral)-})-})
->(VarAssignment
{+(Identifier)+} {+(Identifier)+}
{+(Identifier)+} {+(Identifier)+}) }
{+(Other "expression_list" { (Integer)
{+(NumberLiteral)+} ->(
{+(NumberLiteral)+})+}) }))) {+(Integer)+}
{+(Integer)+}) })))

View File

@ -2,16 +2,15 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
{ (VarAssignment { (
{-(Identifier)-} {-(Identifier)-}
{-(Identifier)-} {-(Identifier)-})
{-(Other "expression_list" ->(Identifier) }
{-(NumberLiteral)-} { (
{-(NumberLiteral)-})-}) {-(Integer)-}
->(VarAssignment {-(Integer)-})
{+(Identifier)+} ->(Integer) })))
{+(Other "expression_list"
{+(NumberLiteral)+})+}) })))

View File

@ -2,10 +2,9 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Integer))))
(NumberLiteral))))))

View File

@ -2,12 +2,13 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment (
(Identifier) (Identifier)
(Identifier) (Identifier))
(Other "expression_list" (
(NumberLiteral) (Integer)
(NumberLiteral)))))) (Integer)))))

View File

@ -2,17 +2,19 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (
(VarAssignment (Assignment
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Other "expression_list" (Identifier))
(Identifier))) (Assignment
(VarAssignment
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) }
(VarAssignment ([]))
(Assignment
{ (Identifier) { (Identifier)
->(Identifier) })))) ->(Identifier) }
([])))))

View File

@ -2,17 +2,19 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (
(VarAssignment (Assignment
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Other "expression_list" (Identifier))
(Identifier))) (Assignment
(VarAssignment
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) }
(VarAssignment ([]))
(Assignment
{ (Identifier) { (Identifier)
->(Identifier) })))) ->(Identifier) }
([])))))

View File

@ -2,14 +2,16 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (
(VarAssignment (Assignment
(Identifier) (Identifier)
(Other "expression_list"
(Identifier)))
(VarAssignment
(Identifier)) (Identifier))
(VarAssignment (Assignment
(Identifier))))) (Identifier)
([]))
(Assignment
(Identifier)
([])))))

View File

@ -2,14 +2,16 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (
(VarAssignment (Assignment
(Identifier) (Identifier)
(Other "expression_list"
(Identifier)))
(VarAssignment
(Identifier)) (Identifier))
(VarAssignment (Assignment
(Identifier))))) (Identifier)
([]))
(Assignment
(Identifier)
([])))))

View File

@ -2,35 +2,40 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
(Call
(Identifier) (Identifier)
(ChannelTy (BiDirectionalChannel
{ (Identifier)
->(Identifier) }))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
(RelationalOperator (Empty))
(Call
(Identifier) (Identifier)
(Other "-") (BiDirectionalChannel
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
{ (NumberLiteral) (Minus
->(NumberLiteral) }
{ (NumberLiteral)
->(NumberLiteral) })
(FunctionCall
(Identifier) (Identifier)
(DictionaryTy (Identifier))
(Empty))
(Call
(Identifier)
(BiDirectionalChannel
{ (Identifier)
->(Identifier) })
{ (Integer)
->(Integer) }
{ (Integer)
->(Integer) }
(Empty))
(Call
(Identifier)
(Map
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) })))) ->(Identifier) })
(Empty)))))

View File

@ -2,35 +2,40 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
(Call
(Identifier) (Identifier)
(ChannelTy (BiDirectionalChannel
{ (Identifier)
->(Identifier) }))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
(RelationalOperator (Empty))
(Call
(Identifier) (Identifier)
(Other "-") (BiDirectionalChannel
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
{ (NumberLiteral) (Minus
->(NumberLiteral) }
{ (NumberLiteral)
->(NumberLiteral) })
(FunctionCall
(Identifier) (Identifier)
(DictionaryTy (Identifier))
(Empty))
(Call
(Identifier)
(BiDirectionalChannel
{ (Identifier)
->(Identifier) })
{ (Integer)
->(Integer) }
{ (Integer)
->(Integer) }
(Empty))
(Call
(Identifier)
(Map
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) })))) ->(Identifier) })
(Empty)))))

View File

@ -2,28 +2,33 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
(Call
(Identifier) (Identifier)
(ChannelTy (BiDirectionalChannel
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier)) (Identifier))
(RelationalOperator (Empty))
(Call
(Identifier) (Identifier)
(Other "-") (BiDirectionalChannel
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier)) (Identifier))
(NumberLiteral) (Minus
(NumberLiteral))
(FunctionCall
(Identifier) (Identifier)
(DictionaryTy (Identifier))
(Empty))
(Call
(Identifier) (Identifier)
(Identifier))))) (BiDirectionalChannel
(Identifier))
(Integer)
(Integer)
(Empty))
(Call
(Identifier)
(Map
(Identifier)
(Identifier))
(Empty)))))

View File

@ -2,28 +2,33 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(FunctionCall (
(Call
(Identifier) (Identifier)
(ChannelTy (BiDirectionalChannel
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier)) (Identifier))
(RelationalOperator (Empty))
(Call
(Identifier) (Identifier)
(Other "-") (BiDirectionalChannel
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier)) (Identifier))
(NumberLiteral) (Minus
(NumberLiteral))
(FunctionCall
(Identifier) (Identifier)
(DictionaryTy (Identifier))
(Empty))
(Call
(Identifier) (Identifier)
(Identifier))))) (BiDirectionalChannel
(Identifier))
(Integer)
(Integer)
(Empty))
(Call
(Identifier)
(Map
(Identifier)
(Identifier))
(Empty)))))

View File

@ -2,35 +2,27 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) }))))
{ (FloatLiteral)
->(FloatLiteral) }))))

View File

@ -2,35 +2,27 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) })
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) { (Float)
(Other "expression_list" ->(Float) }))))
{ (FloatLiteral)
->(FloatLiteral) }))))

View File

@ -2,30 +2,22 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float)))))
(Other "expression_list"
(FloatLiteral)))))

View File

@ -2,30 +2,22 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float))
(Other "expression_list"
(FloatLiteral)))
(Assignment (Assignment
(Other "expression_list" (Identifier)
(Identifier)) (Float)))))
(Other "expression_list"
(FloatLiteral)))))

View File

@ -21,4 +21,14 @@ for x := range y {
a(x) a(x)
break break
} }
for i, s := range a {
g(i, s)
}
for key, val = range m {
h(key, val)
}
for 1 < 2 {
i()
}
for range ch {}
} }

View File

@ -21,4 +21,14 @@ for {
a(x) a(x)
break break
} }
for s, i := range b {
g(i, s)
}
for k, v = range m {
h(k, v)
}
for 2 < 1 {
j()
}
for range b {}
} }

View File

@ -2,81 +2,169 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
{ (For (
{-(ExpressionStatements (For
{-(FunctionCall (Empty)
{-(Identifier)-})-} (Empty)
{-(Other "goto_statement" (Empty)
{-(Identifier)-})-})-}) (
->(For (Call
{+(FunctionCall (Identifier)
{+(Identifier)+})+} (Empty))
{+(Other "goto_statement" (Goto
{+(Identifier)+})+}) } (Identifier))))
{+(For {+(ForEach
{+(Other "expression_list"
{+(Identifier)+})+}
{+(Identifier)+} {+(Identifier)+}
{+(FunctionCall {+(Identifier)+}
{+(Identifier)+})+} {+(
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Break {+(Break
{+(Identifier)+})+})+} {+(Identifier)+})+})+})+}
{+(For {+(For
{+(FunctionCall {+(Empty)+}
{+(Identifier)+})+} {+(Empty)+}
{+(Empty)+}
{+(
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Continue {+(Continue
{+(Identifier)+})+})+} {+(Identifier)+})+})+})+}
{+(For (For
{+(RelationalOperator { (Assignment
{+(Identifier)+}
{+(Other "<")+}
{+(NumberLiteral)+})+}
{+(IncrementStatement)+}
{+(FunctionCall
{+(Identifier)+})+}
{+(Continue)+})+}
{+(For
{+(ExpressionStatements
{+(FunctionCall
{+(Identifier)+}
{+(Identifier)+})+}
{+(Break)+})+})+}
{-(For
{-(VarDecl
{-(Other "expression_list"
{-(Identifier)-})-}
{-(Other "expression_list"
{-(NumberLiteral)-})-})-}
{-(RelationalOperator
{-(Identifier)-} {-(Identifier)-}
{-(Other "<")-} {-(Integer)-})
{-(NumberLiteral)-})-} ->(LessThan
{-(IncrementStatement)-} {+(Identifier)+}
{-(FunctionCall {+(Integer)+}) }
{-(Identifier)-})-} { (LessThan
{-(Identifier)-}
{-(Integer)-})
->(PostIncrement
{+(Identifier)+}) }
{ (PostIncrement
{-(Identifier)-})
->(Empty) }
(
(Call
(Identifier)
(Empty))
{+(Continue
{+(Empty)+})+}
{-(Break {-(Break
{-(Identifier)-})-})-} {-(Identifier)-})-}))
{+(For
{+(Empty)+}
{+(Empty)+}
{+(Empty)+}
{+(
{+(Call
{+(Identifier)+}
{+(Identifier)+}
{+(Empty)+})+}
{+(Break
{+(Empty)+})+})+})+}
{+(ForEach
{+(
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+}
{+(Call
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+}
{+(Empty)+})+})+}
{+(ForEach
{+(
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+}
{+(Call
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+}
{+(Empty)+})+})+}
{+(For
{+(Empty)+}
{+(LessThan
{+(Integer)+}
{+(Integer)+})+}
{+(Empty)+}
{+(Call
{+(Identifier)+}
{+(Empty)+})+})+}
{+(ForEach
{+(Empty)+}
{+(Identifier)+}
{+([])+})+}
{-(For {-(For
{-(RelationalOperator {-(LessThan
{-(Identifier)-} {-(Identifier)-}
{-(Other "<")-} {-(Integer)-})-}
{-(NumberLiteral)-})-} {-(PostIncrement
{-(IncrementStatement)-}
{-(FunctionCall
{-(Identifier)-})-} {-(Identifier)-})-}
{-(Empty)-}
{-(
{-(Call
{-(Identifier)-}
{-(Empty)-})-}
{-(Continue {-(Continue
{-(Identifier)-})-})-} {-(Identifier)-})-})-})-}
{-(For {-(For
{-(FunctionCall {-(Empty)-}
{-(Identifier)-})-} {-(Empty)-}
{-(Continue)-})-} {-(Empty)-}
{-(For {-(
{-(Other "expression_list" {-(Call
{-(Identifier)-})-}
{-(Identifier)-} {-(Identifier)-}
{-(FunctionCall {-(Empty)-})-}
{-(Continue
{-(Empty)-})-})-})-}
{-(ForEach
{-(Identifier)-}
{-(Identifier)-}
{-(
{-(Call
{-(Identifier)-}
{-(Identifier)-}
{-(Empty)-})-}
{-(Break
{-(Empty)-})-})-})-}
{-(ForEach
{-(
{-(Identifier)-} {-(Identifier)-}
{-(Identifier)-})-} {-(Identifier)-})-}
{-(Break)-})-})) {-(Identifier)-}
{-(Call
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-}
{-(Empty)-})-})-}
{-(ForEach
{-(
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-}
{-(Call
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-}
{-(Empty)-})-})-}
{-(For
{-(Empty)-}
{-(LessThan
{-(Integer)-}
{-(Integer)-})-}
{-(Empty)-}
{-(Call
{-(Identifier)-}
{-(Empty)-})-})-}
{-(ForEach
{-(Empty)-}
{-(Identifier)-}
{-([])-})-})))

View File

@ -2,74 +2,166 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
{ (For (
{-(FunctionCall
{-(Identifier)-})-}
{-(Other "goto_statement"
{-(Identifier)-})-})
->(For
{+(ExpressionStatements
{+(FunctionCall
{+(Identifier)+})+}
{+(Other "goto_statement"
{+(Identifier)+})+})+}) }
{+(For
{+(VarDecl
{+(Other "expression_list"
{+(Identifier)+})+}
{+(Other "expression_list"
{+(NumberLiteral)+})+})+}
{+(RelationalOperator
{+(Identifier)+}
{+(Other "<")+}
{+(NumberLiteral)+})+}
{+(IncrementStatement)+}
{+(FunctionCall
{+(Identifier)+})+}
{+(Break
{+(Identifier)+})+})+}
{+(For
{+(RelationalOperator
{+(Identifier)+}
{+(Other "<")+}
{+(NumberLiteral)+})+}
{+(IncrementStatement)+}
{+(FunctionCall
{+(Identifier)+})+}
{+(Continue
{+(Identifier)+})+})+}
{+(For
{+(FunctionCall
{+(Identifier)+})+}
{+(Continue)+})+}
(For (For
(Other "expression_list" (Empty)
(Identifier)) (Empty)
(Empty)
(
(Call
(Identifier) (Identifier)
(FunctionCall (Empty))
(Goto
(Identifier))))
{+(For
{+(Assignment
{+(Identifier)+}
{+(Integer)+})+}
{+(LessThan
{+(Identifier)+}
{+(Integer)+})+}
{+(PostIncrement
{+(Identifier)+})+}
{+(
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Break
{+(Identifier)+})+})+})+}
{+(For
{+(LessThan
{+(Identifier)+}
{+(Integer)+})+}
{+(PostIncrement
{+(Identifier)+})+}
{+(Empty)+}
{+(
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Continue
{+(Identifier)+})+})+})+}
{+(For
{+(Empty)+}
{+(Empty)+}
{+(Empty)+}
{+(
{+(Call
{+(Identifier)+}
{+(Empty)+})+}
{+(Continue
{+(Empty)+})+})+})+}
(ForEach
(Identifier) (Identifier)
{+(Identifier)+}) (Identifier)
(
(Call
(Identifier)
{+(Identifier)+}
(Empty))
(Break (Break
{-(Identifier)-})) { (Identifier)
->(Empty) })))
{+(ForEach
{+(
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+}
{+(Call
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+}
{+(Empty)+})+})+}
{+(ForEach
{+(
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+}
{+(Call
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+}
{+(Empty)+})+})+}
{+(For
{+(Empty)+}
{+(LessThan
{+(Integer)+}
{+(Integer)+})+}
{+(Empty)+}
{+(Call
{+(Identifier)+}
{+(Empty)+})+})+}
{+(ForEach
{+(Empty)+}
{+(Identifier)+}
{+([])+})+}
{-(For {-(For
{-(FunctionCall {-(Empty)-}
{-(Identifier)-})-} {-(Empty)-}
{-(Empty)-}
{-(
{-(Call
{-(Identifier)-}
{-(Empty)-})-}
{-(Continue {-(Continue
{-(Identifier)-})-})-} {-(Identifier)-})-})-})-}
{-(For {-(For
{-(RelationalOperator {-(LessThan
{-(Identifier)-} {-(Identifier)-}
{-(Other "<")-} {-(Integer)-})-}
{-(NumberLiteral)-})-} {-(PostIncrement
{-(IncrementStatement)-}
{-(FunctionCall
{-(Identifier)-})-} {-(Identifier)-})-}
{-(Continue)-})-} {-(Empty)-}
{-(
{-(Call
{-(Identifier)-}
{-(Empty)-})-}
{-(Continue
{-(Empty)-})-})-})-}
{-(For {-(For
{-(ExpressionStatements {-(Empty)-}
{-(FunctionCall {-(Empty)-}
{-(Empty)-}
{-(
{-(Call
{-(Identifier)-}
{-(Identifier)-}
{-(Empty)-})-}
{-(Break
{-(Empty)-})-})-})-}
{-(ForEach
{-(
{-(Identifier)-} {-(Identifier)-}
{-(Identifier)-})-} {-(Identifier)-})-}
{-(Break)-})-})-})) {-(Identifier)-}
{-(Call
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-}
{-(Empty)-})-})-}
{-(ForEach
{-(
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-}
{-(Call
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-}
{-(Empty)-})-})-}
{-(For
{-(Empty)-}
{-(LessThan
{-(Integer)-}
{-(Integer)-})-}
{-(Empty)-}
{-(Call
{-(Identifier)-}
{-(Empty)-})-})-}
{-(ForEach
{-(Empty)-}
{-(Identifier)-}
{-([])-})-})))

View File

@ -2,48 +2,98 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(For (For
(ExpressionStatements (Empty)
(FunctionCall (Empty)
(Identifier)) (Empty)
(Other "goto_statement" (
(Call
(Identifier)
(Empty))
(Goto
(Identifier)))) (Identifier))))
(For (For
(VarDecl (Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(RelationalOperator
(Identifier) (Identifier)
(Other "<") (Integer))
(NumberLiteral)) (LessThan
(IncrementStatement) (Identifier)
(FunctionCall (Integer))
(PostIncrement
(Identifier)) (Identifier))
(
(Call
(Identifier)
(Empty))
(Break (Break
(Identifier))) (Identifier))))
(For (For
(RelationalOperator (LessThan
(Identifier) (Identifier)
(Other "<") (Integer))
(NumberLiteral)) (PostIncrement
(IncrementStatement)
(FunctionCall
(Identifier)) (Identifier))
(Empty)
(
(Call
(Identifier)
(Empty))
(Continue (Continue
(Identifier))) (Identifier))))
(For (For
(FunctionCall (Empty)
(Identifier)) (Empty)
(Continue)) (Empty)
(For (
(Other "expression_list" (Call
(Identifier))
(Identifier) (Identifier)
(FunctionCall (Empty))
(Continue
(Empty))))
(ForEach
(Identifier)
(Identifier)
(
(Call
(Identifier)
(Identifier)
(Empty))
(Break
(Empty))))
(ForEach
(
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Break)))) (Identifier)
(Call
(Identifier)
(Identifier)
(Identifier)
(Empty)))
(ForEach
(
(Identifier)
(Identifier))
(Identifier)
(Call
(Identifier)
(Identifier)
(Identifier)
(Empty)))
(For
(Empty)
(LessThan
(Integer)
(Integer))
(Empty)
(Call
(Identifier)
(Empty)))
(ForEach
(Empty)
(Identifier)
([])))))

View File

@ -2,38 +2,93 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(For (For
(FunctionCall (Empty)
(Identifier)) (Empty)
(Other "goto_statement" (Empty)
(Identifier))) (
(For (Call
(Other "expression_list"
(Identifier))
(Identifier) (Identifier)
(FunctionCall (Empty))
(Identifier)) (Goto
(Identifier))))
(ForEach
(Identifier)
(Identifier)
(
(Call
(Identifier)
(Empty))
(Break (Break
(Identifier))) (Identifier))))
(For (For
(FunctionCall (Empty)
(Identifier)) (Empty)
(Empty)
(
(Call
(Identifier)
(Empty))
(Continue (Continue
(Identifier))) (Identifier))))
(For (For
(RelationalOperator (LessThan
(Identifier) (Identifier)
(Other "<") (Integer))
(NumberLiteral)) (PostIncrement
(IncrementStatement)
(FunctionCall
(Identifier)) (Identifier))
(Continue)) (Empty)
(
(Call
(Identifier)
(Empty))
(Continue
(Empty))))
(For (For
(ExpressionStatements (Empty)
(FunctionCall (Empty)
(Empty)
(
(Call
(Identifier)
(Identifier)
(Empty))
(Break
(Empty))))
(ForEach
(
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Break))))) (Identifier)
(Call
(Identifier)
(Identifier)
(Identifier)
(Empty)))
(ForEach
(
(Identifier)
(Identifier))
(Identifier)
(Call
(Identifier)
(Identifier)
(Identifier)
(Empty)))
(For
(Empty)
(LessThan
(Integer)
(Integer))
(Empty)
(Call
(Identifier)
(Empty)))
(ForEach
(Empty)
(Identifier)
([])))))

View File

@ -5,3 +5,4 @@ func f1() {}
func f2(a int, b, c, d string) int {} func f2(a int, b, c, d string) int {}
func f2() (int, error) {} func f2() (int, error) {}
func f2() (result int, err error) {} func f2() (result int, err error) {}
func lockedOSThread() bool

View File

@ -5,3 +5,5 @@ func fa() {}
func fb(a int, b, c, d string) int {} func fb(a int, b, c, d string) int {}
func fc() (int, error) {} func fc() (int, error) {}
func fd() (result int, err error) {} func fd() (result int, err error) {}
func fe() () {;}
func lockOSThread() int

View File

@ -2,40 +2,63 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args)) ([])
([]))
(Function (Function
(Empty)
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Args)) ([])
([]))
(Function (Function
(Identifier)
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Args (
(ParameterDecl (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Identifier) (Identifier)
(Identifier) (Identifier)
(ParameterDecl (
(Identifier) (Identifier)
(Identifier))) (Identifier)))
(Identifier)) ([]))
(Function (Function
(Empty)
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Args) ([])
(Args (
(Identifier)
(Identifier))
([]))
(Function
(Empty)
{ (Identifier)
->(Identifier) }
([])
(
(
(Identifier)
(Identifier))
(
(Identifier) (Identifier)
(Identifier))) (Identifier)))
([]))
{+(Function
{+(Empty)+}
{+(Identifier)+}
{+([])+}
{+([])+}
{+(NoOp
{+(Empty)+})+})+}
(Function (Function
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Args) { (Identifier)
(Args ->(Identifier) }
(ParameterDecl ([])
(Identifier) (Empty)))
(Identifier))
(ParameterDecl
(Identifier)
(Identifier)))))

View File

@ -2,40 +2,66 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args)) ([])
([]))
(Function (Function
(Empty)
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Args)) ([])
([]))
(Function (Function
(Identifier)
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Args (
(ParameterDecl (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Identifier) (Identifier)
(Identifier) (Identifier)
(ParameterDecl (
(Identifier) (Identifier)
(Identifier))) (Identifier)))
(Identifier)) ([]))
(Function (Function
(Empty)
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Args) ([])
(Args (
(Identifier)
(Identifier))
([]))
(Function
(Empty)
{ (Identifier)
->(Identifier) }
([])
(
(
(Identifier)
(Identifier))
(
(Identifier) (Identifier)
(Identifier))) (Identifier)))
(Function ([]))
{ (Identifier) {+(Function
->(Identifier) } {+(Identifier)+}
(Args) {+(Identifier)+}
(Args {+([])+}
(ParameterDecl {+(Empty)+})+}
(Identifier) {-(Function
(Identifier)) {-(Empty)-}
(ParameterDecl {-(Identifier)-}
(Identifier) {-([])-}
(Identifier))))) {-([])-}
{-(NoOp
{-(Empty)-})-})-}
{-(Function
{-(Identifier)-}
{-(Identifier)-}
{-([])-}
{-(Empty)-})-})

View File

@ -2,36 +2,50 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args)) ([])
([]))
(Function
(Empty)
(Identifier)
([])
([]))
(Function (Function
(Identifier) (Identifier)
(Args))
(Function
(Identifier) (Identifier)
(Args (
(ParameterDecl (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Identifier) (Identifier)
(Identifier) (Identifier)
(ParameterDecl (
(Identifier) (Identifier)
(Identifier))) (Identifier)))
(Identifier)) ([]))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Args (
(Identifier)
(Identifier))
([]))
(Function
(Empty)
(Identifier)
([])
(
(
(Identifier)
(Identifier))
(
(Identifier) (Identifier)
(Identifier))) (Identifier)))
([]))
(Function (Function
(Identifier) (Identifier)
(Args)
(Args
(ParameterDecl
(Identifier) (Identifier)
(Identifier)) ([])
(ParameterDecl (Empty)))
(Identifier)
(Identifier)))))

View File

@ -2,36 +2,57 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args)) ([])
([]))
(Function
(Empty)
(Identifier)
([])
([]))
(Function (Function
(Identifier) (Identifier)
(Args))
(Function
(Identifier) (Identifier)
(Args (
(ParameterDecl (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Identifier) (Identifier)
(Identifier) (Identifier)
(ParameterDecl (
(Identifier) (Identifier)
(Identifier))) (Identifier)))
(Identifier)) ([]))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Args (
(Identifier)
(Identifier))
([]))
(Function
(Empty)
(Identifier)
([])
(
(
(Identifier)
(Identifier))
(
(Identifier) (Identifier)
(Identifier))) (Identifier)))
([]))
(Function
(Empty)
(Identifier)
([])
([])
(NoOp
(Empty)))
(Function (Function
(Identifier) (Identifier)
(Args)
(Args
(ParameterDecl
(Identifier) (Identifier)
(Identifier)) ([])
(ParameterDecl (Empty)))
(Identifier)
(Identifier)))))

View File

@ -2,18 +2,26 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Function
(AnonymousFunction (Empty)
(Empty)
(
(
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }))
(
{ (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier)
->(Identifier) })
(Return (Return
(Other "expression_list" (
(NumberLiteral) (Integer)
(NumberLiteral))))))))) (Integer)))))))

View File

@ -2,18 +2,26 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Function
(AnonymousFunction (Empty)
(Empty)
(
(
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }))
(
{ (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier)
->(Identifier) })
(Return (Return
(Other "expression_list" (
(NumberLiteral) (Integer)
(NumberLiteral))))))))) (Integer)))))))

View File

@ -2,16 +2,22 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Function
(AnonymousFunction (Empty)
(Empty)
(
(
(Identifier) (Identifier)
(Identifier)))
(
(Identifier) (Identifier)
(Identifier))
(Return (Return
(Other "expression_list" (
(NumberLiteral) (Integer)
(NumberLiteral))))))))) (Integer)))))))

View File

@ -2,16 +2,22 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "const_declaration" (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Function
(AnonymousFunction (Empty)
(Empty)
(
(
(Identifier) (Identifier)
(Identifier)))
(
(Identifier) (Identifier)
(Identifier))
(Return (Return
(Other "expression_list" (
(NumberLiteral) (Integer)
(NumberLiteral))))))))) (Integer)))))))

View File

@ -2,29 +2,31 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(FunctionTy (Function
(Args (
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
{ (Identifier) { (Identifier)
->(Identifier) })) ->(Identifier) }))
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(FunctionTy (Function
(Args (
{-(Identifier)-} {-(Identifier)-}
(Identifier) (Identifier)
{+(Identifier)+}) {+(Identifier)+})
(Args (
{+(ParameterDecl {+(
{+(ChannelTy {+(BiDirectionalChannel
{+(Identifier)+})+})+} {+(Identifier)+})+})+}
{-(Identifier)-} {-(Identifier)-}
(Identifier))))))) (Identifier))
(Empty))))))

View File

@ -2,29 +2,31 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(FunctionTy (Function
(Args (
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) })
{ (Identifier) { (Identifier)
->(Identifier) })) ->(Identifier) }))
(TypeDecl (Annotation
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(FunctionTy (Function
(Args (
{-(Identifier)-} {-(Identifier)-}
(Identifier) (Identifier)
{+(Identifier)+}) {+(Identifier)+})
(Args (
{+(Identifier)+} {+(Identifier)+}
{-(ParameterDecl {-(
{-(ChannelTy {-(BiDirectionalChannel
{-(Identifier)-})-})-} {-(Identifier)-})-})-}
(Identifier))))))) (Identifier))
(Empty))))))

View File

@ -2,21 +2,23 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
(Identifier) (Identifier)
(FunctionTy (Function
(Args (
(Identifier)) (Identifier))
(Identifier))) (Identifier)))
(TypeDecl (Annotation
(Identifier) (Identifier)
(FunctionTy (Function
(Args (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Args (
(Identifier) (Identifier)
(Identifier))))))) (Identifier))
(Empty))))))

View File

@ -2,23 +2,25 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "type_declaration" (
(TypeDecl (Annotation
(Identifier) (Identifier)
(FunctionTy (Function
(Args (
(Identifier)) (Identifier))
(Identifier))) (Identifier)))
(TypeDecl (Annotation
(Identifier) (Identifier)
(FunctionTy (Function
(Args (
(Identifier) (Identifier)
(Identifier)) (Identifier))
(Args (
(ParameterDecl (
(ChannelTy (BiDirectionalChannel
(Identifier))) (Identifier)))
(Identifier))))))) (Identifier))
(Empty))))))

View File

@ -2,19 +2,23 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Defer (Defer
(FunctionCall (Call
(SubscriptAccess (MemberAccess
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }))) ->(Identifier) })
(Empty)))
(Go (Go
(FunctionCall (Call
(SubscriptAccess (MemberAccess
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }))))) ->(Identifier) })
(Empty))))))

View File

@ -2,19 +2,23 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Defer (Defer
(FunctionCall (Call
(SubscriptAccess (MemberAccess
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }))) ->(Identifier) })
(Empty)))
(Go (Go
(FunctionCall (Call
(SubscriptAccess (MemberAccess
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
{ (Identifier) { (Identifier)
->(Identifier) }))))) ->(Identifier) })
(Empty))))))

View File

@ -2,15 +2,19 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Defer (Defer
(FunctionCall (Call
(SubscriptAccess (MemberAccess
(Identifier) (Identifier)
(Identifier)))) (Identifier))
(Empty)))
(Go (Go
(FunctionCall (Call
(SubscriptAccess (MemberAccess
(Identifier) (Identifier)
(Identifier)))))) (Identifier))
(Empty))))))

View File

@ -2,15 +2,19 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(Defer (Defer
(FunctionCall (Call
(SubscriptAccess (MemberAccess
(Identifier) (Identifier)
(Identifier)))) (Identifier))
(Empty)))
(Go (Go
(FunctionCall (Call
(SubscriptAccess (MemberAccess
(Identifier) (Identifier)
(Identifier)))))) (Identifier))
(Empty))))))

View File

@ -1,17 +1,17 @@
(Program (Program
(Module (Module
(Identifier)) (Identifier))
(Other "import_declaration"
(Import
{ (StringLiteral)
->(StringLiteral) })
(Import
{ (StringLiteral)
->(StringLiteral) })
(Import (Import
{ (TextElement)
->(TextElement) }
{ (TextElement)
->(TextElement) }
(
(Identifier) (Identifier)
{ (StringLiteral) { (TextElement)
->(StringLiteral) })) ->(TextElement) }))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args))) ([])
([])))

View File

@ -1,17 +1,17 @@
(Program (Program
(Module (Module
(Identifier)) (Identifier))
(Other "import_declaration"
(Import
{ (StringLiteral)
->(StringLiteral) })
(Import
{ (StringLiteral)
->(StringLiteral) })
(Import (Import
{ (TextElement)
->(TextElement) }
{ (TextElement)
->(TextElement) }
(
(Identifier) (Identifier)
{ (StringLiteral) { (TextElement)
->(StringLiteral) })) ->(TextElement) }))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args))) ([])
([])))

View File

@ -1,14 +1,14 @@
(Program (Program
(Module (Module
(Identifier)) (Identifier))
(Other "import_declaration"
(Import
(StringLiteral))
(Import
(StringLiteral))
(Import (Import
(TextElement)
(TextElement)
(
(Identifier) (Identifier)
(StringLiteral))) (TextElement)))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args))) ([])
([])))

View File

@ -1,14 +1,14 @@
(Program (Program
(Module (Module
(Identifier)) (Identifier))
(Other "import_declaration"
(Import
(StringLiteral))
(Import
(StringLiteral))
(Import (Import
(TextElement)
(TextElement)
(
(Identifier) (Identifier)
(StringLiteral))) (TextElement)))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args))) ([])
([])))

View File

@ -2,16 +2,15 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "var_declaration" (
(VarAssignment (Assignment
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Other "expression_list" (Integer))
(NumberLiteral))) (Assignment
(VarAssignment
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Other "expression_list" (Integer)))))
(NumberLiteral))))))

View File

@ -2,16 +2,15 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "var_declaration" (
(VarAssignment (Assignment
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Other "expression_list" (Integer))
(NumberLiteral))) (Assignment
(VarAssignment
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(Other "expression_list" (Integer)))))
(NumberLiteral))))))

View File

@ -2,14 +2,13 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "var_declaration" (
(VarAssignment (Assignment
(Identifier) (Identifier)
(Other "expression_list" (Integer))
(NumberLiteral))) (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Integer)))))
(NumberLiteral))))))

View File

@ -2,14 +2,13 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(Other "var_declaration" (
(VarAssignment (Assignment
(Identifier) (Identifier)
(Other "expression_list" (Integer))
(NumberLiteral))) (Assignment
(VarAssignment
(Identifier) (Identifier)
(Other "expression_list" (Integer)))))
(NumberLiteral))))))

View File

@ -12,4 +12,11 @@ b()
} else { } else {
c() c()
} }
if num := 9; num < 0 {
d()
} else if num < 10 {
e()
} else {
f()
}
} }

View File

@ -12,4 +12,11 @@ b()
} else { } else {
c() c()
} }
if num := 10; num < 0 {
f()
} else if num < 100 {
g()
} else {
h()
}
} }

View File

@ -2,36 +2,69 @@
(Module (Module
(Identifier)) (Identifier))
(Function (Function
(Empty)
(Identifier) (Identifier)
(Args) ([])
(
(If (If
(FunctionCall (
(Call
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) }
(ExpressionStatements (Empty)))
(FunctionCall (Call
(Identifier))))
(If
(Other "if_initializer"
(VarDecl
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(FunctionCall
(Identifier)))))
(Identifier) (Identifier)
(ExpressionStatements (Empty))
(FunctionCall (Empty))
(Identifier))))
(If (If
(FunctionCall (
(Assignment
{ (Identifier) { (Identifier)
->(Identifier) }) ->(Identifier) }
(ExpressionStatements (Call
(FunctionCall (Identifier)
(Identifier))) (Empty)))
(Other "else_clause" (Identifier))
(ExpressionStatements (Call
(FunctionCall (Identifier)
(Identifier))))))) (Empty))
(Empty))
(If
(
(Call
{ (Identifier)
->(Identifier) }
(Empty)))
(Call
(Identifier)
(Empty))
(Call
(Identifier)
(Empty)))
(If
(
(Assignment
(Identifier)
{ (Integer)
->(Integer) })
(LessThan
(Identifier)
(Integer)))
(Call
{ (Identifier)
->(Identifier) }
(Empty))
(If
(
(LessThan
(Identifier)
{ (Integer)
->(Integer) }))
(Call
{ (Identifier)
->(Identifier) }
(Empty))
(Call
{ (Identifier)
->(Identifier) }
(Empty)))))))

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