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 5d6175a72..9ac3c4354 100644 --- a/shard.lock +++ b/shard.lock @@ -6,19 +6,19 @@ shards: ameba: github: veelenga/ameba - version: 0.6.0 + version: 0.7.0 baked_file_system: github: schovi/baked_file_system - version: 0.9.6 + commit: e1447549d5ac0560720fae62179b2f2c62c9bfd1 duktape: github: jessedoyle/duktape.cr - version: 0.13.0 + version: 0.14.1 kemal: github: kemalcr/kemal - version: 0.22.0 + commit: a5870e7d24e5ec75c956bcf3e4423f55a2c4ff78 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..c2fa656ae 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: mint -version: 1.0.0 +version: 0.0.5 targets: mint: @@ -8,20 +8,20 @@ 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 + branch: master kemal: github: kemalcr/kemal + 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: diff --git a/src/ast.cr b/src/ast.cr index 1fab4340b..bed38636d 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -10,18 +10,27 @@ module Mint StringLiteral | NumberLiteral | HtmlComponent | + ArrayLiteral | RecordUpdate | ModuleAccess | FunctionCall | BoolLiteral | HtmlElement | ModuleCall | + Operation | NextCall | Variable | Record | + EnumId | Access | + Decode | + Routes | + Route | With | Case | + Void | + Try | + Do | If | Js 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/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/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 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