{"id":282374,"date":"2016-12-12T15:30:05","date_gmt":"2016-12-12T12:30:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282374"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282374","title":{"rendered":"\u041e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u043c \u0431\u0430\u0431\u0443\u0448\u043a\u0435, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f"},"content":{"rendered":"<p>\u042d\u0442\u043e \u0438\u0433\u0440\u043e\u0432\u0430\u044f \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0430, \u0433\u0434\u0435 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u043b\u044e\u0441\u0435\u043d\u044c\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (Mu). \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0436\u0438\u0432\u0443\u044e \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 <a href=\"http:\/\/swiftlang.ng.bluemix.net\/#\/repl\/5825fba6dee52b5745935831\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438\u043b\u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/marciok\/Mu\/releases\/download\/1.0\/WriteYourLanguage.playground.zip\">\u0442\u0443\u0442<\/a>. \u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/58c\/c0c\/543\/58cc0c543a6a52280b31b2376bb3bebd.png\" alt=\"image\"\/><\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432 Computer Science, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c 2 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0448\u0430\u0433\u0430.<\/p>\n<h2>\u042f\u0437\u044b\u043a: Mu(\u03bc)<\/h2>\n<p>  Mu \u2014 \u044d\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0431\u0438\u043d\u0430\u0440\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u00ab\u043e\u0434\u043d\u043e\u0446\u0438\u0444\u0435\u0440\u043d\u044b\u0435\u00bb \u0447\u0438\u0441\u043b\u0430.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<\/b> (s 2 4) or (s (s 4 5) 4) or (s (s 4 5) (s 3 2))\u2026<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0428\u0430\u0433\u0438:<\/h2>\n<p>  <\/p>\n<ul>\n<li>Lexer<\/li>\n<li>Parser<\/li>\n<li>Interpreter<\/li>\n<\/ul>\n<h2>Lexer<\/h2>\n<p>  \u0412 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u044b\u0445 \u043d\u0430\u0443\u043a\u0430\u0445 \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u00ab\u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438\u00bb (\u043f\u043e\u0434\u043e\u0431\u043d\u043e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0435 \u0431\u0443\u043a\u0432 \u0432 \u0441\u043b\u043e\u0432\u0430\u0445). <\/p>\n<p>  \u0413\u0440\u0443\u043f\u043f\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0435\u043a\u0441\u0435\u043c\u043e\u0439. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043b\u0435\u043a\u0441\u0435\u043c \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<br \/>   \u2014 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044f<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<\/b><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d5f\/602\/5a3\/d5f6025a31757b7e902c223b55487826.png\" alt=\"image\"\/><\/p>\n<p>  \u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e <code>Mu<\/code> \u0442\u0430\u043a \u043c\u0430\u043b \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438 \u0447\u0438\u0441\u043b\u0430 \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0432\u043e\u0434\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b.<\/p>\n<pre><code>enum Token {     case parensOpen     case op(String)     case number(Int)     case parensClose }  struct Lexer {      static func tokenize(_ input: String) -&gt; [Token] {         return input.characters.flatMap {             switch $0 {                 case &quot;(&quot;: return Token.parensOpen                 case &quot;)&quot;: return Token.parensClose                 case &quot;s&quot;: return Token.op($0.description)             default:                 if &quot;0&quot;...&quot;9&quot; ~= $0 {                     return Token.number(Int($0.description)!)                 }             }              return nil         }     } }  let input = &quot;(s (s 4 5) 4)&quot; let tokens = Lexer.tokenize(input) <\/code><\/pre>\n<h2>Parser<\/h2>\n<p>  \u041f\u0430\u0440\u0441\u0435\u0440 \u0438\u043b\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u2014 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0435\u0439 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0435\u043a\u0441\u0442) \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. \u041f\u0430\u0440\u0441\u0435\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<h4>Grammar:<\/h4>\n<p>  <code>expression: parensOpen operator primaryExpression primaryExpression parensClose<\/p>\n<p>  primaryExpression: expression | number<\/p>\n<p>  parensOpen: &quot;(&quot;<\/p>\n<p>  parensClose: &quot;)&quot;<\/p>\n<p>  operator: &quot;s&quot;<\/p>\n<p>  number: [0-9]<\/code><\/p>\n<p>  \u0413\u0440\u0430\u043c\u043c\u0430\u0442\u0438\u043a\u0430 <code>Mu<\/code> \u2014 \u044d\u0442\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u0430\u044f \u0433\u0440\u0430\u043c\u043c\u0430\u0442\u0438\u043a\u0430, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0441\u0442\u0440\u043e\u043a \u0432 \u044f\u0437\u044b\u043a\u0435. \u041f\u0430\u0440\u0441\u0435\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441 \u0432\u0435\u0440\u0445\u0430 (\u043a\u043e\u0440\u043d\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430) \u0438 \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0438\u0436\u043d\u0435\u0433\u043e \u0443\u0437\u043b\u0430.<\/p>\n<p>  <b>\u0421\u043e\u0432\u0435\u0442: \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u044f\u043c\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0433\u0440\u0430\u043c\u043c\u043c\u0430\u0442\u0438\u043a\u0438<\/b><\/p>\n<pre><code>func parseExpression() -&gt; ExpressionNode {    ...    firstPrimaryExpression = parsePrimaryExpression()    secondPrimaryExpression = parsePrimaryExpression()    ... }  func parseExpression() -&gt; PrimaryExpressionNode {    return parseExpression() || parseNumber() }<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/48f\/459\/6b8\/48f4596b863be84855c3c255d9099c2f.png\" alt=\"image\"\/><\/p>\n<pre><code>indirect enum PrimaryExpressionNode {     case number(Int)     case expression(ExpressionNode) }  struct ExpressionNode {     var op: String     var firstExpression: PrimaryExpressionNode     var secondExpression: PrimaryExpressionNode }  struct Parser {      var index = 0     let tokens: [Token]     init(tokens: [Token]) {         self.tokens = tokens     }      mutating func popToken() -&gt; Token {         let token = tokens[index]         index += 1          return token     }      mutating func peekToken() -&gt; Token {         return tokens[index]     }      mutating func parse() throws -&gt; ExpressionNode {         return try parseExpression()     }      mutating func parseExpression() throws -&gt; ExpressionNode {         guard case .parensOpen = popToken() else {             throw ParsingError.unexpectedToken         }         guard case let Token.op(_operator) = popToken() else {             throw ParsingError.unexpectedToken         }          let firstExpression = try parsePrimaryExpression()         let secondExpression = try parsePrimaryExpression()          guard case .parensClose = popToken() else {             throw ParsingError.unexpectedToken         }          return ExpressionNode(op: _operator, firstExpression: firstExpression, secondExpression: secondExpression)     }      mutating func parsePrimaryExpression() throws -&gt; PrimaryExpressionNode {         switch peekToken() {         case .number:             return try parseNumber()         case .parensOpen:             let expressionNode = try parseExpression()              return PrimaryExpressionNode.expression(expressionNode)         default:             throw ParsingError.unexpectedToken         }     }      mutating func parseNumber() throws -&gt; PrimaryExpressionNode {         guard case let Token.number(n) = popToken() else { throw ParsingError.unexpectedToken }          return PrimaryExpressionNode.number(n)     }  }  \/\/MARK: Utils  extension ExpressionNode: CustomStringConvertible {     public var description: String {         return &quot;\\(op) -&gt; [\\(firstExpression), \\(secondExpression)]&quot;     } } extension PrimaryExpressionNode: CustomStringConvertible {     public var description: String {         switch self {         case .number(let n): return n.description         case .expression(let exp): return exp.description         }     } }   let input = &quot;(s 2 (s 3 5))&quot; let tokens = Lexer.tokenize(input) var parser = Parser(tokens: tokens) var ast = try! parser.parse()<\/code><\/pre>\n<h2>Interpreter<\/h2>\n<p>  \u0412 computer science, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434. (\u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044f)<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<\/b><br \/>  \u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 Mu \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0438 A.S.T \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043a \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u0443\u0437\u043b\u0430\u043c. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7f7\/e5d\/e72\/7f7e5de72ab06282886049eea88c4419.png\" alt=\"image\"\/><\/p>\n<pre><code>enum InterpreterError: Error {     case unknownOperator }  struct Interpreter {     static func eval(_ expression: ExpressionNode) throws -&gt; Int {         let firstEval = try eval(expression.first)         let secEval = try eval(expression.second)          if expression.op == &quot;s&quot; {             return firstEval + secEval         }          throw InterpreterError.unknownOperator     }          static func eval(_ prim: PrimaryExpressionNode) throws -&gt; Int {         switch prim {         case .expression(let exp):             return try eval(exp)         case .number(let n):             return Int(n)         }     }  }  let input = &quot;(s (s 5 2) 4)&quot; let tokens = Lexer.tokenize(input) var parser = Parser(tokens: tokens)  let ast = try! parser.parse() try! Interpreter.eval(ast)<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/49f\/d61\/0ed\/49fd610ed03366bed26012ab9e044a1e.png\" alt=\"image\"\/><\/p>\n<ul>\n<li>\u0412\u0432\u043e\u0434 <code>let input = &quot;(s (s 4 5) 4)<\/code><\/li>\n<li>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 (Lexing) <code>let tokens = Lexer.tokenize(input)<\/code><\/li>\n<li>\u041f\u0430\u0440\u0441\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u0432 \u0434\u0435\u0440\u0435\u0432\u043e (Parsing).<\/li>\n<\/ul>\n<p><code>var parser = Parser(tokens: tokens)<br \/>  let ast = try! parser.parse()<\/code>  <\/p>\n<ul>\n<li>\u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0434\u0435\u0440\u0435\u0432\u0443, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0437\u043b\u043e\u0432 (Interpreting). <code>let result = try! Interpreter.eval(ast)<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<h2>Resources<\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/ruslanspivak.com\/lsbasi-part1\/\">ruslanspivak.com\/lsbasi-part1<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Compilers-Principles-Techniques-Tools-2nd\/dp\/0321486811\">www.amazon.com\/Compilers-Principles-Techniques-Tools-2nd\/dp\/0321486811<\/a><\/li>\n<li><a href=\"http:\/\/llvm.org\/docs\/tutorial\/\">llvm.org\/docs\/tutorial<\/a><\/li>\n<\/ul>\n<hr\/>\n<p>  <font color=\"#999999\"><em>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f <a href=\"http:\/\/www.edsd.com\">Edison<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.edsd.ru\/avtomatizaciya-asfaltobetonnogo-zavoda\">\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0441\u0444\u0430\u043b\u044c\u0442\u043d\u044b\u0445 \u0437\u0430\u0432\u043e\u0434\u043e\u0432<\/a> \u0438 <a href=\"https:\/\/www.edsd.ru\/platezhnye-sistemy\">\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u043b\u0430\u0442\u0435\u0436\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u043e\u0432<\/a>.<\/em><\/font><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/315068\/\"> https:\/\/habrahabr.ru\/post\/315068\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u042d\u0442\u043e \u0438\u0433\u0440\u043e\u0432\u0430\u044f \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0430, \u0433\u0434\u0435 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u043b\u044e\u0441\u0435\u043d\u044c\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (Mu). \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0436\u0438\u0432\u0443\u044e \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 <a href=\"http:\/\/swiftlang.ng.bluemix.net\/#\/repl\/5825fba6dee52b5745935831\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438\u043b\u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/marciok\/Mu\/releases\/download\/1.0\/WriteYourLanguage.playground.zip\">\u0442\u0443\u0442<\/a>. \u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/58c\/c0c\/543\/58cc0c543a6a52280b31b2376bb3bebd.png\" alt=\"image\"\/><\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432 Computer Science, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c 2 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0448\u0430\u0433\u0430.<\/p>\n<h2>\u042f\u0437\u044b\u043a: Mu(\u03bc)<\/h2>\n<p>  Mu \u2014 \u044d\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0431\u0438\u043d\u0430\u0440\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u00ab\u043e\u0434\u043d\u043e\u0446\u0438\u0444\u0435\u0440\u043d\u044b\u0435\u00bb \u0447\u0438\u0441\u043b\u0430.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<\/b> (s 2 4) or (s (s 4 5) 4) or (s (s 4 5) (s 3 2))\u2026  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-282374","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=282374"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282374\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}