mt-lang 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f5f1a4cb47c9822d4aef3caefdd90aca32171fe59775d7906ab9c1485a422cb
4
- data.tar.gz: 72e1d25c2082827fd40f723ac4f3b11045391dda39b1f8ef339aa5fac5e57611
3
+ metadata.gz: 180f49844f839480b6aed67ca33f5aef4532cb0a372dce913699b892fc85c4b1
4
+ data.tar.gz: f99ec00f1749c5142694ff93211a9745cc1cbd0c53e7a1b311125a53aafedfd0
5
5
  SHA512:
6
- metadata.gz: b6362b05316203c6b8d6e5c48cbfddad6351540096f9bc90580b8903866bb165e202cc654bd083c4e1de8786acb3f74e86ec85bbb020ee0e5c6874b46ef088fb
7
- data.tar.gz: 0c7ffb83f660d7d1a30dbbb42713e5e798ff983795590d3e14074346d350f268184de505fc0091c14c975fcc7d141039368e652a2f0540b533575dcf8a097389
6
+ metadata.gz: 8874f3444b514ac33d33949a01d438a5de17139443e618ba2fc282a47fefc9138df686493eb368b116802750a03b844535f881a2ba48c3fae8fbcfbb4062b608
7
+ data.tar.gz: 0172adf373b345e1b3d40f79c4c0f3e05e2da088053af78b582f258cff87312dd2bac29ba2434bafab09630e13455c7f75ea32cb33a517694206e46a4f2ce95e
data/lib/milk_tea/base.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "pathname"
4
4
 
5
5
  module MilkTea
6
- VERSION = "0.3.7"
6
+ VERSION = "0.3.8"
7
7
 
8
8
  def self.root
9
9
  @root ||= Pathname.new(File.expand_path("../..", __dir__))
@@ -137,7 +137,12 @@ module MilkTea
137
137
  @graph.add_edge(match_id, next_id)
138
138
  else
139
139
  stmt.arms.each do |arm|
140
- arm_entry = build_block(arm.body, next_id, break_target:, continue_target:)
140
+ arm_body = if arm.respond_to?(:body)
141
+ arm.body
142
+ else
143
+ [MilkTea::AST::ExpressionStmt.new(expression: arm.value, line: arm.value.respond_to?(:line) ? arm.value.line : nil)]
144
+ end
145
+ arm_entry = build_block(arm_body, next_id, break_target:, continue_target:)
141
146
  if arm.binding_name
142
147
  binding_key = declaration_binding_key(arm, arm.binding_name)
143
148
  if binding_key
@@ -204,7 +204,11 @@ module MilkTea
204
204
  lines.concat(statement_list_lines(statement.body))
205
205
  when AST::MatchStmt
206
206
  statement.arms.each do |arm|
207
- lines.concat(statement_list_lines(arm.body))
207
+ if arm.respond_to?(:body)
208
+ lines.concat(statement_list_lines(arm.body))
209
+ else
210
+ lines << expression_end_line(arm.value)
211
+ end
208
212
  end
209
213
  when AST::DeferStmt
210
214
  lines.concat(statement_list_lines(statement.body)) if statement.body
@@ -374,7 +378,13 @@ module MilkTea
374
378
  when AST::WhileStmt, AST::ForStmt, AST::UnsafeStmt, AST::ErrorBlockStmt
375
379
  [stmt.respond_to?(:line) ? stmt.line : nil, last_ast_line(stmt.body)].compact.max
376
380
  when AST::MatchStmt
377
- arm_lines = stmt.arms.filter_map { |arm| last_ast_line(arm.body) }
381
+ arm_lines = stmt.arms.filter_map do |arm|
382
+ if arm.respond_to?(:body)
383
+ last_ast_line(arm.body)
384
+ elsif arm.respond_to?(:value)
385
+ arm.value.respond_to?(:line) ? arm.value.line : nil
386
+ end
387
+ end
378
388
  [stmt.line, *arm_lines].compact.max
379
389
  when AST::DeferStmt
380
390
  [stmt.respond_to?(:line) ? stmt.line : nil, last_ast_line(stmt.body)].compact.max
@@ -376,7 +376,11 @@ module MilkTea
376
376
  else
377
377
  callee_name = expression.callee.callee.is_a?(AST::Identifier) ? expression.callee.callee.name : nil
378
378
  if callee_name
379
- resolved_type = resolve_type_expression(expression.callee)
379
+ resolved_type = begin
380
+ resolve_type_expression(expression.callee)
381
+ rescue SemanticError
382
+ nil
383
+ end
380
384
  if resolved_type && resolved_type.is_a?(Types::Struct)
381
385
  fields = {}
382
386
  expression.arguments.each do |argument|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mt-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Long (Teefan) Tran
@@ -603,7 +603,7 @@ metadata:
603
603
  homepage_uri: https://teefan.github.io/mt-lang/
604
604
  source_code_uri: https://github.com/teefan/mt-lang
605
605
  post_install_message: |
606
- Milk Tea 0.3.7 installed!
606
+ Milk Tea 0.3.8 installed!
607
607
 
608
608
  System requirements:
609
609
  - A C compiler (gcc or clang) must be available on PATH