jaclang 0.7.1__py3-none-any.whl → 0.7.5__py3-none-any.whl

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.

Potentially problematic release.


This version of jaclang might be problematic. Click here for more details.

Files changed (85) hide show
  1. jaclang/cli/cli.py +2 -2
  2. jaclang/compiler/absyntree.py +378 -277
  3. jaclang/compiler/codeloc.py +2 -2
  4. jaclang/compiler/constant.py +2 -0
  5. jaclang/compiler/jac.lark +25 -19
  6. jaclang/compiler/parser.py +115 -92
  7. jaclang/compiler/passes/main/access_modifier_pass.py +15 -9
  8. jaclang/compiler/passes/main/def_impl_match_pass.py +29 -11
  9. jaclang/compiler/passes/main/def_use_pass.py +48 -17
  10. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +49 -30
  11. jaclang/compiler/passes/main/import_pass.py +12 -7
  12. jaclang/compiler/passes/main/pyast_gen_pass.py +110 -47
  13. jaclang/compiler/passes/main/pyast_load_pass.py +49 -13
  14. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +25 -11
  15. jaclang/compiler/passes/main/pyout_pass.py +3 -1
  16. jaclang/compiler/passes/main/registry_pass.py +6 -6
  17. jaclang/compiler/passes/main/sym_tab_build_pass.py +30 -72
  18. jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +21 -4
  19. jaclang/compiler/passes/main/tests/test_def_use_pass.py +5 -10
  20. jaclang/compiler/passes/main/tests/test_import_pass.py +8 -0
  21. jaclang/compiler/passes/main/tests/test_type_check_pass.py +1 -1
  22. jaclang/compiler/passes/main/type_check_pass.py +2 -1
  23. jaclang/compiler/passes/tool/jac_formatter_pass.py +44 -11
  24. jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +16 -0
  25. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +16 -0
  26. jaclang/compiler/passes/tool/tests/fixtures/doc_string.jac +15 -0
  27. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +7 -5
  28. jaclang/compiler/passes/tool/tests/test_unparse_validate.py +1 -2
  29. jaclang/compiler/passes/transform.py +2 -4
  30. jaclang/{core/registry.py → compiler/semtable.py} +1 -3
  31. jaclang/compiler/symtable.py +39 -31
  32. jaclang/compiler/tests/test_parser.py +2 -2
  33. jaclang/core/aott.py +112 -16
  34. jaclang/core/{construct.py → architype.py} +44 -93
  35. jaclang/core/constructs.py +44 -0
  36. jaclang/core/context.py +157 -0
  37. jaclang/core/importer.py +18 -9
  38. jaclang/core/llms/anthropic.py +31 -2
  39. jaclang/core/llms/base.py +3 -3
  40. jaclang/core/llms/groq.py +4 -1
  41. jaclang/core/llms/huggingface.py +4 -1
  42. jaclang/core/llms/ollama.py +4 -1
  43. jaclang/core/llms/openai.py +6 -2
  44. jaclang/core/llms/togetherai.py +4 -1
  45. jaclang/core/memory.py +53 -2
  46. jaclang/core/test.py +90 -0
  47. jaclang/core/utils.py +2 -2
  48. jaclang/langserve/engine.py +119 -122
  49. jaclang/langserve/server.py +27 -5
  50. jaclang/langserve/tests/fixtures/circle.jac +16 -12
  51. jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
  52. jaclang/langserve/tests/fixtures/circle_pure.impl.jac +8 -4
  53. jaclang/langserve/tests/fixtures/circle_pure.jac +2 -2
  54. jaclang/langserve/tests/test_server.py +114 -0
  55. jaclang/langserve/utils.py +104 -10
  56. jaclang/plugin/builtin.py +1 -1
  57. jaclang/plugin/default.py +46 -90
  58. jaclang/plugin/feature.py +32 -16
  59. jaclang/plugin/spec.py +17 -19
  60. jaclang/plugin/tests/test_features.py +0 -33
  61. jaclang/settings.py +4 -0
  62. jaclang/tests/fixtures/abc.jac +16 -12
  63. jaclang/tests/fixtures/byllmissue.jac +12 -0
  64. jaclang/tests/fixtures/edgetypetest.jac +16 -0
  65. jaclang/tests/fixtures/hash_init_check.jac +17 -0
  66. jaclang/tests/fixtures/impl_match_confused.impl.jac +1 -0
  67. jaclang/tests/fixtures/impl_match_confused.jac +5 -0
  68. jaclang/tests/fixtures/math_question.jpg +0 -0
  69. jaclang/tests/fixtures/maxfail_run_test.jac +17 -5
  70. jaclang/tests/fixtures/nosigself.jac +19 -0
  71. jaclang/tests/fixtures/run_test.jac +17 -5
  72. jaclang/tests/fixtures/walker_override.jac +21 -0
  73. jaclang/tests/fixtures/with_llm_vision.jac +25 -0
  74. jaclang/tests/test_bugs.py +19 -0
  75. jaclang/tests/test_cli.py +1 -1
  76. jaclang/tests/test_language.py +116 -11
  77. jaclang/tests/test_reference.py +1 -1
  78. jaclang/utils/lang_tools.py +5 -4
  79. jaclang/utils/test.py +2 -1
  80. jaclang/utils/treeprinter.py +35 -4
  81. {jaclang-0.7.1.dist-info → jaclang-0.7.5.dist-info}/METADATA +3 -2
  82. {jaclang-0.7.1.dist-info → jaclang-0.7.5.dist-info}/RECORD +84 -71
  83. jaclang/core/shelve_storage.py +0 -55
  84. {jaclang-0.7.1.dist-info → jaclang-0.7.5.dist-info}/WHEEL +0 -0
  85. {jaclang-0.7.1.dist-info → jaclang-0.7.5.dist-info}/entry_points.txt +0 -0
@@ -44,8 +44,9 @@ class JacParser(Pass):
44
44
  catch_error = ast.EmptyToken()
45
45
  catch_error.file_path = self.mod_path
46
46
  catch_error.line_no = e.line
47
+ catch_error.end_line = e.line
47
48
  catch_error.c_start = e.column
48
- catch_error.c_end = e.column
49
+ catch_error.c_end = e.column + 1
49
50
  self.error(f"Syntax Error: {e}", node_override=catch_error)
50
51
  except Exception as e:
51
52
  self.error(f"Internal Error: {e}")
@@ -437,13 +438,14 @@ class JacParser(Pass):
437
438
  else:
438
439
  raise self.ice()
439
440
 
440
- def architype(self, kid: list[ast.AstNode]) -> ast.ArchSpec:
441
+ def architype(
442
+ self, kid: list[ast.AstNode]
443
+ ) -> ast.ArchSpec | ast.ArchDef | ast.Enum | ast.EnumDef:
441
444
  """Grammar rule.
442
445
 
443
- architype: decorators architype
444
- | enum
446
+ architype: decorators? architype_decl
445
447
  | architype_def
446
- | architype_decl
448
+ | enum
447
449
  """
448
450
  if isinstance(kid[0], ast.SubNodeList):
449
451
  if isinstance(kid[1], ast.ArchSpec):
@@ -452,7 +454,8 @@ class JacParser(Pass):
452
454
  return self.nu(kid[1])
453
455
  else:
454
456
  raise self.ice()
455
- elif isinstance(kid[0], ast.ArchSpec):
457
+
458
+ elif isinstance(kid[0], (ast.ArchSpec, ast.ArchDef, ast.Enum, ast.EnumDef)):
456
459
  return self.nu(kid[0])
457
460
  else:
458
461
  raise self.ice()
@@ -569,25 +572,14 @@ class JacParser(Pass):
569
572
  else:
570
573
  raise self.ice()
571
574
 
572
- def any_ref(self, kid: list[ast.AstNode]) -> ast.NameSpec:
573
- """Grammar rule.
574
-
575
- any_ref: named_ref
576
- | arch_ref
577
- """
578
- if isinstance(kid[0], ast.NameSpec):
579
- return self.nu(kid[0])
580
- else:
581
- raise self.ice()
582
-
583
- def named_ref(self, kid: list[ast.AstNode]) -> ast.NameSpec:
575
+ def named_ref(self, kid: list[ast.AstNode]) -> ast.NameAtom:
584
576
  """Grammar rule.
585
577
 
586
578
  named_ref: special_ref
587
579
  | KWESC_NAME
588
580
  | NAME
589
581
  """
590
- if isinstance(kid[0], ast.NameSpec):
582
+ if isinstance(kid[0], ast.NameAtom):
591
583
  return self.nu(kid[0])
592
584
  else:
593
585
  raise self.ice()
@@ -602,23 +594,25 @@ class JacParser(Pass):
602
594
  | KW_SELF
603
595
  | KW_HERE
604
596
  """
605
- if isinstance(kid[0], ast.Token):
606
- return self.nu(
607
- ast.SpecialVarRef(
608
- var=kid[0],
609
- kid=kid,
610
- )
611
- )
597
+ if isinstance(kid[0], ast.Name):
598
+ return self.nu(ast.SpecialVarRef(var=kid[0]))
612
599
  else:
613
600
  raise self.ice()
614
601
 
615
602
  def enum(self, kid: list[ast.AstNode]) -> ast.Enum | ast.EnumDef:
616
603
  """Grammar rule.
617
604
 
618
- enum: enum_def
619
- | enum_decl
605
+ enum: decorators? enum_decl
606
+ | enum_def
620
607
  """
621
- if isinstance(kid[0], (ast.Enum, ast.EnumDef)):
608
+ if isinstance(kid[0], ast.SubNodeList):
609
+ if isinstance(kid[1], ast.Enum):
610
+ kid[1].decorators = kid[0]
611
+ kid[1].add_kids_left([kid[0]])
612
+ return self.nu(kid[1])
613
+ else:
614
+ raise self.ice()
615
+ elif isinstance(kid[0], (ast.Enum, ast.EnumDef)):
622
616
  return self.nu(kid[0])
623
617
  else:
624
618
 
@@ -691,6 +685,7 @@ class JacParser(Pass):
691
685
  enum_stmt: NAME (COLON STRING)? EQ expression
692
686
  | NAME (COLON STRING)?
693
687
  | py_code_block
688
+ | free_code
694
689
  """
695
690
  if isinstance(kid[0], ast.PyInlineCode):
696
691
  return self.nu(kid[0])
@@ -739,7 +734,8 @@ class JacParser(Pass):
739
734
  is_enum_stmt=True,
740
735
  )
741
736
  )
742
-
737
+ elif isinstance(kid[0], (ast.PyInlineCode, ast.ModuleCode)):
738
+ return self.nu(kid[0])
743
739
  raise self.ice()
744
740
 
745
741
  def ability(
@@ -747,9 +743,9 @@ class JacParser(Pass):
747
743
  ) -> ast.Ability | ast.AbilityDef | ast.FuncCall:
748
744
  """Grammer rule.
749
745
 
750
- ability: decorators? ability_def
751
- | decorators? KW_ASYNC? ability_decl
746
+ ability: decorators? KW_ASYNC? ability_decl
752
747
  | decorators? genai_ability
748
+ | ability_def
753
749
  """
754
750
  chomp = [*kid]
755
751
  decorators = chomp[0] if isinstance(chomp[0], ast.SubNodeList) else None
@@ -768,7 +764,7 @@ class JacParser(Pass):
768
764
  if isinstance(decorators, ast.SubNodeList):
769
765
  for dec in decorators.items:
770
766
  if (
771
- isinstance(dec, ast.NameSpec)
767
+ isinstance(dec, ast.NameAtom)
772
768
  and dec.sym_name == "staticmethod"
773
769
  and isinstance(ability, (ast.Ability))
774
770
  ):
@@ -785,7 +781,7 @@ class JacParser(Pass):
785
781
  """Grammar rule.
786
782
 
787
783
  ability_decl: KW_OVERRIDE? KW_STATIC? KW_CAN access_tag? STRING?
788
- any_ref (func_decl | event_clause) (code_block | SEMI)
784
+ named_ref (func_decl | event_clause) (code_block | SEMI)
789
785
  """
790
786
  chomp = [*kid]
791
787
  is_override = (
@@ -805,7 +801,7 @@ class JacParser(Pass):
805
801
  signature = chomp[0]
806
802
  chomp = chomp[1:]
807
803
  body = chomp[0] if isinstance(chomp[0], ast.SubNodeList) else None
808
- if isinstance(name, ast.NameSpec) and isinstance(
804
+ if isinstance(name, ast.NameAtom) and isinstance(
809
805
  signature, (ast.FuncSignature, ast.EventSignature)
810
806
  ):
811
807
  return self.nu(
@@ -852,7 +848,7 @@ class JacParser(Pass):
852
848
  """Grammar rule.
853
849
 
854
850
  abstract_ability: KW_OVERRIDE? KW_STATIC? KW_CAN access_tag? STRING?
855
- any_ref (func_decl | event_clause) KW_ABSTRACT SEMI
851
+ named_ref (func_decl | event_clause) KW_ABSTRACT SEMI
856
852
  """
857
853
  chomp = [*kid]
858
854
  is_override = (
@@ -872,7 +868,7 @@ class JacParser(Pass):
872
868
  chomp = chomp[1:]
873
869
  signature = chomp[0]
874
870
  chomp = chomp[1:]
875
- if isinstance(name, ast.NameSpec) and isinstance(
871
+ if isinstance(name, ast.NameAtom) and isinstance(
876
872
  signature, (ast.FuncSignature, ast.EventSignature)
877
873
  ):
878
874
  return self.nu(
@@ -896,7 +892,7 @@ class JacParser(Pass):
896
892
  """Grammar rule.
897
893
 
898
894
  genai_ability: KW_OVERRIDE? KW_STATIC? KW_CAN access_tag? STRING?
899
- any_ref (func_decl) KW_BY atomic_call SEMI
895
+ named_ref (func_decl) KW_BY atomic_call SEMI
900
896
  """
901
897
  chomp = [*kid]
902
898
  is_override = (
@@ -919,7 +915,7 @@ class JacParser(Pass):
919
915
  has_by = isinstance(chomp[0], ast.Token) and chomp[0].name == Tok.KW_BY
920
916
  chomp = chomp[1:] if has_by else chomp
921
917
  if (
922
- isinstance(name, ast.NameSpec)
918
+ isinstance(name, ast.NameAtom)
923
919
  and isinstance(signature, (ast.FuncSignature, ast.EventSignature))
924
920
  and isinstance(chomp[0], ast.FuncCall)
925
921
  and has_by
@@ -1080,7 +1076,7 @@ class JacParser(Pass):
1080
1076
  | doc_tag? has_stmt
1081
1077
  """
1082
1078
  if isinstance(kid[0], ast.ArchBlockStmt):
1083
- return self.nu(kid[0])
1079
+ ret = self.nu(kid[0])
1084
1080
  elif (
1085
1081
  isinstance(kid[1], ast.ArchBlockStmt)
1086
1082
  and isinstance(kid[1], ast.AstDocNode)
@@ -1088,10 +1084,12 @@ class JacParser(Pass):
1088
1084
  ):
1089
1085
  kid[1].doc = kid[0]
1090
1086
  kid[1].add_kids_left([kid[0]])
1091
- return self.nu(kid[1])
1092
-
1087
+ ret = self.nu(kid[1])
1093
1088
  else:
1094
1089
  raise self.ice()
1090
+ if isinstance(ret, ast.Ability):
1091
+ ret.signature.is_method = True
1092
+ return ret
1095
1093
 
1096
1094
  def has_stmt(self, kid: list[ast.AstNode]) -> ast.ArchHas:
1097
1095
  """Grammar rule.
@@ -1209,6 +1207,7 @@ class JacParser(Pass):
1209
1207
  file_path=self.parse_ref.mod_path,
1210
1208
  value=kid[0].value,
1211
1209
  line=kid[0].loc.first_line,
1210
+ end_line=kid[0].loc.last_line,
1212
1211
  col_start=kid[0].loc.col_start,
1213
1212
  col_end=kid[0].loc.col_end,
1214
1213
  pos_start=kid[0].pos_start,
@@ -1258,7 +1257,7 @@ class JacParser(Pass):
1258
1257
  | try_stmt
1259
1258
  | if_stmt
1260
1259
  | expression SEMI
1261
- | yield_expr SEMI
1260
+ | (yield_expr | KW_YIELD) SEMI
1262
1261
  | static_assignment
1263
1262
  | assignment SEMI
1264
1263
  | global_ref SEMI
@@ -1271,6 +1270,18 @@ class JacParser(Pass):
1271
1270
  """
1272
1271
  if isinstance(kid[0], ast.CodeBlockStmt) and len(kid) < 2:
1273
1272
  return self.nu(kid[0])
1273
+ elif isinstance(kid[0], ast.Token) and kid[0].name == Tok.KW_YIELD:
1274
+ return ast.ExprStmt(
1275
+ expr=(
1276
+ expr := ast.YieldExpr(
1277
+ expr=None,
1278
+ with_from=False,
1279
+ kid=kid,
1280
+ )
1281
+ ),
1282
+ in_fstring=False,
1283
+ kid=[expr],
1284
+ )
1274
1285
  elif isinstance(kid[0], ast.Expr):
1275
1286
  return ast.ExprStmt(
1276
1287
  expr=kid[0],
@@ -1617,6 +1628,21 @@ class JacParser(Pass):
1617
1628
  else:
1618
1629
  raise self.ice()
1619
1630
 
1631
+ def check_stmt(self, kid: list[ast.AstNode]) -> ast.CheckStmt:
1632
+ """Grammar rule.
1633
+
1634
+ check_stmt: KW_CHECK expression
1635
+ """
1636
+ if isinstance(kid[1], ast.Expr):
1637
+ return self.nu(
1638
+ ast.CheckStmt(
1639
+ target=kid[1],
1640
+ kid=kid,
1641
+ )
1642
+ )
1643
+ else:
1644
+ raise self.ice()
1645
+
1620
1646
  def ctrl_stmt(self, kid: list[ast.AstNode]) -> ast.CtrlStmt:
1621
1647
  """Grammar rule.
1622
1648
 
@@ -2300,7 +2326,7 @@ class JacParser(Pass):
2300
2326
  """Grammar rule.
2301
2327
 
2302
2328
  atomic_chain: atomic_chain NULL_OK? (filter_compr | assign_compr | index_slice)
2303
- | atomic_chain NULL_OK? (DOT_BKWD | DOT_FWD | DOT) any_ref
2329
+ | atomic_chain NULL_OK? (DOT_BKWD | DOT_FWD | DOT) named_ref
2304
2330
  | (atomic_call | atom | edge_ref_chain)
2305
2331
  """
2306
2332
  if len(kid) < 2 and isinstance(kid[0], ast.Expr):
@@ -2436,10 +2462,11 @@ class JacParser(Pass):
2436
2462
  def atom(self, kid: list[ast.AstNode]) -> ast.Expr:
2437
2463
  """Grammar rule.
2438
2464
 
2439
- atom: any_ref
2465
+ atom: named_ref
2440
2466
  | LPAREN (expression | yield_expr) RPAREN
2441
2467
  | atom_collection
2442
2468
  | atom_literal
2469
+ | type_ref
2443
2470
  """
2444
2471
  if len(kid) == 1:
2445
2472
  if isinstance(kid[0], ast.AtomExpr):
@@ -2464,7 +2491,6 @@ class JacParser(Pass):
2464
2491
 
2465
2492
  yield_expr:
2466
2493
  | KW_YIELD KW_FROM? expression
2467
- | KW_YIELD
2468
2494
  """
2469
2495
  if isinstance(kid[-1], ast.Expr):
2470
2496
  return self.nu(
@@ -2474,19 +2500,6 @@ class JacParser(Pass):
2474
2500
  kid=kid,
2475
2501
  )
2476
2502
  )
2477
- elif (
2478
- len(kid) == 1
2479
- and isinstance(kid[0], ast.Token)
2480
- and kid[0].name == Tok.KW_YIELD
2481
- ):
2482
- return self.nu(
2483
- ast.YieldExpr(
2484
- expr=None,
2485
- with_from=False,
2486
- kid=kid,
2487
- )
2488
- )
2489
-
2490
2503
  else:
2491
2504
  raise self.ice()
2492
2505
 
@@ -2730,11 +2743,11 @@ class JacParser(Pass):
2730
2743
  def kw_expr(self, kid: list[ast.AstNode]) -> ast.KWPair:
2731
2744
  """Grammar rule.
2732
2745
 
2733
- kw_expr: any_ref EQ expression | STAR_POW expression
2746
+ kw_expr: named_ref EQ expression | STAR_POW expression
2734
2747
  """
2735
2748
  if (
2736
2749
  len(kid) == 3
2737
- and isinstance(kid[0], ast.NameSpec)
2750
+ and isinstance(kid[0], ast.NameAtom)
2738
2751
  and isinstance(kid[2], ast.Expr)
2739
2752
  ):
2740
2753
  return self.nu(
@@ -3031,11 +3044,11 @@ class JacParser(Pass):
3031
3044
 
3032
3045
  node_ref: NODE_OP NAME
3033
3046
  """
3034
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3047
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3035
3048
  return self.nu(
3036
3049
  ast.ArchRef(
3037
- arch=kid[0],
3038
- name_ref=kid[1],
3050
+ arch_type=kid[0],
3051
+ arch_name=kid[1],
3039
3052
  kid=kid,
3040
3053
  )
3041
3054
  )
@@ -3047,11 +3060,11 @@ class JacParser(Pass):
3047
3060
 
3048
3061
  edge_ref: EDGE_OP NAME
3049
3062
  """
3050
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3063
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3051
3064
  return self.nu(
3052
3065
  ast.ArchRef(
3053
- arch=kid[0],
3054
- name_ref=kid[1],
3066
+ arch_type=kid[0],
3067
+ arch_name=kid[1],
3055
3068
  kid=kid,
3056
3069
  )
3057
3070
  )
@@ -3063,11 +3076,11 @@ class JacParser(Pass):
3063
3076
 
3064
3077
  walker_ref: WALKER_OP NAME
3065
3078
  """
3066
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3079
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3067
3080
  return self.nu(
3068
3081
  ast.ArchRef(
3069
- arch=kid[0],
3070
- name_ref=kid[1],
3082
+ arch_type=kid[0],
3083
+ arch_name=kid[1],
3071
3084
  kid=kid,
3072
3085
  )
3073
3086
  )
@@ -3079,11 +3092,11 @@ class JacParser(Pass):
3079
3092
 
3080
3093
  class_ref: CLASS_OP name_ref
3081
3094
  """
3082
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3095
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3083
3096
  return self.nu(
3084
3097
  ast.ArchRef(
3085
- arch=kid[0],
3086
- name_ref=kid[1],
3098
+ arch_type=kid[0],
3099
+ arch_name=kid[1],
3087
3100
  kid=kid,
3088
3101
  )
3089
3102
  )
@@ -3095,11 +3108,11 @@ class JacParser(Pass):
3095
3108
 
3096
3109
  object_ref: OBJECT_OP name_ref
3097
3110
  """
3098
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3111
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3099
3112
  return self.nu(
3100
3113
  ast.ArchRef(
3101
- arch=kid[0],
3102
- name_ref=kid[1],
3114
+ arch_type=kid[0],
3115
+ arch_name=kid[1],
3103
3116
  kid=kid,
3104
3117
  )
3105
3118
  )
@@ -3111,11 +3124,11 @@ class JacParser(Pass):
3111
3124
 
3112
3125
  type_ref: TYPE_OP name_ref
3113
3126
  """
3114
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3127
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3115
3128
  return self.nu(
3116
3129
  ast.ArchRef(
3117
- arch=kid[0],
3118
- name_ref=kid[1],
3130
+ arch_type=kid[0],
3131
+ arch_name=kid[1],
3119
3132
  kid=kid,
3120
3133
  )
3121
3134
  )
@@ -3127,11 +3140,11 @@ class JacParser(Pass):
3127
3140
 
3128
3141
  enum_ref: ENUM_OP NAME
3129
3142
  """
3130
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3143
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3131
3144
  return self.nu(
3132
3145
  ast.ArchRef(
3133
- arch=kid[0],
3134
- name_ref=kid[1],
3146
+ arch_type=kid[0],
3147
+ arch_name=kid[1],
3135
3148
  kid=kid,
3136
3149
  )
3137
3150
  )
@@ -3143,11 +3156,11 @@ class JacParser(Pass):
3143
3156
 
3144
3157
  ability_ref: ABILITY_OP (special_ref | name_ref)
3145
3158
  """
3146
- if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameSpec):
3159
+ if isinstance(kid[0], ast.Token) and isinstance(kid[1], ast.NameAtom):
3147
3160
  return self.nu(
3148
3161
  ast.ArchRef(
3149
- arch=kid[0],
3150
- name_ref=kid[1],
3162
+ arch_type=kid[0],
3163
+ arch_name=kid[1],
3151
3164
  kid=kid,
3152
3165
  )
3153
3166
  )
@@ -3601,7 +3614,7 @@ class JacParser(Pass):
3601
3614
  as_pattern: pattern KW_AS NAME
3602
3615
  """
3603
3616
  if isinstance(kid[0], ast.MatchPattern) and isinstance(
3604
- kid[2], ast.NameSpec
3617
+ kid[2], ast.NameAtom
3605
3618
  ):
3606
3619
  return self.nu(
3607
3620
  ast.MatchAs(
@@ -3672,7 +3685,7 @@ class JacParser(Pass):
3672
3685
  kid=kid,
3673
3686
  )
3674
3687
  )
3675
- if isinstance(kid[0], ast.NameSpec):
3688
+ if isinstance(kid[0], ast.NameAtom):
3676
3689
  return self.nu(
3677
3690
  ast.MatchAs(
3678
3691
  name=kid[0],
@@ -3784,7 +3797,7 @@ class JacParser(Pass):
3784
3797
  chomp = chomp[2:]
3785
3798
  else:
3786
3799
  raise self.ice()
3787
- elif isinstance(cur_element, ast.NameSpec):
3800
+ elif isinstance(cur_element, ast.NameAtom):
3788
3801
  chomp = chomp[1:]
3789
3802
  else:
3790
3803
  break
@@ -3815,7 +3828,7 @@ class JacParser(Pass):
3815
3828
  else None
3816
3829
  )
3817
3830
  )
3818
- if isinstance(name, (ast.NameSpec, ast.AtomTrailer)):
3831
+ if isinstance(name, (ast.NameAtom, ast.AtomTrailer)):
3819
3832
  kid_nodes = [name, lparen]
3820
3833
  if arg:
3821
3834
  kid_nodes.append(arg)
@@ -3878,7 +3891,7 @@ class JacParser(Pass):
3878
3891
  name = kid[2]
3879
3892
  eq = kid[3]
3880
3893
  value = kid[4]
3881
- if not isinstance(name, ast.NameSpec) or not isinstance(
3894
+ if not isinstance(name, ast.NameAtom) or not isinstance(
3882
3895
  value, ast.MatchPattern
3883
3896
  ):
3884
3897
  raise self.ice()
@@ -3891,14 +3904,14 @@ class JacParser(Pass):
3891
3904
  name = kid[0]
3892
3905
  eq = kid[1]
3893
3906
  value = kid[2]
3894
- if not isinstance(name, ast.NameSpec) or not isinstance(
3907
+ if not isinstance(name, ast.NameAtom) or not isinstance(
3895
3908
  value, ast.MatchPattern
3896
3909
  ):
3897
3910
  raise self.ice()
3898
3911
  new_kid = [
3899
3912
  ast.MatchKVPair(key=name, value=value, kid=[name, eq, value])
3900
3913
  ]
3901
- if isinstance(name, ast.NameSpec) and isinstance(value, ast.MatchPattern):
3914
+ if isinstance(name, ast.NameAtom) and isinstance(value, ast.MatchPattern):
3902
3915
  valid_kid = [i for i in new_kid if isinstance(i, ast.MatchKVPair)]
3903
3916
  return ast.SubNodeList[ast.MatchKVPair](
3904
3917
  items=valid_kid,
@@ -3913,6 +3926,15 @@ class JacParser(Pass):
3913
3926
  ret_type = ast.Token
3914
3927
  if token.type in [Tok.NAME, Tok.KWESC_NAME]:
3915
3928
  ret_type = ast.Name
3929
+ if token.type in [
3930
+ Tok.KW_INIT,
3931
+ Tok.KW_POST_INIT,
3932
+ Tok.KW_ROOT,
3933
+ Tok.KW_SUPER,
3934
+ Tok.KW_SELF,
3935
+ Tok.KW_HERE,
3936
+ ]:
3937
+ ret_type = ast.Name
3916
3938
  elif token.type == Tok.SEMI:
3917
3939
  ret_type = ast.Semi
3918
3940
  elif token.type == Tok.NULL:
@@ -3942,6 +3964,7 @@ class JacParser(Pass):
3942
3964
  name=token.type,
3943
3965
  value=token.value[2:] if token.type == Tok.KWESC_NAME else token.value,
3944
3966
  line=token.line if token.line is not None else 0,
3967
+ end_line=token.end_line if token.end_line is not None else 0,
3945
3968
  col_start=token.column if token.column is not None else 0,
3946
3969
  col_end=token.end_column if token.end_column is not None else 0,
3947
3970
  pos_start=token.start_pos if token.start_pos is not None else 0,
@@ -8,6 +8,7 @@ from typing import Optional
8
8
 
9
9
  import jaclang.compiler.absyntree as ast
10
10
  from jaclang.compiler.passes.main.sym_tab_build_pass import SymTabPass, SymbolAccess
11
+ from jaclang.settings import settings
11
12
 
12
13
 
13
14
  class AccessCheckPass(SymTabPass):
@@ -17,6 +18,12 @@ class AccessCheckPass(SymTabPass):
17
18
  """After pass."""
18
19
  pass
19
20
 
21
+ def exit_node(self, node: ast.AstNode) -> None:
22
+ """Exit node."""
23
+ super().exit_node(node)
24
+ if settings.lsp_debug and isinstance(node, ast.NameAtom) and not node.sym:
25
+ self.warning(f"Name {node.sym_name} not present in symbol table")
26
+
20
27
  def access_check(self, node: ast.Name) -> None:
21
28
  """Access check."""
22
29
  node_info = (
@@ -25,9 +32,9 @@ class AccessCheckPass(SymTabPass):
25
32
  else None
26
33
  )
27
34
 
28
- if node.sym_link:
35
+ if node.sym:
29
36
  decl_package_path = os.path.dirname(
30
- os.path.abspath(node.sym_link.defn[-1].loc.mod_path)
37
+ os.path.abspath(node.sym.defn[-1].loc.mod_path)
31
38
  )
32
39
  use_package_path = os.path.dirname(os.path.abspath(node.loc.mod_path))
33
40
  else:
@@ -35,7 +42,7 @@ class AccessCheckPass(SymTabPass):
35
42
 
36
43
  if (
37
44
  node_info
38
- and node.sym_link
45
+ and node.sym
39
46
  and node_info.access == SymbolAccess.PROTECTED
40
47
  and decl_package_path != use_package_path
41
48
  ):
@@ -46,12 +53,12 @@ class AccessCheckPass(SymTabPass):
46
53
 
47
54
  if (
48
55
  node_info
49
- and node.sym_link
56
+ and node.sym
50
57
  and node_info.access == SymbolAccess.PRIVATE
51
- and node.sym_link.defn[-1].loc.mod_path != node.loc.mod_path
58
+ and node.sym.defn[-1].loc.mod_path != node.loc.mod_path
52
59
  ):
53
60
  return self.error(
54
- f'Can not access private variable "{node.sym_name}" from {node.sym_link.defn[-1].loc.mod_path}'
61
+ f'Can not access private variable "{node.sym_name}" from {node.sym.defn[-1].loc.mod_path}'
55
62
  f" to {node.loc.mod_path}."
56
63
  )
57
64
 
@@ -59,7 +66,6 @@ class AccessCheckPass(SymTabPass):
59
66
  self, node: ast.AstSymbolNode, acc_tag: Optional[SymbolAccess] = None
60
67
  ) -> None:
61
68
  """Access register."""
62
- node.sym_info.acc_tag = acc_tag
63
69
 
64
70
  def enter_global_vars(self, node: ast.GlobalVars) -> None:
65
71
  """Sub objects.
@@ -167,7 +173,7 @@ class AccessCheckPass(SymTabPass):
167
173
  if isinstance(node.parent, ast.FuncCall):
168
174
  self.access_check(node)
169
175
 
170
- if node.sym_link and Pass.has_parent_of_type(
171
- node=node.sym_link.defn[-1], typ=ast.GlobalVars
176
+ if node.sym and Pass.has_parent_of_type(
177
+ node=node.sym.defn[-1], typ=ast.GlobalVars
172
178
  ):
173
179
  self.access_check(node)