Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/code_void/add_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from beet import Context, Function


def beet_default(ctx: Context):
for f in ctx.data.functions.keys():
ctx.data.functions[f] = Function(f"say {f}")

ctx.data.functions["namespace:"] = Function("give me sugar")
ctx.data.functions["namespace:a/"] = Function("give me apple")
10 changes: 10 additions & 0 deletions examples/code_void/beet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
data_pack:
load: [.]
resource_pack:
load: [.]

output: build


pipeline:
- add_header
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions packages/bolt/examples/bolt_empty_path/beet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require:
- bolt
data_pack:
load: [src]
pipeline:
- mecha

output: build
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@


# defining a function inline to run it
execute run function ./bar:
say fooo

# just defining a function
function ./foo:
say barr

# calling an empty function
function dm:

# next command
say YOLO

# defining a function
function namespace:error:
say error
execute run function ~/nested:
say from nested 1
execute run function ~/nested:
say from nested 2


#defining an empty function
function namespace::
say hello from empty function
execute run function ~/nested:
say from nested 1
execute run function ~/nested:
say from nested 2


function namespace:defining/:
say weird syntax but it work
execute run function ~/nested:
say from nested 1
execute run function ~/nested:
say from nested 2


function dm::
say definig this function referenced

execute run function ~/nested:
say from nested 1
execute run function ~/nested:
say from nested 2



#calling an empty tag
function #name:




#calling an empty tag
function #name:name/



4 changes: 3 additions & 1 deletion packages/bolt/src/bolt/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
CommentDisambiguation,
CompilationDatabase,
MultilineParser,
NoTagConstraint,
Parser,
ResourceLocationParser,
consume_line_continuation,
delegate,
get_stream_properties,
Expand Down Expand Up @@ -317,7 +319,7 @@ def get_bolt_parsers(
literal_parser=delegate("bolt:macro_literal"),
argument_parser=delegate("bolt:macro_argument"),
resource_location_parser=DisableInterpolationParser(
delegate("resource_location")
NoTagConstraint(ResourceLocationParser(allow_empty_path=False))
),
json_properties_parser=DisableInterpolationParser(
AdjacentConstraint(MultilineParser(delegate("json_object")), r"\{")
Expand Down
16 changes: 16 additions & 0 deletions packages/bolt/tests/resources/bolt_examples.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -1393,3 +1393,19 @@ def a(v):
x = None
with a(1) as x, a(x) as y:
say y
###
function minecraft:name:
###
function foo:
say aaa
###
function foo:
say aaa
###
function ::
###
function namespace:path/:
say boooo
###
function namespace:path/

5 changes: 5 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_381__0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#>ERROR Expected non-empty block.
# line 1, column 24
# 1 | function minecraft:name:
# : ^
function minecraft:name:
31 changes: 31 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_382__0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function foo:
say aaa
---
<class 'mecha.ast.AstRoot'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=21, lineno=2, colno=8)
commands:
<class 'mecha.ast.AstCommand'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=13, lineno=1, colno=14)
identifier: 'function:name'
arguments:
<class 'mecha.ast.AstResourceLocation'>
location: SourceLocation(pos=9, lineno=1, colno=10)
end_location: SourceLocation(pos=13, lineno=1, colno=14)
is_tag: False
namespace: 'foo'
path: ''
<class 'mecha.ast.AstCommand'>
location: SourceLocation(pos=14, lineno=2, colno=1)
end_location: SourceLocation(pos=21, lineno=2, colno=8)
identifier: 'say:message'
arguments:
<class 'mecha.ast.AstMessage'>
location: SourceLocation(pos=18, lineno=2, colno=5)
end_location: SourceLocation(pos=21, lineno=2, colno=8)
fragments:
<class 'mecha.ast.AstMessageText'>
location: SourceLocation(pos=18, lineno=2, colno=5)
end_location: SourceLocation(pos=21, lineno=2, colno=8)
value: 'aaa'
4 changes: 4 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_382__1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nothing
---
output = None
---
35 changes: 35 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_383__0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function foo:
say aaa
---
<class 'mecha.ast.AstRoot'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=25, lineno=2, colno=12)
commands:
<class 'mecha.ast.AstCommand'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=25, lineno=2, colno=12)
identifier: 'function:name:commands'
arguments:
<class 'mecha.ast.AstResourceLocation'>
location: SourceLocation(pos=9, lineno=1, colno=10)
end_location: SourceLocation(pos=12, lineno=1, colno=13)
is_tag: False
namespace: None
path: 'foo'
<class 'mecha.ast.AstRoot'>
location: SourceLocation(pos=18, lineno=2, colno=5)
end_location: SourceLocation(pos=25, lineno=2, colno=12)
commands:
<class 'mecha.ast.AstCommand'>
location: SourceLocation(pos=18, lineno=2, colno=5)
end_location: SourceLocation(pos=25, lineno=2, colno=12)
identifier: 'say:message'
arguments:
<class 'mecha.ast.AstMessage'>
location: SourceLocation(pos=22, lineno=2, colno=9)
end_location: SourceLocation(pos=25, lineno=2, colno=12)
fragments:
<class 'mecha.ast.AstMessageText'>
location: SourceLocation(pos=22, lineno=2, colno=9)
end_location: SourceLocation(pos=25, lineno=2, colno=12)
value: 'aaa'
4 changes: 4 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_383__1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nothing
---
output = None
---
5 changes: 5 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_384__0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#>ERROR Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 5 other tokens but got colon ':'.
# line 1, column 11
# 1 | function ::
# : ^
function ::
35 changes: 35 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_385__0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function namespace:path/:
say boooo
---
<class 'mecha.ast.AstRoot'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=39, lineno=2, colno=14)
commands:
<class 'mecha.ast.AstCommand'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=39, lineno=2, colno=14)
identifier: 'function:name:commands'
arguments:
<class 'mecha.ast.AstResourceLocation'>
location: SourceLocation(pos=9, lineno=1, colno=10)
end_location: SourceLocation(pos=24, lineno=1, colno=25)
is_tag: False
namespace: 'namespace'
path: 'path/'
<class 'mecha.ast.AstRoot'>
location: SourceLocation(pos=30, lineno=2, colno=5)
end_location: SourceLocation(pos=39, lineno=2, colno=14)
commands:
<class 'mecha.ast.AstCommand'>
location: SourceLocation(pos=30, lineno=2, colno=5)
end_location: SourceLocation(pos=39, lineno=2, colno=14)
identifier: 'say:message'
arguments:
<class 'mecha.ast.AstMessage'>
location: SourceLocation(pos=34, lineno=2, colno=9)
end_location: SourceLocation(pos=39, lineno=2, colno=14)
fragments:
<class 'mecha.ast.AstMessageText'>
location: SourceLocation(pos=34, lineno=2, colno=9)
end_location: SourceLocation(pos=39, lineno=2, colno=14)
value: 'boooo'
4 changes: 4 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_385__1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nothing
---
output = None
---
18 changes: 18 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_386__0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function namespace:path/

---
<class 'mecha.ast.AstRoot'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=26, lineno=3, colno=1)
commands:
<class 'mecha.ast.AstCommand'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=24, lineno=1, colno=25)
identifier: 'function:name'
arguments:
<class 'mecha.ast.AstResourceLocation'>
location: SourceLocation(pos=9, lineno=1, colno=10)
end_location: SourceLocation(pos=24, lineno=1, colno=25)
is_tag: False
namespace: 'namespace'
path: 'path/'
4 changes: 4 additions & 0 deletions packages/bolt/tests/snapshots/bolt__parse_386__1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nothing
---
output = None
---
Loading