From fa3f881fd4c9f85a22ca8dab3f372ae45662ee9d Mon Sep 17 00:00:00 2001 From: Tomasz Szulc Date: Sat, 1 Aug 2015 15:19:10 +0200 Subject: [PATCH] Update comments --- Swifternalization/ExpressionParser.swift | 4 ++- Swifternalization/ExpressionPatternType.swift | 16 ++++++++--- .../InequalityExpressionMatcher.swift | 8 ++++-- .../InequalityExpressionParser.swift | 6 ++-- .../InequalityExtendedExpressionMatcher.swift | 10 +++++-- Swifternalization/InequalitySign.swift | 28 +++++++++++++++---- Swifternalization/InternalPattern.swift | 12 ++++++-- .../RegexExpressionMatcher.swift | 8 ++++-- Swifternalization/RegexExpressionParser.swift | 4 ++- .../SharedBaseExpression.swift | 24 ++++++++++++---- .../SharedPolishExpression.swift | 8 ++++-- Swifternalization/SharedExpression.swift | 16 ++++++++--- 12 files changed, 108 insertions(+), 36 deletions(-) diff --git a/Swifternalization/ExpressionParser.swift b/Swifternalization/ExpressionParser.swift index 83e9e97..ddc5463 100644 --- a/Swifternalization/ExpressionParser.swift +++ b/Swifternalization/ExpressionParser.swift @@ -13,7 +13,9 @@ or `RegexExpressionParser`. Defines methods and properties that are needed to work as parser. */ protocol ExpressionParser { - /// pattern of expression + /** + Pattern of expression. + */ var pattern: ExpressionPattern {get} /** diff --git a/Swifternalization/ExpressionPatternType.swift b/Swifternalization/ExpressionPatternType.swift index 21ab0af..e83ddeb 100644 --- a/Swifternalization/ExpressionPatternType.swift +++ b/Swifternalization/ExpressionPatternType.swift @@ -8,14 +8,22 @@ import Foundation -/// Supported expression types +/** +Supported expression types. +*/ enum ExpressionPatternType: String { - /// works on Int only, e.g. `x<5`, `x=3` + /** + Works with Int/Float, e.g. `x<5`, `x=3`, `x<4.5`. + */ case Inequality = "ie" - /// works on Int only, e.g. `4 InequalitySign { switch self { case .LessThan: return .GreaterThan diff --git a/Swifternalization/InternalPattern.swift b/Swifternalization/InternalPattern.swift index ed5829f..3b81d03 100644 --- a/Swifternalization/InternalPattern.swift +++ b/Swifternalization/InternalPattern.swift @@ -12,12 +12,18 @@ import Foundation Represents internal patterns used by the framework to avoid copy-pastes. */ enum InternalPattern: String { - /// Pattern that matches expressions. + /** + Pattern that matches expressions. + */ case Expression = "(?<=\\{)(.+)(?=\\})" - /// Pattern that matches expression types. + /** + Pattern that matches expression types. + */ case ExpressionPatternType = "(^.{2,3})(?=:)" - /// Pattern that matches key without expression. + /** + Pattern that matches key without expression. + */ case KeyWithoutExpression = "^(.*?)(?=\\{)" } \ No newline at end of file diff --git a/Swifternalization/RegexExpressionMatcher.swift b/Swifternalization/RegexExpressionMatcher.swift index afc2cdb..6a3b0a9 100644 --- a/Swifternalization/RegexExpressionMatcher.swift +++ b/Swifternalization/RegexExpressionMatcher.swift @@ -8,7 +8,9 @@ import Foundation -/// Type that represents pattern with regular expression +/** +Type that represents pattern with regular expression. +*/ internal typealias RegexPattern = String /** @@ -16,7 +18,9 @@ Matcher is responsible for matching expressions that contains regular expressions. */ struct RegexExpressionMatcher: ExpressionMatcher { - /// Expression pattern with regular expression inside. + /** + Expression pattern with regular expression inside. + */ let pattern: RegexPattern /** diff --git a/Swifternalization/RegexExpressionParser.swift b/Swifternalization/RegexExpressionParser.swift index bd00f1e..2a004d7 100644 --- a/Swifternalization/RegexExpressionParser.swift +++ b/Swifternalization/RegexExpressionParser.swift @@ -12,7 +12,9 @@ import Foundation Parser that parses expressions that contains regular expressions. */ class RegexExpressionParser: ExpressionParser { - /// Expression pattern - regular expression. + /** + Expression pattern - regular expression. + */ let pattern: ExpressionPattern /** diff --git a/Swifternalization/Shared Expressions/SharedBaseExpression.swift b/Swifternalization/Shared Expressions/SharedBaseExpression.swift index 30ee66a..706fcf0 100644 --- a/Swifternalization/Shared Expressions/SharedBaseExpression.swift +++ b/Swifternalization/Shared Expressions/SharedBaseExpression.swift @@ -6,23 +6,35 @@ // Copyright (c) 2015 Tomasz Szulc. All rights reserved. // -/// Contains base expressions that matches every country. +/** +Contains base expressions that matches every country. +*/ class SharedBaseExpression: SharedExpressionProtocol { - /// Return expressions that matches every country. + /** + Return expressions that matches every country. + */ static func allExpressions() -> [SharedExpression] { return [ - /// Matches value equals 1. + /** + Matches value equals 1. + */ SharedExpression(identifier: "one", pattern: "ie:x=1"), - /// Matches value greater than 1. + /** + Matches value greater than 1. + */ SharedExpression(identifier: ">one", pattern: "ie:x>1"), - /// Matches value equals 2. + /** + Matches value equals 2. + */ SharedExpression(identifier: "two", pattern: "ie:x=2"), - /// Matches value other than 1. + /** + Matches value other than 1. + */ SharedExpression(identifier: "other", pattern: "exp:(^[^1])|(^\\d{2,})") ] } diff --git a/Swifternalization/Shared Expressions/SharedPolishExpression.swift b/Swifternalization/Shared Expressions/SharedPolishExpression.swift index 7c4d46c..b9a605d 100644 --- a/Swifternalization/Shared Expressions/SharedPolishExpression.swift +++ b/Swifternalization/Shared Expressions/SharedPolishExpression.swift @@ -6,10 +6,14 @@ // Copyright (c) 2015 Tomasz Szulc. All rights reserved. // -/// Contains Polish expressions. +/** +Contains Polish expressions. +*/ class SharedPolishExpression: SharedExpressionProtocol { - /// Return expressions that are valid in Poland. + /** + Return expressions that are valid in Poland. + */ static func allExpressions() -> [SharedExpression] { return [ /** diff --git a/Swifternalization/SharedExpression.swift b/Swifternalization/SharedExpression.swift index 821bf36..2dcb542 100644 --- a/Swifternalization/SharedExpression.swift +++ b/Swifternalization/SharedExpression.swift @@ -16,7 +16,9 @@ localizing app. Rules: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html */ protocol SharedExpressionProtocol { - /// Method returns all expressions for class that conform this protocol + /** + Method returns all expressions for class that conform this protocol + */ static func allExpressions() -> [SharedExpression] } @@ -24,13 +26,19 @@ protocol SharedExpressionProtocol { Represents built-in expression and expressions from Expressions.strings file. */ struct SharedExpression { - /// Identifier of expression. + /** + Identifier of expression. + */ let identifier: String - /// Pattern of expression. + /** + Pattern of expression. + */ let pattern: String - /// Creates expression. + /** + Creates expression. + */ init(identifier: String, pattern: String) { self.identifier = identifier self.pattern = pattern