-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
258 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/bolt_class/src/data/demo/functions/pydantic.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from pydantic import BaseModel | ||
|
||
class Model(BaseModel, frozen=True): | ||
a: int | ||
b: str | ||
|
||
say Model(a="123", b="123").json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class A(foo=True, bar=1 + 2): | ||
pass | ||
--- | ||
<class 'mecha.ast.AstRoot'> | ||
location: SourceLocation(pos=0, lineno=1, colno=1) | ||
end_location: SourceLocation(pos=39, lineno=3, colno=1) | ||
commands: | ||
<class 'mecha.ast.AstCommand'> | ||
location: SourceLocation(pos=0, lineno=1, colno=1) | ||
end_location: SourceLocation(pos=38, lineno=2, colno=9) | ||
identifier: 'class:name:bases:body' | ||
arguments: | ||
<class 'bolt.ast.AstClassName'> | ||
location: SourceLocation(pos=6, lineno=1, colno=7) | ||
end_location: SourceLocation(pos=7, lineno=1, colno=8) | ||
decorators: | ||
<empty> | ||
value: 'A' | ||
<class 'bolt.ast.AstClassBases'> | ||
location: SourceLocation(pos=7, lineno=1, colno=8) | ||
end_location: SourceLocation(pos=28, lineno=1, colno=29) | ||
inherit: | ||
<empty> | ||
kwargs: | ||
<class 'bolt.ast.AstKeyword'> | ||
location: SourceLocation(pos=8, lineno=1, colno=9) | ||
end_location: SourceLocation(pos=16, lineno=1, colno=17) | ||
name: 'foo' | ||
value: | ||
<class 'bolt.ast.AstValue'> | ||
location: SourceLocation(pos=12, lineno=1, colno=13) | ||
end_location: SourceLocation(pos=16, lineno=1, colno=17) | ||
value: True | ||
<class 'bolt.ast.AstKeyword'> | ||
location: SourceLocation(pos=18, lineno=1, colno=19) | ||
end_location: SourceLocation(pos=27, lineno=1, colno=28) | ||
name: 'bar' | ||
value: | ||
<class 'bolt.ast.AstExpressionBinary'> | ||
location: SourceLocation(pos=22, lineno=1, colno=23) | ||
end_location: SourceLocation(pos=27, lineno=1, colno=28) | ||
operator: '+' | ||
left: | ||
<class 'bolt.ast.AstValue'> | ||
location: SourceLocation(pos=22, lineno=1, colno=23) | ||
end_location: SourceLocation(pos=23, lineno=1, colno=24) | ||
value: 1 | ||
right: | ||
<class 'bolt.ast.AstValue'> | ||
location: SourceLocation(pos=26, lineno=1, colno=27) | ||
end_location: SourceLocation(pos=27, lineno=1, colno=28) | ||
value: 2 | ||
<class 'bolt.ast.AstClassRoot'> | ||
location: SourceLocation(pos=34, lineno=2, colno=5) | ||
end_location: SourceLocation(pos=38, lineno=2, colno=9) | ||
commands: | ||
<class 'mecha.ast.AstCommand'> | ||
location: SourceLocation(pos=34, lineno=2, colno=5) | ||
end_location: SourceLocation(pos=38, lineno=2, colno=9) | ||
identifier: 'pass' | ||
arguments: | ||
<empty> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
_bolt_lineno = [1], [1] | ||
_bolt_helper_children = _bolt_runtime.helpers['children'] | ||
_bolt_helper_replace = _bolt_runtime.helpers['replace'] | ||
with _bolt_runtime.scope() as _bolt_var3: | ||
_bolt_var0 = True | ||
_bolt_var1 = 1 | ||
_bolt_var2 = 2 | ||
_bolt_var1 = _bolt_var1 + _bolt_var2 | ||
class A(foo=_bolt_var0, bar=_bolt_var1): | ||
pass | ||
_bolt_var4 = _bolt_helper_replace(_bolt_refs[0], commands=_bolt_helper_children(_bolt_var3)) | ||
--- | ||
output = _bolt_var4 | ||
--- | ||
_bolt_refs[0] | ||
<class 'mecha.ast.AstRoot'> | ||
location: SourceLocation(pos=0, lineno=1, colno=1) | ||
end_location: SourceLocation(pos=39, lineno=3, colno=1) | ||
commands: | ||
<class 'mecha.ast.AstCommand'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class A: | ||
pass | ||
#>ERROR Base class not allowed after keyword argument "foo". | ||
# line 3, column 19 | ||
# 2 | pass | ||
# 3 | class B(foo=True, A): | ||
# : ^ | ||
# 4 | pass | ||
class B(foo=True, A): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
class A: | ||
pass | ||
class B(A, foo=True): | ||
pass | ||
--- | ||
<class 'mecha.ast.AstRoot'> | ||
location: SourceLocation(pos=0, lineno=1, colno=1) | ||
end_location: SourceLocation(pos=49, lineno=5, colno=1) | ||
commands: | ||
<class 'mecha.ast.AstCommand'> | ||
location: SourceLocation(pos=0, lineno=1, colno=1) | ||
end_location: SourceLocation(pos=17, lineno=2, colno=9) | ||
identifier: 'class:name:body' | ||
arguments: | ||
<class 'bolt.ast.AstClassName'> | ||
location: SourceLocation(pos=6, lineno=1, colno=7) | ||
end_location: SourceLocation(pos=7, lineno=1, colno=8) | ||
decorators: | ||
<empty> | ||
value: 'A' | ||
<class 'bolt.ast.AstClassRoot'> | ||
location: SourceLocation(pos=13, lineno=2, colno=5) | ||
end_location: SourceLocation(pos=17, lineno=2, colno=9) | ||
commands: | ||
<class 'mecha.ast.AstCommand'> | ||
location: SourceLocation(pos=13, lineno=2, colno=5) | ||
end_location: SourceLocation(pos=17, lineno=2, colno=9) | ||
identifier: 'pass' | ||
arguments: | ||
<empty> | ||
<class 'mecha.ast.AstCommand'> | ||
location: SourceLocation(pos=18, lineno=3, colno=1) | ||
end_location: SourceLocation(pos=48, lineno=4, colno=9) | ||
identifier: 'class:name:bases:body' | ||
arguments: | ||
<class 'bolt.ast.AstClassName'> | ||
location: SourceLocation(pos=24, lineno=3, colno=7) | ||
end_location: SourceLocation(pos=25, lineno=3, colno=8) | ||
decorators: | ||
<empty> | ||
value: 'B' | ||
<class 'bolt.ast.AstClassBases'> | ||
location: SourceLocation(pos=25, lineno=3, colno=8) | ||
end_location: SourceLocation(pos=38, lineno=3, colno=21) | ||
inherit: | ||
<class 'bolt.ast.AstIdentifier'> | ||
location: SourceLocation(pos=26, lineno=3, colno=9) | ||
end_location: SourceLocation(pos=27, lineno=3, colno=10) | ||
value: 'A' | ||
kwargs: | ||
<class 'bolt.ast.AstKeyword'> | ||
location: SourceLocation(pos=29, lineno=3, colno=12) | ||
end_location: SourceLocation(pos=37, lineno=3, colno=20) | ||
name: 'foo' | ||
value: | ||
<class 'bolt.ast.AstValue'> | ||
location: SourceLocation(pos=33, lineno=3, colno=16) | ||
end_location: SourceLocation(pos=37, lineno=3, colno=20) | ||
value: True | ||
<class 'bolt.ast.AstClassRoot'> | ||
location: SourceLocation(pos=44, lineno=4, colno=5) | ||
end_location: SourceLocation(pos=48, lineno=4, colno=9) | ||
commands: | ||
<class 'mecha.ast.AstCommand'> | ||
location: SourceLocation(pos=44, lineno=4, colno=5) | ||
end_location: SourceLocation(pos=48, lineno=4, colno=9) | ||
identifier: 'pass' | ||
arguments: | ||
<empty> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
_bolt_lineno = [1, 7], [1, 3] | ||
_bolt_helper_children = _bolt_runtime.helpers['children'] | ||
_bolt_helper_replace = _bolt_runtime.helpers['replace'] | ||
with _bolt_runtime.scope() as _bolt_var2: | ||
class A: | ||
pass | ||
_bolt_var0 = A | ||
_bolt_var1 = True | ||
class B(_bolt_var0, foo=_bolt_var1): | ||
pass | ||
_bolt_var3 = _bolt_helper_replace(_bolt_refs[0], commands=_bolt_helper_children(_bolt_var2)) | ||
--- | ||
output = _bolt_var3 | ||
--- | ||
_bolt_refs[0] | ||
<class 'mecha.ast.AstRoot'> | ||
location: SourceLocation(pos=0, lineno=1, colno=1) | ||
end_location: SourceLocation(pos=49, lineno=5, colno=1) | ||
commands: | ||
<class 'mecha.ast.AstCommand'> | ||
<class 'mecha.ast.AstCommand'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,9 @@ say a | |
say a | ||
say b | ||
``` | ||
|
||
`@function demo:pydantic` | ||
|
||
```mcfunction | ||
say {"a": 123, "b": "123"} | ||
``` |