From 9045fec0221a7e148950b4ee586d9540a45237d8 Mon Sep 17 00:00:00 2001 From: Gusztav Szikszai Date: Fri, 15 Jun 2018 10:14:12 +0200 Subject: [PATCH 1/5] Update to new crystal version. [skip ci] --- shard.lock | 10 +++++----- shard.yml | 5 +++-- src/ast.cr | 1 + src/parsers/basic_expression.cr | 4 ++-- src/parsers/case.cr | 2 +- src/parsers/case_branch.cr | 2 +- src/parsers/catch.cr | 2 +- src/parsers/decode.cr | 2 +- src/parsers/finally.cr | 2 +- src/parsers/function.cr | 4 ++-- src/parsers/html_attribute.cr | 2 +- src/parsers/html_expression.cr | 2 +- src/parsers/if.cr | 6 +++--- src/parsers/inline_function.cr | 4 ++-- src/parsers/negated_expression.cr | 2 +- src/parsers/operation.cr | 6 +++--- src/parsers/parenthesized_expression.cr | 2 +- src/parsers/property.cr | 2 +- src/parsers/record_field.cr | 2 +- src/parsers/statement.cr | 2 +- src/parsers/type.cr | 2 +- src/parsers/with.cr | 4 ++-- src/type_checkers/scope.cr | 9 +++++---- src/utils/server.cr | 4 ++-- src/utils/watcher.cr | 2 +- 25 files changed, 44 insertions(+), 41 deletions(-) diff --git a/shard.lock b/shard.lock index 5d6175a72..0693581e7 100644 --- a/shard.lock +++ b/shard.lock @@ -9,16 +9,16 @@ shards: version: 0.6.0 baked_file_system: - github: schovi/baked_file_system - version: 0.9.6 + github: straight-shoota/baked_file_system + commit: 8f829baaf9b777931160860378cad9473299ed2b duktape: github: jessedoyle/duktape.cr - version: 0.13.0 + version: 0.14.1 kemal: github: kemalcr/kemal - version: 0.22.0 + commit: 32fd19da1ec89548800185d618f912d7f537ce5e kilt: github: jeromegn/kilt @@ -34,7 +34,7 @@ shards: time_format: github: vladfaust/time_format.cr - version: 0.1.0 + version: 0.1.1 tree_template: github: anykeyh/tree_template diff --git a/shard.yml b/shard.yml index 7525cdb3a..1949f4716 100644 --- a/shard.yml +++ b/shard.yml @@ -8,13 +8,14 @@ targets: dependencies: duktape: github: jessedoyle/duktape.cr - version: ~> 0.13.0 string_inflection: github: mosop/string_inflection baked_file_system: - github: schovi/baked_file_system + github: straight-shoota/baked_file_system + commit: 8f829baaf9b777931160860378cad9473299ed2b kemal: github: kemalcr/kemal + commit: 32fd19da1ec89548800185d618f912d7f537ce5e admiral: github: jwaldrip/admiral.cr tree_template: diff --git a/src/ast.cr b/src/ast.cr index 1fab4340b..e4d0cfdd2 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -16,6 +16,7 @@ module Mint BoolLiteral | HtmlElement | ModuleCall | + Operation | NextCall | Variable | Record | diff --git a/src/parsers/basic_expression.cr b/src/parsers/basic_expression.cr index 69e643bdd..e3ca17255 100644 --- a/src/parsers/basic_expression.cr +++ b/src/parsers/basic_expression.cr @@ -2,7 +2,7 @@ module Mint class Parser # NOTE: The order of the parsing is important! def basic_expression : Ast::Expression | Nil - string_literal || + (string_literal || bool_literal || number_literal || array || @@ -27,7 +27,7 @@ module Mint enum_id || js || void || - variable + variable).as(Ast::Expression) end def basic_expression!(error : SyntaxError.class) : Ast::Expression diff --git a/src/parsers/case.cr b/src/parsers/case.cr index 6fae5f1a0..0ac7168f6 100644 --- a/src/parsers/case.cr +++ b/src/parsers/case.cr @@ -31,7 +31,7 @@ module Mint end Ast::Case.new( - condition: condition, + condition: condition.as(Ast::Expression), from: start_position, branches: branches, to: position, diff --git a/src/parsers/case_branch.cr b/src/parsers/case_branch.cr index 6644a36d1..026279083 100644 --- a/src/parsers/case_branch.cr +++ b/src/parsers/case_branch.cr @@ -15,7 +15,7 @@ module Mint expression = expression! CaseBranchExpectedExpression Ast::CaseBranch.new( - expression: expression, + expression: expression.as(Ast::Expression), from: start_position, to: position, match: match, diff --git a/src/parsers/catch.cr b/src/parsers/catch.cr index 78a0e7e05..250e9aafa 100644 --- a/src/parsers/catch.cr +++ b/src/parsers/catch.cr @@ -26,7 +26,7 @@ module Mint end Ast::Catch.new( - expression: expression, + expression: expression.as(Ast::Expression), from: start_position, variable: variable, to: position, diff --git a/src/parsers/decode.cr b/src/parsers/decode.cr index afc3c6449..09415a9cf 100644 --- a/src/parsers/decode.cr +++ b/src/parsers/decode.cr @@ -18,7 +18,7 @@ module Mint type = type! DecodeExpectedType Ast::Decode.new( - expression: expression, + expression: expression.as(Ast::Expression), from: start_position, type: type, to: position, diff --git a/src/parsers/finally.cr b/src/parsers/finally.cr index 5c752e3ab..47b432c23 100644 --- a/src/parsers/finally.cr +++ b/src/parsers/finally.cr @@ -18,7 +18,7 @@ module Mint end Ast::Finally.new( - expression: expression, + expression: expression.as(Ast::Expression), from: start_position, to: position, input: data) diff --git a/src/parsers/function.cr b/src/parsers/function.cr index 64b1c439d..360978f20 100644 --- a/src/parsers/function.cr +++ b/src/parsers/function.cr @@ -48,14 +48,14 @@ module Mint whitespace Ast::Function.new( + body: body.as(Ast::Expression), arguments: arguments, from: start_position, to: end_position, wheres: where, input: data, name: name, - type: type, - body: body) + type: type) end end end diff --git a/src/parsers/html_attribute.cr b/src/parsers/html_attribute.cr index edd0ca771..743b9ba2f 100644 --- a/src/parsers/html_attribute.cr +++ b/src/parsers/html_attribute.cr @@ -26,8 +26,8 @@ module Mint end Ast::HtmlAttribute.new( + value: value.as(Ast::Expression), from: start_position, - value: value, to: position, input: data, name: name) diff --git a/src/parsers/html_expression.cr b/src/parsers/html_expression.cr index 35c0ce02d..1a7d4e866 100644 --- a/src/parsers/html_expression.cr +++ b/src/parsers/html_expression.cr @@ -14,7 +14,7 @@ module Mint keyword! "}>", HtmlExpressionExpectedClosingTag Ast::HtmlExpression.new( - expression: expression, + expression: expression.as(Ast::Expression), from: start_position, to: position, input: data) diff --git a/src/parsers/if.cr b/src/parsers/if.cr index d3aa55638..23a68b55b 100644 --- a/src/parsers/if.cr +++ b/src/parsers/if.cr @@ -38,10 +38,10 @@ module Mint end Ast::If.new( - condition: condition, + condition: condition.as(Ast::Expression), + truthy: truthy.as(Ast::Expression), + falsy: falsy.as(Ast::Expression), from: start_position, - truthy: truthy, - falsy: falsy, to: position, input: data) end diff --git a/src/parsers/inline_function.cr b/src/parsers/inline_function.cr index f0ce01193..80622f9fa 100644 --- a/src/parsers/inline_function.cr +++ b/src/parsers/inline_function.cr @@ -21,11 +21,11 @@ module Mint body = expression! InlineFunctionExpectedExpression Ast::InlineFunction.new( + body: body.as(Ast::Expression), arguments: arguments, from: start_position, to: position, - input: data, - body: body) + input: data) end end end diff --git a/src/parsers/negated_expression.cr b/src/parsers/negated_expression.cr index b431bdefd..439c92875 100644 --- a/src/parsers/negated_expression.cr +++ b/src/parsers/negated_expression.cr @@ -15,8 +15,8 @@ module Mint expression = expression! NegatedExpressionExpectedExpression Ast::NegatedExpression.new( + expression: expression.as(Ast::Expression), negations: negations, - expression: expression, from: start_position, to: position, input: data) diff --git a/src/parsers/operation.cr b/src/parsers/operation.cr index f448203c5..b1e89b7a4 100644 --- a/src/parsers/operation.cr +++ b/src/parsers/operation.cr @@ -45,12 +45,12 @@ module Mint else return operation( Ast::Operation.new( + right: right.as(Ast::Expression), + left: left.as(Ast::Expression), operator: operator, from: left.from, to: right.to, - right: right, - input: data, - left: left), + input: data), next_operator) end end diff --git a/src/parsers/parenthesized_expression.cr b/src/parsers/parenthesized_expression.cr index 575e2d750..a48eb2632 100644 --- a/src/parsers/parenthesized_expression.cr +++ b/src/parsers/parenthesized_expression.cr @@ -14,7 +14,7 @@ module Mint char ')', ParenthesizedExpressionExpectedClosingParentheses Ast::ParenthesizedExpression.new( - expression: expression, + expression: expression.as(Ast::Expression), from: start_position, to: position, input: data) diff --git a/src/parsers/property.cr b/src/parsers/property.cr index 692b0b52c..7ec815c90 100644 --- a/src/parsers/property.cr +++ b/src/parsers/property.cr @@ -26,8 +26,8 @@ module Mint default = expression! PropertyExpectedDefaultValue Ast::Property.new( + default: default.as(Ast::Expression), from: start_position, - default: default, to: position, input: data, type: type, diff --git a/src/parsers/record_field.cr b/src/parsers/record_field.cr index 1fbb00f47..07ecdd516 100644 --- a/src/parsers/record_field.cr +++ b/src/parsers/record_field.cr @@ -14,8 +14,8 @@ module Mint value = expression! RecordFieldExpectedExpression Ast::RecordField.new( + value: value.as(Ast::Expression), from: start_position, - value: value, to: position, input: data, key: key) diff --git a/src/parsers/statement.cr b/src/parsers/statement.cr index 9c10aed7c..740917ceb 100644 --- a/src/parsers/statement.cr +++ b/src/parsers/statement.cr @@ -15,8 +15,8 @@ module Mint skip unless body Ast::Statement.new( + expression: body.as(Ast::Expression), from: start_position, - expression: body, to: position, input: data, name: name) diff --git a/src/parsers/type.cr b/src/parsers/type.cr index d765c168c..a6589af95 100644 --- a/src/parsers/type.cr +++ b/src/parsers/type.cr @@ -26,7 +26,7 @@ module Mint end Ast::Type.new( - parameters: parameters || [] of Ast::Type | Ast::Variable, + parameters: parameters || [] of Ast::Type | Ast::TypeVariable, from: start_position, to: position, input: data, diff --git a/src/parsers/with.cr b/src/parsers/with.cr index 64a9a020f..9e500e65d 100644 --- a/src/parsers/with.cr +++ b/src/parsers/with.cr @@ -21,11 +21,11 @@ module Mint end Ast::With.new( + body: body.as(Ast::Expression), from: start_position, to: position, input: data, - name: name, - body: body) + name: name) end end end diff --git a/src/type_checkers/scope.cr b/src/type_checkers/scope.cr index db6b610aa..6eef33613 100644 --- a/src/type_checkers/scope.cr +++ b/src/type_checkers/scope.cr @@ -7,7 +7,8 @@ module Mint Ast::Function | Ast::Provider | Ast::Module | - Ast::Store + Ast::Store | + Ast::Get alias Level = Tuple(Ast::Node | Type, Node) alias Lookup = Tuple(Ast::Node | Type, Node, Array(Node)) @@ -185,7 +186,7 @@ module Mint end end end.compact - .reduce([] of Ast::Property) { |memo, item| memo.concat(item) } + .reduce([] of Ast::Property) { |memo, item| memo.concat(item) } end private def store_gets(component) @@ -199,7 +200,7 @@ module Mint end end end.compact - .reduce([] of Ast::Get) { |memo, item| memo.concat(item) } + .reduce([] of Ast::Get) { |memo, item| memo.concat(item) } end private def store_functions(component) @@ -212,7 +213,7 @@ module Mint end end end.compact - .reduce([] of Ast::Function) { |memo, item| memo.concat(item) } + .reduce([] of Ast::Function) { |memo, item| memo.concat(item) } end end end diff --git a/src/utils/server.cr b/src/utils/server.cr index 38d615989..6d187fe00 100644 --- a/src/utils/server.cr +++ b/src/utils/server.cr @@ -26,7 +26,7 @@ module Mint if port_open?(host, port) server = - HTTP::Server.new(host, port, config.handlers) + HTTP::Server.new(config.handlers) terminal.print "#{COG} Development server started on http://#{host}:#{port}/\n" elsif STDIN.tty? new_port = config.port + 1 @@ -49,7 +49,7 @@ module Mint config.server = server config.running = true - config.server.try(&.listen) + config.server.try(&.listen(host, port)) end def terminal diff --git a/src/utils/watcher.cr b/src/utils/watcher.cr index d0c38b10b..7ad10a359 100644 --- a/src/utils/watcher.cr +++ b/src/utils/watcher.cr @@ -15,7 +15,7 @@ module Mint current = Set(Tuple(String, Time)).new Dir.glob(@pattern).each do |file| - current.add({file, File.stat(file).mtime}) + current.add({file, File.info(file).modification_time}) end yield @state ^ current From c3aba600d70eea9411da512ca8706399cf91cb7e Mon Sep 17 00:00:00 2001 From: Gusztav Szikszai Date: Fri, 15 Jun 2018 10:23:32 +0200 Subject: [PATCH 2/5] Tests run successfully [skip ci] --- src/ast.cr | 8 ++++++++ src/parsers/basic_expression.cr | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ast.cr b/src/ast.cr index e4d0cfdd2..bed38636d 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -10,6 +10,7 @@ module Mint StringLiteral | NumberLiteral | HtmlComponent | + ArrayLiteral | RecordUpdate | ModuleAccess | FunctionCall | @@ -20,9 +21,16 @@ module Mint NextCall | Variable | Record | + EnumId | Access | + Decode | + Routes | + Route | With | Case | + Void | + Try | + Do | If | Js diff --git a/src/parsers/basic_expression.cr b/src/parsers/basic_expression.cr index e3ca17255..69e643bdd 100644 --- a/src/parsers/basic_expression.cr +++ b/src/parsers/basic_expression.cr @@ -2,7 +2,7 @@ module Mint class Parser # NOTE: The order of the parsing is important! def basic_expression : Ast::Expression | Nil - (string_literal || + string_literal || bool_literal || number_literal || array || @@ -27,7 +27,7 @@ module Mint enum_id || js || void || - variable).as(Ast::Expression) + variable end def basic_expression!(error : SyntaxError.class) : Ast::Expression From 23c0143aef76a157002f23ed5bdecc4076be9d29 Mon Sep 17 00:00:00 2001 From: Gusztav Szikszai Date: Fri, 15 Jun 2018 11:03:21 +0200 Subject: [PATCH 3/5] Remove ameba for now and debug flag from build. [skip ci] --- Makefile | 2 +- shard.lock | 4 ---- shard.yml | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Makefile b/Makefile index e37b248e0..5618b094e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ build: - crystal build src/mint.cr -o mint -p -d && mv mint ~/.bin/mint && mint + crystal build src/mint.cr -o mint -p && mv mint ~/.bin/mint && mint test: crystal spec -p && bin/ameba diff --git a/shard.lock b/shard.lock index 0693581e7..768d7669f 100644 --- a/shard.lock +++ b/shard.lock @@ -4,10 +4,6 @@ shards: github: jwaldrip/admiral.cr version: 1.6.1 - ameba: - github: veelenga/ameba - version: 0.6.0 - baked_file_system: github: straight-shoota/baked_file_system commit: 8f829baaf9b777931160860378cad9473299ed2b diff --git a/shard.yml b/shard.yml index 1949f4716..2bdb5fcda 100644 --- a/shard.yml +++ b/shard.yml @@ -23,7 +23,3 @@ dependencies: time_format: github: vladfaust/time_format.cr version: ~> 0.1.0 - -development_dependencies: - ameba: - github: veelenga/ameba From 07fb62fbaec6e024a7fbb69c58d5ae335807bd7a Mon Sep 17 00:00:00 2001 From: Gusztav Szikszai Date: Fri, 15 Jun 2018 12:04:20 +0200 Subject: [PATCH 4/5] Use new version of ameba. [skip ci] --- shard.lock | 4 ++++ shard.yml | 5 +++++ src/compilers/component.cr | 2 +- src/mint_json.cr | 4 ++-- src/test_runner.cr | 12 ++++++------ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/shard.lock b/shard.lock index 768d7669f..7abecdd49 100644 --- a/shard.lock +++ b/shard.lock @@ -4,6 +4,10 @@ shards: github: jwaldrip/admiral.cr version: 1.6.1 + ameba: + github: veelenga/ameba + commit: d9f04af057efe5517a6d2339b0ec96df3e269b5e + baked_file_system: github: straight-shoota/baked_file_system commit: 8f829baaf9b777931160860378cad9473299ed2b diff --git a/shard.yml b/shard.yml index 2bdb5fcda..a48a887b4 100644 --- a/shard.yml +++ b/shard.yml @@ -23,3 +23,8 @@ dependencies: time_format: github: vladfaust/time_format.cr version: ~> 0.1.0 + +development_dependencies: + ameba: + github: veelenga/ameba + commit: d9f04af057efe5517a6d2339b0ec96df3e269b5e diff --git a/src/compilers/component.cr b/src/compilers/component.cr index 211ce0b78..db5ffc05a 100644 --- a/src/compilers/component.cr +++ b/src/compilers/component.cr @@ -57,7 +57,7 @@ module Mint def compile_component_store_data(node : Ast::Component) : Array(String) node.connects.reduce([] of String) do |memo, item| - store = ast.stores.find { |store| store.name == item.store } + store = ast.stores.find { |entity| entity.name == item.store } if store item.keys.map do |key| diff --git a/src/mint_json.cr b/src/mint_json.cr index 7296bdf1f..2e3e9bf9a 100644 --- a/src/mint_json.cr +++ b/src/mint_json.cr @@ -384,8 +384,8 @@ module Mint repository = nil constraint = nil - @parser.read_object_or_null do |key| - case key + @parser.read_object_or_null do |dependency_key| + case dependency_key when "repository" repository = @parser.read_string when "constraint" diff --git a/src/test_runner.cr b/src/test_runner.cr index e7965aa2d..138e3723e 100644 --- a/src/test_runner.cr +++ b/src/test_runner.cr @@ -122,15 +122,15 @@ module Mint end def compile_ast - file = + file_argument = @arguments.test ast = Ast.new sources = - if file - Dir.glob([file] + SourceFiles.all) + if file_argument + Dir.glob([file_argument] + SourceFiles.all) else Dir.glob(SourceFiles.tests + SourceFiles.all) end @@ -245,9 +245,9 @@ module Mint puts " #{ARROW} #{@succeeded} passed" puts " #{ARROW} #{@failed.size} failed" - @failed.each do |message| - puts " #{message.name}".colorize(:red).to_s - puts " |> #{message.result}".colorize(:red).to_s + @failed.each do |faliure| + puts " #{faliure.name}".colorize(:red).to_s + puts " |> #{faliure.result}".colorize(:red).to_s end Kemal.config.server.try(&.close) unless @flags.manual From 203339e6201e65d8e6eae83e47c7fc8516ed5115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szikszai=20Guszt=C3=A1v?= Date: Sun, 17 Jun 2018 06:20:19 +0200 Subject: [PATCH 5/5] Update shards. --- shard.lock | 8 ++++---- shard.yml | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/shard.lock b/shard.lock index 7abecdd49..9ac3c4354 100644 --- a/shard.lock +++ b/shard.lock @@ -6,11 +6,11 @@ shards: ameba: github: veelenga/ameba - commit: d9f04af057efe5517a6d2339b0ec96df3e269b5e + version: 0.7.0 baked_file_system: - github: straight-shoota/baked_file_system - commit: 8f829baaf9b777931160860378cad9473299ed2b + github: schovi/baked_file_system + commit: e1447549d5ac0560720fae62179b2f2c62c9bfd1 duktape: github: jessedoyle/duktape.cr @@ -18,7 +18,7 @@ shards: kemal: github: kemalcr/kemal - commit: 32fd19da1ec89548800185d618f912d7f537ce5e + commit: a5870e7d24e5ec75c956bcf3e4423f55a2c4ff78 kilt: github: jeromegn/kilt diff --git a/shard.yml b/shard.yml index a48a887b4..c2fa656ae 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: mint -version: 1.0.0 +version: 0.0.5 targets: mint: @@ -11,20 +11,18 @@ dependencies: string_inflection: github: mosop/string_inflection baked_file_system: - github: straight-shoota/baked_file_system - commit: 8f829baaf9b777931160860378cad9473299ed2b + github: schovi/baked_file_system + branch: master kemal: github: kemalcr/kemal - commit: 32fd19da1ec89548800185d618f912d7f537ce5e + branch: master admiral: github: jwaldrip/admiral.cr tree_template: github: anykeyh/tree_template time_format: github: vladfaust/time_format.cr - version: ~> 0.1.0 development_dependencies: ameba: github: veelenga/ameba - commit: d9f04af057efe5517a6d2339b0ec96df3e269b5e