├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── .yanagiba ├── LICENSE ├── Makefile ├── Package.swift ├── README.md ├── Sources ├── AST │ ├── ASTNode.swift │ ├── ASTNodeContext.swift │ ├── ASTTextRepresentable.swift │ ├── ASTUnit.swift │ ├── ASTUnitCollection.swift │ ├── ASTVisitor+Traversal.swift │ ├── ASTVisitor.swift │ ├── Attribute.swift │ ├── Attributes.swift │ ├── CodeBlock.swift │ ├── Declaration.swift │ ├── Declaration │ │ ├── Block │ │ │ ├── GetterSetterBlock.swift │ │ │ ├── GetterSetterKeywordBlock.swift │ │ │ └── WillSetDidSetBlock.swift │ │ ├── ClassDeclaration.swift │ │ ├── ConstantDeclaration.swift │ │ ├── DeinitializerDeclaration.swift │ │ ├── EnumDeclaration.swift │ │ ├── ExtensionDeclaration.swift │ │ ├── Function │ │ │ ├── FunctionResult.swift │ │ │ └── FunctionSignature.swift │ │ ├── FunctionDeclaration.swift │ │ ├── ImportDeclaration.swift │ │ ├── Initializer │ │ │ └── PatternInitializer.swift │ │ ├── InitializerDeclaration.swift │ │ ├── Modifier │ │ │ ├── AccessLevelModifier.swift │ │ │ ├── DeclarationModifier.swift │ │ │ ├── DeclarationModifiers.swift │ │ │ └── MutationModifier.swift │ │ ├── OperatorDeclaration.swift │ │ ├── PrecedenceGroupDeclaration.swift │ │ ├── ProtocolDeclaration.swift │ │ ├── StructDeclaration.swift │ │ ├── SubscriptDeclaration.swift │ │ ├── TypealiasDeclaration.swift │ │ └── VariableDeclaration.swift │ ├── Expression.swift │ ├── Expression │ │ ├── AssignmentOperatorExpression.swift │ │ ├── BinaryOperatorExpression.swift │ │ ├── ClosureExpression.swift │ │ ├── ExplicitMemberExpression.swift │ │ ├── ForcedValueExpression.swift │ │ ├── FunctionCallExpression.swift │ │ ├── IdentifierExpression.swift │ │ ├── ImplicitMemberExpression.swift │ │ ├── InOutExpression.swift │ │ ├── InitializerExpression.swift │ │ ├── KeyPathExpression.swift │ │ ├── KeyPathStringExpression.swift │ │ ├── LiteralExpression.swift │ │ ├── OptionalChainingExpression.swift │ │ ├── ParenthesizedExpression.swift │ │ ├── PostfixOperatorExpression.swift │ │ ├── PostfixSelfExpression.swift │ │ ├── PrefixOperatorExpression.swift │ │ ├── SelectorExpression.swift │ │ ├── SelfExpression.swift │ │ ├── SequenceExpression.swift │ │ ├── Subscript │ │ │ └── SubscriptArgument.swift │ │ ├── SubscriptExpression.swift │ │ ├── SuperclassExpression.swift │ │ ├── TernaryConditionalOperatorExpression.swift │ │ ├── TryOperatorExpression.swift │ │ ├── TupleExpression.swift │ │ ├── TypeCastingOperatorExpression.swift │ │ └── WildcardExpression.swift │ ├── ExpressionList.swift │ ├── Generic │ │ ├── GenericArgumentClause.swift │ │ ├── GenericParameterClause.swift │ │ └── GenericWhereClause.swift │ ├── Identifier.swift │ ├── IdentifierList.swift │ ├── LocatableNode.swift │ ├── Operator.swift │ ├── Pattern.swift │ ├── Pattern │ │ ├── EnumCasePattern.swift │ │ ├── ExpressionPattern.swift │ │ ├── IdentifierPattern.swift │ │ ├── OptionalPattern.swift │ │ ├── TuplePattern.swift │ │ ├── TypeCastingPattern.swift │ │ ├── ValueBindingPattern.swift │ │ └── WildcardPattern.swift │ ├── Statement.swift │ ├── Statement │ │ ├── BreakStatement.swift │ │ ├── CompilerControlStatement.swift │ │ ├── Condition │ │ │ ├── AvailabilityCondition.swift │ │ │ ├── Condition.swift │ │ │ └── ConditionList.swift │ │ ├── ContinueStatement.swift │ │ ├── DeferStatement.swift │ │ ├── DoStatement.swift │ │ ├── FallthroughStatement.swift │ │ ├── ForInStatement.swift │ │ ├── GuardStatement.swift │ │ ├── IfStatement.swift │ │ ├── LabeledStatement.swift │ │ ├── RepeatWhileStatement.swift │ │ ├── ReturnStatement.swift │ │ ├── SwitchStatement.swift │ │ ├── ThrowStatement.swift │ │ └── WhileStatement.swift │ ├── Statements.swift │ ├── ThrowsKind.swift │ ├── TopLevelDeclaration.swift │ ├── Type.swift │ ├── Type │ │ ├── AnyType.swift │ │ ├── ArrayType.swift │ │ ├── DictionaryType.swift │ │ ├── FunctionType.swift │ │ ├── ImplicitlyUnwrappedOptionalType.swift │ │ ├── MetatypeType.swift │ │ ├── OpaqueType.swift │ │ ├── OptionalType.swift │ │ ├── ProtocolCompositionType.swift │ │ ├── SelfType.swift │ │ ├── TupleType.swift │ │ ├── TypeAnnotation.swift │ │ ├── TypeIdentifier.swift │ │ └── TypeInheritanceClause.swift │ └── Version.swift ├── Bocho │ ├── CommandLine │ │ └── CLIOption.swift │ ├── DotYanagiba │ │ ├── DotYanagiba+Merge.swift │ │ ├── DotYanagibaModels.swift │ │ ├── DotYanagibaParser.swift │ │ └── DotYanagibaReader.swift │ └── SwiftExtensions │ │ ├── String+FileHandle.swift │ │ ├── String+Indentation.swift │ │ ├── String+Path.swift │ │ └── String+TTYColor.swift ├── Diagnostic │ ├── Diagnostic.swift │ ├── DiagnosticConsumer.swift │ ├── DiagnosticKind.swift │ └── DiagnosticPool.swift ├── Frontend │ └── Terminal │ │ ├── ASTDump │ │ ├── ASTDump+Declaration.swift │ │ ├── ASTDump+Expression.swift │ │ ├── ASTDump+Statement.swift │ │ └── TTYASTDumpRepresentable.swift │ │ ├── ASTPrint │ │ ├── ASTPrint+Declaration.swift │ │ ├── ASTPrint+Expression.swift │ │ ├── ASTPrint+Statement.swift │ │ └── TTYASTPrintRepresentable.swift │ │ ├── GitHubIssueGen.swift │ │ ├── SourceRange+TTY.swift │ │ ├── TerminalDiagnosticConsumer.swift │ │ └── TerminalMain.swift ├── Lexer │ ├── Char.swift │ ├── Lexer+Checkpoint.swift │ ├── Lexer+Comment.swift │ ├── Lexer+Identifier.swift │ ├── Lexer+NumericLiteral.swift │ ├── Lexer+Operator.swift │ ├── Lexer+StringLiteral.swift │ ├── Lexer.swift │ ├── NamedIdentifier.swift │ ├── Role+Lexer.swift │ ├── Role.swift │ ├── Scanner.swift │ ├── Token.swift │ ├── TokenInvalidReason.swift │ ├── TokenKind+Dummy.swift │ ├── TokenKind+Equatable.swift │ ├── TokenKind+Modifier.swift │ ├── TokenKind+Naming.swift │ └── UnicodeScalar+Lexer.swift ├── Parser │ ├── Parser+Attribute.swift │ ├── Parser+Common.swift │ ├── Parser+Declaration.swift │ ├── Parser+Diagnostic.swift │ ├── Parser+Expression.swift │ ├── Parser+Generic.swift │ ├── Parser+Lexing.swift │ ├── Parser+Modifier.swift │ ├── Parser+Pattern.swift │ ├── Parser+Statement.swift │ ├── Parser+Type.swift │ ├── Parser+Util.swift │ └── Parser.swift ├── Sema │ ├── LexicalParentAssignment.swift │ └── SequenceExpressionFolding.swift ├── Source │ ├── Comment.swift │ ├── CommentSet.swift │ ├── Shebang.swift │ ├── SourceError.swift │ ├── SourceFile.swift │ ├── SourceLocatable.swift │ ├── SourceLocation.swift │ ├── SourceRange.swift │ └── SourceReader.swift ├── Tooling │ ├── ToolAction.swift │ ├── ToolActionOptions.swift │ └── ToolActionResult.swift └── swift-ast │ └── main.swift ├── Tests ├── ASTTests │ ├── LocatableNodeTests.swift │ ├── TopLevelDeclarationTests.swift │ └── XCTestManifests.swift ├── ASTVisitorTests │ ├── ASTVisitorCodeBlockTraversalTests.swift │ ├── ASTVisitorTopLevelDeclTraversalTests.swift │ ├── DefaultTraverseImplementationTests.swift │ ├── DefaultVisitImplementationTests.swift │ └── XCTestManifests.swift ├── CanaryTests │ ├── CanaryTests.swift │ └── XCTestManifests.swift ├── CommandLineTests │ ├── CLIOptionTests.swift │ └── XCTestManifests.swift ├── DiagnosticTests │ ├── DiagnosticPoolTests.swift │ └── XCTestManifests.swift ├── DotYanagibaTests │ ├── DotYanagibaMergeTests.swift │ ├── DotYanagibaParserTests.swift │ └── XCTestManifests.swift ├── IntegrationTests │ ├── IntegrationTestRunner.swift │ ├── SemaIntegrationTests.swift │ ├── SemaTestResources │ │ ├── SequenceExpressionFolding.result │ │ └── SequenceExpressionFolding.source │ ├── ShebangIntegrationTests.swift │ ├── ShebangResources │ │ ├── ShebangDump.result │ │ ├── ShebangDump.source │ │ ├── ShebangPrint.result │ │ └── ShebangPrint.source │ ├── TTYASTDumpTestResources │ │ ├── AssignmentOperatorExpression.result │ │ ├── AssignmentOperatorExpression.source │ │ ├── BinaryOperatorExpression.result │ │ ├── BinaryOperatorExpression.source │ │ ├── BreakStatement.result │ │ ├── BreakStatement.source │ │ ├── ClassDeclaration.result │ │ ├── ClassDeclaration.source │ │ ├── ClosureExpression.result │ │ ├── ClosureExpression.source │ │ ├── CompilerControlStatement.result │ │ ├── CompilerControlStatement.source │ │ ├── ConstantDeclaration.result │ │ ├── ConstantDeclaration.source │ │ ├── ContinueStatement.result │ │ ├── ContinueStatement.source │ │ ├── DeferStatement.result │ │ ├── DeferStatement.source │ │ ├── DeinitializerDeclaration.result │ │ ├── DeinitializerDeclaration.source │ │ ├── DoStatement.result │ │ ├── DoStatement.source │ │ ├── EnumDeclaration.result │ │ ├── EnumDeclaration.source │ │ ├── ExplicitMemberExpression.result │ │ ├── ExplicitMemberExpression.source │ │ ├── ExtensionDeclaration.result │ │ ├── ExtensionDeclaration.source │ │ ├── FallthroughStatement.result │ │ ├── FallthroughStatement.source │ │ ├── ForInStatement.result │ │ ├── ForInStatement.source │ │ ├── ForcedValueExpression.result │ │ ├── ForcedValueExpression.source │ │ ├── FunctionCallExpression.result │ │ ├── FunctionCallExpression.source │ │ ├── FunctionDeclaration.result │ │ ├── FunctionDeclaration.source │ │ ├── GuardStatement.result │ │ ├── GuardStatement.source │ │ ├── IdentifierExpression.result │ │ ├── IdentifierExpression.source │ │ ├── IfStatement.result │ │ ├── IfStatement.source │ │ ├── ImplicitMemberExpression.result │ │ ├── ImplicitMemberExpression.source │ │ ├── ImportDeclaration.result │ │ ├── ImportDeclaration.source │ │ ├── InOutExpression.result │ │ ├── InOutExpression.source │ │ ├── InitializerDeclaration.result │ │ ├── InitializerDeclaration.source │ │ ├── InitializerExpression.result │ │ ├── InitializerExpression.source │ │ ├── KeyPathExpression.result │ │ ├── KeyPathExpression.source │ │ ├── KeyPathStringExpression.result │ │ ├── KeyPathStringExpression.source │ │ ├── LabeledStatement.result │ │ ├── LabeledStatement.source │ │ ├── LiteralExpression.result │ │ ├── LiteralExpression.source │ │ ├── OperatorDeclaration.result │ │ ├── OperatorDeclaration.source │ │ ├── OptionalChainingExpression.result │ │ ├── OptionalChainingExpression.source │ │ ├── ParenthesizedExpression.result │ │ ├── ParenthesizedExpression.source │ │ ├── PostfixOperatorExpression.result │ │ ├── PostfixOperatorExpression.source │ │ ├── PostfixSelfExpression.result │ │ ├── PostfixSelfExpression.source │ │ ├── PrecedenceGroupDeclaration.result │ │ ├── PrecedenceGroupDeclaration.source │ │ ├── PrefixOperatorExpression.result │ │ ├── PrefixOperatorExpression.source │ │ ├── ProtocolDeclaration.result │ │ ├── ProtocolDeclaration.source │ │ ├── RepeatWhileStatement.result │ │ ├── RepeatWhileStatement.source │ │ ├── ReturnStatement.result │ │ ├── ReturnStatement.source │ │ ├── SelectorExpression.result │ │ ├── SelectorExpression.source │ │ ├── SelfExpression.result │ │ ├── SelfExpression.source │ │ ├── SequenceExpression.result │ │ ├── SequenceExpression.source │ │ ├── StructDeclaration.result │ │ ├── StructDeclaration.source │ │ ├── SubscriptDeclaration.result │ │ ├── SubscriptDeclaration.source │ │ ├── SubscriptExpression.result │ │ ├── SubscriptExpression.source │ │ ├── SuperclassExpression.result │ │ ├── SuperclassExpression.source │ │ ├── SwitchStatement.result │ │ ├── SwitchStatement.source │ │ ├── TernaryConditionalOperatorExpression.result │ │ ├── TernaryConditionalOperatorExpression.source │ │ ├── ThrowStatement.result │ │ ├── ThrowStatement.source │ │ ├── TryOperatorExpression.result │ │ ├── TryOperatorExpression.source │ │ ├── TupleExpression.result │ │ ├── TupleExpression.source │ │ ├── TypeCastingOperatorExpression.result │ │ ├── TypeCastingOperatorExpression.source │ │ ├── TypealiasDeclaration.result │ │ ├── TypealiasDeclaration.source │ │ ├── VariableDeclaration.result │ │ ├── VariableDeclaration.source │ │ ├── WhileStatement.result │ │ ├── WhileStatement.source │ │ ├── WildcardExpression.result │ │ └── WildcardExpression.source │ ├── TTYASTDumpTests.swift │ ├── TTYASTPrintTestResources │ │ ├── AssignmentOperatorExpression.result │ │ ├── AssignmentOperatorExpression.source │ │ ├── BinaryOperatorExpression.result │ │ ├── BinaryOperatorExpression.source │ │ ├── BreakStatement.result │ │ ├── BreakStatement.source │ │ ├── ClassDeclaration.result │ │ ├── ClassDeclaration.source │ │ ├── ClosureExpression.result │ │ ├── ClosureExpression.source │ │ ├── CompilerControlStatement.result │ │ ├── CompilerControlStatement.source │ │ ├── ConstantDeclaration.result │ │ ├── ConstantDeclaration.source │ │ ├── ContinueStatement.result │ │ ├── ContinueStatement.source │ │ ├── DeferStatement.result │ │ ├── DeferStatement.source │ │ ├── DeinitializerDeclaration.result │ │ ├── DeinitializerDeclaration.source │ │ ├── DoStatement.result │ │ ├── DoStatement.source │ │ ├── EnumDeclaration.result │ │ ├── EnumDeclaration.source │ │ ├── ExplicitMemberExpression.result │ │ ├── ExplicitMemberExpression.source │ │ ├── ExtensionDeclaration.result │ │ ├── ExtensionDeclaration.source │ │ ├── FallthroughStatement.result │ │ ├── FallthroughStatement.source │ │ ├── ForInStatement.result │ │ ├── ForInStatement.source │ │ ├── ForcedValueExpression.result │ │ ├── ForcedValueExpression.source │ │ ├── FunctionCallExpression.result │ │ ├── FunctionCallExpression.source │ │ ├── FunctionDeclaration.result │ │ ├── FunctionDeclaration.source │ │ ├── GuardStatement.result │ │ ├── GuardStatement.source │ │ ├── IdentifierExpression.result │ │ ├── IdentifierExpression.source │ │ ├── IfStatement.result │ │ ├── IfStatement.source │ │ ├── ImplicitMemberExpression.result │ │ ├── ImplicitMemberExpression.source │ │ ├── ImportDeclaration.result │ │ ├── ImportDeclaration.source │ │ ├── InOutExpression.result │ │ ├── InOutExpression.source │ │ ├── InitializerDeclaration.result │ │ ├── InitializerDeclaration.source │ │ ├── InitializerExpression.result │ │ ├── InitializerExpression.source │ │ ├── KeyPathExpression.result │ │ ├── KeyPathExpression.source │ │ ├── KeyPathStringExpression.result │ │ ├── KeyPathStringExpression.source │ │ ├── LabeledStatement.result │ │ ├── LabeledStatement.source │ │ ├── LiteralExpression.result │ │ ├── LiteralExpression.source │ │ ├── OperatorDeclaration.result │ │ ├── OperatorDeclaration.source │ │ ├── OptionalChainingExpression.result │ │ ├── OptionalChainingExpression.source │ │ ├── ParenthesizedExpression.result │ │ ├── ParenthesizedExpression.source │ │ ├── PostfixOperatorExpression.result │ │ ├── PostfixOperatorExpression.source │ │ ├── PostfixSelfExpression.result │ │ ├── PostfixSelfExpression.source │ │ ├── PrecedenceGroupDeclaration.result │ │ ├── PrecedenceGroupDeclaration.source │ │ ├── PrefixOperatorExpression.result │ │ ├── PrefixOperatorExpression.source │ │ ├── ProtocolDeclaration.result │ │ ├── ProtocolDeclaration.source │ │ ├── RepeatWhileStatement.result │ │ ├── RepeatWhileStatement.source │ │ ├── ReturnStatement.result │ │ ├── ReturnStatement.source │ │ ├── SelectorExpression.result │ │ ├── SelectorExpression.source │ │ ├── SelfExpression.result │ │ ├── SelfExpression.source │ │ ├── SequenceExpression.result │ │ ├── SequenceExpression.source │ │ ├── StructDeclaration.result │ │ ├── StructDeclaration.source │ │ ├── SubscriptDeclaration.result │ │ ├── SubscriptDeclaration.source │ │ ├── SubscriptExpression.result │ │ ├── SubscriptExpression.source │ │ ├── SuperclassExpression.result │ │ ├── SuperclassExpression.source │ │ ├── SwitchStatement.result │ │ ├── SwitchStatement.source │ │ ├── TernaryConditionalOperatorExpression.result │ │ ├── TernaryConditionalOperatorExpression.source │ │ ├── ThrowStatement.result │ │ ├── ThrowStatement.source │ │ ├── TryOperatorExpression.result │ │ ├── TryOperatorExpression.source │ │ ├── TupleExpression.result │ │ ├── TupleExpression.source │ │ ├── TypeCastingOperatorExpression.result │ │ ├── TypeCastingOperatorExpression.source │ │ ├── TypealiasDeclaration.result │ │ ├── TypealiasDeclaration.source │ │ ├── VariableDeclaration.result │ │ ├── VariableDeclaration.source │ │ ├── WhileStatement.result │ │ ├── WhileStatement.source │ │ ├── WildcardExpression.result │ │ └── WildcardExpression.source │ ├── TTYASTPrintTests.swift │ └── XCTestManifests.swift ├── LexerTests │ ├── Lexer+XCTest.swift │ ├── LexerBooleanLiteralTests.swift │ ├── LexerCheckpointTests.swift │ ├── LexerCommentTests.swift │ ├── LexerIdentifierTests.swift │ ├── LexerKeywordTests.swift │ ├── LexerNumericLiteralTests.swift │ ├── LexerOperatorTests.swift │ ├── LexerStringLiteralTests.swift │ ├── LexerTests.swift │ ├── RoleTests.swift │ ├── ScannerTests.swift │ └── XCTestManifests.swift ├── LinuxMain.swift ├── ParserTests │ ├── AST+EnumCollection.swift │ ├── Attribute │ │ └── ParserAttributeTests.swift │ ├── Declaration │ │ ├── Modifier │ │ │ ├── ParserAccessLevelModifierTest.swift │ │ │ ├── ParserDeclarationModifierTests.swift │ │ │ ├── ParserDeclarationModifiersTests.swift │ │ │ └── ParserMutationModifierTests.swift │ │ ├── ParserClassDeclarationTests.swift │ │ ├── ParserCodeBlockTests.swift │ │ ├── ParserConstantDeclarationTests.swift │ │ ├── ParserDeinitializerDeclarationTests.swift │ │ ├── ParserEnumDeclarationTests.swift │ │ ├── ParserExtensionDeclarationTests.swift │ │ ├── ParserFunctionDeclarationTests.swift │ │ ├── ParserImportDeclarationTests.swift │ │ ├── ParserInitializerDeclarationTests.swift │ │ ├── ParserOperatorDeclarationTests.swift │ │ ├── ParserPrecedenceGroupDeclarationTests.swift │ │ ├── ParserProtocolDeclarationTests.swift │ │ ├── ParserStructDeclarationTests.swift │ │ ├── ParserSubscriptDeclarationTests.swift │ │ ├── ParserTopLevelDeclarationTests.swift │ │ ├── ParserTypealiasDeclarationTests.swift │ │ └── ParserVariableDeclarationTests.swift │ ├── Expression │ │ ├── Binary │ │ │ ├── ParserAssignmentOperatorExpressionTests.swift │ │ │ ├── ParserBinaryOperatorExpressionTests.swift │ │ │ ├── ParserSequenceExpressionTests.swift │ │ │ ├── ParserTernaryConditionalOperatorExpressionTests.swift │ │ │ └── ParserTypeCastingOperatorExpressionTests.swift │ │ ├── ParserTryOperatorExpressionTests.swift │ │ ├── Postfix │ │ │ ├── ParserExplicitMemberExpressionTests.swift │ │ │ ├── ParserForcedValueExpressionTests.swift │ │ │ ├── ParserFunctionCallExpressionTests.swift │ │ │ ├── ParserInitializerExpressionTests.swift │ │ │ ├── ParserOptionalChainingExpressionTests.swift │ │ │ ├── ParserPostfixOperatorExpressionTests.swift │ │ │ ├── ParserPostfixSelfExpressionTests.swift │ │ │ └── ParserSubscriptExpressionTests.swift │ │ ├── Prefix │ │ │ ├── ParserInOutExpressionTests.swift │ │ │ └── ParserPrefixOperatorExpressionTests.swift │ │ └── Primary │ │ │ ├── ParserClosureExpressionTests.swift │ │ │ ├── ParserIdentifierExpressionTests.swift │ │ │ ├── ParserImplicitMemberExpressionTests.swift │ │ │ ├── ParserKeyPathExpressionTests.swift │ │ │ ├── ParserKeyPathStringExpressionTests.swift │ │ │ ├── ParserLiteralExpressionTests.swift │ │ │ ├── ParserParenthesizedExpressionTests.swift │ │ │ ├── ParserSelectorExpressionTests.swift │ │ │ ├── ParserSelfExpressionTests.swift │ │ │ ├── ParserSuperclassExpressionTests.swift │ │ │ ├── ParserTupleExpressionTests.swift │ │ │ └── ParserWildcardExpressionTests.swift │ ├── Generic │ │ ├── ParserGenericArgumentClauseTests.swift │ │ ├── ParserGenericParameterClauseTests.swift │ │ └── ParserGenericWhereClauseTests.swift │ ├── Others │ │ ├── GenericOpeningChevronTests.swift │ │ ├── KeywordUsedAsIdentifierTests.swift │ │ ├── OptionalInPatternMatchingTests.swift │ │ ├── ParserErrorKindTests.swift │ │ └── RangeOperatorTests.swift │ ├── Parser+XCTest.swift │ ├── Pattern │ │ ├── ParserEnumCasePatternTests.swift │ │ ├── ParserExpressionPatternTests.swift │ │ ├── ParserIdentifierPatternTests.swift │ │ ├── ParserOptionalPatternTests.swift │ │ ├── ParserTuplePatternTests.swift │ │ ├── ParserTypeCastingPatternTests.swift │ │ ├── ParserValueBindingPatternTests.swift │ │ └── ParserWildcardPatternTests.swift │ ├── Statement │ │ ├── Condition │ │ │ └── ParserConditionTests.swift │ │ ├── ParserBreakStatementTests.swift │ │ ├── ParserCompilerControlStatementTests.swift │ │ ├── ParserContinueStatementTests.swift │ │ ├── ParserDeclarationStatementTests.swift │ │ ├── ParserDeferStatementTests.swift │ │ ├── ParserDoStatementTests.swift │ │ ├── ParserExpressionStatementTests.swift │ │ ├── ParserFallthroughStatementTests.swift │ │ ├── ParserForInStatementTests.swift │ │ ├── ParserGuardStatementTests.swift │ │ ├── ParserIfStatementTests.swift │ │ ├── ParserLabeledStatementTests.swift │ │ ├── ParserRepeatWhileStatementTests.swift │ │ ├── ParserReturnStatementTests.swift │ │ ├── ParserSwitchStatementTests.swift │ │ ├── ParserThrowStatementTests.swift │ │ └── ParserWhileStatementTests.swift │ ├── Type │ │ ├── ParserAnyTypeTests.swift │ │ ├── ParserArrayTypeTests.swift │ │ ├── ParserDictionaryTypeTests.swift │ │ ├── ParserFunctionTypeTests.swift │ │ ├── ParserImplicitlyUnwrappedOptionalTypeTests.swift │ │ ├── ParserMetatypeTypeTests.swift │ │ ├── ParserOpaqueTypeTests.swift │ │ ├── ParserOptionalTypeTests.swift │ │ ├── ParserProtocolCompositionTypeTests.swift │ │ ├── ParserSelfTypeTests.swift │ │ ├── ParserTupleTypeTests.swift │ │ ├── ParserTypeIdentifierTests.swift │ │ └── ParserTypeInheritanceClauseTests.swift │ ├── XCTest+ASTTextRepresentable.swift │ └── XCTestManifests.swift ├── SemaTests │ ├── LexicalParentAssignmentTests.swift │ ├── Sema+XCTest.swift │ ├── SequenceExpressionFoldingTests.swift │ └── XCTestManifests.swift ├── SourceTests │ ├── SourceFileTests.swift │ ├── SourceLocationTests.swift │ ├── SourceRangeTests.swift │ ├── SourceReaderTests.swift │ └── XCTestManifests.swift └── SwiftExtensionsTests │ ├── StringIdentationTests.swift │ ├── StringPathTests.swift │ ├── StringTTYColorTests.swift │ └── XCTestManifests.swift ├── codecov.yml ├── dogFooding.sh ├── lint.sh ├── run.sh └── runXcodeTest.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .build 3 | .swift_lint 4 | swift-ast.xcodeproj/ 5 | build/ 6 | swift-ast_github_issue_*.md 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | - osx 4 | language: generic 5 | sudo: required 6 | dist: trusty 7 | osx_image: xcode11 8 | install: 9 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 10 | eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"; 11 | swiftenv install 5.1; 12 | swiftenv global 5.1; 13 | export LD_LIBRARY_PATH=$HOME/.swiftenv/versions/5.1/usr/lib/swift/linux:$LD_LIBRARY_PATH; 14 | fi 15 | - swift --version 16 | script: 17 | - make test 18 | - ./dogFooding.sh -diagnostics-only 19 | after_success: 20 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./runXcodeTest.sh; bash <(curl -s https://codecov.io/bash); fi 21 | - ./lint.sh 22 | -------------------------------------------------------------------------------- /.yanagiba: -------------------------------------------------------------------------------- 1 | lint: 2 | rule-configurations: 3 | - NESTED_CODE_BLOCK_DEPTH: 6 4 | - CYCLOMATIC_COMPLEXITY: 15 5 | - NPATH_COMPLEXITY: 300 6 | - NCSS: 45 7 | - LONG_LINE: 120 8 | severity-thresholds: 9 | - critical: 0 10 | - major: 0 11 | - minor: 0 12 | - cosmetic: 0 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR=.build/debug 2 | 3 | .PHONY: all clean build test xcodegen 4 | 5 | all: build 6 | 7 | clean: 8 | swift package clean 9 | rm -rf swift-ast_github_issue_* 10 | 11 | build: 12 | swift build 13 | 14 | test: build 15 | swift test 16 | 17 | xcodegen: 18 | swift package generate-xcodeproj --enable-code-coverage 19 | -------------------------------------------------------------------------------- /Sources/AST/ASTNode.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public class ASTNode : LocatableNode { 20 | public private(set) weak var lexicalParent: ASTNode? 21 | 22 | public func setLexicalParent(_ node: ASTNode) { 23 | lexicalParent = node 24 | } 25 | } 26 | 27 | extension ASTNode : ASTNodeContext, ASTTextRepresentable, SourceLocatable { 28 | } 29 | -------------------------------------------------------------------------------- /Sources/AST/ASTNodeContext.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public protocol ASTNodeContext { 20 | var lexicalParent: ASTNode? { get } 21 | var sourceRange: SourceRange { get } 22 | } 23 | -------------------------------------------------------------------------------- /Sources/AST/ASTTextRepresentable.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public protocol ASTTextRepresentable : CustomStringConvertible { 18 | var textDescription: String { get } 19 | } 20 | 21 | extension ASTTextRepresentable { 22 | public var description: String { 23 | return textDescription 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/AST/ASTUnit.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public protocol ASTUnit { 20 | var translationUnit: TopLevelDeclaration { get } 21 | var sourceFile: SourceFile? { get } 22 | } 23 | -------------------------------------------------------------------------------- /Sources/AST/ASTUnitCollection.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias ASTUnitCollection = [ASTUnit] 18 | -------------------------------------------------------------------------------- /Sources/AST/Attributes.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias Attributes = [Attribute] 18 | 19 | extension Collection where Iterator.Element == Attribute { 20 | public var textDescription: String { 21 | return self.map({ $0.textDescription }).joined(separator: " ") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/AST/Declaration.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public protocol Declaration : Statement { 18 | } 19 | -------------------------------------------------------------------------------- /Sources/AST/Declaration/DeinitializerDeclaration.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class DeinitializerDeclaration : ASTNode, Declaration { 18 | public let attributes: Attributes 19 | public let body: CodeBlock 20 | 21 | public init(attributes: Attributes = [], body: CodeBlock) { 22 | self.attributes = attributes 23 | self.body = body 24 | } 25 | 26 | // MARK: - ASTTextRepresentable 27 | 28 | override public var textDescription: String { 29 | let attrsText = attributes.isEmpty ? "" : "\(attributes.textDescription) " 30 | return "\(attrsText)deinit \(body.textDescription)" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sources/AST/Declaration/Modifier/AccessLevelModifier.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public enum AccessLevelModifier : String { 18 | case `private`, privateSet = "private(set)" 19 | case `fileprivate`, fileprivateSet = "fileprivate(set)" 20 | case `internal`, internalSet = "internal(set)" 21 | case `public`, publicSet = "public(set)" 22 | case `open`, openSet = "open(set)" 23 | } 24 | 25 | extension AccessLevelModifier : ASTTextRepresentable { 26 | public var textDescription: String { 27 | return self.rawValue 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Declaration/Modifier/DeclarationModifiers.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias DeclarationModifiers = [DeclarationModifier] 18 | 19 | extension Collection where Iterator.Element == DeclarationModifier { 20 | public var textDescription: String { 21 | return self.map({ $0.textDescription }).joined(separator: " ") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/AST/Declaration/Modifier/MutationModifier.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public enum MutationModifier : String { 18 | case mutating, nonmutating 19 | } 20 | 21 | extension MutationModifier : ASTTextRepresentable { 22 | public var textDescription: String { 23 | return self.rawValue 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/AST/Expression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public protocol Expression : Statement { 18 | } 19 | 20 | public protocol BinaryExpression : Expression { 21 | } 22 | 23 | public protocol PrefixExpression : Expression { 24 | } 25 | 26 | public protocol PostfixExpression : Expression { 27 | } 28 | 29 | public protocol PrimaryExpression : PostfixExpression { 30 | } 31 | -------------------------------------------------------------------------------- /Sources/AST/Expression/ForcedValueExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class ForcedValueExpression : ASTNode, PostfixExpression { 18 | public let postfixExpression: PostfixExpression 19 | 20 | public init(postfixExpression: PostfixExpression) { 21 | self.postfixExpression = postfixExpression 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "\(postfixExpression.textDescription)!" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Expression/ImplicitMemberExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class ImplicitMemberExpression : ASTNode, PrimaryExpression { 18 | public let identifier: Identifier 19 | 20 | public init(identifier: Identifier) { 21 | self.identifier = identifier 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return ".\(identifier)" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Expression/InOutExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class InOutExpression : ASTNode, PrefixExpression { 18 | public let identifier: Identifier 19 | 20 | public init(identifier: Identifier) { 21 | self.identifier = identifier 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "&\(identifier)" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Expression/KeyPathStringExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class KeyPathStringExpression : ASTNode, PrimaryExpression { 18 | public let expression: Expression 19 | 20 | public init(expression: Expression) { 21 | self.expression = expression 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "#keyPath(\(expression.textDescription))" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Expression/OptionalChainingExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class OptionalChainingExpression : ASTNode, PostfixExpression { 18 | public let postfixExpression: PostfixExpression 19 | 20 | public init(postfixExpression: PostfixExpression) { 21 | self.postfixExpression = postfixExpression 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "\(postfixExpression.textDescription)?" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Expression/ParenthesizedExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class ParenthesizedExpression : ASTNode, PrimaryExpression { 18 | public private(set) var expression: Expression 19 | 20 | public init(expression: Expression) { 21 | self.expression = expression 22 | } 23 | 24 | // MARK: - Node Mutations 25 | 26 | public func reset(with newExpression: Expression) { 27 | expression = newExpression 28 | } 29 | 30 | // MARK: - ASTTextRepresentable 31 | 32 | override public var textDescription: String { 33 | return "(\(expression.textDescription))" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/AST/Expression/PostfixSelfExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Merry Christmas 2016! -Ryuichi 18 | 19 | public class PostfixSelfExpression : ASTNode, PostfixExpression { 20 | public let postfixExpression: PostfixExpression 21 | 22 | public init(postfixExpression: PostfixExpression) { 23 | self.postfixExpression = postfixExpression 24 | } 25 | 26 | // MARK: - ASTTextRepresentable 27 | 28 | override public var textDescription: String { 29 | return "\(postfixExpression.textDescription).self" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sources/AST/Expression/WildcardExpression.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class WildcardExpression : ASTNode, PrimaryExpression { 18 | override public init() { 19 | } 20 | // MARK: - ASTTextRepresentable 21 | 22 | override public var textDescription: String { 23 | return "_" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/AST/ExpressionList.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias ExpressionList = [Expression] 18 | 19 | extension Collection where Iterator.Element == Expression { 20 | public var textDescription: String { 21 | return self.map({ $0.textDescription }).joined(separator: ", ") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/AST/Generic/GenericArgumentClause.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public struct GenericArgumentClause { 20 | public let argumentList: [Type] 21 | public var sourceRange: SourceRange = .EMPTY 22 | 23 | public init(argumentList: [Type]) { 24 | self.argumentList = argumentList 25 | } 26 | } 27 | 28 | extension GenericArgumentClause : ASTTextRepresentable { 29 | public var textDescription: String { 30 | return "<\(argumentList.map({ $0.textDescription }).joined(separator: ", "))>" 31 | } 32 | } 33 | 34 | extension GenericArgumentClause : SourceLocatable { 35 | } 36 | -------------------------------------------------------------------------------- /Sources/AST/IdentifierList.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-2018 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias IdentifierList = [Identifier] 18 | 19 | extension Collection where Iterator.Element == Identifier { 20 | public var textDescription: String { 21 | return map({ $0.textDescription }).joined(separator: ", ") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/AST/Operator.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias Operator = String 18 | // TODO: operator will have its own dedicated class when it becomes more complicated 19 | -------------------------------------------------------------------------------- /Sources/AST/Pattern.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public protocol Pattern : ASTTextRepresentable, SourceLocatable { 20 | } 21 | 22 | public class PatternBase : LocatableNode { 23 | } 24 | 25 | extension PatternBase : Pattern { 26 | } 27 | -------------------------------------------------------------------------------- /Sources/AST/Pattern/ExpressionPattern.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public class ExpressionPattern : PatternBase { 20 | public let expression: Expression 21 | 22 | public init(expression: Expression) { 23 | self.expression = expression 24 | } 25 | 26 | override public var sourceRange: SourceRange { 27 | return expression.sourceRange 28 | } 29 | 30 | // MARK: - ASTTextRepresentable 31 | 32 | override public var textDescription: String { 33 | return expression.textDescription 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/AST/Pattern/IdentifierPattern.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class IdentifierPattern : PatternBase { 18 | public let identifier: Identifier 19 | public let typeAnnotation: TypeAnnotation? 20 | 21 | public init(identifier: Identifier, typeAnnotation: TypeAnnotation? = nil) { 22 | self.identifier = identifier 23 | self.typeAnnotation = typeAnnotation 24 | } 25 | 26 | // MARK: - ASTTextRepresentable 27 | 28 | override public var textDescription: String { 29 | return "\(identifier)\(typeAnnotation?.textDescription ?? "")" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sources/AST/Pattern/WildcardPattern.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class WildcardPattern : PatternBase { 18 | public let typeAnnotation: TypeAnnotation? 19 | 20 | public init(typeAnnotation: TypeAnnotation? = nil) { 21 | self.typeAnnotation = typeAnnotation 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "_\(typeAnnotation?.textDescription ?? "")" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Statement.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public protocol Statement : ASTTextRepresentable, ASTNodeContext { 18 | } 19 | -------------------------------------------------------------------------------- /Sources/AST/Statement/BreakStatement.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class BreakStatement : ASTNode, Statement { 18 | public let labelName: Identifier? 19 | 20 | public init(labelName: Identifier? = nil) { 21 | self.labelName = labelName 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | if let labelName = labelName { 28 | return "break \(labelName)" 29 | } 30 | return "break" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sources/AST/Statement/Condition/ConditionList.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias ConditionList = [Condition] 18 | 19 | extension Collection where Iterator.Element == Condition { 20 | public var textDescription: String { 21 | return self.map({ $0.textDescription }).joined(separator: ", ") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/AST/Statement/ContinueStatement.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | public class ContinueStatement : ASTNode, Statement { 19 | public let labelName: Identifier? 20 | 21 | public init(labelName: Identifier? = nil) { 22 | self.labelName = labelName 23 | } 24 | 25 | // MARK: - ASTTextRepresentable 26 | 27 | override public var textDescription: String { 28 | if let labelName = labelName { 29 | return "continue \(labelName)" 30 | } 31 | return "continue" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Sources/AST/Statement/DeferStatement.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | public class DeferStatement : ASTNode, Statement { 19 | public let codeBlock: CodeBlock 20 | 21 | public init(codeBlock: CodeBlock) { 22 | self.codeBlock = codeBlock 23 | } 24 | 25 | // MARK: - ASTTextRepresentable 26 | 27 | override public var textDescription: String { 28 | return "defer \(codeBlock.textDescription)" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sources/AST/Statement/FallthroughStatement.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | public class FallthroughStatement : ASTNode, Statement { 19 | override public init() { 20 | } 21 | // MARK: - ASTTextRepresentable 22 | 23 | override public var textDescription: String { 24 | return "fallthrough" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/AST/Statement/LabeledStatement.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | public class LabeledStatement : ASTNode, Statement { 19 | public let labelName: Identifier 20 | public let statement: Statement 21 | 22 | public init(labelName: Identifier, statement: Statement) { 23 | self.labelName = labelName 24 | self.statement = statement 25 | } 26 | 27 | // MARK: - ASTTextRepresentable 28 | 29 | override public var textDescription: String { 30 | return "\(labelName): \(statement.textDescription)" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sources/AST/Statement/ThrowStatement.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | public class ThrowStatement : ASTNode, Statement { 19 | public private(set) var expression: Expression 20 | 21 | public init(expression: Expression) { 22 | self.expression = expression 23 | } 24 | 25 | // MARK: - Node Mutations 26 | 27 | public func replaceExpression(with expr: Expression) { 28 | expression = expr 29 | } 30 | 31 | // MARK: - ASTTextRepresentable 32 | 33 | override public var textDescription: String { 34 | return "throw \(expression.textDescription)" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Sources/AST/Statements.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias Statements = [Statement] 18 | 19 | extension Collection where Iterator.Element == Statement { 20 | public var textDescription: String { 21 | return self.map({ $0.textDescription }).joined(separator: "\n") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/AST/ThrowsKind.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public enum ThrowsKind { 18 | case nothrowing 19 | case throwing 20 | case rethrowing 21 | } 22 | 23 | extension ThrowsKind : ASTTextRepresentable { 24 | public var textDescription: String { 25 | switch self { 26 | case .nothrowing: 27 | return "" 28 | case .throwing: 29 | return "throws" 30 | case .rethrowing: 31 | return "rethrows" 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Sources/AST/Type.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public protocol Type : ASTTextRepresentable, SourceLocatable { 20 | } 21 | 22 | public class TypeBase : LocatableNode { 23 | } 24 | 25 | extension TypeBase : Type { 26 | } 27 | -------------------------------------------------------------------------------- /Sources/AST/Type/AnyType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class AnyType : TypeBase { 18 | override public init() {} 19 | 20 | // MARK: - ASTTextRepresentable 21 | 22 | override public var textDescription: String { 23 | return "Any" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/AST/Type/ArrayType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class ArrayType : TypeBase { 18 | public let elementType: Type 19 | 20 | public init(elementType: Type) { 21 | self.elementType = elementType 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "Array<\(elementType.textDescription)>" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Type/DictionaryType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class DictionaryType : TypeBase { 18 | public let keyType: Type 19 | public let valueType: Type 20 | 21 | public init(keyType: Type, valueType: Type) { 22 | self.keyType = keyType 23 | self.valueType = valueType 24 | } 25 | 26 | // MARK: - ASTTextRepresentable 27 | 28 | override public var textDescription: String { 29 | return "Dictionary<\(keyType.textDescription), \(valueType.textDescription)>" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sources/AST/Type/ImplicitlyUnwrappedOptionalType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class ImplicitlyUnwrappedOptionalType : TypeBase { 18 | public let wrappedType: Type 19 | 20 | public init(wrappedType: Type) { 21 | self.wrappedType = wrappedType 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "ImplicitlyUnwrappedOptional<\(wrappedType.textDescription)>" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Type/OpaqueType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class OpaqueType : TypeBase { 18 | public let wrappedType: Type 19 | 20 | public init(wrappedType: Type) { 21 | self.wrappedType = wrappedType 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | // the concrete type is unknown at this point, so we just save it syntactically 28 | return "Opaque<\(wrappedType.textDescription)>" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sources/AST/Type/OptionalType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class OptionalType : TypeBase { 18 | public let wrappedType: Type 19 | 20 | public init(wrappedType: Type) { 21 | self.wrappedType = wrappedType 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "Optional<\(wrappedType.textDescription)>" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Type/ProtocolCompositionType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class ProtocolCompositionType : TypeBase { 18 | public let protocolTypes: [Type] 19 | 20 | public init(protocolTypes: [Type]) { 21 | self.protocolTypes = protocolTypes 22 | } 23 | 24 | // MARK: - ASTTextRepresentable 25 | 26 | override public var textDescription: String { 27 | return "protocol<\(protocolTypes.map({ $0.textDescription }).joined(separator: ", "))>" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/AST/Type/SelfType.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public class SelfType : TypeBase { 18 | override public init() {} 19 | 20 | // MARK: - ASTTextRepresentable 21 | 22 | override public var textDescription: String { 23 | return "Self" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/AST/Version.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public struct Version { 18 | public let library: String 19 | public let swift: String 20 | 21 | public static let current = Version(library: "0.19.9", swift: "5.1") 22 | } 23 | -------------------------------------------------------------------------------- /Sources/Bocho/SwiftExtensions/String+Indentation.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-2017, 2019 Ryuichi Intellectual Property 3 | and the Yanagiba project contributors 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | public extension String { 19 | init(indentation: Int) { 20 | self.init(repeating: " ", count: indentation) 21 | } 22 | 23 | static let indent = String(indentation: 1) 24 | 25 | var indented: String { 26 | return components(separatedBy: .newlines) 27 | .map { String.indent + $0 } 28 | .joined(separator: "\n") 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sources/Diagnostic/Diagnostic.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | 19 | public struct Diagnostic { 20 | public enum Level : String { 21 | case fatal 22 | case error 23 | case warning 24 | } 25 | 26 | public let level: Level 27 | public let kind: DiagnosticKind 28 | public let location: SourceLocation 29 | 30 | public init(level: Level, kind: DiagnosticKind, location: SourceLocation) { 31 | self.level = level 32 | self.kind = kind 33 | self.location = location 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/Diagnostic/DiagnosticConsumer.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public protocol DiagnosticConsumer { 18 | func consume(diagnostics: [Diagnostic]) 19 | } 20 | -------------------------------------------------------------------------------- /Sources/Diagnostic/DiagnosticKind.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public protocol DiagnosticKind { 18 | var diagnosticMessage: String { get } 19 | } 20 | -------------------------------------------------------------------------------- /Sources/Frontend/Terminal/ASTPrint/TTYASTPrintRepresentable.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | protocol TTYASTPrintRepresentable { 18 | var ttyPrint: String { get } 19 | } 20 | -------------------------------------------------------------------------------- /Sources/Frontend/Terminal/SourceRange+TTY.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Source 18 | import Bocho 19 | 20 | extension SourceRange { 21 | var ttyDescription: String { 22 | return description.truncatedPath 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Sources/Lexer/Char.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Foundation 18 | 19 | struct Char: Equatable { 20 | let unicodeScalar: UnicodeScalar 21 | let role: Role 22 | } 23 | 24 | extension Char { 25 | var string: String { 26 | return unicodeScalar.string 27 | } 28 | 29 | var int: Int? { 30 | return unicodeScalar.int 31 | } 32 | } 33 | 34 | extension Char { 35 | static let eof = Char(unicodeScalar: UnicodeScalar(0), role: .eof) 36 | static let doubleQuote = Char(unicodeScalar: "\"", role: .doubleQuote) 37 | } 38 | -------------------------------------------------------------------------------- /Sources/Lexer/Lexer+Checkpoint.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | extension Lexer /* checkpoint */ { 18 | public func checkPoint() -> String { 19 | let id = _scanner.checkPoint() 20 | _checkpoints[id] = _loadedTokens 21 | return id 22 | } 23 | 24 | @discardableResult public func restore(fromCheckpoint cpId: String) -> Bool { 25 | guard let loadedTokens = _checkpoints[cpId] else { return false } 26 | guard _scanner.restore(fromCheckpoint: cpId) else { return false } 27 | 28 | _loadedTokens = loadedTokens 29 | return true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sources/Lexer/NamedIdentifier.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public enum NamedIdentifier { 18 | case name(String) 19 | case backtickedName(String) 20 | case wildcard 21 | } 22 | -------------------------------------------------------------------------------- /Sources/Parser/Parser.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import AST 18 | import Lexer 19 | import Source 20 | 21 | public class Parser { 22 | let _sourceFile: SourceFile 23 | let _lexer: Lexer 24 | 25 | public init(source: SourceFile) { 26 | _sourceFile = source 27 | _lexer = Lexer(source: source) 28 | } 29 | 30 | public func parse() throws -> TopLevelDeclaration { 31 | let topLevelDecl = try parseTopLevelDeclaration() 32 | topLevelDecl.setSourceFile(_sourceFile) 33 | return topLevelDecl 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/Source/Comment.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public struct Comment: Equatable, Hashable { 18 | public let content: String 19 | public let location: SourceLocation 20 | 21 | public init(content: String, location: SourceLocation) { 22 | self.content = content 23 | self.location = location 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Sources/Source/CommentSet.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public typealias CommentSet = Set 18 | -------------------------------------------------------------------------------- /Sources/Source/Shebang.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public struct Shebang { 18 | public let interpreterDirective: String 19 | 20 | public init(interpreterDirective: String) { 21 | self.interpreterDirective = interpreterDirective 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/Source/SourceError.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public enum SourceError : Error { 18 | case cannotReadFile(String) 19 | } 20 | -------------------------------------------------------------------------------- /Sources/Source/SourceLocatable.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public protocol SourceLocatable { 18 | var sourceLocation: SourceLocation { get } 19 | var sourceRange: SourceRange { get } 20 | } 21 | 22 | extension SourceLocatable { 23 | public var sourceLocation: SourceLocation { 24 | return sourceRange.start 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/Tooling/ToolActionOptions.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | public struct ToolActionOptions : OptionSet { 18 | public let rawValue: Int 19 | 20 | public init(rawValue: Int) { 21 | self.rawValue = rawValue 22 | } 23 | 24 | public static let foldSequenceExpression = ToolActionOptions(rawValue: 1 << 0) 25 | public static let assignLexicalParent = ToolActionOptions(rawValue: 1 << 1) 26 | } 27 | -------------------------------------------------------------------------------- /Tests/ASTTests/TopLevelDeclarationTests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | @testable import AST 20 | @testable import Source 21 | 22 | class TopLevelDeclarationTests : XCTestCase { 23 | func testEmptyContent() { 24 | let topLevelDecl = TopLevelDeclaration() 25 | XCTAssertTrue(topLevelDecl.statements.isEmpty) 26 | XCTAssertTrue(topLevelDecl.comments.isEmpty) 27 | XCTAssertEqual(topLevelDecl.sourceRange, .EMPTY) 28 | } 29 | 30 | static var allTests = [ 31 | ("testEmptyContent", testEmptyContent), 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /Tests/ASTTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(LocatableNodeTests.allTests), 23 | testCase(TopLevelDeclarationTests.allTests), 24 | ] 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /Tests/ASTVisitorTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(DefaultVisitImplementationTests.allTests), 23 | testCase(DefaultTraverseImplementationTests.allTests), 24 | testCase(ASTVisitorTopLevelDeclTraversalTests.allTests), 25 | testCase(ASTVisitorCodeBlockTraversalTests.allTests), 26 | ] 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /Tests/CanaryTests/CanaryTests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | class CanaryTests: XCTestCase { 20 | func testCanary() { 21 | XCTAssertTrue(true) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/CanaryTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase([("testCanary", CanaryTests.testCanary)]), 23 | ] 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /Tests/CommandLineTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(CLIOptionTests.allTests), 23 | ] 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /Tests/DiagnosticTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(DiagnosticPoolTests.allTests), 23 | ] 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /Tests/DotYanagibaTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(DotYanagibaParserTests.allTests), 23 | testCase(DotYanagibaMergeTests.allTests), 24 | ] 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/ShebangResources/ShebangDump.result: -------------------------------------------------------------------------------- 1 | shebang `/usr/bin/env swift` 2 | top_level_decl 3 | function_call_expr 4 | identifier_expr 5 | kind: `identifier`, identifier: `print` 6 | arguments: 7 | 0: kind: `expression` 8 | literal_expr 9 | kind: `string`, raw_text: `"foobar"` 10 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/ShebangResources/ShebangDump.source: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env swift 2 | 3 | /* 4 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | print("foobar") 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/ShebangResources/ShebangPrint.result: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env swift 2 | 3 | print("foobar") 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/ShebangResources/ShebangPrint.source: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env swift 2 | 3 | /* 4 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | print("foobar") 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/AssignmentOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | (a, _, (b, c)) = ("test", 9.45, (12, 3)) 18 | foo = bar 19 | foo = try bar 20 | foo = try? bar 21 | foo = try! bar 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/BinaryOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo/bar 18 | foo<>bar 19 | foo...bar 20 | foo / bar 21 | foo <> bar 22 | foo ... bar 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/BreakStatement.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | break_stmt 3 | label_name: `foo` 4 | break_stmt 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/BreakStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | break foo 18 | break 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/CompilerControlStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #if os(macOS) 18 | break 19 | #elseif swift(>=3.1) 20 | return 21 | #else 22 | continue 23 | #endif 24 | 25 | #sourceLocation(file: "filename", line: 10) 26 | #sourceLocation() 27 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ConstantDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | let foo 18 | let foo: Foo 19 | let foo: Foo = bar 20 | let foo = bar, a, x = y 21 | @a let foo 22 | private nonmutating static final let foo = bar 23 | @a fileprivate let foo 24 | let foo = bar { $0 == 0 } 25 | let foo = bar { $0 = 0 }, a = b { _ in true }, x = y { t -> Int in t^2 } 26 | let foo = bar { $0 == 0 }.joined() 27 | let range = 1..<9 28 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ContinueStatement.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | continue_stmt 3 | label_name: `foo` 4 | continue_stmt 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ContinueStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | continue foo 18 | continue 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/DeferStatement.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | defer_stmt 3 | break_stmt 4 | defer_stmt 5 | defer_stmt 6 | return_stmt 7 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/DeferStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | defer { 18 | break 19 | } 20 | 21 | defer { 22 | defer { 23 | return 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/DeinitializerDeclaration.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | deinit_decl 3 | function_call_expr 4 | explicit_member_expr 5 | identifier_expr 6 | kind: `identifier`, identifier: `NSNotificationCenter` 7 | identifier: `removeObserver` 8 | arguments: 9 | 0: kind: `expression` 10 | self_expr 11 | kind: `self` 12 | deinit_decl 13 | attributes: `@a @b @c` 14 | 15 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/DeinitializerDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | deinit { NSNotificationCenter.removeObserver(self) } 18 | @a @b @c deinit {} 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/DoStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | do { 18 | try foo 19 | } 20 | 21 | do { 22 | try expression 23 | } catch pattern1 { 24 | foo() 25 | } catch pattern2 where condition { 26 | bar() 27 | } catch { 28 | all() 29 | } 30 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ExplicitMemberExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo.0 18 | foo.bar 19 | foo.bar 20 | foo.bar(a:b:c:) 21 | foo.bar.a.100.b(y:) 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ExtensionDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | extension Foo {} 18 | @a @b @c extension Foo {} 19 | fileprivate extension Foo {} 20 | @a public extension Foo {} 21 | extension a.b.c.Foo {} 22 | extension Foo: String {} 23 | extension Foo where Foo == Bar {} 24 | extension Foo { 25 | let a = 1 // TODO: Suppose you can't have stored properties in extensions 26 | } 27 | extension Foo { 28 | let a = 1 29 | var b = 2 30 | } 31 | extension Foo { 32 | #if a 33 | let a = 1 34 | #elseif b 35 | let b = 2 36 | #else 37 | let e = 3 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/FallthroughStatement.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | fallthrough_stmt 3 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/FallthroughStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | fallthrough 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ForInStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | for i in aCollection { print(i) } 18 | for case i in aCollection {} 19 | for (k, v) in [1: true, 0: false] where v {} 20 | for (index, it) in enumerate([]) {} 21 | for e in 0..<9 {} 22 | for e in 0..< {} 23 | for e in ...9 {} 24 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ForcedValueExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | forced_value_expr 3 | identifier_expr 4 | kind: `identifier`, identifier: `foo` 5 | forced_value_expr 6 | forced_value_expr 7 | identifier_expr 8 | kind: `identifier`, identifier: `foo` 9 | forced_value_expr 10 | optional_chaining_expr 11 | identifier_expr 12 | kind: `identifier`, identifier: `foo` 13 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ForcedValueExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo! 18 | foo!! 19 | foo?! 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/GuardStatement.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | guard_stmt 3 | conditions: 4 | 0: identifier_expr 5 | kind: `identifier`, identifier: `foo` 6 | return_stmt 7 | literal_expr 8 | kind: `bool`, literal: `false` 9 | guard_stmt 10 | conditions: 11 | 0: try_expr 12 | kind: `optional_try` 13 | function_call_expr 14 | identifier_expr 15 | kind: `identifier`, identifier: `bar` 16 | arguments: 17 | 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/GuardStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | guard foo else { 18 | return false 19 | } 20 | 21 | guard try? bar() else { 22 | // do nothing 23 | } 24 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/IdentifierExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | identifier_expr 3 | kind: `identifier`, identifier: `foo` 4 | identifier_expr 5 | kind: `identifier`, identifier: `foo`, generic_argument: `` 6 | identifier_expr 7 | kind: `identifier`, identifier: ``class`` 8 | identifier_expr 9 | kind: `identifier`, identifier: ``class``, generic_argument: `

` 10 | identifier_expr 11 | kind: `implicit_param_name`, index: `0` 12 | identifier_expr 13 | kind: `implicit_param_name`, index: `0`, generic_argument: `` 14 | identifier_expr 15 | kind: `binding_reference`, variable: `a` 16 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/IdentifierExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017, 2019 Ryuichi Intellectual Property 3 | and the Yanagiba project contributors 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | foo 19 | foo 20 | `class` 21 | `class`

22 | $0 23 | $0 24 | $a 25 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ImplicitMemberExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | assign_expr 3 | wildcard_expr 4 | implicit_member_expr 5 | identifier: `identifier` 6 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ImplicitMemberExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = .foo 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ImportDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import foo 18 | import >> 19 | import A.B.C.<<= 20 | @a import foo 21 | import typealias foo 22 | import struct foo 23 | import class foo 24 | import enum foo 25 | @x @y @z import protocol foo 26 | import var foo 27 | import func foo 28 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/InOutExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | in_out_expr 3 | identifier: `foo` 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/InOutExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | &foo 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/InitializerExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | initializer_expr 3 | identifier_expr 4 | kind: `identifier`, identifier: `foo` 5 | arguments: 6 | initializer_expr 7 | identifier_expr 8 | kind: `identifier`, identifier: `foo` 9 | arguments: 10 | 0: name: `bar` 11 | initializer_expr 12 | identifier_expr 13 | kind: `identifier`, identifier: `foo` 14 | arguments: 15 | 0: name: `a` 16 | 1: name: `b` 17 | 2: name: `c` 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/InitializerExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo.init 18 | foo.init(bar:) 19 | foo.init(a:b:c:) 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/KeyPathExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = \.foo 18 | _ = \.foo.bar 19 | _ = \A.foo.bar 20 | _ = \.! 21 | _ = \.? 22 | _ = \.[foo, bar] 23 | _ = \.b! 24 | _ = \.b? 25 | _ = \.b[foo, bar] 26 | _ = \a.b! 27 | _ = \a.b? 28 | _ = \a.b[foo, bar] 29 | _ = \.?!?! 30 | _ = \.![x]!?[y][z]! 31 | _ = \.?.!.[foo, bar].a?.b!.c[foo, bar].?!?!.![x]!?[y][z]! 32 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/KeyPathStringExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | assign_expr 3 | wildcard_expr 4 | key_path_string_expr 5 | identifier_expr 6 | kind: `identifier`, identifier: `foo` 7 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/KeyPathStringExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = #keyPath(foo) 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/LabeledStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo: for _ in 0..<10 {} 18 | foo: while true {} 19 | foo: repeat {} while true 20 | foo: if x {} 21 | foo: switch bar {} 22 | foo: do { try bar() } 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/OperatorDeclaration.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | op_decl 3 | kind: `prefix`, operator: `` 4 | op_decl 5 | kind: `infix`, operator: `` 6 | op_decl 7 | kind: `infix`, operator: ``, precedence_group_name: `foo` 8 | op_decl 9 | kind: `postfix`, operator: `` 10 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/OperatorDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | prefix operator 18 | infix operator 19 | infix operator :foo 20 | postfix operator 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/OptionalChainingExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | optional_chaining_expr 3 | identifier_expr 4 | kind: `identifier`, identifier: `foo` 5 | optional_chaining_expr 6 | optional_chaining_expr 7 | identifier_expr 8 | kind: `identifier`, identifier: `foo` 9 | optional_chaining_expr 10 | forced_value_expr 11 | identifier_expr 12 | kind: `identifier`, identifier: `foo` 13 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/OptionalChainingExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo? 18 | foo?? 19 | foo!? 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ParenthesizedExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | assign_expr 3 | wildcard_expr 4 | paren_expr 5 | identifier_expr 6 | kind: `identifier`, identifier: `foo` 7 | assign_expr 8 | wildcard_expr 9 | paren_expr 10 | paren_expr 11 | paren_expr 12 | identifier_expr 13 | kind: `identifier`, identifier: `bar` 14 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ParenthesizedExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = (foo) 18 | _ = (((bar))) 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/PostfixOperatorExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | postfix_op_expr 3 | operator: `/` 4 | identifier_expr 5 | kind: `identifier`, identifier: `foo` 6 | postfix_op_expr 7 | operator: `<>` 8 | identifier_expr 9 | kind: `identifier`, identifier: `foo` 10 | postfix_op_expr 11 | operator: `...` 12 | identifier_expr 13 | kind: `identifier`, identifier: `foo` 14 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/PostfixOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo/ 18 | foo<> 19 | foo... 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/PostfixSelfExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | postfix_self_expr 3 | identifier_expr 4 | kind: `identifier`, identifier: `foo` 5 | postfix_self_expr 6 | explicit_member_expr 7 | identifier_expr 8 | kind: `identifier`, identifier: `foo` 9 | identifier: `bar` 10 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/PostfixSelfExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo.self 18 | foo.bar.self 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/PrefixOperatorExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | prefix_op_expr 3 | operator: `/` 4 | identifier_expr 5 | kind: `identifier`, identifier: `foo` 6 | prefix_op_expr 7 | operator: `<>` 8 | identifier_expr 9 | kind: `identifier`, identifier: `foo` 10 | prefix_op_expr 11 | operator: `...` 12 | identifier_expr 13 | kind: `identifier`, identifier: `foo` 14 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/PrefixOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /foo 18 | <>foo 19 | ...foo 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/RepeatWhileStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | repeat {} while true 18 | 19 | repeat { 20 | print(i) 21 | } while shouldContinue(with: i) 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ReturnStatement.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | return_stmt 3 | return_stmt 4 | identifier_expr 5 | kind: `identifier`, identifier: `foo` 6 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ReturnStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | return 18 | return foo 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/SelectorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = #selector(foo) 18 | _ = #selector(self.bar) 19 | _ = #selector(getter: SomeClass.property) 20 | _ = #selector(setter: SomeClass.property) 21 | _ = #selector(pillTapped(_:)) 22 | _ = #selector(self.pillTapped(_:)) 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/SelfExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | self_expr 3 | kind: `self` 4 | self_expr 5 | kind: `method`, method_name: `foo` 6 | self_expr 7 | kind: `initializer` 8 | self_expr 9 | kind: `subscript` 10 | 0: identifier_expr 11 | kind: `identifier`, identifier: `foo` 12 | 1: identifier_expr 13 | kind: `identifier`, identifier: `bar` 14 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/SelfExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | self 18 | self.foo 19 | self.init 20 | self[foo, bar] 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/SubscriptExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo[0] 18 | foo [ a ,0, b ,1 , 5,_] 19 | foo [n-1, n--1] 20 | foo [n+1] 21 | foo [bar()] 22 | foo [try bar()] 23 | foo[0...1] 24 | foo[0..<1] 25 | foo[0...] 26 | foo[...1] 27 | foo[0..<] 28 | foo[..<1] 29 | a[safe: i] 30 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/SuperclassExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | superclass_expr 3 | kind: `method`, method_name: `foo` 4 | superclass_expr 5 | kind: `initializer` 6 | superclass_expr 7 | kind: `subscript` 8 | 0: identifier_expr 9 | kind: `identifier`, identifier: `foo` 10 | 1: identifier_expr 11 | kind: `identifier`, identifier: `bar` 12 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/SuperclassExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | super.foo 18 | super.init 19 | super[foo, bar] 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/TernaryConditionalOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | condition ? true : false 18 | c() ? t() : f() 19 | try? c() ? try t() : try! f() 20 | a ? b ? c ? d : e : f : g // a ? (b ? (c ? d : e) : f) : g 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ThrowStatement.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | throw_stmt 3 | identifier_expr 4 | kind: `identifier`, identifier: `foo` 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/ThrowStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | throw foo 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/TryOperatorExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | try_expr 3 | kind: `try` 4 | identifier_expr 5 | kind: `identifier`, identifier: `foo` 6 | try_expr 7 | kind: `optional_try` 8 | identifier_expr 9 | kind: `identifier`, identifier: `foo` 10 | try_expr 11 | kind: `forced_try` 12 | identifier_expr 13 | kind: `identifier`, identifier: `foo` 14 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/TryOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | try foo 18 | try? foo 19 | try! foo 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/TupleExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = () 18 | _ = (a: 1) 19 | _ = (foo, bar) 20 | _ = ( a : 1 , b : foo, ( ) ) 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/TypeCastingOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo is bar 18 | foo as bar 19 | foo as? bar 20 | foo as! bar 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/TypealiasDeclaration.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | typealias_decl 3 | name: Foo 4 | type: Bar 5 | typealias_decl 6 | name: Foo 7 | attributes: `@a @b @c` 8 | type: Bar 9 | typealias_decl 10 | name: Foo 11 | access_level: fileprivate 12 | type: Bar 13 | typealias_decl 14 | name: Foo 15 | attributes: `@a` 16 | access_level: public 17 | type: Bar 18 | typealias_decl 19 | name: Foo 20 | generic_param: `` 21 | type: (a, b, c) throws -> Bar 22 | typealias_decl 23 | name: Foo 24 | attributes: `@a` 25 | access_level: public 26 | generic_param: `` 27 | type: Bar 28 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/TypealiasDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | typealias Foo = Bar 18 | @a @b @c typealias Foo = Bar 19 | fileprivate typealias Foo = Bar 20 | @a public typealias Foo = Bar 21 | typealias Foo = (a, b, c) throws -> Bar 22 | @a public typealias Foo = Bar 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/WhileStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | while true {} 18 | 19 | while shouldContinue(with: i) { 20 | print(i) 21 | } 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/WildcardExpression.result: -------------------------------------------------------------------------------- 1 | top_level_decl 2 | wildcard_expr 3 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTDumpTestResources/WildcardExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/AssignmentOperatorExpression.result: -------------------------------------------------------------------------------- 1 | (a, _, (b, c)) = ("test", 9.45, (12, 3)) 2 | foo = bar 3 | foo = try bar 4 | foo = try? bar 5 | foo = try! bar 6 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/AssignmentOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | (a, _, (b, c)) = ("test", 9.45, (12, 3)) 18 | foo = bar 19 | foo = try bar 20 | foo = try? bar 21 | foo = try! bar 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/BinaryOperatorExpression.result: -------------------------------------------------------------------------------- 1 | foo / bar 2 | foo <> bar 3 | foo ... bar 4 | foo / bar 5 | foo <> bar 6 | foo ... bar 7 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/BinaryOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo/bar 18 | foo<>bar 19 | foo...bar 20 | foo / bar 21 | foo <> bar 22 | foo ... bar 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/BreakStatement.result: -------------------------------------------------------------------------------- 1 | break foo 2 | break 3 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/BreakStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | break foo 18 | break 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ClassDeclaration.result: -------------------------------------------------------------------------------- 1 | class Foo {} 2 | @a @b @c class Foo {} 3 | fileprivate class Foo {} 4 | @a public class Foo {} 5 | final class Foo {} 6 | @a public final class Foo {} 7 | @a public final class Foo {} 8 | class Foo {} 9 | class Foo: String {} 10 | class Foo where Foo == Bar {} 11 | class Foo: Array where T: protocol {} 12 | class Foo { 13 | let a = 1 14 | } 15 | class Foo { 16 | let a = 1 17 | var b = 2 18 | } 19 | class Foo { 20 | class Bar { 21 | let b = 2 22 | } 23 | } 24 | class Foo { 25 | #if a 26 | let a = 1 27 | #elseif b 28 | let b = 2 29 | #else 30 | let e = 3 31 | #endif 32 | } 33 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ClosureExpression.result: -------------------------------------------------------------------------------- 1 | _ = {} 2 | _ = { self.present(vc, animated: true) } 3 | _ = { 4 | vc.foo = foo 5 | self.present(vc, animated: true) 6 | } 7 | _ = { [self] in } 8 | _ = { [weak self] in } 9 | _ = { [weak self, foo, unowned bar, unowned(safe) abc, unowned(unsafe) xyz] in } 10 | _ = { [weak self] in 11 | self.present(vc, animated: true) 12 | } 13 | _ = { () in } 14 | _ = { (foo) in } 15 | _ = { (foo: Foo) in } 16 | _ = { (foo: Foo...) in } 17 | _ = { (_, b: Bar, c: Foo...) in } 18 | _ = { (a, b, c) in 19 | print(a) 20 | print(b) 21 | print(c) 22 | } 23 | _ = { foo in } 24 | _ = { foo, _, bar in } 25 | _ = { a, b, c in 26 | print(a) 27 | print(b) 28 | print(c) 29 | } 30 | _ = { () throws in } 31 | _ = { () -> Foo in } 32 | _ = { () -> @a @b @c Foo in } 33 | _ = { () throws -> @foo Bar in } 34 | _ = { [weak foo = self.foo] (a, b, c) throws -> @x @y @z Bar in 35 | print(foo!.title) 36 | } 37 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/CompilerControlStatement.result: -------------------------------------------------------------------------------- 1 | #if os(macOS) 2 | break 3 | #elseif swift(>=3.1) 4 | return 5 | #else 6 | continue 7 | #endif 8 | #sourceLocation(file: "filename", line: 10) 9 | #sourceLocation() 10 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/CompilerControlStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #if os(macOS) 18 | break 19 | #elseif swift(>=3.1) 20 | return 21 | #else 22 | continue 23 | #endif 24 | 25 | #sourceLocation(file: "filename", line: 10) 26 | #sourceLocation() 27 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ConstantDeclaration.result: -------------------------------------------------------------------------------- 1 | let foo 2 | let foo: Foo 3 | let foo: Foo = bar 4 | let foo = bar, a, x = y 5 | @a let foo 6 | private nonmutating static final let foo = bar 7 | @a fileprivate let foo 8 | let foo = bar { $0 == 0 } 9 | let foo = bar { $0 = 0 }, a = b { _ in 10 | true 11 | }, x = y { t -> Int in 12 | t ^ 2 13 | } 14 | let foo = bar { $0 == 0 }.joined() 15 | let foo = 1 ... 9 16 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ConstantDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | let foo 18 | let foo: Foo 19 | let foo: Foo = bar 20 | let foo = bar, a, x = y 21 | @a let foo 22 | private nonmutating static final let foo = bar 23 | @a fileprivate let foo 24 | let foo = bar { $0 == 0 } 25 | let foo = bar { $0 = 0 }, a = b { _ in true }, x = y { t -> Int in t^2 } 26 | let foo = bar { $0 == 0 }.joined() 27 | let foo = 1...9 28 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ContinueStatement.result: -------------------------------------------------------------------------------- 1 | continue foo 2 | continue 3 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ContinueStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | continue foo 18 | continue 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/DeferStatement.result: -------------------------------------------------------------------------------- 1 | defer { 2 | break 3 | } 4 | defer { 5 | defer { 6 | return 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/DeferStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | defer { 18 | break 19 | } 20 | 21 | defer { 22 | defer { 23 | return 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/DeinitializerDeclaration.result: -------------------------------------------------------------------------------- 1 | deinit { 2 | NSNotificationCenter.removeObserver(self) 3 | } 4 | @a @b @c deinit {} 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/DeinitializerDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | deinit { NSNotificationCenter.removeObserver(self) } 18 | @a @b @c deinit {} 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/DoStatement.result: -------------------------------------------------------------------------------- 1 | do { 2 | try foo 3 | } 4 | do { 5 | try expression 6 | } catch pattern1 { 7 | foo() 8 | } catch pattern2 where condition { 9 | bar() 10 | } catch { 11 | all() 12 | } 13 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/DoStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | do { 18 | try foo 19 | } 20 | 21 | do { 22 | try expression 23 | } catch pattern1 { 24 | foo() 25 | } catch pattern2 where condition { 26 | bar() 27 | } catch { 28 | all() 29 | } 30 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ExplicitMemberExpression.result: -------------------------------------------------------------------------------- 1 | foo.0 2 | foo.bar 3 | foo.bar 4 | foo.bar(a:b:c:) 5 | foo.bar.a.100.b(y:) 6 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ExplicitMemberExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo.0 18 | foo.bar 19 | foo.bar 20 | foo.bar(a:b:c:) 21 | foo.bar.a.100.b(y:) 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ExtensionDeclaration.result: -------------------------------------------------------------------------------- 1 | extension Foo {} 2 | @a @b @c extension Foo {} 3 | fileprivate extension Foo {} 4 | @a public extension Foo {} 5 | extension a.b.c.Foo {} 6 | extension Foo: String {} 7 | extension Foo where Foo == Bar {} 8 | extension Foo { 9 | let a = 1 10 | } 11 | extension Foo { 12 | let a = 1 13 | var b = 2 14 | } 15 | extension Foo { 16 | #if a 17 | let a = 1 18 | #elseif b 19 | let b = 2 20 | #else 21 | let e = 3 22 | #endif 23 | } 24 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ExtensionDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | extension Foo {} 18 | @a @b @c extension Foo {} 19 | fileprivate extension Foo {} 20 | @a public extension Foo {} 21 | extension a.b.c.Foo {} 22 | extension Foo: String {} 23 | extension Foo where Foo == Bar {} 24 | extension Foo { 25 | let a = 1 // TODO: Suppose you can't have stored properties in extensions 26 | } 27 | extension Foo { 28 | let a = 1 29 | var b = 2 30 | } 31 | extension Foo { 32 | #if a 33 | let a = 1 34 | #elseif b 35 | let b = 2 36 | #else 37 | let e = 3 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/FallthroughStatement.result: -------------------------------------------------------------------------------- 1 | fallthrough 2 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/FallthroughStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | fallthrough 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ForInStatement.result: -------------------------------------------------------------------------------- 1 | for i in aCollection { 2 | print(i) 3 | } 4 | for case i in aCollection {} 5 | for (k, v) in [1: true, 0: false] where v {} 6 | for (index, it) in enumerate([]) {} 7 | for e in 0 ..< 9 {} 8 | for e in 0..< {} 9 | for e in ...9 {} 10 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ForInStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | for i in aCollection { print(i) } 18 | for case i in aCollection {} 19 | for (k, v) in [1: true, 0: false] where v {} 20 | for (index, it) in enumerate([]) {} 21 | for e in 0..<9 {} 22 | for e in 0..< {} 23 | for e in ...9 {} 24 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ForcedValueExpression.result: -------------------------------------------------------------------------------- 1 | foo! 2 | foo!! 3 | foo?! 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ForcedValueExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo! 18 | foo!! 19 | foo?! 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/FunctionCallExpression.result: -------------------------------------------------------------------------------- 1 | foo() 2 | foo(1) 3 | foo(a: 1) 4 | foo([:]) 5 | foo(+) 6 | foo(<+>) 7 | foo(!) 8 | foo(....) 9 | foo(op: +) 10 | foo(-, op: -, -bar, expr: -bar) 11 | min(-data.yMax * 0.1, data.yMin) 12 | assert(!bytes.isEmpty) 13 | foo(+, a: -, b: b, _) 14 | map({ $0.textDescription }) 15 | foo() { self.foo = $0 } 16 | foo(1) { self.foo = $0 } 17 | foo { self.foo = $0 } 18 | foo.bar(x) 19 | foo.bar() 20 | foo(&bar) 21 | foo(a: &A.b) 22 | foo([1, 2, 3].map { i in 23 | i ^ 2 24 | }.joined()) 25 | foo([1, 2, 3].map { i in 26 | i ^ 2 27 | }) 28 | map { i -> String in 29 | let j = i ^ 2 30 | return "\(j)" 31 | } 32 | toggle(isOn: $favorited) 33 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/FunctionDeclaration.result: -------------------------------------------------------------------------------- 1 | func foo() 2 | func () 3 | infix func <() 4 | postfix func <() 5 | prefix func >() 6 | @a @b @c func foo() 7 | fileprivate static final override func foo() 8 | @a @b @c private prefix func √() 9 | func foo>() 10 | func foo(bar: Bar) 11 | func foo(bar: inout Bar) 12 | func foo(_b bar: Bar) 13 | func foo(_ bar: Bar) 14 | func foo(_: Bar, and _: Bar) 15 | func foo(i: Int = 12) 16 | func foo(bar: Bar...) 17 | func foo(a: A, _ b: B, c: inout C, d: @a D, e: E...) 18 | func foo(bar: Bar) throws 19 | func foo(bar: Bar) rethrows 20 | func foo(bar: Bar) -> @a @b @c Foo 21 | func foo(bar: Bar) throws -> Foo 22 | func foo(bar: Bar) rethrows -> Foo 23 | func foo() -> Opaque 24 | func foo() where A == Foo 25 | func foo() {} 26 | func foo() { 27 | print("hello world") 28 | } 29 | func foo() where A == Foo {} 30 | func foo(b: () -> String) 31 | func foo(b: @autoclosure (Int) rethrows -> String) 32 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/GuardStatement.result: -------------------------------------------------------------------------------- 1 | guard foo else { 2 | return false 3 | } 4 | guard try? bar() else {} 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/GuardStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | guard foo else { 18 | return false 19 | } 20 | 21 | guard try? bar() else { 22 | // do nothing 23 | } 24 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/IdentifierExpression.result: -------------------------------------------------------------------------------- 1 | foo 2 | foo 3 | `class` 4 | `class`

5 | $0 6 | $0 7 | $a 8 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/IdentifierExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017, 2019 Ryuichi Intellectual Property 3 | and the Yanagiba project contributors 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | foo 19 | foo 20 | `class` // TODO: need to take care of the backtick 21 | `class`

22 | $0 23 | $0 24 | $a 25 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/IfStatement.result: -------------------------------------------------------------------------------- 1 | if true {} 2 | if cond1 && cond2 || cond3 { 3 | print("🌝") 4 | } 5 | if (cond1 && cond2 || cond3) { 6 | print("🌚") 7 | } 8 | if #available(*) {} 9 | if #available(iOS 10, *) { 10 | print("⛰") 11 | } else if #available(iOS 10.2, *) { 12 | print("🏔") 13 | } else if #available(iOS 10.2.1, *) { 14 | print("🗻") 15 | } else { 16 | print("🌋") 17 | } 18 | if case .foo(let bar) = foobar {} 19 | if case 0 ..< 255 = aNumber {} 20 | if let foo = foo, !foo.isEmpty {} 21 | if var foo = foo, !foo.isEmpty {} 22 | if foo < 1 {} 23 | if foo < bar {} 24 | if foo < (bar) {} 25 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ImplicitMemberExpression.result: -------------------------------------------------------------------------------- 1 | _ = .foo 2 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ImplicitMemberExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = .foo 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ImportDeclaration.result: -------------------------------------------------------------------------------- 1 | import foo 2 | import >> 3 | import A.B.C.<<= 4 | @a import foo 5 | import typealias foo 6 | import struct foo 7 | import class foo 8 | import enum foo 9 | @x @y @z import protocol foo 10 | import var foo 11 | import func foo 12 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ImportDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import foo 18 | import >> 19 | import A.B.C.<<= 20 | @a import foo 21 | import typealias foo 22 | import struct foo 23 | import class foo 24 | import enum foo 25 | @x @y @z import protocol foo 26 | import var foo 27 | import func foo 28 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/InOutExpression.result: -------------------------------------------------------------------------------- 1 | &foo 2 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/InOutExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | &foo 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/InitializerDeclaration.result: -------------------------------------------------------------------------------- 1 | init() {} 2 | init?() { 3 | return nil 4 | } 5 | init!() { 6 | self.foo = nil 7 | } 8 | @a @b @c init() {} 9 | fileprivate convenience required init() {} 10 | @a @b @c private override init() {} 11 | init>() {} 12 | init(bar: Bar) {} 13 | init(bar: inout Bar) {} 14 | init(_b bar: Bar) {} 15 | init(_ bar: Bar) {} 16 | init(i: Int = 12) {} 17 | init(bar: Bar...) {} 18 | init(a: A, _ b: B, c: inout C, d: @a D, e: E...) {} 19 | init(bar: Bar) throws {} 20 | init(bar: Bar) rethrows {} 21 | init() where A == Foo {} 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/InitializerExpression.result: -------------------------------------------------------------------------------- 1 | foo.init 2 | foo.init(bar:) 3 | foo.init(a:b:c:) 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/InitializerExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo.init 18 | foo.init(bar:) 19 | foo.init(a:b:c:) 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/KeyPathExpression.result: -------------------------------------------------------------------------------- 1 | _ = \.foo 2 | _ = \.foo.bar 3 | _ = \A.foo.bar 4 | _ = \.! 5 | _ = \.? 6 | _ = \.[foo, bar] 7 | _ = \.b! 8 | _ = \.b? 9 | _ = \.b[foo, bar] 10 | _ = \a.b! 11 | _ = \a.b? 12 | _ = \a.b[foo, bar] 13 | _ = \.?!?! 14 | _ = \.![x]!?[y][z]! 15 | _ = \.?.!.[foo, bar].a?.b!.c[foo, bar].?!?!.![x]!?[y][z]! 16 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/KeyPathExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = \.foo 18 | _ = \.foo.bar 19 | _ = \A.foo.bar 20 | _ = \.! 21 | _ = \.? 22 | _ = \.[foo, bar] 23 | _ = \.b! 24 | _ = \.b? 25 | _ = \.b[foo, bar] 26 | _ = \a.b! 27 | _ = \a.b? 28 | _ = \a.b[foo, bar] 29 | _ = \.?!?! 30 | _ = \.![x]!?[y][z]! 31 | _ = \.?.!.[foo, bar].a?.b!.c[foo, bar].?!?!.![x]!?[y][z]! 32 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/KeyPathStringExpression.result: -------------------------------------------------------------------------------- 1 | _ = #keyPath(foo) 2 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/KeyPathStringExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = #keyPath(foo) 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/LabeledStatement.result: -------------------------------------------------------------------------------- 1 | foo: for _ in 0 ..< 10 {} 2 | foo: while true {} 3 | foo: repeat {} while true 4 | foo: if x {} 5 | foo: switch bar {} 6 | foo: do { 7 | try bar() 8 | } 9 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/LabeledStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo: for _ in 0..<10 {} 18 | foo: while true {} 19 | foo: repeat {} while true 20 | foo: if x {} 21 | foo: switch bar {} 22 | foo: do { try bar() } 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/OperatorDeclaration.result: -------------------------------------------------------------------------------- 1 | prefix operator 2 | infix operator 3 | infix operator : foo 4 | postfix operator 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/OperatorDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | prefix operator 18 | infix operator 19 | infix operator :foo 20 | postfix operator 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/OptionalChainingExpression.result: -------------------------------------------------------------------------------- 1 | foo? 2 | foo?? 3 | foo!? 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/OptionalChainingExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo? 18 | foo?? 19 | foo!? 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ParenthesizedExpression.result: -------------------------------------------------------------------------------- 1 | _ = (foo) 2 | _ = (((bar))) 3 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ParenthesizedExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = (foo) 18 | _ = (((bar))) 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/PostfixOperatorExpression.result: -------------------------------------------------------------------------------- 1 | foo/ 2 | foo<> 3 | foo... 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/PostfixOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo/ 18 | foo<> 19 | foo... 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/PostfixSelfExpression.result: -------------------------------------------------------------------------------- 1 | foo.self 2 | foo.bar.self 3 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/PostfixSelfExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo.self 18 | foo.bar.self 19 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/PrecedenceGroupDeclaration.result: -------------------------------------------------------------------------------- 1 | precedencegroup foo {} 2 | precedencegroup foo { 3 | higherThan: bar 4 | } 5 | precedencegroup foo { 6 | higherThan: a, b, c 7 | } 8 | precedencegroup foo { 9 | lowerThan: bar 10 | } 11 | precedencegroup foo { 12 | lowerThan: a, b, c 13 | } 14 | precedencegroup foo { 15 | assignment: true 16 | } 17 | precedencegroup foo { 18 | assignment: false 19 | } 20 | precedencegroup foo { 21 | associativity: left 22 | } 23 | precedencegroup foo { 24 | associativity: right 25 | } 26 | precedencegroup foo { 27 | associativity: none 28 | } 29 | precedencegroup foo { 30 | higherThan: bar 31 | higherThan: a, b, c 32 | lowerThan: bar 33 | lowerThan: a, b, c 34 | assignment: true 35 | assignment: false 36 | associativity: left 37 | associativity: right 38 | associativity: none 39 | } 40 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/PrefixOperatorExpression.result: -------------------------------------------------------------------------------- 1 | /foo 2 | <>foo 3 | ...foo 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/PrefixOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /foo 18 | <>foo 19 | ...foo 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/RepeatWhileStatement.result: -------------------------------------------------------------------------------- 1 | repeat {} while true 2 | repeat { 3 | print(i) 4 | } while shouldContinue(with: i) 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/RepeatWhileStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | repeat {} while true 18 | 19 | repeat { 20 | print(i) 21 | } while shouldContinue(with: i) 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ReturnStatement.result: -------------------------------------------------------------------------------- 1 | return 2 | return foo 3 | return foo { $0.ttyPrint } 4 | return foo { i in 5 | i.ttyPrint 6 | } 7 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ReturnStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | return 18 | return foo 19 | return foo { $0.ttyPrint } 20 | return foo { i in 21 | i.ttyPrint 22 | } 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SelectorExpression.result: -------------------------------------------------------------------------------- 1 | _ = #selector(foo) 2 | _ = #selector(self.bar) 3 | _ = #selector(getter: SomeClass.property) 4 | _ = #selector(setter: SomeClass.property) 5 | _ = #selector(pillTapped(_:)) 6 | _ = #selector(self.pillTapped(_:)) 7 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SelectorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = #selector(foo) 18 | _ = #selector(self.bar) 19 | _ = #selector(getter: SomeClass.property) 20 | _ = #selector(setter: SomeClass.property) 21 | _ = #selector(pillTapped(_:)) 22 | _ = #selector(self.pillTapped(_:)) 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SelfExpression.result: -------------------------------------------------------------------------------- 1 | self 2 | self.foo 3 | self.init 4 | self[foo, bar] 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SelfExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | self 18 | self.foo 19 | self.init 20 | self[foo, bar] 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/StructDeclaration.result: -------------------------------------------------------------------------------- 1 | struct Foo {} 2 | @a @b @c struct Foo {} 3 | fileprivate struct Foo {} 4 | @a public struct Foo {} 5 | struct Foo {} 6 | struct Foo: String {} 7 | struct Foo where Foo == Bar {} 8 | struct Foo: Array where T: protocol {} 9 | struct Foo { 10 | let a = 1 11 | } 12 | struct Foo { 13 | let a = 1 14 | var b = 2 15 | } 16 | struct Foo { 17 | struct Bar { 18 | let b = 2 19 | } 20 | } 21 | struct Foo { 22 | #if a 23 | let a = 1 24 | #elseif b 25 | let b = 2 26 | #else 27 | let e = 3 28 | #endif 29 | } 30 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SubscriptDeclaration.result: -------------------------------------------------------------------------------- 1 | subscript() -> Self {} 2 | @a subscript() -> Self {} 3 | private nonmutating static final subscript() -> Self {} 4 | @a fileprivate subscript() -> Self {} 5 | subscript(i: Int) -> Self {} 6 | subscript(section: Int, row: Int) -> Self {} 7 | subscript() -> @a @b @c Self {} 8 | subscript() -> Self { 9 | let foo = 3 10 | return _weakSelf 11 | } 12 | subscript() -> Self { 13 | get { 14 | return _foo 15 | } 16 | set { 17 | _foo = newValue 18 | } 19 | } 20 | subscript() -> Self { 21 | @a mutating get { 22 | return _foo 23 | } 24 | @a mutating set(newFoo) { 25 | _foo = newFoo 26 | } 27 | } 28 | subscript() -> Self { 29 | @a @b @c mutating get 30 | @x @y @z nonmutating set 31 | } 32 | subscript() -> Self {} 33 | subscript() -> Self where T == S {} 34 | subscript() -> Self where T: S {} 35 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SubscriptExpression.result: -------------------------------------------------------------------------------- 1 | foo[0] 2 | foo[a, 0, b, 1, 5, _] 3 | foo[n - 1, n -- 1] 4 | foo[n + 1] 5 | foo[bar()] 6 | foo[try bar()] 7 | foo[0 ... 1] 8 | foo[0 ..< 1] 9 | foo[0...] 10 | foo[...1] 11 | foo[0..<] 12 | foo[..<1] 13 | a[safe: i] 14 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SubscriptExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo[0] 18 | foo [ a ,0, b ,1 , 5,_] 19 | foo [n-1, n--1] 20 | foo [n+1] 21 | foo [bar()] 22 | foo [try bar()] 23 | foo[0...1] 24 | foo[0..<1] 25 | foo[0...] 26 | foo[...1] 27 | foo[0..<] 28 | foo[..<1] 29 | a[safe: i] 30 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SuperclassExpression.result: -------------------------------------------------------------------------------- 1 | super.foo 2 | super.init 3 | super[foo, bar] 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SuperclassExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | super.foo 18 | super.init 19 | super[foo, bar] 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/SwitchStatement.result: -------------------------------------------------------------------------------- 1 | switch foo {} 2 | switch foo { 3 | default: 4 | () 5 | } 6 | switch foo { 7 | case 1: 8 | print(1) 9 | foo = 2 10 | } 11 | switch foo { 12 | case let (x, y) where x == y: 13 | print(x) 14 | print(y) 15 | } 16 | switch foo { 17 | case 1, 2, 3, x where x < 0: 18 | foo = 0 19 | } 20 | switch controlExpression { 21 | case pattern1: 22 | statements 23 | case pattern2 where condition: 24 | statements 25 | case pattern3 where condition, pattern4 where condition: 26 | statements 27 | default: 28 | statements 29 | } 30 | switch a { 31 | case zero ..< 5: 32 | print("less than 5") 33 | default: 34 | print("more than 5") 35 | } 36 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TernaryConditionalOperatorExpression.result: -------------------------------------------------------------------------------- 1 | condition ? true : false 2 | c() ? t() : f() 3 | try? c() ? try t() : try! f() 4 | a ? b ? c ? d : e : f : g 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TernaryConditionalOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | condition ? true : false 18 | c() ? t() : f() 19 | try? c() ? try t() : try! f() 20 | a ? b ? c ? d : e : f : g // a ? (b ? (c ? d : e) : f) : g 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ThrowStatement.result: -------------------------------------------------------------------------------- 1 | throw foo 2 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/ThrowStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | throw foo 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TryOperatorExpression.result: -------------------------------------------------------------------------------- 1 | try foo 2 | try? foo 3 | try! foo 4 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TryOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | try foo 18 | try? foo 19 | try! foo 20 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TupleExpression.result: -------------------------------------------------------------------------------- 1 | _ = () 2 | _ = (a: 1) 3 | _ = (foo, bar) 4 | _ = (a: 1, b: foo, ()) 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TupleExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ = () 18 | _ = (a: 1) 19 | _ = (foo, bar) 20 | _ = ( a : 1 , b : foo, ( ) ) 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TypeCastingOperatorExpression.result: -------------------------------------------------------------------------------- 1 | foo is bar 2 | foo as bar 3 | foo as? bar 4 | foo as! bar 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TypeCastingOperatorExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | foo is bar 18 | foo as bar 19 | foo as? bar 20 | foo as! bar 21 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TypealiasDeclaration.result: -------------------------------------------------------------------------------- 1 | typealias Foo = Bar 2 | @a @b @c typealias Foo = Bar 3 | fileprivate typealias Foo = Bar 4 | @a public typealias Foo = Bar 5 | typealias Foo = (a, b, c) throws -> Bar 6 | @a public typealias Foo = Bar 7 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/TypealiasDeclaration.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | typealias Foo = Bar 18 | @a @b @c typealias Foo = Bar 19 | fileprivate typealias Foo = Bar 20 | @a public typealias Foo = Bar 21 | typealias Foo = (a, b, c) throws -> Bar 22 | @a public typealias Foo = Bar 23 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/WhileStatement.result: -------------------------------------------------------------------------------- 1 | while true {} 2 | while shouldContinue(with: i) { 3 | print(i) 4 | } 5 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/WhileStatement.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | while true {} 18 | 19 | while shouldContinue(with: i) { 20 | print(i) 21 | } 22 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/WildcardExpression.result: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/TTYASTPrintTestResources/WildcardExpression.source: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | _ 18 | -------------------------------------------------------------------------------- /Tests/IntegrationTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(TTYASTDumpTests.allTests), 23 | testCase(TTYASTPrintTests.allTests), 24 | testCase(ShebangIntegrationTests.allTests), 25 | testCase(SemaIntegrationTests.allTests), 26 | ] 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /Tests/LexerTests/LexerBooleanLiteralTests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-2016 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | @testable import Lexer 20 | @testable import Source 21 | 22 | class LexerBooleanLiteralTests: XCTestCase { 23 | func testTrue() { 24 | lexAndTest("true") { 25 | XCTAssertEqual($0, .booleanLiteral(true)) 26 | } 27 | } 28 | 29 | func testFalse() { 30 | lexAndTest("false") { 31 | XCTAssertEqual($0, .booleanLiteral(false)) 32 | } 33 | } 34 | 35 | static var allTests = [ 36 | ("testTrue", testTrue), 37 | ("testFalse", testFalse), 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /Tests/ParserTests/Type/ParserOpaqueTypeTests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | class ParserOpaqueTypeTests: XCTestCase { 20 | func testOpaqueType() { 21 | parseTypeAndTest("some Thing", "Opaque") 22 | } 23 | 24 | static var allTests = [ 25 | ("testOpaqueType", testOpaqueType), 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /Tests/SemaTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016-2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(SequenceExpressionFoldingTests.allTests), 23 | testCase(LexicalParentAssignmentTests.allTests), 24 | ] 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /Tests/SourceTests/SourceLocationTests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | @testable import Source 20 | 21 | class SourceLocationTests : XCTestCase { 22 | func testDummyLocation() { 23 | let loc = SourceLocation.DUMMY 24 | XCTAssertEqual(loc.identifier, "dummy") 25 | XCTAssertEqual(loc.line, 0) 26 | XCTAssertEqual(loc.column, 0) 27 | XCTAssertEqual(loc.description, "dummy:0:0") 28 | } 29 | 30 | static var allTests = [ 31 | ("testDummyLocation", testDummyLocation), 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /Tests/SourceTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(SourceFileTests.allTests), 23 | testCase(SourceLocationTests.allTests), 24 | testCase(SourceRangeTests.allTests), 25 | testCase(SourceReaderTests.allTests), 26 | ] 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /Tests/SwiftExtensionsTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Ryuichi Intellectual Property and the Yanagiba project contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | #if !os(macOS) 20 | public func allTests() -> [XCTestCaseEntry] { 21 | return [ 22 | testCase(StringIdentationTests.allTests), 23 | testCase(StringPathTests.allTests), 24 | testCase(StringTTYColorTests.allTests), 25 | ] 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: 2 | layout: header, changes, diff 3 | coverage: 4 | ignore: 5 | - Sources/Tooling 6 | - Sources/Frontend 7 | - Sources/swift-ast 8 | - Tests 9 | -------------------------------------------------------------------------------- /dogFooding.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | make 6 | 7 | allFiles="" 8 | 9 | for f in $(find . -regex "\.\/Sources.*\.swift") 10 | do 11 | allFiles="$allFiles $f" 12 | done 13 | 14 | for f in $(find . -regex "\.\/Tests.*\.swift") 15 | do 16 | allFiles="$allFiles $f" 17 | done 18 | 19 | allFiles="$allFiles Package.swift" 20 | 21 | .build/debug/swift-ast $@ $allFiles 22 | -------------------------------------------------------------------------------- /lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SWIFT_LINT_ROOT="../swift-lint" 6 | 7 | if [ "$CI" == "true" ]; then 8 | rm -rf .swift_lint 9 | git clone https://github.com/yanagiba/swift-lint .swift_lint 10 | cd .swift_lint 11 | make 12 | cd .. 13 | SWIFT_LINT_ROOT=".swift_lint" 14 | fi 15 | 16 | allFiles="" 17 | 18 | for f in $(find . -regex "\.\/Sources.*\.swift") 19 | do 20 | allFiles="$allFiles $f" 21 | done 22 | 23 | for f in $(find . -regex "\.\/Tests.*\.swift") 24 | do 25 | allFiles="$allFiles $f" 26 | done 27 | 28 | allFiles="$allFiles Package.swift" 29 | 30 | $SWIFT_LINT_ROOT/.build/debug/swift-lint $@ $allFiles 31 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | make 6 | .build/debug/swift-ast $@ 7 | -------------------------------------------------------------------------------- /runXcodeTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | make xcodegen 4 | WORKING_DIRECTORY=$(PWD) xcodebuild -project swift-ast.xcodeproj -scheme swift-ast-Package clean > /dev/null 2>&1 5 | WORKING_DIRECTORY=$(PWD) xcodebuild -project swift-ast.xcodeproj -scheme swift-ast-Package -sdk macosx10.14 -destination arch=x86_64 -configuration Debug -enableCodeCoverage YES test > /dev/null 2>&1 6 | --------------------------------------------------------------------------------