yuho 5.0.0__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.
Files changed (91) hide show
  1. yuho/__init__.py +16 -0
  2. yuho/ast/__init__.py +196 -0
  3. yuho/ast/builder.py +926 -0
  4. yuho/ast/constant_folder.py +280 -0
  5. yuho/ast/dead_code.py +199 -0
  6. yuho/ast/exhaustiveness.py +503 -0
  7. yuho/ast/nodes.py +907 -0
  8. yuho/ast/overlap.py +291 -0
  9. yuho/ast/reachability.py +293 -0
  10. yuho/ast/scope_analysis.py +490 -0
  11. yuho/ast/transformer.py +490 -0
  12. yuho/ast/type_check.py +471 -0
  13. yuho/ast/type_inference.py +425 -0
  14. yuho/ast/visitor.py +239 -0
  15. yuho/cli/__init__.py +14 -0
  16. yuho/cli/commands/__init__.py +1 -0
  17. yuho/cli/commands/api.py +431 -0
  18. yuho/cli/commands/ast_viz.py +334 -0
  19. yuho/cli/commands/check.py +218 -0
  20. yuho/cli/commands/config.py +311 -0
  21. yuho/cli/commands/contribute.py +122 -0
  22. yuho/cli/commands/diff.py +487 -0
  23. yuho/cli/commands/explain.py +240 -0
  24. yuho/cli/commands/fmt.py +253 -0
  25. yuho/cli/commands/generate.py +316 -0
  26. yuho/cli/commands/graph.py +410 -0
  27. yuho/cli/commands/init.py +120 -0
  28. yuho/cli/commands/library.py +656 -0
  29. yuho/cli/commands/lint.py +503 -0
  30. yuho/cli/commands/lsp.py +36 -0
  31. yuho/cli/commands/preview.py +377 -0
  32. yuho/cli/commands/repl.py +444 -0
  33. yuho/cli/commands/serve.py +44 -0
  34. yuho/cli/commands/test.py +528 -0
  35. yuho/cli/commands/transpile.py +121 -0
  36. yuho/cli/commands/wizard.py +370 -0
  37. yuho/cli/completions.py +182 -0
  38. yuho/cli/error_formatter.py +193 -0
  39. yuho/cli/main.py +1064 -0
  40. yuho/config/__init__.py +46 -0
  41. yuho/config/loader.py +235 -0
  42. yuho/config/mask.py +194 -0
  43. yuho/config/schema.py +147 -0
  44. yuho/library/__init__.py +84 -0
  45. yuho/library/index.py +328 -0
  46. yuho/library/install.py +699 -0
  47. yuho/library/lockfile.py +330 -0
  48. yuho/library/package.py +421 -0
  49. yuho/library/resolver.py +791 -0
  50. yuho/library/signature.py +335 -0
  51. yuho/llm/__init__.py +45 -0
  52. yuho/llm/config.py +75 -0
  53. yuho/llm/factory.py +123 -0
  54. yuho/llm/prompts.py +146 -0
  55. yuho/llm/providers.py +383 -0
  56. yuho/llm/utils.py +470 -0
  57. yuho/lsp/__init__.py +14 -0
  58. yuho/lsp/code_action_handler.py +518 -0
  59. yuho/lsp/completion_handler.py +85 -0
  60. yuho/lsp/diagnostics.py +100 -0
  61. yuho/lsp/hover_handler.py +130 -0
  62. yuho/lsp/server.py +1425 -0
  63. yuho/mcp/__init__.py +10 -0
  64. yuho/mcp/server.py +1452 -0
  65. yuho/parser/__init__.py +8 -0
  66. yuho/parser/source_location.py +108 -0
  67. yuho/parser/wrapper.py +311 -0
  68. yuho/testing/__init__.py +48 -0
  69. yuho/testing/coverage.py +274 -0
  70. yuho/testing/fixtures.py +263 -0
  71. yuho/transpile/__init__.py +52 -0
  72. yuho/transpile/alloy_transpiler.py +546 -0
  73. yuho/transpile/base.py +100 -0
  74. yuho/transpile/blocks_transpiler.py +338 -0
  75. yuho/transpile/english_transpiler.py +470 -0
  76. yuho/transpile/graphql_transpiler.py +404 -0
  77. yuho/transpile/json_transpiler.py +217 -0
  78. yuho/transpile/jsonld_transpiler.py +250 -0
  79. yuho/transpile/latex_preamble.py +161 -0
  80. yuho/transpile/latex_transpiler.py +406 -0
  81. yuho/transpile/latex_utils.py +206 -0
  82. yuho/transpile/mermaid_transpiler.py +357 -0
  83. yuho/transpile/registry.py +275 -0
  84. yuho/verify/__init__.py +43 -0
  85. yuho/verify/alloy.py +352 -0
  86. yuho/verify/combined.py +218 -0
  87. yuho/verify/z3_solver.py +1155 -0
  88. yuho-5.0.0.dist-info/METADATA +186 -0
  89. yuho-5.0.0.dist-info/RECORD +91 -0
  90. yuho-5.0.0.dist-info/WHEEL +4 -0
  91. yuho-5.0.0.dist-info/entry_points.txt +2 -0
yuho/__init__.py ADDED
@@ -0,0 +1,16 @@
1
+ """
2
+ Yuho v5 - A domain-specific language for encoding legal statutes
3
+
4
+ This package provides:
5
+ - Parser: tree-sitter based parser for .yh files
6
+ - AST: Internal representation for semantic analysis
7
+ - Transpilers: Code generation to JSON, JSON-LD, English, LaTeX, Mermaid, Alloy
8
+ - LSP: Language Server Protocol implementation
9
+ - MCP: Model Context Protocol server
10
+ """
11
+
12
+ __version__ = "5.0.0"
13
+
14
+ from yuho.parser import Parser, SourceLocation
15
+
16
+ __all__ = ["Parser", "SourceLocation", "__version__"]
yuho/ast/__init__.py ADDED
@@ -0,0 +1,196 @@
1
+ """
2
+ Yuho AST (Abstract Syntax Tree) module.
3
+
4
+ This module provides immutable AST node classes for representing
5
+ parsed Yuho source code, along with Visitor and Transformer base
6
+ classes for AST traversal and transformation.
7
+ """
8
+
9
+ from yuho.ast.nodes import (
10
+ # Base
11
+ ASTNode,
12
+ # Literals
13
+ IntLit,
14
+ FloatLit,
15
+ BoolLit,
16
+ StringLit,
17
+ MoneyNode,
18
+ PercentNode,
19
+ DateNode,
20
+ DurationNode,
21
+ # Expressions
22
+ IdentifierNode,
23
+ FieldAccessNode,
24
+ IndexAccessNode,
25
+ FunctionCallNode,
26
+ BinaryExprNode,
27
+ UnaryExprNode,
28
+ PassExprNode,
29
+ # Patterns
30
+ PatternNode,
31
+ WildcardPattern,
32
+ LiteralPattern,
33
+ BindingPattern,
34
+ StructPattern,
35
+ FieldPattern,
36
+ # Match
37
+ MatchArm,
38
+ MatchExprNode,
39
+ # Structs
40
+ FieldDef,
41
+ StructDefNode,
42
+ FieldAssignment,
43
+ StructLiteralNode,
44
+ # Functions
45
+ ParamDef,
46
+ FunctionDefNode,
47
+ # Statements
48
+ VariableDecl,
49
+ AssignmentStmt,
50
+ ReturnStmt,
51
+ PassStmt,
52
+ ExpressionStmt,
53
+ Block,
54
+ # Statutes
55
+ DefinitionEntry,
56
+ ElementNode,
57
+ PenaltyNode,
58
+ IllustrationNode,
59
+ StatuteNode,
60
+ # Imports
61
+ ImportNode,
62
+ # Module
63
+ ModuleNode,
64
+ # Types
65
+ TypeNode,
66
+ BuiltinType,
67
+ NamedType,
68
+ GenericType,
69
+ OptionalType,
70
+ ArrayType,
71
+ # Currency
72
+ Currency,
73
+ )
74
+
75
+ from yuho.ast.visitor import Visitor
76
+ from yuho.ast.transformer import Transformer
77
+ from yuho.ast.builder import ASTBuilder
78
+ from yuho.ast.exhaustiveness import (
79
+ ExhaustivenessChecker,
80
+ ExhaustivenessError,
81
+ ExhaustivenessResult,
82
+ check_exhaustiveness,
83
+ )
84
+ from yuho.ast.reachability import (
85
+ ReachabilityChecker,
86
+ ReachabilityError,
87
+ ReachabilityResult,
88
+ check_reachability,
89
+ )
90
+ from yuho.ast.overlap import (
91
+ OverlapDetector,
92
+ OverlapWarning,
93
+ OverlapResult,
94
+ check_overlaps,
95
+ )
96
+ from yuho.ast.constant_folder import (
97
+ ConstantFolder,
98
+ ConstantFoldingError,
99
+ fold_constants,
100
+ )
101
+ from yuho.ast.dead_code import (
102
+ DeadCodeEliminator,
103
+ EliminationStats,
104
+ eliminate_dead_code,
105
+ )
106
+
107
+ __all__ = [
108
+ # Base
109
+ "ASTNode",
110
+ # Literals
111
+ "IntLit",
112
+ "FloatLit",
113
+ "BoolLit",
114
+ "StringLit",
115
+ "MoneyNode",
116
+ "PercentNode",
117
+ "DateNode",
118
+ "DurationNode",
119
+ # Expressions
120
+ "IdentifierNode",
121
+ "FieldAccessNode",
122
+ "IndexAccessNode",
123
+ "FunctionCallNode",
124
+ "BinaryExprNode",
125
+ "UnaryExprNode",
126
+ "PassExprNode",
127
+ # Patterns
128
+ "PatternNode",
129
+ "WildcardPattern",
130
+ "LiteralPattern",
131
+ "BindingPattern",
132
+ "StructPattern",
133
+ "FieldPattern",
134
+ # Match
135
+ "MatchArm",
136
+ "MatchExprNode",
137
+ # Structs
138
+ "FieldDef",
139
+ "StructDefNode",
140
+ "FieldAssignment",
141
+ "StructLiteralNode",
142
+ # Functions
143
+ "ParamDef",
144
+ "FunctionDefNode",
145
+ # Statements
146
+ "VariableDecl",
147
+ "AssignmentStmt",
148
+ "ReturnStmt",
149
+ "PassStmt",
150
+ "ExpressionStmt",
151
+ "Block",
152
+ # Statutes
153
+ "DefinitionEntry",
154
+ "ElementNode",
155
+ "PenaltyNode",
156
+ "IllustrationNode",
157
+ "StatuteNode",
158
+ # Imports
159
+ "ImportNode",
160
+ # Module
161
+ "ModuleNode",
162
+ # Types
163
+ "TypeNode",
164
+ "BuiltinType",
165
+ "NamedType",
166
+ "GenericType",
167
+ "OptionalType",
168
+ "ArrayType",
169
+ # Currency
170
+ "Currency",
171
+ # Traversal
172
+ "Visitor",
173
+ "Transformer",
174
+ "ASTBuilder",
175
+ # Analysis
176
+ "ExhaustivenessChecker",
177
+ "ExhaustivenessError",
178
+ "ExhaustivenessResult",
179
+ "check_exhaustiveness",
180
+ "ReachabilityChecker",
181
+ "ReachabilityError",
182
+ "ReachabilityResult",
183
+ "check_reachability",
184
+ "OverlapDetector",
185
+ "OverlapWarning",
186
+ "OverlapResult",
187
+ "check_overlaps",
188
+ # Constant folding
189
+ "ConstantFolder",
190
+ "ConstantFoldingError",
191
+ "fold_constants",
192
+ # Dead code elimination
193
+ "DeadCodeEliminator",
194
+ "EliminationStats",
195
+ "eliminate_dead_code",
196
+ ]